Ejemplo n.º 1
0
 /** Constructor, registering statically available XQuery functions. */
 private Functions() {
   for (final Function def : Function.values()) {
     final String dsc = def.desc;
     final byte[] ln = token(dsc.substring(0, dsc.indexOf(PAR1)));
     final int i = add(new QNm(ln, def.uri()).id());
     if (i < 0) Util.notexpected("Function defined twice:" + def);
     funcs[i] = def;
   }
 }
Ejemplo n.º 2
0
  /**
   * Checks the list of updates for violations. Updates must be ordered strictly from the highest to
   * the lowest PRE value.
   *
   * <p>A single node must not be affected by more than one {@link Rename}, {@link UpdateValue}
   * operation.
   *
   * <p>A single node must not be affected by more than one destructive operation. These operations
   * include {@link Replace}, {@link Delete}.
   */
  public void check() {
    if (ok || updStructural.size() < 2 && updValue.size() < 2) return;

    int i = 0;
    while (i + 1 < updStructural.size()) {
      final BasicUpdate current = updStructural.get(i);
      final BasicUpdate next = updStructural.get(++i);

      // check order of location PRE
      if (current.location < next.location)
        Util.notexpected("Invalid order at location " + current.location);

      if (current.location == next.location) {
        // check multiple {@link Delete}, {@link Replace}
        if (current.destructive() && next.destructive())
          Util.notexpected("Multiple deletes/replaces on node " + current.location);
      }
    }

    i = 0;
    while (i + 1 < updValue.size()) {
      final BasicUpdate current = updValue.get(i++);
      final BasicUpdate next = updValue.get(i);

      // check order of location PRE
      if (current.location < next.location)
        Util.notexpected("Invalid order at location " + current.location);

      if (current.location == next.location) {
        // check multiple {@link Rename}
        if (current instanceof Rename && next instanceof Rename)
          Util.notexpected("Multiple renames on node " + current.location);

        // check multiple {@link UpdateValue}
        if (current instanceof UpdateValue && next instanceof UpdateValue)
          Util.notexpected("Multiple updates on node " + current.location);
      }
    }
    ok = true;
  }
Ejemplo n.º 3
0
 /**
  * Returns the index reference for the specified index type.
  *
  * @param type index type
  * @return index
  */
 final Index index(final IndexType type) {
   switch (type) {
     case TAG:
       return tagindex;
     case ATTNAME:
       return atnindex;
     case TEXT:
       return txtindex;
     case ATTRIBUTE:
       return atvindex;
     case FULLTEXT:
       return ftxindex;
     case PATH:
       return paths;
     default:
       throw Util.notexpected();
   }
 }