コード例 #1
0
 // 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 ;
 }
コード例 #2
0
 private Node createLiteral(String lex, String datatype, String lang) {
   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);
 }