Finalizes the index and writes the node to the specified output stream. @param out output stream @param meta meta data @throws IOException I/O exception
(final DataOutput out, final MetaData meta)
| 131 | * @throws IOException I/O exception |
| 132 | */ |
| 133 | void write(final DataOutput out, final MetaData meta) throws IOException { |
| 134 | out.writeNum(name); |
| 135 | out.write1(kind); |
| 136 | // legacy (required before version 7.1) |
| 137 | out.writeNum(0); |
| 138 | out.writeNum(children.length); |
| 139 | // legacy (required before version 7.1) |
| 140 | out.writeDouble(1); |
| 141 | |
| 142 | // update leaf flag |
| 143 | boolean leaf = stats.isLeaf(); |
| 144 | for(final PathNode child : children) { |
| 145 | if(child.kind == Data.TEXT) { |
| 146 | if(empty != 0) child.stats.add(Token.EMPTY, meta); |
| 147 | } else if(child.kind != Data.ATTR) { |
| 148 | leaf = false; |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | stats.setLeaf(leaf); |
| 153 | stats.write(out); |
| 154 | for(final PathNode child : children) child.write(out, meta); |
| 155 | } |
| 156 | |
| 157 | /** |
| 158 | * Recursively adds the node and its descendants to the specified list. |