com.hp.hpl.jena.datatypes.TypeMapper Java Examples
The following examples show how to use
com.hp.hpl.jena.datatypes.TypeMapper.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GeneralR2RMLCompiler.java From GeoTriples with Apache License 2.0 | 6 votes |
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; }
Example #2
Source File: R2RMLCompiler.java From GeoTriples with Apache License 2.0 | 6 votes |
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; }
Example #3
Source File: JenaNeoNode.java From neo4jena with Apache License 2.0 | 6 votes |
@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; }
Example #4
Source File: GeneralR2RMLCompiler.java From GeoTriples with Apache License 2.0 | 5 votes |
public void visitComponent(GeometryFunction gf,GeometryParametersTerms.Position position, ConstantIRI datatype) { GeometryParametersTerms termMaptemp =null; for(Resource r:gf.getObjectMaps().keySet()) { termMaptemp=gf.getObjectMaps().get(r); } GeometryParametersTerms.ColumnValuedTermMap termMap=(GeometryParametersTerms.ColumnValuedTermMap)termMaptemp; ColumnName qualified = ColumnName.create(table.getTableName(), termMap.getColumnName().asIdentifier(Vendor.MySQL)); NodeType nodeType=null; if(datatype!=null) { nodeType= TypedNodeMaker.typedLiteral( TypeMapper.getInstance().getSafeTypeByName(datatype.toString())); } else { nodeType = TypedNodeMaker.URI;//getNodeType(termMap, position, table.getColumnType(qualified)); } ValueMaker baseValueMaker = new ColumnValueMaker(qualified); if (nodeType == TypedNodeMaker.URI) { baseValueMaker = new BaseIRIValueMaker(mapping.getBaseIRI(), baseValueMaker); } result = new TypedNodeTransformationMaker(nodeType, baseValueMaker,gf.getFunction(), connection); }
Example #5
Source File: NodeMakerFactory.java From GeoTriples with Apache License 2.0 | 5 votes |
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; }
Example #6
Source File: JenaNeoNode.java From neo4jena with Apache License 2.0 | 5 votes |
@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; }
Example #7
Source File: DataTypeTesting.java From semweb4j with BSD 2-Clause "Simplified" License | 4 votes |
@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)); }