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


Java Node類代碼示例

本文整理匯總了Java中org.apache.jena.graph.Node的典型用法代碼示例。如果您正苦於以下問題:Java Node類的具體用法?Java Node怎麽用?Java Node使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Node類屬於org.apache.jena.graph包,在下文中一共展示了Node類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testVocabulary

import org.apache.jena.graph.Node; //導入依賴的package包/類
@Test
public void testVocabulary() {
    final Graph graph = getVocabulary(namespace());

    final Set<String> subjects = graph.find(ANY, ANY, ANY).mapWith(Triple::getSubject)
            .filterKeep(Node::isURI).mapWith(Node::getURI).filterKeep(Objects::nonNull).toSet();

    fields().forEach(field -> {
        if (isStrict()) {
            assertTrue(subjects.contains(namespace() + field),
                    "Field definition is not in published ontology! " + field);
        } else if (!subjects.contains(namespace() + field)) {
            LOGGER.warn("Field definition is not in published ontology! {}", field);
        }
    });
}
 
開發者ID:trellis-ldp,項目名稱:trellis,代碼行數:17,代碼來源:AbstractVocabularyTest.java

示例2: writeNodeToTable

import org.apache.jena.graph.Node; //導入依賴的package包/類
@Override
protected NodeId writeNodeToTable(Node node) {
    // Alloc key.
    long id = nextId++;
    try {
        Bytes.setLong(id, key);
        byte[] bytes = codec.encode(node);
        db.put(columnFamily, key, bytes);
        // Record the counter every so often.
        if ( nextId % IdAllocSaveTick == 0 ) {
            Bytes.setLong(nextId, nextIdBytes);
            db.put(columnFamily, nextIdKey, nextIdBytes);
        }
    } catch (Exception e) { throw new TDBException(e); }
    return NodeIdFactory.createPtr(id);
}
 
開發者ID:afs,項目名稱:tdb3,代碼行數:17,代碼來源:RocksNodeTable.java

示例3: modifiedToInstant

import org.apache.jena.graph.Node; //導入依賴的package包/類
/**
 * Convert a "modified" header field into an Instant
 * @param line the line
 * @return the instant
 */
private static Instant modifiedToInstant(final String line) {
    final Tokenizer tokenizer = makeTokenizerString(line);
    try {
        tokenizer.next(); // H
        tokenizer.next(); // modified
        if (tokenizer.hasNext()) {
            final Node n = tokenizer.next().asNode();
            if (nonNull(n) && n.isLiteral()) {
                return parse(n.getLiteralLexicalForm());
            }
        }
    } finally {
        tokenizer.close();
    }
    return null;
}
 
開發者ID:trellis-ldp-archive,項目名稱:trellis-rosid-file,代碼行數:22,代碼來源:RDFPatch.java

示例4: processObject

import org.apache.jena.graph.Node; //導入依賴的package包/類
private NPPhraseSpec processObject(Node object, boolean isClass) throws IOException {
	NPPhraseSpec element;
	if (object.isVariable()) {
		element = processVarNode(object);
	} else if (object.isLiteral()) {
		element = processLiteralNode(object);
	} else if (object.isURI()) {
		if (isClass) {
			element = processClassNode(object, false);
		} else {
			element = processResourceNode(object);
		}
	} else {
		throw new IllegalArgumentException("Can not convert blank node " + object + ".");
	}
	return element;
}
 
開發者ID:dice-group,項目名稱:RDF2PT,代碼行數:18,代碼來源:TripleConverterPortuguese.java

示例5: intersect

import org.apache.jena.graph.Node; //導入依賴的package包/類
@Override
public DirectedGraph<Node, Triple> intersect(DirectedGraph<Node, Triple> baseGraph, DirectedGraph<Node, Triple> removalGraph) {
    DirectedGraph<Node, Triple> result = new DirectedSubgraph<>(baseGraph, removalGraph.vertexSet(), removalGraph.edgeSet());

    //Materialize the intersection
    //DirectedGraph<Node, Triple> tmp = createNew();
    //Graphs.addGraph(tmp, result);
    //result = tmp

    return result;
}
 
開發者ID:SmartDataAnalytics,項目名稱:SubgraphIsomorphismIndex,代碼行數:12,代碼來源:SetOpsJGraphTRdfJena.java

