當前位置: 首頁>>代碼示例>>Java>>正文


Java ResourceFactory.createPlainLiteral方法代碼示例

本文整理匯總了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 );
    }
}
 
開發者ID:hartig,項目名稱:BlazegraphBasedTPFServer,代碼行數:26,代碼來源:BigdataStatementToJenaStatementMapper.java

示例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());
}
 
開發者ID:d2rq,項目名稱:r2rml-kit,代碼行數:8,代碼來源:R2RMLReader.java

示例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;
}
 
開發者ID:SmartDataAnalytics,項目名稱:R2RLint,代碼行數:40,代碼來源:NoOntologyHijacking.java

示例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());
}
 
開發者ID:AKSW,項目名稱:sml-converters,代碼行數:16,代碼來源:TermConstructorConverter.java

示例5: getLang

import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入方法依賴的package包/類
public Literal getLang() {
    if (langStr != null) {
        return ResourceFactory.createPlainLiteral(langStr);
    } else {
        return null;
    }
}
 
開發者ID:AKSW,項目名稱:sml-converters,代碼行數:8,代碼來源:TermConstructorConverter.java

示例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;
}
 
開發者ID:AKSW,項目名稱:sml-converters,代碼行數:43,代碼來源:SML2R2RMLConverter.java

示例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;
}
 
開發者ID:wxwilcke,項目名稱:mdb2rdf,代碼行數:61,代碼來源:RdbToRdf.java

示例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;
    }
 
開發者ID:jacekkopecky,項目名稱:parkjam,代碼行數:70,代碼來源:FBRuleInfGraph.java


注:本文中的com.hp.hpl.jena.rdf.model.ResourceFactory.createPlainLiteral方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。