Example #1
0
 /**
  * Returns a string representation of a path summary node.
  *
  * @param data data reference
  * @param level level
  * @return string representation
  */
 byte[] info(final Data data, final int level) {
   final TokenBuilder tb = new TokenBuilder();
   if (level != 0) tb.add(Text.NL);
   for (int i = 0; i < level << 1; ++i) tb.add(' ');
   switch (kind) {
     case Data.DOC:
       tb.add(DOC);
       break;
     case Data.ELEM:
       tb.add(data.elemNames.key(name));
       break;
     case Data.TEXT:
       tb.add(TEXT);
       break;
     case Data.ATTR:
       tb.add(ATT);
       tb.add(data.attrNames.key(name));
       break;
     case Data.COMM:
       tb.add(COMMENT);
       break;
     case Data.PI:
       tb.add(PI);
       break;
   }
   tb.add(": " + stats);
   for (final PathNode p : children) tb.add(p.info(data, level + 1));
   return tb.finish();
 }
Example #2
0
  /**
   * Writes the node to the specified output stream.
   *
   * @param out output stream
   * @throws IOException I/O exception
   */
  void write(final DataOutput out) throws IOException {
    out.writeNum(name);
    out.write1(kind);
    out.writeNum(0);
    out.writeNum(children.length);
    out.writeDouble(1);

    // update leaf flag
    boolean leaf = stats.isLeaf();
    for (final PathNode child : children) {
      leaf &= child.kind == Data.TEXT || child.kind == Data.ATTR;
    }
    stats.setLeaf(leaf);
    stats.write(out);
    for (final PathNode child : children) child.write(out);
  }
Example #3
0
 /**
  * Recursively adds the node and its descendants to the specified list with the specified name.
  *
  * @param nodes node list
  * @param nm name id
  */
 public void addDesc(final ArrayList<PathNode> nodes, final int nm) {
   if (kind == Data.ELEM && nm == name) nodes.add(this);
   for (final PathNode child : children) child.addDesc(nodes, nm);
 }
Example #4
0
 /**
  * Recursively adds the node and its descendants to the specified list.
  *
  * @param nodes node list
  */
 void addDesc(final ArrayList<PathNode> nodes) {
   nodes.add(this);
   for (final PathNode child : children) child.addDesc(nodes);
 }