本文整理汇总了Java中com.hp.hpl.jena.datatypes.xsd.XSDDatatype类的典型用法代码示例。如果您正苦于以下问题:Java XSDDatatype类的具体用法?Java XSDDatatype怎么用?Java XSDDatatype使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
XSDDatatype类属于com.hp.hpl.jena.datatypes.xsd包,在下文中一共展示了XSDDatatype类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addQualityReport
import com.hp.hpl.jena.datatypes.xsd.XSDDatatype; //导入依赖的package包/类
public Resource addQualityReport(Model model) {
Resource qualityReport = model.createResource(LDQM.QUALITY_REPORT_PREFIX + UUID.randomUUID().toString(),QPRO.QualityReport);
qualityReport.addProperty(QPRO.computedOn, ResourceFactory.createTypedLiteral(DATE_FORMAT.format(new Date()), XSDDatatype.XSDdateTime));
Resource noDerefSubjectsProblem = model.createResource(QPRO.QualityProblem);
noDerefSubjectsProblem.addProperty(QPRO.isDescribedBy, LDQM.IRIdereferenceability);
for (HttpResponse response : responseMap.values()) {
if (response.getStatusCode() >= 300 || response.getStatusCode() < 200) {
Resource errSubject = model.createResource(LDQM.Defect_UndereferenceableURI);
errSubject.addProperty(DCTerms.subject,response.getUri());
if (response.getStatusCode() > 0) {
errSubject.addLiteral(HTTP.statusCodeValue, model.createTypedLiteral(response.getStatusCode(), XSDDatatype.XSDint));
}
errSubject.addLiteral(HTTP.methodName, response.getMethod());
if (response.getReason() != null) {
errSubject.addLiteral(HTTP.reasonPhrase, response.getReason());
}
noDerefSubjectsProblem.addProperty(QPRO.problematicThing, errSubject);
}
}
qualityReport.addProperty(QPRO.hasProblem, noDerefSubjectsProblem);
qualityReport.addProperty(PROV.wasGeneratedBy, evaluation);
return qualityReport;
}
示例2: typedLiteral
import com.hp.hpl.jena.datatypes.xsd.XSDDatatype; //导入依赖的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);
}
示例3: testNodePrettyPrinting
import com.hp.hpl.jena.datatypes.xsd.XSDDatatype; //导入依赖的package包/类
@Test
public void testNodePrettyPrinting() {
assertEquals("\"foo\"",
PrettyPrinter.toString(Node.createLiteral("foo")));
assertEquals("\"foo\"@en",
PrettyPrinter.toString(Node.createLiteral("foo", "en", null)));
assertEquals("\"1\"^^xsd:int",
PrettyPrinter.toString(Node.createLiteral("1", null, XSDDatatype.XSDint)));
assertEquals("\"1\"^^xsd:int",
PrettyPrinter.toString(Node.createLiteral("1", null, XSDDatatype.XSDint), PrefixMapping.Standard));
assertEquals("_:foo",
PrettyPrinter.toString(Node.createAnon(new AnonId("foo"))));
assertEquals("<http://example.org/>",
PrettyPrinter.toString(Node.createURI("http://example.org/")));
assertEquals("<" + RDF.type.getURI() + ">",
PrettyPrinter.toString(RDF.type.asNode(), new PrefixMappingImpl()));
assertEquals("rdf:type",
PrettyPrinter.toString(RDF.type.asNode(), PrefixMapping.Standard));
assertEquals("?x",
PrettyPrinter.toString(Node.createVariable("x")));
assertEquals("?ANY",
PrettyPrinter.toString(Node.ANY));
}
示例4: writeColumn
import com.hp.hpl.jena.datatypes.xsd.XSDDatatype; //导入依赖的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.");
}
示例5: testSPARQLGetTopics
import com.hp.hpl.jena.datatypes.xsd.XSDDatatype; //导入依赖的package包/类
public void testSPARQLGetTopics() {
sparql("SELECT ?x ?y WHERE { ?x skos:primarySubject ?z . ?z skos:prefLabel ?y }");
// dump();
expectVariable("x", this.model.createResource("http://test/papers/1"));
expectVariable("y", this.model.createTypedLiteral("Semantic Web", XSDDatatype.XSDstring));
assertSolution();
expectVariable("x", this.model.createResource("http://test/papers/4"));
expectVariable("y", this.model.createTypedLiteral("Semantic Web Infrastructure", XSDDatatype.XSDstring));
assertSolution();
expectVariable("x", this.model.createResource("http://test/papers/5"));
expectVariable("y", this.model.createTypedLiteral("Artificial Intelligence", XSDDatatype.XSDstring));
assertSolution();
assertResultCount(3);
}
示例6: testDataType
import com.hp.hpl.jena.datatypes.xsd.XSDDatatype; //导入依赖的package包/类
public void testDataType()
{
List<Triple> pattern = new ArrayList<Triple>();
pattern.add(Triple.create(Node.createVariable("s"), Node.createURI("http://example.org/value"), Node.createVariable("o")));
NodeRelation[] rels = translate(pattern, "optimizer/filtertests.n3");
NodeRelation intvalue = search("table2", "intvalue", rels);
NodeRelation value = search("table2", "value", rels);
pattern.clear();
pattern.add(Triple.create(Node.createVariable("s"), RDFS.label.asNode(), Node.createVariable("o")));
rels = translate(pattern, "optimizer/filtertests.n3");
NodeRelation langliteral = search("table1", "label_en", rels);
Expr filterint = new E_Equals(new E_Datatype(new ExprVar("o")), NodeValueNode.makeNode(Node.createURI(XSDDatatype.XSDint.getURI())));
Expr filterstring = new E_Equals(new E_Datatype(new ExprVar("o")), NodeValueNode.makeNode(Node.createURI(XSDDatatype.XSDstring.getURI())));
assertEquals("DATATYPE(intliteral) = xsd:int should be TRUE", Expression.TRUE, TransformExprToSQLApplyer.convert(filterint, intvalue));
assertEquals("DATATYPE(simpleliteral) = xsd:string should be TRUE", Expression.TRUE, TransformExprToSQLApplyer.convert(filterstring, value));
assertEquals("DATATYPE(langliteral) = xsd:string should be TRUE", Expression.TRUE, TransformExprToSQLApplyer.convert(filterstring, langliteral));
}
示例7: testDisjunction
import com.hp.hpl.jena.datatypes.xsd.XSDDatatype; //导入依赖的package包/类
public void testDisjunction()
{
List<Triple> pattern = new ArrayList<Triple>();
pattern.add(Triple.create(Node.createVariable("s"), Node.createURI("http://example.org/value"), Node.createVariable("o")));
NodeRelation[] rels = translate(pattern, "optimizer/filtertests.n3");
NodeRelation intvalue = search("table2", "intvalue", rels);
Expr disjunction = new E_LogicalOr(new E_Equals(new ExprVar("o"), NodeValue.makeNode("1", XSDDatatype.XSDint)), new E_Equals(new ExprVar("o"), NodeValue.makeNode("2", XSDDatatype.XSDint)));
Expression result = TransformExprToSQLApplyer.convert(disjunction, intvalue);
TypedNodeMaker nm = (TypedNodeMaker) intvalue.nodeMaker(Var.alloc("o"));
Expression e1 = nm.valueMaker().valueExpression("1");
Expression e2 = nm.valueMaker().valueExpression("2");
Expression expected = e1.or(e2);
assertEquals("?o = \"1\"^^xsd:int || ?o = \"2\"^^xsd:int", expected, result);
}
示例8: testNodePrettyPrinting
import com.hp.hpl.jena.datatypes.xsd.XSDDatatype; //导入依赖的package包/类
public void testNodePrettyPrinting() {
assertEquals("\"foo\"",
PrettyPrinter.toString(Node.createLiteral("foo")));
assertEquals("\"foo\"@en",
PrettyPrinter.toString(Node.createLiteral("foo", "en", null)));
assertEquals("\"1\"^^<" + XSDDatatype.XSDint.getURI() + ">",
PrettyPrinter.toString(Node.createLiteral("1", null, XSDDatatype.XSDint)));
assertEquals("\"1\"^^xsd:int",
PrettyPrinter.toString(Node.createLiteral("1", null, XSDDatatype.XSDint), PrefixMapping.Standard));
assertEquals("_:foo",
PrettyPrinter.toString(Node.createAnon(new AnonId("foo"))));
assertEquals("<http://example.org/>",
PrettyPrinter.toString(Node.createURI("http://example.org/")));
assertEquals("<" + RDF.type.getURI() + ">",
PrettyPrinter.toString(RDF.type.asNode(), new PrefixMappingImpl()));
assertEquals("rdf:type",
PrettyPrinter.toString(RDF.type.asNode(), PrefixMapping.Standard));
assertEquals("?x",
PrettyPrinter.toString(Node.createVariable("x")));
assertEquals("?ANY",
PrettyPrinter.toString(Node.ANY));
}
示例9: verifyValue
import com.hp.hpl.jena.datatypes.xsd.XSDDatatype; //导入依赖的package包/类
@Override
protected QueryIterator verifyValue(Binding binding, Graph graph, Node product, Geometry geometry, Node object,
ExecutionContext execCxt) {
boolean b = false;
try {
if (product.getLocalName().equals("IfcWallStandardCase_5397")){
System.out.println("");
}
HashSet<Geometry> allGeometries=getProcessableElements(graph);
b = new ExternalQuadTreeImpl(geometry, allGeometries).getIsExternal();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Node node = NodeFactory.createLiteral(Boolean.toString(b), null, XSDDatatype.XSDboolean);
if (node.equals(object)) {
return IterLib.result(binding, execCxt);
} else {
return IterLib.noResults(execCxt);
}
}
示例10: createObservations
import com.hp.hpl.jena.datatypes.xsd.XSDDatatype; //导入依赖的package包/类
private void createObservations(List<Property> headers, Resource ds) {
HashMap<Integer, HashMap<String, Resource>> entities = createEntities();
String obsPrefix = localNS.DATASET + "-" + id + "/" + localNS.OBS_NAME + "-";
for (Row row : table.getRows()) {
Resource obs = model.createResource(obsPrefix + UUID.randomUUID()).addProperty(RDF.type, QB.OBSERVATION);
obs.addProperty(QB.DATASET_PROPERTY, ds);
for (int i = 0; i < row.getCells().size(); i++) {
Cell cell = row.getCells().get(i);
if (i < getMeasureCount()) {
// TODO use more data types
XSDDatatype xsdDatatype = XSDDatatype.XSDdouble;
Literal literal = model.createTypedLiteral(cell.getValue().getValue(), xsdDatatype);
obs.addProperty(headers.get(i), literal);
} else {
Resource entity = entities.get(i).get(cell.getValue().getValue());
obs.addProperty(headers.get(i), entity);
}
}
}
}
示例11: readXPathPointerRange
import com.hp.hpl.jena.datatypes.xsd.XSDDatatype; //导入依赖的package包/类
private Resource readXPathPointerRange(XPathPointerRange item) {
Resource result = addRangeProperties(item, XSDDatatype.XSDnonNegativeInteger);
Statement statement = null;
String hasXPathContext = item.hasXPathContext();
try {
result.addProperty(phasxpathcontext_r, hasXPathContext.toString(), XSDDatatype.XSDstring);
} catch (NullPointerException e) {
getLogger().warning("The XPath pointer range " + item.hasId() + " has not any XPath context specified"
+ " [in 'readXPathPointerRange' method]\nException: " + e.getMessage());
statement = model.createStatement(result, RDF.type, xpathpointerrange_r);
}
if (statement == null) {
model.add(result, RDF.type, xpathpointerrange_r);
} else {
model.add(statement);
}
return result;
}
示例12: readDocuverse
import com.hp.hpl.jena.datatypes.xsd.XSDDatatype; //导入依赖的package包/类
private Docuverse readDocuverse(Resource resource) {
Docuverse result = null;
Statement hasContent = resource.getProperty(phascontent_r);
try {
if (hasContent.getObject().asNode().getLiteralDatatype().equals(XSDDatatype.XSDanyURI)) {
result = readURIDocuverse(resource);
} else {
result = readStringDocuverse(resource);
}
} catch (Exception e) {
result = readStringDocuverse(resource);
}
return result;
}
示例13: parseNumber
import com.hp.hpl.jena.datatypes.xsd.XSDDatatype; //导入依赖的package包/类
/**
* Turn a possible numeric token into typed literal else a plain literal
* @return the constructed literal node
*/
Node parseNumber(String lit) {
if ( Character.isDigit(lit.charAt(0)) ||
(lit.charAt(0) == '-' && lit.length() > 1 && Character.isDigit(lit.charAt(1))) ) {
if (lit.indexOf(".") != -1) {
// Float?
if (XSDDatatype.XSDfloat.isValid(lit)) {
return Node.createLiteral(lit, "", XSDDatatype.XSDfloat);
}
} else {
// Int?
if (XSDDatatype.XSDint.isValid(lit)) {
return Node.createLiteral(lit, "", XSDDatatype.XSDint);
}
}
}
// Default is a plain literal
return Node.createLiteral(lit, "", false);
}
示例14: toLightString
import com.hp.hpl.jena.datatypes.xsd.XSDDatatype; //导入依赖的package包/类
/**
* Convert a resource to its string representation and try to replace the namespace by its prefix (or remove it if it's the default one).<br/>
* It uses {@link #contract(String)} to replace or remove the namespace.<br/>
* If the prefix for the namespace is unknown, complete URI is returned.
*
* @param res The RDFNode which is to output as a string.
* @return The literal representation of the resource, with short namespace (or no namespace if it is the default one).
*/
public static String toLightString(final RDFNode res)
{
if (res.isAnon()) return "anonymousNode_" + res.toString();
if (res.isResource() && ((Resource)res).getURI() != null)
return contract(((Resource)res).getURI());
if (res.isLiteral())
{
Literal lit = (Literal)res;
if (lit.getDatatype() == XSDDatatype.XSDdouble ||
lit.getDatatype() == XSDDatatype.XSDint ||
lit.getDatatype() == XSDDatatype.XSDboolean)
return lit.getLexicalForm();
if (lit.getDatatype() == null) //plain literal
return lit.getLexicalForm();
return "'" + lit.getLexicalForm() + "'^^" + contract((lit).getDatatypeURI());
}
return res.toString();
}
示例15: createAmount
import com.hp.hpl.jena.datatypes.xsd.XSDDatatype; //导入依赖的package包/类
protected Resource createAmount(Model m, Resource measurement,
MeasurementValue v, Resource unit) {
Resource amount = m.createResource(
fragment(measurement, v.getPhenomenon().getName() +
VALUE_FRAGMENT_POSTFIX));
amount.addProperty(RDF.type, DUL.Amount);
amount.addProperty(DUL.isClassifiedBy, unit);
if (v.getValue() instanceof Number) {
amount.addLiteral(DUL.hasDataValue,
((Number) v.getValue()).doubleValue());
} else if (v.getValue() instanceof Boolean) {
amount.addLiteral(DUL.hasDataValue,
((Boolean) v.getValue()).booleanValue());
} else if (v.getValue() instanceof String) {
amount.addProperty(DUL.hasDataValue,
(String) v.getValue(),
XSDDatatype.XSDstring);
} else {
amount.addProperty(DUL.hasDataValue,
v.getValue().toString(),
XSDDatatype.XSDstring);
}
return amount;
}