当前位置: 首页>>代码示例>>Java>>正文


Java NodeFactory.getType方法代码示例

本文整理汇总了Java中org.apache.jena.graph.NodeFactory.getType方法的典型用法代码示例。如果您正苦于以下问题:Java NodeFactory.getType方法的具体用法?Java NodeFactory.getType怎么用?Java NodeFactory.getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.jena.graph.NodeFactory的用法示例。


在下文中一共展示了NodeFactory.getType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fromThrift

import org.apache.jena.graph.NodeFactory; //导入方法依赖的package包/类
public static Node fromThrift(RDF_Term term) {
    if ( term.isSetIri() )
        return NodeFactory.createURI(term.getIri().getIri()) ;

    if ( term.isSetBnode() )
        return NodeFactory.createBlankNode(term.getBnode().getLabel()) ;

    if ( term.isSetLiteral() ) {
        RDF_Literal lit = term.getLiteral() ;
        String lex = lit.getLex() ;
        String dtString = null ;
        if ( lit.isSetDatatype() )
            dtString = lit.getDatatype() ;
        RDFDatatype dt = NodeFactory.getType(dtString) ;

        String lang = lit.getLangtag() ;
        return NodeFactory.createLiteral(lex, lang, dt) ;
    }

    throw new PatchException("No conversion to a Node: "+term.toString()) ;
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:22,代码来源:RDFPatchReaderBinary.java

示例2: createTyped

import org.apache.jena.graph.NodeFactory; //导入方法依赖的package包/类
public static final RDFNode createTyped(String value, Resource valueType)
   {
if (value == null) throw new IllegalArgumentException("Param value cannot be null");

       // without value type, return default xsd:string value
       if (valueType == null) return ResourceFactory.createTypedLiteral(value, XSDDatatype.XSDstring);

       // if value type is from XSD namespace, value is treated as typed literal with XSD datatype
       if (valueType.getNameSpace().equals(XSD.getURI()))
       {
           RDFDatatype dataType = NodeFactory.getType(valueType.getURI());
           return ResourceFactory.createTypedLiteral(value, dataType);
       }
       // otherwise, value is treated as URI resource
       else
           return ResourceFactory.createResource(value);
   }
 
开发者ID:AtomGraph,项目名称:Processor,代码行数:18,代码来源:RDFNodeFactory.java

示例3: createNode

import org.apache.jena.graph.NodeFactory; //导入方法依赖的package包/类
private Node createNode(Map<String, Object> map) {
    String type = (String)map.get("type") ;
    String lex = (String)map.get("value") ;
    if ( type.equals(IRI) )
        return NodeFactory.createURI(lex);
    else if ( type.equals(BLANK_NODE) )
        return labels.get(null, lex) ;  //??
    else if ( type.equals(LITERAL) ) {
        String lang = (String)map.get("language") ;
        String datatype = (String)map.get("datatype") ;
        if ( Objects.equals(xsdString, datatype) )
            // In RDF 1.1, simple literals and xsd:string are the same.
            // During migration, we prefer simple literals to xsd:strings. 
            datatype = null ;
        if ( lang == null && datatype == null )
            return NodeFactory.createLiteral(lex);
        if ( lang != null )
            return NodeFactory.createLiteral(lex, lang);
        RDFDatatype dt = NodeFactory.getType(datatype) ;
        return NodeFactory.createLiteral(lex, dt);
    } else
        throw new InternalErrorException("Node is not a IRI, bNode or a literal: " + type) ;
}
 
开发者ID:UKGovLD,项目名称:registry-core,代码行数:24,代码来源:JenaTripleCallBack.java

示例4: asJenaNode

import org.apache.jena.graph.NodeFactory; //导入方法依赖的package包/类
/**
 * Convert a CommonsRDF RDFTerm to a Jena Node. If the RDFTerm was from Jena
 * originally, return that original object, else create a copy using Jena
 * objects.
 *
 * @param term
 *            Commons RDF {@link RDFTerm} to convert
 * @return Converted Jena {@link Node}
 */
public Node asJenaNode(final RDFTerm term) {
    if (term == null) {
        return null;
    }
    if (term instanceof JenaRDFTerm) {
        // TODO: What if it's a JenaBlankNodeImpl with
        // a different salt? Do we need to rewrite the
        // jena blanknode identifier?
        return ((JenaRDFTerm) term).asJenaNode();
    }

    if (term instanceof IRI) {
        return NodeFactory.createURI(((IRI) term).getIRIString());
    }

    if (term instanceof Literal) {
        final Literal lit = (Literal) term;
        final RDFDatatype dt = NodeFactory.getType(lit.getDatatype().getIRIString());
        final String lang = lit.getLanguageTag().orElse("");
        return NodeFactory.createLiteral(lit.getLexicalForm(), lang, dt);
    }

    if (term instanceof BlankNode) {
        final String id = ((BlankNode) term).uniqueReference();
        return NodeFactory.createBlankNode(id);
    }
    throw new ConversionException("Not a concrete RDF Term: " + term);
}
 
开发者ID:apache,项目名称:commons-rdf,代码行数:38,代码来源:JenaRDF.java


注:本文中的org.apache.jena.graph.NodeFactory.getType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。