本文整理汇总了Java中com.hp.hpl.jena.datatypes.TypeMapper类的典型用法代码示例。如果您正苦于以下问题:Java TypeMapper类的具体用法?Java TypeMapper怎么用?Java TypeMapper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypeMapper类属于com.hp.hpl.jena.datatypes包,在下文中一共展示了TypeMapper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNodeType
import com.hp.hpl.jena.datatypes.TypeMapper; //导入依赖的package包/类
private NodeType getNodeType(ColumnOrTemplateValuedTermMap termMap, Position position, DataType naturalType) {
if (termMap.getTermType(position) == TermType.IRI) {
return TypedNodeMaker.URI;
}
if (termMap.getTermType(position) == TermType.BLANK_NODE) {
return TypedNodeMaker.BLANK;
}
if (termMap.getLanguageTag() != null) {
return TypedNodeMaker.languageLiteral(
termMap.getLanguageTag().toString());
}
if (termMap.getDatatype() != null) {
return TypedNodeMaker.typedLiteral(
TypeMapper.getInstance().getSafeTypeByName(termMap.getDatatype().toString()));
}
if (!XSD.xstring.getURI().equals(naturalType.rdfType())) {
return TypedNodeMaker.typedLiteral(TypeMapper.getInstance().getSafeTypeByName(naturalType.rdfType()));
}
return TypedNodeMaker.PLAIN_LITERAL;
}
示例2: writeColumn
import com.hp.hpl.jena.datatypes.TypeMapper; //导入依赖的package包/类
public void writeColumn(Attribute column) {
this.out.println(propertyBridgeIRITurtle(column) + " a d2rq:PropertyBridge;");
this.out.println("\td2rq:belongsToClassMap " + classMapIRITurtle(column.relationName()) + ";");
this.out.println("\td2rq:property " + vocabularyIRITurtle(column) + ";");
if (generateDefinitionLabels) {
this.out.println("\td2rq:propertyDefinitionLabel \"" + toLabel(column) + "\";");
}
this.out.println("\td2rq:column \"" + column.qualifiedName() + "\";");
DataType colType = this.schema.columnType(column);
String xsd = colType.rdfType();
if (xsd != null && !"xsd:string".equals(xsd)) {
// We use plain literals instead of xsd:strings, so skip
// this if it's an xsd:string
this.out.println("\td2rq:datatype " + xsd + ";");
}
if (colType.valueRegex() != null) {
this.out.println("\td2rq:valueRegex \"" + colType.valueRegex() + "\";");
}
if (xsd == null) {
createDatatypeProperty(column, null);
} else {
String datatypeURI = xsd.replaceAll("xsd:", XSDDatatype.XSD + "#");
createDatatypeProperty(column, TypeMapper.getInstance().getSafeTypeByName(datatypeURI));
}
this.out.println("\t.");
}
示例3: getLiteral
import com.hp.hpl.jena.datatypes.TypeMapper; //导入依赖的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;
}
示例4: isTypeOK
import com.hp.hpl.jena.datatypes.TypeMapper; //导入依赖的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;
}
示例5: transform
import com.hp.hpl.jena.datatypes.TypeMapper; //导入依赖的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;
}
示例6: getNodeType
import com.hp.hpl.jena.datatypes.TypeMapper; //导入依赖的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;
}
示例7: read
import com.hp.hpl.jena.datatypes.TypeMapper; //导入依赖的package包/类
@Override
public Node_Literal read(Kryo kryo, Input input, Class<Node_Literal> type) {
final String lexicalForm = input.readString();
final String langauge = input.readString();
final String datatypeURI = input.readString();
final RDFDatatype dtype = TypeMapper.getInstance().getSafeTypeByName(datatypeURI);
return (Node_Literal) Node.createLiteral(lexicalForm, langauge, dtype);
}
示例8: getLiteralDatatype
import com.hp.hpl.jena.datatypes.TypeMapper; //导入依赖的package包/类
@Override
public RDFDatatype getLiteralDatatype(){
graphDb.beginTx();
RDFDatatype datatype = null;
TypeMapper mapper = new TypeMapper();
if(delegate.hasProperty(NeoGraph.PROPERTY_DATATYPE))
datatype = mapper.getTypeByName( delegate.getProperty(NeoGraph.PROPERTY_DATATYPE).toString());
return datatype;
}
示例9: createRdfsDatatype
import com.hp.hpl.jena.datatypes.TypeMapper; //导入依赖的package包/类
private OntClass createRdfsDatatype(String newDatatypeUri, List<RDFNode> unionOfTypes,
com.hp.hpl.jena.rdf.model.Resource onDatatype, SadlDataTypeFacet facet) throws JenaProcessorException {
OntClass datatype = getTheJenaModel().createOntResource(OntClass.class, RDFS.Datatype, newDatatypeUri);
OntClass equivClass = getTheJenaModel().createOntResource(OntClass.class, RDFS.Datatype, null);
if (onDatatype != null) {
equivClass.addProperty(OWL2.onDatatype, onDatatype);
if (facet != null) {
com.hp.hpl.jena.rdf.model.Resource restrictions = facetsToRestrictionNode(newDatatypeUri, facet);
// Create a list containing the restrictions
RDFList list = getTheJenaModel().createList(new RDFNode[] { restrictions });
equivClass.addProperty(OWL2.withRestrictions, list);
}
} else if (unionOfTypes != null) {
Iterator<RDFNode> iter = unionOfTypes.iterator();
RDFList collection = getTheJenaModel().createList();
while (iter.hasNext()) {
RDFNode dt = iter.next();
collection = collection.with(dt);
}
equivClass.addProperty(OWL.unionOf, collection);
} else {
throw new JenaProcessorException("Invalid arguments to createRdfsDatatype");
}
datatype.addEquivalentClass(equivClass);
TypeMapper.getInstance().getSafeTypeByName(newDatatypeUri);
return datatype;
}
示例10: o2n
import com.hp.hpl.jena.datatypes.TypeMapper; //导入依赖的package包/类
/**
* Convert a Mulgara Value to a Jena graph node.
* @param obj The Mulgara value to convert.
* @return A new Jena graph node.
*/
static Node o2n(org.jrdf.graph.Node obj) {
if (obj == null) return Node.ANY;
// testing for org.jrdf.graph.URIReference
if (obj.isURIReference()) {
URIReference uRef = (URIReference)obj;
if (skolemizedBlankNodes) {
String x = uRef.getURI().toString();
if (x.startsWith(bNodeScheme)) {
x = x.substring(bNodeScheme.length());
Node n = Node.createAnon(new AnonId(x));
return n;
}
}
return Node.createURI(uRef.getURI().toString());
}
// testing for org.jrdf.graph.Literal
if (obj.isLiteral()) {
Literal literal = (Literal)obj;
if (literal.getDatatypeURI() != null) {
RDFDatatype type = TypeMapper.getInstance().getSafeTypeByName(literal.getDatatypeURI().toString()) ;
return Node.createLiteral(literal.getLexicalForm(), null, type);
}
return Node.createLiteral(literal.getLexicalForm(), literal.getLanguage(), null);
}
if (obj.isBlankNode()) {
BlankNodeImpl b = (BlankNodeImpl)obj;
// check if this was a Jena-allocated node
Node jenaNode = valuesToNodes.get(b);
// if not known, then create a Jena node from the Mulgara ID
return jenaNode != null ? jenaNode : Node.createAnon(new AnonId(b.getID()));
}
throw new RuntimeException("Can't convert to Jena Node : "+obj) ;
}
示例11: createLiteral
import com.hp.hpl.jena.datatypes.TypeMapper; //导入依赖的package包/类
/**
* Create a literal node with the content passed as argument
*
* @param content string content to represent inside the literal
* @return a literal node in using the model used by this backend
*/
@Override
public RDFNode createLiteral(String content, Locale language, URI type) {
if(language != null && type == null) {
return model.createLiteral(content,language.getLanguage());
} else if(language == null && type != null) {
return model.createTypedLiteral(content, TypeMapper.getInstance().getSafeTypeByName(type.toString()));
} else {
return model.createLiteral(content);
}
}
示例12: createLiteral
import com.hp.hpl.jena.datatypes.TypeMapper; //导入依赖的package包/类
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 = Node.createLiteral(lexicalForm, null, dType) ;
}
else
n = Node.createLiteral(lexicalForm, langTag, null) ;
return n ;
}
示例13: testSomeRDFDatatypeToString
import com.hp.hpl.jena.datatypes.TypeMapper; //导入依赖的package包/类
@Test
public void testSomeRDFDatatypeToString() {
RDFDatatype someDatatype = TypeMapper.getInstance().getSafeTypeByName("http://example.org/mytype");
assertEquals("<http://example.org/mytype>", PrettyPrinter.toString(someDatatype));
}
示例14: buildDatatype
import com.hp.hpl.jena.datatypes.TypeMapper; //导入依赖的package包/类
private RDFDatatype buildDatatype(String datatypeURI) {
return TypeMapper.getInstance().getSafeTypeByName(datatypeURI);
}
示例15: testSomeRDFDatatypeToString
import com.hp.hpl.jena.datatypes.TypeMapper; //导入依赖的package包/类
public void testSomeRDFDatatypeToString() {
RDFDatatype someDatatype = TypeMapper.getInstance().getSafeTypeByName("http://example.org/mytype");
assertEquals("<http://example.org/mytype>", PrettyPrinter.toString(someDatatype));
}