本文整理汇总了Java中com.hp.hpl.jena.datatypes.RDFDatatype类的典型用法代码示例。如果您正苦于以下问题:Java RDFDatatype类的具体用法?Java RDFDatatype怎么用?Java RDFDatatype使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RDFDatatype类属于com.hp.hpl.jena.datatypes包,在下文中一共展示了RDFDatatype类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: typedLiteral
import com.hp.hpl.jena.datatypes.RDFDatatype; //导入依赖的package包/类
public static NodeType typedLiteral(RDFDatatype datatype) {
// TODO These subclasses can be abolished; just introduce an RDFDatatypeValidator instead
if (datatype.equals(XSDDatatype.XSDdate)) {
return XSD_DATE;
}
if (datatype.equals(XSDDatatype.XSDtime)) {
return XSD_TIME;
}
if (datatype.equals(XSDDatatype.XSDdateTime)) {
return XSD_DATETIME;
}
if (datatype.equals(XSDDatatype.XSDboolean)) {
return XSD_BOOLEAN;
}
return new LiteralNodeType("", datatype);
}
示例2: limitToLiterals
import com.hp.hpl.jena.datatypes.RDFDatatype; //导入依赖的package包/类
public void limitToLiterals(String language, RDFDatatype datatype) {
if (isEmpty) return;
limitToNodeType(NODE_TYPE_LITERAL);
if (constantLanguage == null) {
constantLanguage = language;
} else {
if (!constantLanguage.equals(language)) {
limitToEmptySet();
}
}
if (constantDatatype == null) {
constantDatatype = datatype;
} else {
if (!constantDatatype.equals(datatype)) {
limitToEmptySet();
}
}
}
示例3: convertToJenaRDFNode
import com.hp.hpl.jena.datatypes.RDFDatatype; //导入依赖的package包/类
public RDFNode convertToJenaRDFNode( final BigdataValue v )
{
if ( v instanceof BigdataResource )
return convertToJenaResource( (BigdataResource) v );
if ( !(v instanceof BigdataLiteral) )
throw new IllegalArgumentException( v.getClass().getName() );
final BigdataLiteral l = (BigdataLiteral) v;
final String lex = l.getLabel();
final URI datatypeURI = l.getDatatype();
final String languageTag = l.getLanguage();
if ( datatypeURI != null ) {
final RDFDatatype dt = JENA_TYPE_MAPPER.getSafeTypeByName(
datatypeURI.stringValue() );
return ResourceFactory.createTypedLiteral( lex, dt );
}
else if ( languageTag != null ) {
return ResourceFactory.createLangLiteral( lex, languageTag );
}
else {
return ResourceFactory.createPlainLiteral( lex );
}
}
示例4: getLiteral
import com.hp.hpl.jena.datatypes.RDFDatatype; //导入依赖的package包/类
@Override
public LiteralLabel getLiteral() {
graphDb.beginTx();
String value = delegate.getProperty(NeoGraph.PROPERTY_VALUE).toString();
String language = null;
RDFDatatype datatype = null;
if(delegate.hasProperty(NeoGraph.PROPERTY_LANGUAGE))
language = delegate.getProperty(NeoGraph.PROPERTY_LANGUAGE).toString();
TypeMapper mapper = new TypeMapper();
if(delegate.hasProperty(NeoGraph.PROPERTY_DATATYPE))
datatype = mapper.getTypeByName( delegate.getProperty(NeoGraph.PROPERTY_DATATYPE).toString());
LiteralLabel label = LiteralLabelFactory.create(value, language, datatype); //datatype);
//System.out.println("Label: " +label);
return label;
}
示例5: isBaseTypeCompatible
import com.hp.hpl.jena.datatypes.RDFDatatype; //导入依赖的package包/类
/**
* Test if the given typed value is in the right partition of the XSD type
* space. If this test passes then if the typed value has a legal lexical
* form for this type then it is a legal instance.
*/
public boolean isBaseTypeCompatible(LiteralLabel lit) {
XSDBuiltinType base = getFoundingType();
RDFDatatype litDT = lit.getDatatype();
if (litDT instanceof XSDDatatype) {
XSDBuiltinType litBase = ((XSDDatatype) litDT).getFoundingType();
return base.equals(litBase);
} else if (litDT == null && lit.language().equals("")) {
// Special RDF case, a plain literal is type compatible with and
// xsd:string-based type
return base.equals(XSDstring.typeDeclaration);
} else {
return false;
}
}
示例6: checkLiteral
import com.hp.hpl.jena.datatypes.RDFDatatype; //导入依赖的package包/类
/**
* Check a given literal value for a property against the set of
* known range constraints for it.
* @param prop the property node whose range is under scrutiny
* @param triple the statement whose object value is to be checked.
* @return null if the range is legal, otherwise a ValidityReport.Report
* which describes the problem.
*/
public ValidityReport.Report checkLiteral(Node prop, Triple triple) {
Node value = triple.getObject();
List<RDFDatatype> range = getDTRange().get(prop);
if (range != null) {
if (value.isBlank()) return null;
if (!value.isLiteral()) {
return new ValidityReport.Report(true, "dtRange",
"Property " + prop + " has a typed range but was given a non literal value " + value);
}
LiteralLabel ll = value.getLiteral();
for (Iterator<RDFDatatype> i = range.iterator(); i.hasNext(); ) {
RDFDatatype dt = i.next();
if (!dt.isValidLiteral(ll)) {
return new ValidityReport.Report(true, "dtRange",
"Property " + prop + " has a typed range " + dt +
"that is not compatible with " + value, triple);
}
}
}
return null;
}
示例7: isTypeOK
import com.hp.hpl.jena.datatypes.RDFDatatype; //导入依赖的package包/类
/**
* Check if a literal value node is a legal value for the given datatype.
* @param val the literal value node
* @param dt the Node designating a datatype URI
*/
public static boolean isTypeOK(Node val, Node dt) {
if (!dt.isURI()) return false;
if (val.isBlank()) return true;
if (val.isLiteral()) {
LiteralLabel ll = val.getLiteral();
if (ll.getDatatype() != null && (! ll.isWellFormed())) return false;
if (dt.equals(RDFS.Nodes.Literal)) {
return true;
} else {
RDFDatatype dtype = TypeMapper.getInstance().getSafeTypeByName(dt.getURI());
return dtype.isValidLiteral(val.getLiteral());
}
}
return false;
}
示例8: transform
import com.hp.hpl.jena.datatypes.RDFDatatype; //导入依赖的package包/类
/**
* Parses and transforms a stream with service description(s), e.g. SAWSDL, OWL-S, hRESTS, etc., and
* returns a list of Service objects defined in the stream.
*
* @param originalDescription The semantic Web service description(s)
* @param baseUri The base URI to use while transforming the service description
* @return A List with the services transformed conforming to MSM model
*/
@Override
public List<Service> transform(InputStream originalDescription, String baseUri) throws TransformationException {
// read the file
// TODO: figure out the syntax?
// Register the expression types for conditions
RDFDatatype rtype = PddlType.TYPE;
TypeMapper.getInstance().registerDatatype(rtype);
OntModel model = ModelFactory.createOntologyModel(this.modelSpec);
// Read also the PDDL file to obtain the right Literal Type with OWL-S TC4
model.read("http://127.0.0.1/ontology/PDDLExpression.owl");
model.read(originalDescription, baseUri);
// Transform the original model (may have several service definitions)
List<Service> services = transform(model, baseUri);
return services;
}
示例9: getNodeType
import com.hp.hpl.jena.datatypes.RDFDatatype; //导入依赖的package包/类
public NodeType getNodeType() {
if (map.getDatatype() != null) {
RDFDatatype datatype = TypeMapper.getInstance().getSafeTypeByName(map.getDatatype());
return TypedNodeMaker.typedLiteral(datatype);
}
if (map.getLang() != null) {
return TypedNodeMaker.languageLiteral(map.getLang());
}
if (super.getNodeType() != null) {
return super.getNodeType();
}
return TypedNodeMaker.PLAIN_LITERAL;
}
示例10: limitToLiterals
import com.hp.hpl.jena.datatypes.RDFDatatype; //导入依赖的package包/类
public void limitToLiterals(String language, RDFDatatype datatype) {
logger.debug("limitting to literals");
limitedToLiterals = true;
this.datatype = datatype;
this.language = language;
}
示例11: cast
import com.hp.hpl.jena.datatypes.RDFDatatype; //导入依赖的package包/类
static NodeMaker cast(NodeMaker nodeMaker, RDFDatatype datatype)
{
if (nodeMaker instanceof TypedNodeMaker)
return new TypedNodeMaker(TypedNodeMaker.typedLiteral(datatype), ((TypedNodeMaker) nodeMaker).valueMaker(), nodeMaker.isUnique());
if (nodeMaker instanceof FixedNodeMaker) {
Node node = nodeMaker.makeNode(null);
return new FixedNodeMaker(XSD.cast(node, datatype), nodeMaker.isUnique());
}
throw new RuntimeException("unknown nodeMaker type");
}
示例12: getNumericType
import com.hp.hpl.jena.datatypes.RDFDatatype; //导入依赖的package包/类
public static RDFDatatype getNumericType(RDFDatatype lhs, RDFDatatype rhs)
{
int lhsType = getNumericType(lhs);
int rhsType = getNumericType(rhs);
if (lhsType == XSConstants.INTEGER_DT) {
if (rhsType == XSConstants.INTEGER_DT)
return XSDDatatype.XSDinteger;
if (rhsType == XSConstants.DECIMAL_DT)
return XSDDatatype.XSDdecimal;
if (rhsType == XSConstants.FLOAT_DT)
return XSDDatatype.XSDfloat;
return XSDDatatype.XSDdouble;
} else if (lhsType == XSConstants.DECIMAL_DT) {
if (rhsType == XSConstants.INTEGER_DT || rhsType == XSConstants.DECIMAL_DT)
return XSDDatatype.XSDdecimal;
if (rhsType == XSConstants.FLOAT_DT)
return XSDDatatype.XSDfloat;
return XSDDatatype.XSDdouble;
} else if (lhsType == XSConstants.FLOAT_DT) {
if (rhsType == XSConstants.INTEGER_DT || rhsType == XSConstants.DECIMAL_DT || rhsType == XSConstants.FLOAT_DT)
return XSDDatatype.XSDfloat;
return XSDDatatype.XSDdouble;
} else if (lhsType == XSConstants.DOUBLE_DT) {
return XSDDatatype.XSDdouble;
}
throw new IllegalArgumentException();
}
示例13: isNumeric
import com.hp.hpl.jena.datatypes.RDFDatatype; //导入依赖的package包/类
public static boolean isNumeric(Node node)
{
if (!node.isLiteral())
return false;
RDFDatatype datatype = node.getLiteral().getDatatype();
return datatype != null && isNumeric(datatype);
}
示例14: createDatatypeProperty
import com.hp.hpl.jena.datatypes.RDFDatatype; //导入依赖的package包/类
private void createDatatypeProperty(Attribute column, RDFDatatype datatype) {
Resource r = propertyResource(column);
r.addProperty(RDF.type, RDF.Property);
r.addProperty(RDFS.label, toUniqueString(column));
r.addProperty(RDFS.domain, classResource(column.relationName()));
r.addProperty(RDFS.isDefinedBy, ontologyResource());
r.addProperty(RDF.type, OWL.DatatypeProperty);
if (datatype != null) {
r.addProperty(RDFS.range, this.vocabModel.getResource(datatype.getURI()));
}
}
示例15: toNode
import com.hp.hpl.jena.datatypes.RDFDatatype; //导入依赖的package包/类
private Node toNode(String value) {
if (value.startsWith("http://") || value.startsWith("https://")) {
return NodeFactory.createURI(value);
} else if (value.contains("^^")) {
String[] parts = value.split("\\^\\^");
RDFDatatype dtype = NodeFactory.getType(toUri(parts[1]));
return NodeFactory.createLiteral(unquoting(parts[0]), dtype);
} else {
return NodeFactory.createLiteral(value);
}
}