001: /*
002: * LICENSE INFORMATION
003: * Copyright 2005-2007 by FZI (http://www.fzi.de).
004: * Licensed under a BSD license (http://www.opensource.org/licenses/bsd-license.php)
005: * <OWNER> = Max Völkel
006: * <ORGANIZATION> = FZI Forschungszentrum Informatik Karlsruhe, Karlsruhe, Germany
007: * <YEAR> = 2007
008: *
009: * Project information at http://semweb4j.org/rdf2go
010: */
011: package org.ontoware.rdf2go.model;
012:
013: import org.ontoware.aifbcommons.collection.ClosableIterator;
014: import org.ontoware.rdf2go.exception.ModelRuntimeException;
015: import org.ontoware.rdf2go.model.node.NodeOrVariable;
016: import org.ontoware.rdf2go.model.node.ResourceOrVariable;
017: import org.ontoware.rdf2go.model.node.UriOrVariable;
018:
019: /**
020: * A model where you can list all statements, find statements and check if a
021: * statement is contained.
022: *
023: * @author voelkel
024: *
025: */
026: public interface FindableModel {
027:
028: /**
029: * get all statements in the model with this subject, predicate and object.
030: * Each of those (s,p,o) can be Variable.ANY
031: *
032: * Iterator must be auto-close, i.e. when last element is fetched, the
033: * implementation must call close().
034: *
035: * @param subject
036: * URI or Object (= blankNode) or Variable
037: * @param predicate
038: * URI or Variable
039: * @param object
040: * URI or String (=plainLiteral) or BlankNode (=blankNode) or
041: * TypedLiteral or LanguageTagLiteral or Variable
042: * @return a statement iterator
043: * @throws ModelRuntimeException
044: */
045: public ClosableIterator<Statement> findStatements(
046: ResourceOrVariable subject, UriOrVariable predicate,
047: NodeOrVariable object) throws ModelRuntimeException;
048:
049: /**
050: * Iterator must be auto-close, i.e. when last element is fetched, the
051: * implementation must call close().
052: * @param pattern
053: * @return statement iterator returning all triples matching the given
054: * pattern
055: * @throws ModelRuntimeException
056: */
057: public ClosableIterator<Statement> findStatements(
058: TriplePattern pattern) throws ModelRuntimeException;
059:
060: // ////////////////////////////
061: // counting
062:
063: /**
064: * @return the number of statements in the model matching the query
065: */
066: public long countStatements(TriplePattern pattern)
067: throws ModelRuntimeException;
068:
069: /**
070: * @param subject
071: * @param predicate
072: * @param object
073: * @return true if the statement (subject, predicate, object) is in the
074: * model
075: * @throws ModelRuntimeException
076: */
077: public boolean contains(ResourceOrVariable subject,
078: UriOrVariable predicate, NodeOrVariable object)
079: throws ModelRuntimeException;
080:
081: /**
082: * Convenience function.
083: * @param subject
084: * @param predicate
085: * @param plainLiteral
086: * @return true if model contains statement (s,p,'o')
087: * @throws ModelRuntimeException
088: */
089: public boolean contains(ResourceOrVariable subject,
090: UriOrVariable predicate, String plainLiteral)
091: throws ModelRuntimeException;
092:
093: /**
094: * @param s a Statement
095: * @return true if the model contains a statement s
096: * @throws ModelRuntimeException
097: */
098: public boolean contains(Statement s) throws ModelRuntimeException;
099:
100: /**
101: * @param subject
102: * @param predicate
103: * @param object
104: * @return a triple pattern
105: */
106: public TriplePattern createTriplePattern(
107: ResourceOrVariable subject, UriOrVariable predicate,
108: NodeOrVariable object);
109:
110: }
|