This class stores the path summary of a database. It contains all unique location paths. @author BaseX Team, BSD License @author Christian Gruen
| 23 | * @author Christian Gruen |
| 24 | */ |
| 25 | public final class PathIndex implements Index { |
| 26 | /** Node stack for building the summary. */ |
| 27 | private final ArrayList<PathNode> stack = new ArrayList<>(); |
| 28 | /** Data reference. */ |
| 29 | private Data data; |
| 30 | /** Root node. */ |
| 31 | private PathNode root; |
| 32 | |
| 33 | /** |
| 34 | * Constructor. |
| 35 | * The {@link Data} reference must be set in a second step via {@link #data(Data)}. |
| 36 | */ |
| 37 | public PathIndex() { |
| 38 | init(); |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Constructor, specifying a data reference. |
| 43 | * @param data data reference |
| 44 | */ |
| 45 | public PathIndex(final Data data) { |
| 46 | this(); |
| 47 | this.data = data; |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Constructor, specifying an input file. |
| 52 | * @param data data reference |
| 53 | * @param in input stream |
| 54 | * @throws IOException I/O exception |
| 55 | */ |
| 56 | public PathIndex(final Data data, final DataInput in) throws IOException { |
| 57 | root = in.readBool() ? new PathNode(in, null) : new PathNode(); |
| 58 | this.data = data; |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Writes the path summary to the specified output. |
| 63 | * @param out output stream |
| 64 | * @throws IOException I/O exception |
| 65 | */ |
| 66 | public void write(final DataOutput out) throws IOException { |
| 67 | out.writeBool(root != null); |
| 68 | if(root != null) root.write(out, data.meta); |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * Sets the data reference. |
| 73 | * @param dt reference |
| 74 | */ |
| 75 | public void data(final Data dt) { |
| 76 | data = dt; |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * Initializes the index. |
| 81 | */ |
| 82 | public void init() { |
nothing calls this directly
no outgoing calls
no test coverage detected