/** * Joins the path. * * @param s segment to start with * @return joined path */ private String join(final int s) { final TokenBuilder tb = new TokenBuilder(); for (int p = s; p < segments.length; p++) { if (!tb.isEmpty()) tb.add('/'); tb.add(segments[p]); } return tb.toString(); }
/** * Returns an exception string for a wrong key. * * @param key property key * @param found found value * @param allowed allowed values * @return exception * @throws SerializerException serializer exception */ public static SerializerException error( final Object key, final String found, final String... allowed) throws SerializerException { final TokenBuilder tb = new TokenBuilder(); tb.addExt(SERVAL, key, allowed[0]); for (int a = 1; a < allowed.length; ++a) tb.addExt(SERVAL2, allowed[a]); tb.addExt(SERVAL3, found); throw SERANY.thrwSerial(tb); }
/** * Returns the database path (i.e., all path entries except for the first). * * @return path depth */ public String dbpath() { final TokenBuilder tb = new TokenBuilder(); final int ps = segments.length; for (int p = 1; p < ps; p++) { if (!tb.isEmpty()) tb.add('/'); tb.add(segments[p]); } return tb.toString(); }
@Override public synchronized byte[] info(final MainOptions options) { final TokenBuilder tb = new TokenBuilder(); final long l = inX.length() + inY.length() + inZ.length(); tb.add(LI_NAMES).add(data.meta.ftinclude).add(NL); tb.add(LI_SIZE + Performance.format(l, true) + NL); final IndexStats stats = new IndexStats(options.get(MainOptions.MAXSTAT)); addOccs(stats); stats.print(tb); return tb.finish(); }
/** * Converts the path to a string array, containing the single segments. * * @param path path, or {@code null} * @return path depth */ public static String[] toSegments(final String path) { final StringList sl = new StringList(); if (path != null) { final TokenBuilder tb = new TokenBuilder(); for (int s = 0; s < path.length(); s++) { final char ch = path.charAt(s); if (ch == '/') { if (tb.isEmpty()) continue; sl.add(tb.toString()); tb.reset(); } else { tb.add(ch); } } if (!tb.isEmpty()) sl.add(tb.toString()); } return sl.toArray(); }
/** * 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(); }