use of org.apache.jena.datatypes.RDFDatatype in project jena by apache.
the class FBRuleInfGraph method getDTRange.
/**
* Return a map from property nodes to a list of RDFDatatype objects
* which have been declared as the range of that property.
*/
protected HashMap<Node, List<RDFDatatype>> getDTRange() {
if (dtRange == null) {
dtRange = new HashMap<>();
for (Iterator<Triple> i = find(null, RDFS.range.asNode(), null); i.hasNext(); ) {
Triple triple = i.next();
Node prop = triple.getSubject();
Node rangeValue = triple.getObject();
if (rangeValue.isURI()) {
RDFDatatype dt = TypeMapper.getInstance().getTypeByName(rangeValue.getURI());
if (dt != null) {
List<RDFDatatype> range = dtRange.get(prop);
if (range == null) {
range = new ArrayList<>();
dtRange.put(prop, range);
}
range.add(dt);
}
}
}
}
return dtRange;
}
use of org.apache.jena.datatypes.RDFDatatype in project jena by apache.
the class Util method isSimpleString.
/**
* A Node is a simple string if:
* <li>(RDF 1.0) No datatype and no language tag.
* <li>(RDF 1.1) xsd:string
*/
public static boolean isSimpleString(Node n) {
Objects.requireNonNull(n);
RDFDatatype dt = n.getLiteralDatatype();
if (dt == null)
return !isLangString(n);
if (JenaRuntime.isRDF11)
return dt.equals(XSDDatatype.XSDstring);
return false;
}
use of org.apache.jena.datatypes.RDFDatatype in project jena by apache.
the class ModelCom method createTypedLiteral.
/**
* Build a typed literal from its lexical form. The
* lexical form will be parsed now and the value stored. If
* the form is not legal this will throw an exception.
*
* @param lex the lexical form of the literal
* @param typeURI the uri of the type of the literal, null for old style "plain" literals
* @throws DatatypeFormatException if lex is not a legal form of dtype
*/
@Override
public Literal createTypedLiteral(String lex, String typeURI) {
RDFDatatype dt = TypeMapper.getInstance().getSafeTypeByName(typeURI);
LiteralLabel ll = LiteralLabelFactory.create(lex, dt);
return new LiteralImpl(NodeFactory.createLiteral(ll), this);
}
use of org.apache.jena.datatypes.RDFDatatype in project jena by apache.
the class ParserBase method createLiteral.
protected Node createLiteral(String lexicalForm, String langTag, String datatypeURI) {
Node n = null;
// Can't have type and lang tag.
if (datatypeURI != null) {
RDFDatatype dType = TypeMapper.getInstance().getSafeTypeByName(datatypeURI);
n = NodeFactory.createLiteral(lexicalForm, null, dType);
} else
n = NodeFactory.createLiteral(lexicalForm, langTag, null);
return n;
}
use of org.apache.jena.datatypes.RDFDatatype in project jena by apache.
the class ParserBase method createLiteral.
protected Node createLiteral(String lexicalForm, String langTag, String datatypeURI) {
Node n = null;
// Can't have type and lang tag in parsing.
if (datatypeURI != null) {
RDFDatatype dType = TypeMapper.getInstance().getSafeTypeByName(datatypeURI);
n = NodeFactory.createLiteral(lexicalForm, dType);
} else if (langTag != null && !langTag.isEmpty())
n = NodeFactory.createLiteral(lexicalForm, langTag);
else
n = NodeFactory.createLiteral(lexicalForm);
return n;
}
Aggregations