Beispiel #1
0
 /**
  * Returns the distance of the specified node.
  *
  * @param pre pre value
  * @param kind node kind
  * @return distance
  */
 public int dist(final int pre, final int kind) {
   switch (kind) {
     case ELEM:
       return table.read4(pre, 4);
     case TEXT:
     case COMM:
     case PI:
       return table.read4(pre, 8);
     case ATTR:
       int d = table.read1(pre, 0) >> 3 & IO.MAXATTS;
       // skip additional attributes, if value is larger than maximum range
       if (d >= IO.MAXATTS) while (d < pre && kind(pre - d) == ATTR) d++;
       return d;
     default:
       return pre + 1;
   }
 }
Beispiel #2
0
 /**
  * Sets the namespace flag. Should be only called for element nodes.
  *
  * @param pre pre value
  * @param ne namespace flag
  */
 public final void nsFlag(final int pre, final boolean ne) {
   table.write1(pre, 1, table.read1(pre, 1) & 0x7F | (ne ? 0x80 : 0));
 }
Beispiel #3
0
 /**
  * Returns the namespace flag of the addressed element.
  *
  * @param pre pre value
  * @return namespace flag
  */
 public final boolean nsFlag(final int pre) {
   return (table.read1(pre, 1) & 0x80) != 0;
 }
Beispiel #4
0
 /**
  * Returns a reference to the namespace of the addressed element or attribute.
  *
  * @param pre pre value
  * @param kind node kind
  * @return namespace URI
  */
 public final int uri(final int pre, final int kind) {
   return kind == ELEM || kind == ATTR ? table.read1(pre, kind == ELEM ? 3 : 11) & 0xFF : 0;
 }
Beispiel #5
0
 /**
  * Returns a number of attributes.
  *
  * @param pre pre value
  * @param kind node kind
  * @return number of attributes
  */
 public final int attSize(final int pre, final int kind) {
   int s = kind == ELEM ? table.read1(pre, 0) >> 3 & IO.MAXATTS : 1;
   // skip additional attributes, if value is larger than maximum range
   if (s >= IO.MAXATTS) while (s < meta.size - pre && kind(pre + s) == ATTR) s++;
   return s;
 }
Beispiel #6
0
 /**
  * Returns the node kind, which may be {@link #DOC}, {@link #ELEM}, {@link #TEXT}, {@link #ATTR},
  * {@link #COMM} or {@link #PI}.
  *
  * @param pre pre value
  * @return node kind
  */
 public final int kind(final int pre) {
   return table.read1(pre, 0) & 0x07;
 }