Example #1
0
 @Test
 public void allocGraphScope3() {
   LabelToNode alloc = LabelToNode.createScopeByGraph();
   Node b1 = alloc.get(gragh1, "xyz");
   Node b2 = alloc.get(gragh2, "xyz");
   // DIFFERENT
   assertNotEquals(b1, b2);
 }
Example #2
0
 @Test
 public void allocOneScope5() {
   LabelToNode alloc = SyntaxLabels.createLabelToNode();
   Node b1 = alloc.get(null, "xyz");
   Node b2 = alloc.get(null, "xyz");
   // SAME
   assertEquals(b1, b2);
 }
Example #3
0
 @Test
 public void allocOneScope2() {
   LabelToNode alloc = SyntaxLabels.createLabelToNode();
   Node b1 = alloc.get(gragh1, "xyz");
   Node b2 = alloc.get(gragh1, "123");
   // DIFFERENT
   assertNotEquals(b1, b2);
 }
Example #4
0
 @Test
 public void allocGraphScope4() {
   LabelToNode alloc = SyntaxLabels.createLabelToNode();
   Node b1 = alloc.get(null, "xyz");
   Node b2 = alloc.get(gragh2, "xyz");
   // DIFFERENT
   assertEquals(b1, b2);
 }
Example #5
0
 // ---- Graph Scope
 @Test
 public void allocGraphScope1() {
   LabelToNode alloc = LabelToNode.createScopeByGraph();
   Node b1 = alloc.get(gragh1, "xyz");
   Node b2 = alloc.get(gragh1, "xyz");
   // SAME
   assertEquals(b1, b2);
   assertSame(b1, b2);
 }
 // See RDFParser
 private Node createNode(Map<String, Object> map) {
   String type = (String) map.get("type");
   String lex = (String) map.get("value");
   if (type.equals(IRI)) return NodeFactory.createURI(lex);
   else if (type.equals(BLANK_NODE)) return labels.get(null, lex);
   else if (type.equals(LITERAL)) {
     String lang = (String) map.get("language");
     String datatype = (String) map.get("datatype");
     if (lang == null && datatype == null) return NodeFactory.createLiteral(lex);
     if (lang != null) return NodeFactory.createLiteral(lex, lang, null);
     RDFDatatype dt = NodeFactory.getType(datatype);
     return NodeFactory.createLiteral(lex, dt);
   } else throw new InternalErrorException("Node is not a IRI, bNode or a literal: " + type);
   //        /*
   //     *  "value" : The value of the node.
   //     *            "subject" can be an IRI or blank node id.
   //     *            "predicate" should only ever be an IRI
   //     *            "object" can be and IRI or blank node id, or a literal value (represented as
   // a string)
   //     *  "type" : "IRI" if the value is an IRI or "blank node" if the value is a blank node.
   //     *           "object" can also be "literal" in the case of literals.
   //     * The value of "object" can  also contain the following optional key-value pairs:
   //     *  "language" : the language value of a string literal
   //     *  "datatype" : the datatype of the literal. (if not set will default to XSD:string, if
   // set to null, null will be used).         */
   //        System.out.println(map.get("value")) ;
   //        System.out.println(map.get("type")) ;
   //        System.out.println(map.get("language")) ;
   //        System.out.println(map.get("datatype")) ;
   //        return null ;
 }
Example #7
0
  /**
   * Create a parser profile for the given setup
   *
   * @param baseIRI Base IRI
   * @param resolveIRIs Whether to resolve IRIs
   * @param checking Whether to check
   * @param handler Error handler
   * @return ParserProfile
   * @see #profile for per-language setup
   */
  public static ParserProfile profile(
      String baseIRI, boolean resolveIRIs, boolean checking, ErrorHandler handler) {
    LabelToNode labelToNode =
        true ? SyntaxLabels.createLabelToNode() : LabelToNode.createUseLabelEncoded();

    Prologue prologue;
    if (resolveIRIs)
      prologue = new Prologue(PrefixMapFactory.createForInput(), IRIResolver.create(baseIRI));
    else prologue = new Prologue(PrefixMapFactory.createForInput(), IRIResolver.createNoResolve());

    if (checking) return new ParserProfileChecker(prologue, handler, labelToNode);
    else return new ParserProfileBase(prologue, handler, labelToNode);
  }
 private Node createURI(String str) {
   if (str.startsWith("_:")) return labels.get(null, str);
   else return NodeFactory.createURI(str);
 }