MCPcopy Create free account
hub / github.com/BaseXdb/basex / Names

Class Names

basex-core/src/main/java/org/basex/index/name/Names.java:22–191  ·  view source on GitHub ↗

This class indexes and organizes the element or attribute names used in an XML document. @author BaseX Team, BSD License @author Christian Gruen @author Lukas Kircher

Source from the content-addressed store, hash-verified

20 * @author Lukas Kircher
21 */
22public final class Names extends TokenSet implements Index {
23 /** Statistical information. */
24 private Stats[] stats;
25 /** Meta data. */
26 private final MetaData meta;
27
28 /**
29 * Default constructor.
30 * @param meta meta data
31 */
32 public Names(final MetaData meta) {
33 this.meta = meta;
34 stats = new Stats[Array.INITIAL_CAPACITY];
35 }
36
37 /**
38 * Constructor, specifying an input file.
39 * @param in input stream
40 * @param meta meta data
41 * @throws IOException I/O exception
42 */
43 public Names(final DataInput in, final MetaData meta) throws IOException {
44 super(in);
45 this.meta = meta;
46 stats = new Stats[keys.length];
47 for(int i = 1; i < size; i++) stats[i] = new Stats(in);
48 }
49
50 /**
51 * Initializes the index.
52 */
53 public void init() {
54 for(int i = 1; i < size; i++) stats[i] = new Stats();
55 }
56
57 /**
58 * Stores a name, updates the statistics, and returns the index of the name.
59 * @param name name to be added
60 * @return index
61 */
62 public int store(final byte[] name) {
63 return store(name, null);
64 }
65
66 /**
67 * Stores a name, updates the statistics, and returns the index of the name.
68 * @param name name to be added
69 * @param value value, added to statistics (can be {@code null})
70 * @return index
71 */
72 public int store(final byte[] name, final byte[] value) {
73 final int i = put(name);
74 Stats s = stats[i];
75 if(s == null) {
76 s = new Stats();
77 stats[i] = s;
78 }
79 if(value != null) s.add(value, meta);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected