本文整理匯總了Java中com.hp.hpl.jena.rdf.model.ResourceFactory.createPlainLiteral方法的典型用法代碼示例。如果您正苦於以下問題:Java ResourceFactory.createPlainLiteral方法的具體用法?Java ResourceFactory.createPlainLiteral怎麽用?Java ResourceFactory.createPlainLiteral使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.hp.hpl.jena.rdf.model.ResourceFactory
的用法示例。
在下文中一共展示了ResourceFactory.createPlainLiteral方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: convertToJenaRDFNode
import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入方法依賴的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 );
}
}
示例2: coerce
import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入方法依賴的package包/類
RDFNode coerce(RDFNode in) {
if (in.isAnon()) return null;
if (in.isURIResource()) {
return ResourceFactory.createPlainLiteral(in.asResource().getURI());
}
return ResourceFactory.createPlainLiteral(in.asLiteral().getLexicalForm());
}
示例3: convertObjectNodeToRes
import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入方法依賴的package包/類
private RDFNode convertObjectNodeToRes(Node object) {
RDFNode objRes;
// URI
if (object.isURI()) {
objRes = ResourceFactory.createResource(object.getURI());
// literal
} else if (object.isLiteral()) {
// typed literal
if (object.getLiteralDatatypeURI() != null
&& !object.getLiteralDatatypeURI().isEmpty()) {
objRes = ResourceFactory.createTypedLiteral(
object.getLiteralLexicalForm(),
object.getLiteralDatatype());
} else {
// plain literal with lang tag
if (object.getLiteralLanguage() != null
&& !object.getLiteralLanguage().isEmpty()) {
objRes = ResourceFactory.createLangLiteral(
object.getLiteralLexicalForm(),
object.getLiteralLanguage());
// plain literal without lang tag
} else {
objRes = ResourceFactory.createPlainLiteral(object
.getLiteralLexicalForm());
}
}
} else {
// blank node
objRes = ResourceFactory.createResource();
}
return objRes;
}
示例4: getMapObject
import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入方法依賴的package包/類
public Literal getMapObject() {
StringBuilder exprStrBuilder = new StringBuilder();
if (getMapPredicate().equals(RR.column)) {
// there is only one variable in this.exprs
Var colVar = expr.asVar();
exprStrBuilder.append(colVar.getName());
} else {
for (Expr arg : expr.getFunction().getArgs()) {
buildMapObjStr(exprStrBuilder, arg);
}
}
return ResourceFactory.createPlainLiteral(exprStrBuilder.toString());
}
示例5: getLang
import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入方法依賴的package包/類
public Literal getLang() {
if (langStr != null) {
return ResourceFactory.createPlainLiteral(langStr);
} else {
return null;
}
}
示例6: buildLogicalTableTriple
import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入方法依賴的package包/類
/**
* Builds up the one triple that states where the actual data for the target
* mapping comes from. Such a source can be simply a database table or an
* SQL query.
*
* @param relation the data source (table name or SQL query)
* @param r2rml the target Jena model
* @return the whole Statement stating where the data comes from,
* e.g. '[] rr:tableName "EMP"'
* @throws SMLVocabException
*/
private static Statement buildLogicalTableTriple(SqlOpBase relation, Model r2rml) throws SMLVocabException {
// subject (a blank node [])
Resource logicalTableSubject = ResourceFactory.createResource();
// predicate (rr:tableName or rr:sqlQuery)
Property logicalTablePredicate;
// object (a Literal like "SELECT DEPTNO FROM DEPT WHERE DEPTNO > 23" or
// simply a table name like "DEPTNO"
Literal logicalTableObject;
if (relation instanceof SqlOpTable) {
// it's a table
SqlOpTable tbl = (SqlOpTable) relation;
logicalTablePredicate = RR.tableName;
logicalTableObject = ResourceFactory.createPlainLiteral(tbl.getTableName());
} else if (relation instanceof SqlOpQuery) {
// it's a query
SqlOpQuery query = (SqlOpQuery) relation;
logicalTablePredicate = RR.sqlQuery;
logicalTableObject = ResourceFactory.createPlainLiteral(query.getQueryString());
} else {
// it's not possible
throw new SMLVocabException();
}
Statement logicalTblStatement = r2rml.createStatement(
logicalTableSubject, logicalTablePredicate, logicalTableObject);
return logicalTblStatement;
}
示例7: createRDFNode
import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入方法依賴的package包/類
private RDFNode createRDFNode(Column column, Object value) {
RDFNode node = ResourceFactory.createResource(); //bnode
DataType t = column.getType();
switch(t) {
case TEXT:
case MEMO:
case GUID:
if (isURI(value.toString())) {
node = ResourceFactory.createTypedLiteral(value.toString(), XSDDatatype.XSDanyURI);
break;
} else if (isSentence(value.toString())) {
if ((Boolean) getConfig().get("useLangTag")) {
String lang = (String) getConfig().get("langTag");
node = ResourceFactory.createLangLiteral(value.toString(), lang);
}
else {
node = ResourceFactory.createTypedLiteral(value.toString(), XSDDatatype.XSDstring);
}
break;
}
node = ResourceFactory.createResource(genRURI(value.toString()));
break;
case BINARY:
node = ResourceFactory.createTypedLiteral(value.toString(), XSDDatatype.XSDbase64Binary);
break;
case BOOLEAN:
node = ResourceFactory.createTypedLiteral(value.toString(), XSDDatatype.XSDboolean);
break;
case BYTE:
node = ResourceFactory.createTypedLiteral(value.toString(), XSDDatatype.XSDbyte);
break;
case DOUBLE:
node = ResourceFactory.createTypedLiteral(value.toString(), XSDDatatype.XSDdouble);
break;
case FLOAT:
node = ResourceFactory.createTypedLiteral(value.toString(), XSDDatatype.XSDfloat);
break;
case INT:
node = ResourceFactory.createTypedLiteral(value.toString(), XSDDatatype.XSDint);
break;
case LONG:
case COMPLEX_TYPE:
node = ResourceFactory.createTypedLiteral(value.toString(), XSDDatatype.XSDlong);
break;
case NUMERIC:
case MONEY:
node = ResourceFactory.createTypedLiteral(value.toString(), XSDDatatype.XSDdecimal);
break;
case SHORT_DATE_TIME:
node = ResourceFactory.createTypedLiteral(value.toString(), XSDDatatype.XSDdate);
break;
default:
node = ResourceFactory.createPlainLiteral(value.toString());
break;
}
return node;
}
示例8: validate
import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入方法依賴的package包/類
/**
* Test the consistency of the bound data. This normally tests
* the validity of the bound instance data against the bound
* schema data.
* @return a ValidityReport structure
*/
@Override
public ValidityReport validate() {
checkOpen();
StandardValidityReport report = new StandardValidityReport();
// Switch on validation
Triple validateOn = new Triple(Node.createAnon(),
ReasonerVocabulary.RB_VALIDATION.asNode(),
Functor.makeFunctorNode("on", new Node[] {}));
// We sneak this switch directly into the engine to avoid contaminating the
// real data - this is only possible only the forward engine has been prepared
// add(validateOn);
if (!isPrepared) {
prepare();
}
engine.add(validateOn);
// Look for all reports
TriplePattern pattern = new TriplePattern(null, ReasonerVocabulary.RB_VALIDATION_REPORT.asNode(), null);
for (Iterator<Triple> i = findFull(pattern); i.hasNext(); ) {
Triple t = i.next();
Node rNode = t.getObject();
boolean foundReport = false;
if (rNode.isLiteral()) {
Object rVal = rNode.getLiteralValue();
if (rVal instanceof Functor) {
Functor rFunc = (Functor)rVal;
foundReport = true;
StringBuffer description = new StringBuffer();
String nature = rFunc.getName();
String type = rFunc.getArgs()[0].toString();
String text = rFunc.getArgs()[1].toString();
description.append( text + "\n");
description.append( "Culprit = " + PrintUtil.print(t.getSubject()) +"\n");
for (int j = 2; j < rFunc.getArgLength(); j++) {
description.append( "Implicated node: " + PrintUtil.print(rFunc.getArgs()[j]) + "\n");
}
Node culpritN = t.getSubject();
RDFNode culprit = null;
if (culpritN.isURI()) {
culprit = ResourceFactory.createResource(culpritN.getURI());
} else if (culpritN.isLiteral()) {
RDFDatatype dtype = culpritN.getLiteralDatatype();
String lex = culpritN.getLiteralLexicalForm();
Object value = culpritN.getLiteralValue();
if (dtype == null) {
if (value instanceof String) {
culprit = ResourceFactory.createPlainLiteral(lex);
} else {
culprit = ResourceFactory.createTypedLiteral(value);
}
} else {
culprit = ResourceFactory.createTypedLiteral(lex, dtype);
}
}
report.add(nature.equalsIgnoreCase("error"), type, description.toString(), culprit);
}
}
}
if (requestDatatypeRangeValidation) {
performDatatypeRangeValidation( report );
}
return report;
}