001: /*
002: * Copyright Aduna (http://www.aduna-software.com/) (c) 1997-2007.
003: *
004: * Licensed under the Aduna BSD-style license.
005: */
006: package org.openrdf.repository;
007:
008: import java.io.File;
009: import java.io.IOException;
010: import java.io.InputStream;
011: import java.io.Reader;
012: import java.net.URL;
013:
014: import info.aduna.iteration.CloseableIteration;
015: import info.aduna.iteration.Iteration;
016:
017: import org.openrdf.model.Namespace;
018: import org.openrdf.model.Resource;
019: import org.openrdf.model.Statement;
020: import org.openrdf.model.URI;
021: import org.openrdf.model.Value;
022: import org.openrdf.query.BooleanQuery;
023: import org.openrdf.query.GraphQuery;
024: import org.openrdf.query.MalformedQueryException;
025: import org.openrdf.query.Query;
026: import org.openrdf.query.QueryLanguage;
027: import org.openrdf.query.TupleQuery;
028: import org.openrdf.query.UnsupportedQueryLanguageException;
029: import org.openrdf.rio.RDFFormat;
030: import org.openrdf.rio.RDFHandler;
031: import org.openrdf.rio.RDFHandlerException;
032: import org.openrdf.rio.RDFParseException;
033: import org.openrdf.rio.UnsupportedRDFormatException;
034:
035: /**
036: * Main interface for updating data in and performing queries on a Sesame
037: * repository. By default, a RepositoryConnection is in autoCommit mode, meaning
038: * that each operation corresponds to a single transaction on the underlying
039: * store. autoCommit can be switched off in which case it is up to the user to
040: * handle transaction commit/rollback. Note that care should be taking to always
041: * properly close a RepositoryConnection after one is finished with it, to free
042: * up resources and avoid unnecessary locks.
043: * <p>
044: * Several methods take a vararg argument that optionally specifies a (set of)
045: * context(s) on which the method should operate. Note that a vararg parameter
046: * is optional, it can be completely left out of the method call, in which case
047: * a method either operates on a provided statements context (if one of the
048: * method parameters is a statement or collection of statements), or operates on
049: * the repository as a whole, completely ignoring context. A vararg argument may
050: * also be 'null' (cast to Resource) meaning that the method operates on those
051: * statements which have no associated context only.
052: * <p>
053: * Examples:
054: *
055: * <pre>
056: * // Ex 1: this method retrieves all statements that appear in either context1 or context2, or both.
057: * RepositoryConnection.getStatements(null, null, null, true, context1, context2);
058: *
059: * // Ex 2: this method retrieves all statements that appear in the repository (regardless of context).
060: * RepositoryConnection.getStatements(null, null, null, true);
061: *
062: * // Ex 3: this method retrieves all statements that have no associated context in the repository.
063: * // Observe that this is not equivalent to the previous method call.
064: * RepositoryConnection.getStatements(null, null, null, true, (Resource)null);
065: *
066: * // Ex 4: this method adds a statement to the store. If the statement object itself has
067: * // a context (i.e. statement.getContext() != null) the statement is added to that context. Otherwise,
068: * // it is added without any associated context.
069: * RepositoryConnection.add(statement);
070: *
071: * // Ex 5: this method adds a statement to context1 in the store. It completely ignores any
072: * // context the statement itself has.
073: * RepositoryConnection.add(statement, context1);
074: * </pre>
075: *
076: * @author Arjohn Kampman
077: * @author jeen
078: */
079: public interface RepositoryConnection {
080:
081: /**
082: * Returns the Repository object to which this connection belongs.
083: */
084: public Repository getRepository();
085:
086: /**
087: * Checks whether this connection is open. A connection is open from the
088: * moment it is created until it is closed.
089: *
090: * @see #close()
091: */
092: public boolean isOpen() throws RepositoryException;
093:
094: /**
095: * Closes the connection, freeing resources. If the connection is not in
096: * autoCommit mode, all non-committed operations will be lost.
097: *
098: * @throws RepositoryException
099: * If the connection could not be closed.
100: */
101: public void close() throws RepositoryException;
102:
103: /**
104: * Prepares a query for evaluation on this repository (optional operation).
105: * In case the query contains relative URIs that need to be resolved against
106: * an external base URI, one should use
107: * {@link #prepareQuery(QueryLanguage, String, String)} instead.
108: *
109: * @param ql
110: * The query language in which the query is formulated.
111: * @param query
112: * The query string.
113: * @return A query ready to be evaluated on this repository.
114: * @throws MalformedQueryException
115: * If the supplied query is malformed.
116: * @throws UnsupportedQueryLanguageException
117: * If the supplied query language is not supported.
118: * @throws UnsupportedOperationException
119: * If the <tt>prepareQuery</tt> method is not supported by this
120: * repository.
121: */
122: public Query prepareQuery(QueryLanguage ql, String query)
123: throws RepositoryException, MalformedQueryException;
124:
125: /**
126: * Prepares a query for evaluation on this repository (optional operation).
127: *
128: * @param ql
129: * The query language in which the query is formulated.
130: * @param query
131: * The query string.
132: * @param baseURI
133: * The base URI to resolve any relative URIs that are in the query
134: * against, can be <tt>null</tt> if the query does not contain any
135: * relative URIs.
136: * @return A query ready to be evaluated on this repository.
137: * @throws MalformedQueryException
138: * If the supplied query is malformed.
139: * @throws UnsupportedQueryLanguageException
140: * If the supplied query language is not supported.
141: * @throws UnsupportedOperationException
142: * If the <tt>prepareQuery</tt> method is not supported by this
143: * repository.
144: */
145: public Query prepareQuery(QueryLanguage ql, String query,
146: String baseURI) throws RepositoryException,
147: MalformedQueryException;
148:
149: /**
150: * Prepares a query that produces sets of value tuples. In case the query
151: * contains relative URIs that need to be resolved against an external base
152: * URI, one should use
153: * {@link #prepareTupleQuery(QueryLanguage, String, String)} instead.
154: *
155: * @param ql
156: * The query language in which the query is formulated.
157: * @param query
158: * The query string.
159: * @throws IllegalArgumentException
160: * If the supplied query is not a tuple query.
161: * @throws MalformedQueryException
162: * If the supplied query is malformed.
163: * @throws UnsupportedQueryLanguageException
164: * If the supplied query language is not supported.
165: */
166: public TupleQuery prepareTupleQuery(QueryLanguage ql, String query)
167: throws RepositoryException, MalformedQueryException;
168:
169: /**
170: * Prepares a query that produces sets of value tuples.
171: *
172: * @param ql
173: * The query language in which the query is formulated.
174: * @param query
175: * The query string.
176: * @param baseURI
177: * The base URI to resolve any relative URIs that are in the query
178: * against, can be <tt>null</tt> if the query does not contain any
179: * relative URIs.
180: * @throws IllegalArgumentException
181: * If the supplied query is not a tuple query.
182: * @throws MalformedQueryException
183: * If the supplied query is malformed.
184: * @throws UnsupportedQueryLanguageException
185: * If the supplied query language is not supported.
186: */
187: public TupleQuery prepareTupleQuery(QueryLanguage ql, String query,
188: String baseURI) throws RepositoryException,
189: MalformedQueryException;
190:
191: /**
192: * Prepares queries that produce RDF graphs. In case the query contains
193: * relative URIs that need to be resolved against an external base URI, one
194: * should use {@link #prepareGraphQuery(QueryLanguage, String, String)}
195: * instead.
196: *
197: * @param ql
198: * The query language in which the query is formulated.
199: * @param query
200: * The query string.
201: * @throws IllegalArgumentException
202: * If the supplied query is not a graph query.
203: * @throws MalformedQueryException
204: * If the supplied query is malformed.
205: * @throws UnsupportedQueryLanguageException
206: * If the supplied query language is not supported.
207: */
208: public GraphQuery prepareGraphQuery(QueryLanguage ql, String query)
209: throws RepositoryException, MalformedQueryException;
210:
211: /**
212: * Prepares queries that produce RDF graphs.
213: *
214: * @param ql
215: * The query language in which the query is formulated.
216: * @param query
217: * The query string.
218: * @param baseURI
219: * The base URI to resolve any relative URIs that are in the query
220: * against, can be <tt>null</tt> if the query does not contain any
221: * relative URIs.
222: * @throws IllegalArgumentException
223: * If the supplied query is not a graph query.
224: * @throws MalformedQueryException
225: * If the supplied query is malformed.
226: * @throws UnsupportedQueryLanguageException
227: * If the supplied query language is not supported.
228: */
229: public GraphQuery prepareGraphQuery(QueryLanguage ql, String query,
230: String baseURI) throws RepositoryException,
231: MalformedQueryException;
232:
233: /**
234: * Prepares <tt>true</tt>/<tt>false</tt> queries. In case the query
235: * contains relative URIs that need to be resolved against an external base
236: * URI, one should use
237: * {@link #prepareBooleanQuery(QueryLanguage, String, String)} instead.
238: *
239: * @param ql
240: * The query language in which the query is formulated.
241: * @param query
242: * The query string.
243: * @throws IllegalArgumentException
244: * If the supplied query is not a boolean query.
245: * @throws MalformedQueryException
246: * If the supplied query is malformed.
247: * @throws UnsupportedQueryLanguageException
248: * If the supplied query language is not supported.
249: */
250: public BooleanQuery prepareBooleanQuery(QueryLanguage ql,
251: String query) throws RepositoryException,
252: MalformedQueryException;
253:
254: /**
255: * Prepares <tt>true</tt>/<tt>false</tt> queries.
256: *
257: * @param ql
258: * The query language in which the query is formulated.
259: * @param query
260: * The query string.
261: * @param baseURI
262: * The base URI to resolve any relative URIs that are in the query
263: * against, can be <tt>null</tt> if the query does not contain any
264: * relative URIs.
265: * @throws IllegalArgumentException
266: * If the supplied query is not a boolean query.
267: * @throws MalformedQueryException
268: * If the supplied query is malformed.
269: * @throws UnsupportedQueryLanguageException
270: * If the supplied query language is not supported.
271: */
272: public BooleanQuery prepareBooleanQuery(QueryLanguage ql,
273: String query, String baseURI) throws RepositoryException,
274: MalformedQueryException;
275:
276: /**
277: * Gets all resources that are used as content identifiers. Care should be
278: * taken that the returned {@link RepositoryResult} is closed to free any
279: * resources that it keeps hold of.
280: *
281: * @return a RepositoryResult object containing Resources that are used as
282: * context identifiers.
283: */
284: public RepositoryResult<Resource> getContextIDs()
285: throws RepositoryException;
286:
287: /**
288: * Gets all statements with a specific subject, predicate and/or object from
289: * the repository. The result is optionally restricted to the specified set
290: * of named contexts.
291: *
292: * @param subj
293: * A Resource specifying the subject, or <tt>null</tt> for a
294: * wildcard.
295: * @param pred
296: * A URI specifying the predicate, or <tt>null</tt> for a wildcard.
297: * @param obj
298: * A Value specifying the object, or <tt>null</tt> for a wildcard.
299: * @param contexts
300: * The context(s) to get the data from. Note that this parameter is a
301: * vararg and as such is optional. If no contexts are supplied the
302: * method operates on the entire repository.
303: * @param includeInferred
304: * if false, no inferred statements are returned; if true, inferred
305: * statements are returned if available. The default is true.
306: * @return The statements matching the specified pattern. The result object
307: * is a {@link RepositoryResult} object, a lazy Iterator-like object
308: * containing {@link Statement}s and optionally throwing a
309: * {@link RepositoryException} when an error when a problem occurs
310: * during retrieval.
311: */
312: public RepositoryResult<Statement> getStatements(Resource subj,
313: URI pred, Value obj, boolean includeInferred,
314: Resource... contexts) throws RepositoryException;
315:
316: /**
317: * Checks whether the repository contains statements with a specific subject,
318: * predicate and/or object, optionally in the specified contexts.
319: *
320: * @param subj
321: * A Resource specifying the subject, or <tt>null</tt> for a
322: * wildcard.
323: * @param pred
324: * A URI specifying the predicate, or <tt>null</tt> for a wildcard.
325: * @param obj
326: * A Value specifying the object, or <tt>null</tt> for a wildcard.
327: * @param contexts
328: * The context(s) the need to be searched. Note that this parameter is
329: * a vararg and as such is optional. If no contexts are supplied the
330: * method operates on the entire repository.
331: * @param includeInferred
332: * if false, no inferred statements are considered; if true, inferred
333: * statements are considered if available
334: * @return true If a matching statement is in the repository in the specified
335: * context, false otherwise.
336: */
337: public boolean hasStatement(Resource subj, URI pred, Value obj,
338: boolean includeInferred, Resource... contexts)
339: throws RepositoryException;
340:
341: /**
342: * Checks whether the repository contains the specified statement, optionally
343: * in the specified contexts.
344: *
345: * @param st
346: * The statement to look for. Context information in the statement is
347: * ignored.
348: * @param contexts
349: * The context(s) to get the data from. Note that this parameter is a
350: * vararg and as such is optional. If no contexts are supplied the
351: * method operates on the entire repository.
352: * @param includeInferred
353: * if false, no inferred statements are considered; if true, inferred
354: * statements are considered if available
355: * @return true If the repository contains the specified statement, false
356: * otherwise.
357: */
358: public boolean hasStatement(Statement st, boolean includeInferred,
359: Resource... contexts) throws RepositoryException;
360:
361: /**
362: * Exports all statements with a specific subject, predicate and/or object
363: * from the repository, optionally from the specified contexts.
364: *
365: * @param subj
366: * The subject, or null if the subject doesn't matter.
367: * @param pred
368: * The predicate, or null if the predicate doesn't matter.
369: * @param obj
370: * The object, or null if the object doesn't matter.
371: * @param contexts
372: * The context(s) to get the data from. Note that this parameter is a
373: * vararg and as such is optional. If no contexts are supplied the
374: * method operates on the entire repository.
375: * @param handler
376: * The handler that will handle the RDF data.
377: * @param includeInferred
378: * if false, no inferred statements are returned; if true, inferred
379: * statements are returned if available
380: * @throws RDFHandlerException
381: * If the handler encounters an unrecoverable error.
382: */
383: public void exportStatements(Resource subj, URI pred, Value obj,
384: boolean includeInferred, RDFHandler handler,
385: Resource... contexts) throws RepositoryException,
386: RDFHandlerException;
387:
388: /**
389: * Exports all explicit statements in the specified contexts to the supplied
390: * RDFHandler.
391: *
392: * @param contexts
393: * The context(s) to get the data from. Note that this parameter is a
394: * vararg and as such is optional. If no contexts are supplied the
395: * method operates on the entire repository.
396: * @param handler
397: * The handler that will handle the RDF data.
398: * @throws RDFHandlerException
399: * If the handler encounters an unrecoverable error.
400: */
401: public void export(RDFHandler handler, Resource... contexts)
402: throws RepositoryException, RDFHandlerException;
403:
404: /**
405: * Returns the number of (explicit) statements that are in the specified
406: * contexts in this repository.
407: *
408: * @param contexts
409: * The context(s) to get the data from. Note that this parameter is a
410: * vararg and as such is optional. If no contexts are supplied the
411: * method operates on the entire repository.
412: * @return The number of explicit statements from the specified contexts in
413: * this repository.
414: */
415: public long size(Resource... contexts) throws RepositoryException;
416:
417: /**
418: * Returns <tt>true</tt> if this repository does not contain any (explicit)
419: * statements.
420: *
421: * @return <tt>true</tt> if this repository is empty, <tt>false</tt>
422: * otherwise.
423: * @throws RepositoryException
424: * If the repository could not be checked to be empty.
425: */
426: public boolean isEmpty() throws RepositoryException;
427:
428: /**
429: * Enables or disables auto-commit mode for the connection. If a connection
430: * is in auto-commit mode, then all updates will be executed and committed as
431: * individual transactions. Otherwise, the updates are grouped into
432: * transactions that are terminated by a call to either {@link #commit} or
433: * {@link #rollback}. By default, new connections are in auto-commit mode.
434: * <p>
435: * <b>NOTE:</b> If this connection is switched to auto-commit mode during a
436: * transaction, the transaction is committed.
437: *
438: * @throws RepositoryException
439: * In case the mode switch failed, for example because a currently
440: * active transaction failed to commit.
441: * @see #commit
442: */
443: public void setAutoCommit(boolean autoCommit)
444: throws RepositoryException;
445:
446: /**
447: * Checks whether the connection is in auto-commit mode.
448: *
449: * @see #setAutoCommit
450: */
451: public boolean isAutoCommit() throws RepositoryException;
452:
453: /**
454: * Commits all updates that have been performed as part of this connection
455: * sofar.
456: *
457: * @throws RepositoryException
458: * If the connection could not be committed.
459: */
460: public void commit() throws RepositoryException;
461:
462: /**
463: * Rolls back all updates that have been performed as part of this connection
464: * sofar.
465: *
466: * @throws RepositoryException
467: * If the connection could not be rolled back.
468: */
469: public void rollback() throws RepositoryException;
470:
471: /**
472: * Adds RDF data from an InputStream to the repository, optionally to one or
473: * more named contexts.
474: *
475: * @param in
476: * An InputStream from which RDF data can be read.
477: * @param baseURI
478: * The base URI to resolve any relative URIs that are in the data
479: * against.
480: * @param dataFormat
481: * The serialization format of the data.
482: * @param contexts
483: * The contexts to add the data to. If one or more contexts are
484: * supplied the method ignores contextual information in the actual
485: * data. If no contexts are supplied the contextual information in the
486: * input stream is used, if no context information is available the
487: * data is added without any context.
488: * @throws IOException
489: * If an I/O error occurred while reading from the input stream.
490: * @throws UnsupportedRDFormatException
491: * If no parser is available for the specified RDF format.
492: * @throws RDFParseException
493: * If an error was found while parsing the RDF data.
494: * @throws RepositoryException
495: * If the data could not be added to the repository, for example
496: * because the repository is not writable.
497: */
498: public void add(InputStream in, String baseURI,
499: RDFFormat dataFormat, Resource... contexts)
500: throws IOException, RDFParseException, RepositoryException;
501:
502: /**
503: * Adds RDF data from a Reader to the repository, optionally to one or more
504: * named contexts. <b>Note: using a Reader to upload byte-based data means
505: * that you have to be careful not to destroy the data's character encoding
506: * by enforcing a default character encoding upon the bytes. If possible,
507: * adding such data using an InputStream is to be preferred.</b>
508: *
509: * @param reader
510: * A Reader from which RDF data can be read.
511: * @param baseURI
512: * The base URI to resolve any relative URIs that are in the data
513: * against.
514: * @param dataFormat
515: * The serialization format of the data.
516: * @param contexts
517: * The contexts to add the data to. If one or more contexts are
518: * specified the data is added to these contexts, ignoring any context
519: * information in the data itself.
520: * @throws IOException
521: * If an I/O error occurred while reading from the reader.
522: * @throws UnsupportedRDFormatException
523: * If no parser is available for the specified RDF format.
524: * @throws RDFParseException
525: * If an error was found while parsing the RDF data.
526: * @throws RepositoryException
527: * If the data could not be added to the repository, for example
528: * because the repository is not writable.
529: */
530: public void add(Reader reader, String baseURI,
531: RDFFormat dataFormat, Resource... contexts)
532: throws IOException, RDFParseException, RepositoryException;
533:
534: /**
535: * Adds the RDF data that can be found at the specified URL to the
536: * repository, optionally to one or more named contexts.
537: *
538: * @param url
539: * The URL of the RDF data.
540: * @param baseURI
541: * The base URI to resolve any relative URIs that are in the data
542: * against. This defaults to the value of {@link
543: * java.net.URL#toExternalForm() url.toExternalForm()} if the value is
544: * set to <tt>null</tt>.
545: * @param dataFormat
546: * The serialization format of the data.
547: * @param contexts
548: * The contexts to add the data to. If one or more contexts are
549: * specified the data is added to these contexts, ignoring any context
550: * information in the data itself.
551: * @throws IOException
552: * If an I/O error occurred while reading from the URL.
553: * @throws UnsupportedRDFormatException
554: * If no parser is available for the specified RDF format.
555: * @throws RDFParseException
556: * If an error was found while parsing the RDF data.
557: * @throws RepositoryException
558: * If the data could not be added to the repository, for example
559: * because the repository is not writable.
560: */
561: public void add(URL url, String baseURI, RDFFormat dataFormat,
562: Resource... contexts) throws IOException,
563: RDFParseException, RepositoryException;
564:
565: /**
566: * Adds RDF data from the specified file to a specific contexts in the
567: * repository.
568: *
569: * @param file
570: * A file containing RDF data.
571: * @param baseURI
572: * The base URI to resolve any relative URIs that are in the data
573: * against. This defaults to the value of
574: * {@link java.io.File#toURI() file.toURI()} if the value is set to
575: * <tt>null</tt>.
576: * @param dataFormat
577: * The serialization format of the data.
578: * @param contexts
579: * The contexts to add the data to. Note that this parameter is a
580: * vararg and as such is optional. If no contexts are specified, the
581: * data is added to any context specified in the actual data file, or
582: * if the data contains no context, it is added without context. If
583: * one or more contexts are specified the data is added to these
584: * contexts, ignoring any context information in the data itself.
585: * @throws IOException
586: * If an I/O error occurred while reading from the file.
587: * @throws UnsupportedRDFormatException
588: * If no parser is available for the specified RDF format.
589: * @throws RDFParseException
590: * If an error was found while parsing the RDF data.
591: * @throws RepositoryException
592: * If the data could not be added to the repository, for example
593: * because the repository is not writable.
594: */
595: public void add(File file, String baseURI, RDFFormat dataFormat,
596: Resource... contexts) throws IOException,
597: RDFParseException, RepositoryException;
598:
599: /**
600: * Adds a statement with the specified subject, predicate and object to this
601: * repository, optionally to one or more named contexts.
602: *
603: * @param subject
604: * The statement's subject.
605: * @param predicate
606: * The statement's predicate.
607: * @param object
608: * The statement's object.
609: * @param contexts
610: * The contexts to add the data to. Note that this parameter is a
611: * vararg and as such is optional. If no contexts are specified, the
612: * data is added to any context specified in the actual data file, or
613: * if the data contains no context, it is added without context. If
614: * one or more contexts are specified the data is added to these
615: * contexts, ignoring any context information in the data itself.
616: * @throws RepositoryException
617: * If the data could not be added to the repository, for example
618: * because the repository is not writable.
619: */
620: public void add(Resource subject, URI predicate, Value object,
621: Resource... contexts) throws RepositoryException;
622:
623: /**
624: * Adds the supplied statement to this repository, optionally to one or more
625: * named contexts.
626: *
627: * @param st
628: * The statement to add.
629: * @param contexts
630: * The contexts to add the statements to. Note that this parameter is
631: * a vararg and as such is optional. If no contexts are specified, the
632: * statement is added to any context specified in each statement, or
633: * if the statement contains no context, it is added without context.
634: * If one or more contexts are specified the statement is added to
635: * these contexts, ignoring any context information in the statement
636: * itself.
637: * @throws RepositoryException
638: * If the statement could not be added to the repository, for example
639: * because the repository is not writable.
640: */
641: public void add(Statement st, Resource... contexts)
642: throws RepositoryException;
643:
644: /**
645: * Adds the supplied statements to this repository, optionally to one or more
646: * named contexts.
647: *
648: * @param statements
649: * The statements that should be added.
650: * @param contexts
651: * The contexts to add the statements to. Note that this parameter is
652: * a vararg and as such is optional. If no contexts are specified,
653: * each statement is added to any context specified in the statement,
654: * or if the statement contains no context, it is added without
655: * context. If one or more contexts are specified each statement is
656: * added to these contexts, ignoring any context information in the
657: * statement itself. ignored.
658: * @throws RepositoryException
659: * If the statements could not be added to the repository, for
660: * example because the repository is not writable.
661: */
662: public void add(Iterable<? extends Statement> statements,
663: Resource... contexts) throws RepositoryException;
664:
665: /**
666: * Adds the supplied statements to this repository, optionally to one or more
667: * named contexts.
668: *
669: * @param statementIter
670: * The statements to add. In case the iterator is a
671: * {@link CloseableIteration}, it will be closed before this method
672: * returns.
673: * @param contexts
674: * The contexts to add the statements to. Note that this parameter is
675: * a vararg and as such is optional. If no contexts are specified,
676: * each statement is added to any context specified in the statement,
677: * or if the statement contains no context, it is added without
678: * context. If one or more contexts are specified each statement is
679: * added to these contexts, ignoring any context information in the
680: * statement itself. ignored.
681: * @throws RepositoryException
682: * If the statements could not be added to the repository, for
683: * example because the repository is not writable.
684: */
685: public <E extends Exception> void add(
686: Iteration<? extends Statement, E> statementIter,
687: Resource... contexts) throws RepositoryException, E;
688:
689: /**
690: * Removes the statement(s) with the specified subject, predicate and object
691: * from the repository, optionally restricted to the specified contexts.
692: *
693: * @param subject
694: * The statement's subject, or <tt>null</tt> for a wildcard.
695: * @param predicate
696: * The statement's predicate, or <tt>null</tt> for a wildcard.
697: * @param object
698: * The statement's object, or <tt>null</tt> for a wildcard.
699: * @param contexts
700: * The context(s) to remove the data from. Note that this parameter is
701: * a vararg and as such is optional. If no contexts are supplied the
702: * method operates on the entire repository.
703: * @throws RepositoryException
704: * If the statement(s) could not be removed from the repository, for
705: * example because the repository is not writable.
706: */
707: public void remove(Resource subject, URI predicate, Value object,
708: Resource... contexts) throws RepositoryException;
709:
710: /**
711: * Removes the supplied statement from the specified contexts in the
712: * repository.
713: *
714: * @param st
715: * The statement to remove.
716: * @param contexts
717: * The context(s) to remove the data from. Note that this parameter is
718: * a vararg and as such is optional. If no contexts are supplied the
719: * method operates on the contexts associated with the statement
720: * itself, and if no context is associated with the statement, on the
721: * entire repository.
722: * @throws RepositoryException
723: * If the statement could not be removed from the repository, for
724: * example because the repository is not writable.
725: */
726: public void remove(Statement st, Resource... contexts)
727: throws RepositoryException;
728:
729: /**
730: * Removes the supplied statements from the specified contexts in this
731: * repository.
732: *
733: * @param statements
734: * The statements that should be added.
735: * @param contexts
736: * The context(s) to remove the data from. Note that this parameter is
737: * a vararg and as such is optional. If no contexts are supplied the
738: * method operates on the contexts associated with the statement
739: * itself, and if no context is associated with the statement, on the
740: * entire repository.
741: * @throws RepositoryException
742: * If the statements could not be added to the repository, for
743: * example because the repository is not writable.
744: */
745: public void remove(Iterable<? extends Statement> statements,
746: Resource... contexts) throws RepositoryException;
747:
748: /**
749: * Removes the supplied statements from a specific context in this
750: * repository, ignoring any context information carried by the statements
751: * themselves.
752: *
753: * @param statementIter
754: * The statements to remove. In case the iterator is a
755: * {@link CloseableIteration}, it will be closed before this method
756: * returns.
757: * @param contexts
758: * The context(s) to remove the data from. Note that this parameter is
759: * a vararg and as such is optional. If no contexts are supplied the
760: * method operates on the contexts associated with the statement
761: * itself, and if no context is associated with the statement, on the
762: * entire repository.
763: * @throws RepositoryException
764: * If the statements could not be removed from the repository, for
765: * example because the repository is not writable.
766: */
767: public <E extends Exception> void remove(
768: Iteration<? extends Statement, E> statementIter,
769: Resource... contexts) throws RepositoryException, E;
770:
771: /**
772: * Removes all statements from a specific contexts in the repository.
773: *
774: * @param contexts
775: * The context(s) to remove the data from. Note that this parameter is
776: * a vararg and as such is optional. If no contexts are supplied the
777: * method operates on the entire repository.
778: * @throws RepositoryException
779: * If the statements could not be removed from the repository, for
780: * example because the repository is not writable.
781: */
782: public void clear(Resource... contexts) throws RepositoryException;
783:
784: /**
785: * Gets all declared namespaces as a RepositoryResult of {@link Namespace}
786: * objects. Each Namespace object consists of a prefix and a namespace name.
787: *
788: * @return A RepositoryResult containing Namespace objects. Care should be
789: * taken to close the RepositoryResult after use.
790: * @throws RepositoryException
791: * If the namespaces could not be read from the repository.
792: */
793: public RepositoryResult<Namespace> getNamespaces()
794: throws RepositoryException;
795:
796: /**
797: * Gets the namespace that is associated with the specified prefix, if any.
798: *
799: * @param prefix
800: * A namespace prefix.
801: * @return The namespace name that is associated with the specified prefix,
802: * or <tt>null</tt> if there is no such namespace.
803: * @throws RepositoryException
804: * If the namespace could not be read from the repository.
805: */
806: public String getNamespace(String prefix)
807: throws RepositoryException;
808:
809: /**
810: * Sets the prefix for a namespace.
811: *
812: * @param prefix
813: * The new prefix.
814: * @param name
815: * The namespace name that the prefix maps to.
816: * @throws RepositoryException
817: * If the namespace could not be set in the repository, for example
818: * because the repository is not writable.
819: */
820: public void setNamespace(String prefix, String name)
821: throws RepositoryException;
822:
823: /**
824: * Removes a namespace declaration by removing the association between a
825: * prefix and a namespace name.
826: *
827: * @param prefix
828: * The namespace prefix of which the assocation with a namespace name
829: * is to be removed.
830: * @throws RepositoryException
831: * If the namespace prefix could not be removed.
832: */
833: public void removeNamespace(String prefix)
834: throws RepositoryException;
835:
836: /**
837: * Removes all namespace declarations from the repository.
838: *
839: * @throws RepositoryException
840: * If the namespace declarations could not be removed.
841: */
842: public void clearNamespaces() throws RepositoryException;
843:
844: }
|