示例#1
0
文件: ANode.java 项目: fpapai/basex
 @Override
 public final int diff(final Item it, final Collation coll, final InputInfo ii)
     throws QueryException {
   return it.type.isUntyped()
       ? coll == null ? Token.diff(string(), it.string(ii)) : coll.compare(string(), it.string(ii))
       : -it.diff(this, coll, ii);
 }
示例#2
0
文件: ANode.java 项目: fpapai/basex
 @Override
 public final boolean eq(
     final Item it, final Collation coll, final StaticContext sc, final InputInfo ii)
     throws QueryException {
   return it.type.isUntyped()
       ? coll == null
           ? Token.eq(string(), it.string(ii))
           : coll.compare(string(), it.string(ii)) == 0
       : it.eq(this, coll, sc, ii);
 }
示例#3
0
  /**
   * Compares results.
   *
   * @param expected expected result
   * @param returned returned result
   * @throws Exception exception
   */
  private static void compare(final ItemList expected, final ItemList returned) throws Exception {

    // Compare response with expected result
    assertEquals("Different number of results", expected.size(), returned.size());

    final long es = expected.size();
    for (int e = 0; e < es; e++) {
      final Item exp = expected.get(e), ret = returned.get(e);
      if (!new DeepEqual().equal(exp, ret)) {
        final TokenBuilder tb = new TokenBuilder("Result ").addLong(e).add(" differs:\nReturned: ");
        tb.addExt(ret.serialize()).add("\nExpected: ").addExt(exp.serialize());
        fail(tb.toString());
      }
    }
  }
示例#4
0
  /**
   * Creates annotation child elements.
   *
   * @param anns annotations
   * @param parent parent element
   * @param uri include uri
   * @throws QueryException query exception
   */
  final void annotation(final AnnList anns, final FElem parent, final boolean uri)
      throws QueryException {

    for (final Ann ann : anns) {
      final FElem annotation = elem("annotation", parent);
      if (ann.sig != null) {
        annotation.add("name", ann.sig.id());
        if (uri) annotation.add("uri", ann.sig.uri);
      } else {
        annotation.add("name", ann.name.string());
        if (uri) annotation.add("uri", ann.name.uri());
      }

      for (final Item it : ann.args) {
        final FElem literal = elem("literal", annotation);
        literal.add("type", it.type.toString()).add(it.string(null));
      }
    }
  }