/** * 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); }
/** * Default constructor. * * @param name node name * @param kind node kind * @param parent parent node * @param count counter */ private PathNode(final int name, final byte kind, final PathNode parent, final int count) { this.children = new PathNode[0]; this.name = (short) name; this.kind = kind; this.parent = parent; stats = new Stats(); stats.count = count; }
/** * Constructor, specifying an input stream. * * @param in input stream * @param node parent node * @throws IOException I/O exception */ PathNode(final DataInput in, final PathNode node) throws IOException { name = (short) in.readNum(); kind = (byte) in.read(); final int count = in.readNum(); children = new PathNode[in.readNum()]; if (in.readDouble() == 1) { // "1" indicates the format introduced with Version 7.1 stats = new Stats(in); } else { // create old format stats = new Stats(); stats.count = count; } parent = node; for (int c = 0; c < children.length; ++c) children[c] = new PathNode(in, this); }