示例6: addEdge

import org.apache.jena.graph.Node; //導入依賴的package包/類
@Override
public boolean addEdge(Node sourceVertex, Node targetVertex, Triple e) {
    boolean isValid = e.getSubject().equals(sourceVertex) && e.getObject().equals(targetVertex);
    if(!isValid) {
        throw new RuntimeException("Source and/or target vertex does not match those of the triple: " + sourceVertex + " " + targetVertex + " " + e);
    }

    if(!confinementPredicate.equals(Node.ANY) && e.getPredicate().equals(confinementPredicate)) {
        throw new RuntimeException("Graph is confined to predicate " + confinementPredicate + " therefore cannot add edge with predicate " + e);
    }

    boolean result = !graph.contains(e);
    if(result) {
        graph.add(e);
    }
    return true;
}
 
開發者ID:SmartDataAnalytics,項目名稱:SubgraphIsomorphismIndex,代碼行數:18,代碼來源:PseudoGraphJenaGraph.java

示例7: outputValuesOneRow

import org.apache.jena.graph.Node; //導入依賴的package包/類
private static void outputValuesOneRow(IndentedWriter out, List<Var> variables, Binding row, SerializationContext cxt) {
    // A value may be null for UNDEF
    for (Var var : variables) {
        out.print(" ");
        Node value = row.get(var);
        if (value == null) {
            out.print("UNDEF");
        } else {
            // Context for bnodes.
            // Bnodes don't occur in legal syntax but a rewritten query may
            // have them.  The output will not be legal SPARQL.
            // ARQ (SPARQL with extensions) does parse blankd nodes in VALUES. 
            SPARQLGenerateFmtUtils.printNode(out, value, cxt);
        }
    }
}
 
開發者ID:thesmartenergy,項目名稱:sparql-generate,代碼行數:17,代碼來源:SPARQLGenerateQuerySerializer.java

示例8: exec

import org.apache.jena.graph.Node; //導入依賴的package包/類
@Override
public NodeValue exec(NodeValue timeStampValue) {

    BigInteger timeStamp;
    if (timeStampValue == null || !timeStampValue.isInteger()) {
        throw new ExprEvalException("The NodeValue " + timeStampValue + " MUST be an integer."
        );
    } else {
        timeStamp = timeStampValue.getInteger();
    }

    if (timeStamp.compareTo(BigInteger.valueOf(Long.MAX_VALUE)) != -1) {
        throw new ExprEvalException("The NodeValue " + timeStamp + " MUST be less than the biggest long value."
        );
    } else if (timeStamp.signum() != 1) {
        throw new ExprEvalException("The NodeValue " + timeStamp + " MUST be positive."
        );
    }

    Timestamp stamp = new Timestamp(timeStamp.longValue());
    Date date = new Date(stamp.getTime());

    Node node = NodeFactory.createLiteral(df.format(date), XSDDatatype.XSDdateTime);
    return new NodeValueNode(node);
}
 
開發者ID:thesmartenergy,項目名稱:sparql-generate,代碼行數:26,代碼來源:FUN_dateTime.java

示例9: readerHeader

import org.apache.jena.graph.Node; //導入依賴的package包/類
/** Read the header */
private static PatchHeader readerHeader(TupleReader input) {
    Map<String, Node> header = new LinkedHashMap<>();
    int lineNumber = 0 ;
    while(input.hasNext()) {
        Tuple<Token> line = input.next() ;
        lineNumber ++ ;
        if ( line.isEmpty() )
            throw new PatchException("["+lineNumber+"] empty line") ;
        Token token1 = line.get(0) ;
        if ( ! token1.isWord() )
            throw new PatchException("["+token1.getLine()+"] Token1 is not a word "+token1) ;
        String code = token1.getImage() ;
        if ( ! code.equals("H") )
            break;
        readHeaderLine(line, (f,n)->header.put(f, n));
    }
    return new PatchHeader(header);
}
 
開發者ID:afs,項目名稱:rdf-delta,代碼行數:20,代碼來源:RDFPatchReaderText.java

示例10: fromThrift

import org.apache.jena.graph.Node; //導入依賴的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

示例11: deleteAny

