Ejemplo n.º 1
0
  /**
   * Calculates the text offset and writes the text value.
   *
   * @param value value to be inlined
   * @param text text/attribute flag
   * @return inline value or text position
   * @throws IOException I/O exception
   */
  private long textOff(final byte[] value, final boolean text) throws IOException {
    // inline integer values...
    final long v = Token.toSimpleInt(value);
    if (v != Integer.MIN_VALUE) return v | IO.OFFNUM;

    // store text
    final DataOutput store = text ? xout : vout;
    final long off = store.size();
    final byte[] val = COMP.get().pack(value);
    store.writeToken(val);
    return val == value ? off : off | IO.OFFCOMP;
  }
Ejemplo n.º 2
0
 /**
  * Returns a readable representation of this node.
  *
  * @param data data reference
  * @return completions
  */
 public byte[] token(final Data data) {
   switch (kind) {
     case Data.ELEM:
       return data.elemNames.key(name);
     case Data.ATTR:
       return Token.concat(ATT, data.attrNames.key(name));
     case Data.TEXT:
       return TEXT;
     case Data.COMM:
       return COMMENT;
     case Data.PI:
       return PI;
     default:
       return Token.EMPTY;
   }
 }