本文整理汇总了Java中com.hp.hpl.jena.datatypes.TypeMapper类的典型用法代码示例。如果您正苦于以下问题:Java TypeMapper类的具体用法?Java TypeMapper怎么用?Java TypeMapper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypeMapper类属于com.hp.hpl.jena.datatypes包,在下文中一共展示了TypeMapper类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:d2rq,项目名称:r2rml-kit,代码行数:21,代码来源:R2RMLCompiler.java
示例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.");
}
开发者ID:aitoralmeida,项目名称:c4a_data_repository,代码行数:27,代码来源:MappingGenerator.java
示例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;
}
开发者ID:semr,项目名称:neo4jena,代码行数:19,代码来源:JenaNeoNode.java
示例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;
}
开发者ID:jacekkopecky,项目名称:parkjam,代码行数:21,代码来源:IsDType.java
示例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;
}
开发者ID:kmi,项目名称:msm4j,代码行数:29,代码来源:OwlsTransformer.java
示例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;
}
开发者ID:d2rq,项目名称:r2rml-kit,代码行数:14,代码来源:NodeMakerFactory.java
示例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);
}
开发者ID:openimaj,项目名称:openimaj,代码行数:10,代码来源:JenaStormUtils.java
示例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;
}
开发者ID:semr,项目名称:neo4jena,代码行数:10,代码来源:JenaNeoNode.java
示例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;
}
开发者ID:crapo,项目名称:sadlos2,代码行数:28,代码来源:JenaBasedSadlModelProcessor.java
示例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) ;
}
开发者ID:quoll,项目名称:mulgara,代码行数:43,代码来源:Jenara.java
示例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);
}
}
开发者ID:apache,项目名称:marmotta,代码行数:17,代码来源:GenericJenaBackend.java
示例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 ;
}
开发者ID:jacekkopecky,项目名称:parkjam,代码行数:14,代码来源:ParserBase.java
示例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));
}
开发者ID:d2rq,项目名称:r2rml-kit,代码行数:6,代码来源:PrettyPrinterTest.java
示例14: buildDatatype
import com.hp.hpl.jena.datatypes.TypeMapper; //导入依赖的package包/类
private RDFDatatype buildDatatype(String datatypeURI) {
return TypeMapper.getInstance().getSafeTypeByName(datatypeURI);
}
开发者ID:aitoralmeida,项目名称:c4a_data_repository,代码行数:4,代码来源:ResourceMap.java
示例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));
}
开发者ID:aitoralmeida,项目名称:c4a_data_repository,代码行数:5,代码来源:PrettyPrinterTest.java
示例16: testOldDataTypesUsedAsIntended
import com.hp.hpl.jena.datatypes.TypeMapper; //导入依赖的package包/类
@Test
public void testOldDataTypesUsedAsIntended() throws Exception {
// laut der jena-dev Mailingliste, sollte man Datentypen so erzeugen:
// siehe http://groups.yahoo.com/group/jena-dev/message/14052
// String dtURI = tmpProp.getRange().getURI();
// RDFDatatype dt = TypeMapper.getInstance().getTypeByName(dtURI);
// Literal tmpLit = tmpModel.createTypedLiteral("123", dt );
// leider f�hrt das dann dazu das "test"^^xsd:funky equal zu "test" ist,
// da dann xsd:funky ein unknown data type ist und
// somit "test"^^xsd:funky genau wie ein plain literal behandelt wird.
// die erste DatenTyp URI
// URI testA = URIUtils.createURI("test://somedata-A");
String strTestA = new String("test://somedata-A");
// die zweite DatenTyp URI
// URI testB = URIUtils.createURI("test://somedata-B");
String strTestB = new String("test://somedata-B");
// der erste BaseDatatype wird von der ersten DatenTyp URI erzeugt
RDFDatatype DTtestA1 = TypeMapper.getInstance().getTypeByName(strTestA);
// der zweite BaseDatatype ebenso
RDFDatatype DTtestA2 = TypeMapper.getInstance().getTypeByName(strTestA);
// f�r den dritten BaseDatatype nehmen wir eine neue Datentyp URI
RDFDatatype DTtestB = TypeMapper.getInstance().getTypeByName(strTestB);
com.hp.hpl.jena.rdf.model.Model model = ModelFactory.createDefaultModel();
Literal litA11 = model.createTypedLiteral("teststring", DTtestA1);
Literal litA12 = model.createTypedLiteral("teststring", DTtestA1);
Literal litA2 = model.createTypedLiteral("teststring", DTtestA2);
@SuppressWarnings("unused")
Literal litB = model.createTypedLiteral("teststring", DTtestB);
// alle Literals haben den gleichen Wert !
// dann wollen wir mal schauen was passiert:
// reflexivit�t: A == A , passt
assertTrue(litA11.equals(litA11));
// gleicher Inhalt, in zwei versch. Objekten, passt auch
assertTrue(litA11.equals(litA12));
// zwei Objekte, mit untersch. BaseDatatypes, von der gleichen Datatype
// URI:
assertTrue(litA11.equals(litA2));
// und zur sicherheit: 2 versch Datentyp URIs:
// -> das sollte eigentlich nicht sein
// TODO jena bug assertFalse(litA11.equals(litB));
}
开发者ID:semweb4j,项目名称:semweb4j,代码行数:55,代码来源:DataTypeTesting.java
示例17: loadXSDSimpleTypes
import com.hp.hpl.jena.datatypes.TypeMapper; //导入依赖的package包/类
/**
* Add all of the XSD pre-defined simple types to the given type mapper
* registry.
*/
public static void loadXSDSimpleTypes(TypeMapper tm) {
tm.registerDatatype(new XSDDatatype("anySimpleType"));
tm.registerDatatype(XSDdecimal);
tm.registerDatatype(XSDinteger);
tm.registerDatatype(XSDnonPositiveInteger);
tm.registerDatatype(XSDnonNegativeInteger);
tm.registerDatatype(XSDpositiveInteger);
tm.registerDatatype(XSDnegativeInteger);
tm.registerDatatype(XSDbyte);
tm.registerDatatype(XSDunsignedByte);
tm.registerDatatype(XSDdouble);
tm.registerDatatype(XSDfloat);
tm.registerDatatype(XSDlong);
tm.registerDatatype(XSDunsignedInt);
tm.registerDatatype(XSDunsignedShort);
tm.registerDatatype(XSDunsignedLong);
tm.registerDatatype(XSDint);
tm.registerDatatype(XSDshort);
tm.registerDatatype(XSDboolean);
tm.registerDatatype(XSDbase64Binary);
tm.registerDatatype(XSDhexBinary);
tm.registerDatatype(XSDdate);
tm.registerDatatype(XSDtime);
tm.registerDatatype(XSDdateTime);
tm.registerDatatype(XSDduration);
tm.registerDatatype(XSDgYearMonth);
tm.registerDatatype(XSDgMonthDay);
tm.registerDatatype(XSDgMonth);
tm.registerDatatype(XSDgDay);
tm.registerDatatype(XSDgYear);
tm.registerDatatype(XSDnormalizedString);
tm.registerDatatype(XSDstring);
tm.registerDatatype(XSDanyURI);
tm.registerDatatype(XSDtoken);
tm.registerDatatype(XSDName);
tm.registerDatatype(XSDlanguage);
tm.registerDatatype(XSDQName);
tm.registerDatatype(XSDNMTOKEN);
tm.registerDatatype(XSDID);
tm.registerDatatype(XSDENTITY);
tm.registerDatatype(XSDNCName);
tm.registerDatatype(XSDNOTATION);
tm.registerDatatype(XSDIDREF);
// tm.registerDatatype(XSDIDREFS);
// tm.registerDatatype(XSDENTITIES);
// tm.registerDatatype(XSDNMTOKENS);
}
开发者ID:jacekkopecky,项目名称:parkjam,代码行数:59,代码来源:XSDDatatype.java
示例18: getType
import com.hp.hpl.jena.datatypes.TypeMapper; //导入依赖的package包/类
public static RDFDatatype getType( String s )
{ return TypeMapper.getInstance().getSafeTypeByName( s ); }
开发者ID:jacekkopecky,项目名称:parkjam,代码行数:3,代码来源:Node.java
示例19: serializeSummary
import com.hp.hpl.jena.datatypes.TypeMapper; //导入依赖的package包/类
public Model serializeSummary (BoundingBox bbox)
{
// define GEO classes
OntClass GeoGeometry = modelGEO.createClass( GEO_URI + "Geometry" );
OntClass GeoSpatialObject = modelGEO.createClass( GEO_URI + "SpatialObject");
OntProperty GeoasWKT = modelGEO.createObjectProperty(GEO_URI + "asWKT");
OntProperty GeosfContains = modelGEO.createObjectProperty(GEO_URI + "sfContains");
OntProperty GeohasGeometry = modelGEO.createObjectProperty(GEO_URI + "hasGeometry");
// create models
OntModel model = ModelFactory.createOntologyModel();
// create prefixes
model.setNsPrefix("geo", GEO_URI);
model.setNsPrefix("oa", OPEN_ANNOTATION_URI);
model.setNsPrefix("prov", PROV_URI);
model.setNsPrefix("geosummly", GEOSUMMLY_URI);
RDFDatatype wkttype = WKTType.type;
TypeMapper.getInstance().registerDatatype(wkttype);
// some definitions
String summaryURI = GEOSUMMLY_URI
.concat("summary/")
.concat(UUID.randomUUID().toString());
String ne = Double.toString(bbox.getNorth().doubleValue())
.concat(" " + Double.toString(bbox.getEast().doubleValue()) );
String sw = Double.toString(bbox.getSouth().doubleValue())
.concat(" " + Double.toString(bbox.getWest().doubleValue()) );
String polygon = "Polygon(("
.concat(ne)
.concat("),(")
.concat(sw)
.concat("))");
Literal wkt = model.createTypedLiteral(polygon, wkttype);
Resource geometry = model.createResource().addProperty(GeoasWKT, wkt);
Resource summary = model.createResource(summaryURI)
.addProperty(RDF.type, GeoSpatialObject)
.addProperty(RDFS.label, "geosummly")
.addProperty(GeohasGeometry, geometry);
for (Resource r : fingerprints)
summary.addProperty(GeosfContains, r);
return model;
}
开发者ID:giusepperizzo,项目名称:geosummly,代码行数:50,代码来源:GeoTurtleWriter.java
示例20: obtainAxiom
import com.hp.hpl.jena.datatypes.TypeMapper; //导入依赖的package包/类
private LogicalAxiom obtainAxiom(Model model, QuerySolution querySolution, LogicalAxiom.Type type) {
LogicalAxiom result = null;
Resource res;
// Get the appropriate resource
if (type == LogicalAxiom.Type.CONDITION) {
res = querySolution.getResource(CONDITION_VAR);
} else {
res = querySolution.getResource(EFFECT_VAR);
}
if (res != null) {
URI axiomUri = null;
try {
if (!res.isAnon()) {
axiomUri = new URI(res.getURI());
}
// TODO: earlier version used to deal with labels on conditions. Keep this?
// Set the axiom
Literal body;
Resource lang;
if (type == LogicalAxiom.Type.CONDITION) {
result = new Condition(axiomUri);
body = querySolution.getLiteral(CONDITION_EXPR_BODY_VAR);
lang = querySolution.getResource(CONDITION_EXPR_LANG_VAR);
} else {
result = new Effect(axiomUri);
body = querySolution.getLiteral(EFFECT_EXPR_BODY_VAR);
lang = querySolution.getResource(EFFECT_EXPR_LANG_VAR);
}
// Clean the body
String expression = body.getString().trim();
expression = expression.replaceAll("[\n\t]", "");
Literal exprLiteral;
if (lang != null) {
exprLiteral = model.createTypedLiteral(expression, TypeMapper.getInstance().getTypeByName(lang.getURI()));
} else {
exprLiteral = model.createLiteral(expression, null);
}
result.setTypedValue(exprLiteral.getValue());
} catch (URISyntaxException e) {
log.error("Incorrect URI specified for Axiom", e);
}
}
return result;
}
开发者ID:kmi,项目名称:msm4j,代码行数:54,代码来源:OwlsTransformer.java
注:本文中的com.hp.hpl.jena.datatypes.TypeMapper类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论