Esempio n. 1
0
 @Override
 protected void indexDelete(final int pre, final int size) {
   final boolean textI = meta.textindex, attrI = meta.attrindex;
   if (textI || attrI) {
     // collect all keys and ids
     indexBegin();
     final int l = pre + size;
     for (int p = pre; p < l; ++p) {
       final int k = kind(p);
       // consider nodes which are attribute, text, comment, or proc. instruction
       final boolean text = k == TEXT || k == COMM || k == PI;
       if (textI && text || attrI && k == ATTR) {
         final byte[] key = text(p, text);
         if (key.length <= meta.maxlen) {
           final TokenObjMap<IntList> m = text ? txtBuffer : atvBuffer;
           IntList ids = m.get(key);
           if (ids == null) {
             ids = new IntList(1);
             m.put(key, ids);
           }
           ids.add(id(p));
         }
       }
     }
     indexDelete();
   }
 }
Esempio n. 2
0
  @Override
  protected long index(final int pre, final int id, final byte[] value, final int kind) {
    final DataAccess store;
    final TokenObjMap<IntList> map;
    if (kind == ATTR) {
      store = values;
      map = meta.attrindex ? atvBuffer : null;
    } else {
      store = texts;
      // don't index document names
      map = meta.textindex && kind != DOC ? txtBuffer : null;
    }

    // add text to map to index later
    if (meta.updindex && map != null && value.length <= meta.maxlen) {
      IntList ids = map.get(value);
      if (ids == null) {
        ids = new IntList(1);
        map.put(value, ids);
      }
      ids.add(id);
    }

    // add text to text file
    // inline integer value...
    final long v = toSimpleInt(value);
    if (v != Integer.MIN_VALUE) return v | IO.OFFNUM;

    // store text
    final long off = store.length();
    final byte[] val = COMP.get().pack(value);
    store.writeToken(off, val);
    return val == value ? off : off | IO.OFFCOMP;
  }
Esempio n. 3
0
 /**
  * Returns a value for the specified parameter or {@code null}.
  *
  * @param doc documentation
  * @param name parameter name
  * @return documentation of specified variable
  */
 public static byte[] doc(final TokenObjMap<TokenList> doc, final byte[] name) {
   final TokenList params = doc != null ? doc.get(DOC_PARAM) : null;
   if (params != null) {
     for (final byte[] param : params) {
       final int vl = param.length;
       final int s = startsWith(param, '$') ? 1 : 0;
       for (int v = s; v < vl; v++) {
         if (!ws(param[v])) continue;
         if (!eq(substring(param, s, v), name)) break;
         return trim(substring(param, v + 1, vl));
       }
     }
   }
   return null;
 }
Esempio n. 4
0
 /**
  * Creates a comment sub element.
  *
  * @param tags map with tags
  * @param parent parent element
  */
 final void comment(final TokenObjMap<TokenList> tags, final FElem parent) {
   for (final byte[] tag : tags) {
     for (final byte[] name : tags.get(tag)) add(name, elem(tag, parent));
   }
 }