Exemplo n.º 1
0
  @Override
  public Data getNumberOfLinksInChain() {
    // TODO: rewrite this using user-defined data & functions
    int numberOfLinks = 0;
    Data next = getNext();

    while (notAtLinkEnd(next)) {
      numberOfLinks++;
      next = next.getNext();
    }
    ;

    Integer numberOfLinksInChain = new Integer(numberOfLinks);
    return Data.Factory.create(numberOfLinksInChain.toString());
  }
Exemplo n.º 2
0
  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();

    Number numLinksInChain = Data.Converter.convertFrom(getNumberOfLinksInChain());
    sb.append("number of links: ").append(numLinksInChain).append(Values.LINE_FEED);

    Data current = getNext();
    int numLinks = numLinksInChain.intValue();
    for (int i = 0; i < numLinks; i++) {
      sb.append(current.toString()).append(Values.LINE_FEED);
      current = current.getNext();
    }

    return sb.toString();
  }