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


Java ResourceFactory.createTypedLiteral方法代碼示例

本文整理匯總了Java中com.hp.hpl.jena.rdf.model.ResourceFactory.createTypedLiteral方法的典型用法代碼示例。如果您正苦於以下問題:Java ResourceFactory.createTypedLiteral方法的具體用法?Java ResourceFactory.createTypedLiteral怎麽用?Java ResourceFactory.createTypedLiteral使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.hp.hpl.jena.rdf.model.ResourceFactory的用法示例。


在下文中一共展示了ResourceFactory.createTypedLiteral方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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

示例3: 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

示例4: add

import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入方法依賴的package包/類
/**
 * Adds a single {@link GeneAnnotation} to a model
 *
 * @param ann
 */
public void add(GeneAnnotation ann) {
	if (ann == null) {
		return;
	}
	final Bioentity bioentity = ann.getBioentityObject();
	// TODO - why are we trimming here?
	final String isoForm = StringUtils.trimToNull(ann.getGeneProductForm());

	// TODO: don't use blank nodes
	Resource rAnn = model.createResource();
	Resource rBioentity = createResourceFromId(bioentity.getId());
	Resource rDescriptor = createResourceFromId(ann.getCls());

	model.add(rAnn, RDF.type, getAnnotationType());
	model.add(rAnn, getAnnotationToBioentityProperty(), rBioentity);
	model.add(rAnn, getAnnotationToDescriptorProperty(), rDescriptor);

	// TODO
	if (isoForm != null) {
		//Resource x = createResourceFromId(isoForm);
		//model.add(rAnn, getAnnotationToIsoformProperty(), x);

	}

	if (ann.getEcoEvidenceCls() != null) {
		Resource rEvidenceType = createResourceFromId(ann.getEcoEvidenceCls());
		model.add(rAnn, getAnnotationToEvidenceProperty(), rEvidenceType);
	}

	for (String refId : ann.getReferenceIds()) {
		//model.add(rAnn, getAnnotationToReferencesProperty(), rDescriptor);
	}

	/// TODO
	if (ann.isNegated()) {
	}


	for (List<ExtensionExpression> xl : ann.getExtensionExpressions()) {
		for (ExtensionExpression x : xl) {
			if (false) {
				// TODO - relations ontology needs loaded for mapping
				Resource xn = model.createResource(); // TODO - alternative to blank nodes?
				model.add(xn, 
						createPropertyFromId(x.getRelation()), 
						createResourceFromId(x.getCls()));
				model.add(rAnn, getAnnotationToExtensionProperty(), xn);
			}
		}
	}

	Pair<String, String> actsOnTaxon = ann.getActsOnTaxonId();
	if (actsOnTaxon != null) {
		// TODO
	}

	String date = ann.getLastUpdateDate();
	if (date != null) {
		// TODO - convert to xsd:date if use oa
		String isoDate = 
				date.substring(0, 4) + "-" + date.substring(4, 6) + "-" + date.substring(6, 8);
		Literal xsdDate = ResourceFactory.createTypedLiteral (isoDate, XSDDatatype.XSDdate);
		model.add(rAnn, getAnnotationDateProperty(), xsdDate);
	}

	if (ann.getAssignedBy() != null) {
		// TODO - use ORCID?
		model.add(rAnn, getAssignedByProperty(), ann.getAssignedBy());
	}

	for (String w : ann.getWithInfos()) {
		model.add(rAnn, getAnnotationToWithProperty(), createResourceFromId(w));

	}

}
 
開發者ID:owlcollab,項目名稱:owltools,代碼行數:82,代碼來源:OpenAnnotationRDFWriter.java

示例5: 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.createTypedLiteral方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。