import org.apache.jena.graph.Node; //導入依賴的package包/類
@Override
/** Simple implementation but done without assuming iterator.remove() */
public void deleteAny(Node g, Node s, Node p, Node o) {
    Quad[] buffer = new Quad[DeleteBufferSize];
    while (true) {
        Iterator<Quad> iter = find(g, s, p, o);
        // Get a slice
        int len = 0;
        for ( ; len < DeleteBufferSize ; len++ ) {
            if ( !iter.hasNext() )
                break;
            buffer[len] = iter.next();
        }
        // Delete them.
        for ( int i = 0 ; i < len ; i++ ) {
            delete(buffer[i]);
            buffer[i] = null;
        }
        // Finished?
        if ( len < DeleteBufferSize )
            break;
    }
}
 
開發者ID:afs,項目名稱:rdf-delta,代碼行數:24,代碼來源:DatasetGraphChanges.java

示例12: translateToExternalUri

import org.apache.jena.graph.Node; //導入依賴的package包/類
private Node translateToExternalUri(final Node node) {
    if (node.isURI()) {
        final String uri = node.getURI();
        if (uri.startsWith(INTERNAL_URI_PREFIX)) {
            return createURI(toExternalURI(URI.create(uri), headers).toString());
        }
    }
    return node;
}
 
開發者ID:duraspace,項目名稱:lambdora,代碼行數:10,代碼來源:LambdoraLdp.java

示例13: create

import org.apache.jena.graph.Node; //導入依賴的package包/類
@Override
protected Container create(final URI identifier) {
    LOGGER.debug("Create: {}", identifier);
    final Node identifierNode = createURI(identifier.toString());
    final ResourceTripleDao dao = getResourceTripleDao();

    // Add system generated triples
    for (Triple t : getSystemTriples(identifier)) {
        dao.addResourceTriple(toResourceTriple(identifier, t));
    }

    //add containment triples
    final URI parent = getParent(identifier);
    if (parent != null) {
        final Node parentNode = createURI(parent.toString());

        dao.addResourceTriple(toResourceTriple(identifier,
            new Triple(identifierNode,
                HAS_PARENT.asNode(),
                parentNode)));

        dao.addResourceTriple(toResourceTriple(parent,
            new Triple(parentNode,
                CONTAINS.asNode(),
                identifierNode)));

    }

    //TODO recursively create parents if do not exist

    return new ContainerImpl(identifier, dao);
}
 
開發者ID:duraspace,項目名稱:lambdora,代碼行數:33,代碼來源:ContainerServiceImpl.java

示例14: getSystemTriples

import org.apache.jena.graph.Node; //導入依賴的package包/類
/**
 * Get system generated triples for this resource
 * @param identifier resource URI
 * @return List of Triples
 */
private List<Triple> getSystemTriples(final URI identifier) {
    final List<Triple> triples = new ArrayList<>();
    final Node subject = createURI(identifier.toString());

    // rdf:type = ldp:container
    triples.add(new Triple(subject,
        TYPE.asNode(),
        CONTAINER.asNode()));

    // rdf:type = ldp:resource
    triples.add(new Triple(subject,
        TYPE.asNode(),
        RDF_SOURCE.asNode()));

    // rdf:type = fedora:container
    triples.add(new Triple(subject,
        TYPE.asNode(),
        FEDORA_CONTAINER.asNode()));

    // rdf:type = fedora:resource
    triples.add(new Triple(subject,
        TYPE.asNode(),
        FEDORA_RESOURCE.asNode()));

    // fedora:created = now
    triples.add(new Triple(subject,
        CREATED_DATE.asNode(),
        createLiteral(Instant.now().toString())));

    return triples;
}
 
開發者ID:duraspace,項目名稱:lambdora,代碼行數:37,代碼來源:ContainerServiceImpl.java

示例15: getTriples

import org.apache.jena.graph.Node; //導入依賴的package包/類
private static Stream<Triple> getTriples() {
    final Node sub = createURI("trellis:repository/resource");
    return of(
            create(sub, title.asNode(), createLiteral("A title")),
            create(sub, spatial.asNode(), createURI("http://sws.geonames.org/4929022/")),
            create(sub, type, Text.asNode()))
        .map(rdf::asTriple);
}
 
開發者ID:trellis-ldp,項目名稱:trellis,代碼行數:9,代碼來源:IOServiceTest.java


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