Refine search
public static RdfTermType deriveType(Node node) { if(node.isURI()) { return RdfTermType.URI; } else if(node.isLiteral()) { return RdfTermType.LITERAL; } else if(node.isBlank()) { throw new RuntimeException("Decide on what to return here."); //return Type.URI; } else { return RdfTermType.UNKNOWN; } }
public static RdfTermType getNodeType(Node node) { if(node == null) { return RdfTermType.UNKNOWN; } else if(node.isURI()) { return RdfTermType.URI; } else if(node.isLiteral()) { return RdfTermType.LITERAL; } else if(node.isBlank()) { return RdfTermType.BLANK; } else { throw new RuntimeException("Should not happen"); } }
static public NodeType lookup(Node n) { if ( n.isURI() ) return URI ; if ( n.isBlank() ) return BNODE ; if ( n.isLiteral() ) { return LITERAL ; // if ( n.getLiteralDatatypeURI() == null ) // // String - plain literal // return STRING ; // if ( n.getLiteralDatatype() == XSDDatatype.XSDstring ) // return XSDSTRING ; // if ( n.getLiteralDatatype() == XSDDatatype.XSDinteger ) // return INTEGER ; // if ( n.getLiteralDatatype() == XSDDatatype.XSDdouble ) // return DOUBLE ; // if ( n.getLiteralDatatype() == XSDDatatype.XSDdateTime ) // return DATETIME ; } return OTHER ; }
protected static Expr buildFunctionCall(ItemList list) { Item head = list.get(0) ; Node node = head.getNode() ; if ( node.isBlank() ) BuilderLib.broken(head, "Blank node for function call!") ; if ( node.isLiteral() ) BuilderLib.broken(head, "Literal node for function call!") ; ExprList args = buildExprListUntagged(list, 1) ; // Args return new E_Function(node.getURI(), args) ; }
public SerialisableTriple(Triple triple){ this.triple = triple; Node _sbj = this.triple.getSubject(); if (_sbj.isBlank()) isSubjectBlank = true; this.subject = _sbj.toString(); this.predicate = this.triple.getPredicate().toString(); Node _obj = this.triple.getObject(); if (_obj.isBlank()) isObjectBlank = true; this.object = _obj.toString(); if (_obj.isLiteral()) { isObjectLiteral = true; objectDataType = _obj.getLiteralDatatype(); objectDT = _obj.getLiteralDatatypeURI(); objectLang = _obj.getLiteralLanguage(); object = _obj.getLiteralLexicalForm(); } }
public SerialisableQuad(Quad quad){ super(quad.getGraph(), quad.asTriple()); this.quad = quad; Node _sbj = this.quad.getSubject(); if (_sbj.isBlank()) isSubjectBlank = true; this.subject = _sbj.toString(); this.predicate = this.quad.getPredicate().toString(); Node _obj = this.quad.getObject(); if (_obj.isBlank()) isObjectBlank = true; if (_obj.isLiteral()) isObjectLiteral = true; this.object = _obj.toString(); Node _graph = this.quad.getGraph(); if (_graph != null){ this.graph = _graph.getURI(); this.hasGraph = true; } }
@Override public boolean equal(Node n1, Node n2) { if ( n1 == null && n2 == null ) return true ; if ( n1 == null ) return false ; if ( n2 == null ) return false ; if ( n1.isURI() && n2.isURI() ) return n1.equals(n2) ; if ( n1.isLiteral() && n2.isLiteral() ) return literalTest.equal(n1, n2) ; if ( n1.isBlank() && n2.isBlank() ) return mapping.makeIsomorphic(n1, n2) ; return false ; } }
/** Check a triple against the RDF rules for a triple : subject is a IRI or bnode, predicate is a IRI and object is an bnode, literal or IRI */ public boolean checkTriple(Node subject, Node predicate, Node object, long line, long col) { boolean rc = true ; if ( subject == null || ( ! subject.isURI() && ! subject.isBlank() ) ) { handler.error("Subject is not a URI or blank node", line, col) ; rc = false ; } if ( predicate == null || ( ! predicate.isURI() ) ) { handler.error("Predicate not a URI", line, col) ; rc = false ; } if ( object == null || ( ! object.isURI() && ! object.isBlank() && ! object.isLiteral() ) ) { handler.error("Object is not a URI, blank node or literal", line, col) ; rc = false ; } return rc ; }
@Override public boolean doCheck( Node n, EnhGraph g ) { if ( n.isURI() || n.isBlank() ) { return !hasType( n, g, new Resource[] {RDFS.Class, RDF.Property, OWL.Class, OWL.ObjectProperty, OWL.DatatypeProperty, OWL.TransitiveProperty, OWL.FunctionalProperty, OWL.InverseFunctionalProperty} ); } else { return false; } } }
@Override protected final boolean accepts(TKey key, QuadWritable tuple) { Quad q = tuple.get(); return (q.getGraph().isURI() || q.getGraph().isBlank()) && (q.getSubject().isURI() || q.getSubject().isBlank()) && q.getPredicate().isURI() && (q.getObject().isURI() || q.getObject().isBlank() || q.getObject().isLiteral()); }