001: /*
002: * (c) Copyright 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
003: * All rights reserved.
004: *
005: * Redistribution and use in source and binary forms, with or without
006: * modification, are permitted provided that the following conditions
007: * are met:
008: * 1. Redistributions of source code must retain the above copyright
009: * notice, this list of conditions and the following disclaimer.
010: * 2. Redistributions in binary form must reproduce the above copyright
011: * notice, this list of conditions and the following disclaimer in the
012: * documentation and/or other materials provided with the distribution.
013: * 3. The name of the author may not be used to endorse or promote products
014: * derived from this software without specific prior written permission.
015:
016: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
017: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
018: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
019: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
020: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
021: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
022: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
023: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
024: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
025: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
026: *
027: * Container.java
028: *
029: * Created on 26 July 2000, 07:49
030: */
031:
032: package com.hp.hpl.jena.rdf.model;
033:
034: /** An RDF Container.
035: *
036: * <p>This interface defines methods for accessing RDF container resources.
037: * These methods operate on the RDF statements contained in a model. The
038: * container implementation may cache state from the underlying model, so
039: * objects should not be added to or removed from the container by directly
040: * manipulating its properties, whilst the container is being
041: * accessed through this interface.</p>
042: *
043: * <p>When a member is deleted from a container using this interface, or an
044: * iterator returned through this interface, all the other members with
045: * higher ordinals are renumbered using an algorithm which may depend on the
046: * type of the container.</p>
047: *
048: * <p>This interface provides methods supporting typed literals. This means
049: * that methods are provided which will translate a built in type, or an
050: * object to an RDF Literal. This translation is done by invoking the
051: * <CODE>toString()</CODE> method of the object, or its built in equivalent.
052: * The reverse translation is also supported. This is built in for built
053: * in types. Factory objects, provided by the application, are used
054: * for application objects.</p>
055: * <p>This interface provides methods for supporting enhanced resources. An
056: * enhanced resource is a resource to which the application has added
057: * behaviour. RDF containers are examples of enhanced resources built in
058: * to this package. Enhanced resources are supported by encapsulating a
059: * resource created by an implementation in another class which adds
060: * the extra behaviour. Factory objects are used to construct such
061: * enhanced resources.</p>
062: * @author bwm
063: * @version Release='$Name: $' Revision='$Revision: 1.7 $' Date='$Date: 2008/01/02 12:05:48 $'
064: */
065: public interface Container extends Resource {
066:
067: public boolean isAlt();
068:
069: public boolean isSeq();
070:
071: public boolean isBag();
072:
073: /** Add a new value to a container.
074: *
075: * <p>The size of the container is extended by 1 and the new value is added as
076: * the last element of the container.</p>
077: * @param o The value to be added.
078:
079: * @return this object so that calls may be cascaded.
080: */
081: public Container add(RDFNode o);
082:
083: /** Add a new value to a container.
084: *
085: * <p>The size of the container is extended by 1 and the new value is added as
086: * the last element of the container.</p>
087: * @param o The value to be added.
088:
089: * @return this object so that calls may be cascaded.
090: */
091: public Container add(boolean o);
092:
093: /** Add a new value to a container.
094: *
095: * <p>The size of the container is extended by 1 and the new value is added as
096: * the last element of the container.</p>
097: * @param o The value to be added.
098:
099: * @return this object so that calls may be cascaded.
100: */
101: public Container add(long o);
102:
103: /** Add a new value to a container.
104: *
105: * <p>The size of the container is extended by 1 and the new value is added as
106: * the last element of the container.</p>
107: * @param o The value to be added.
108:
109: * @return this object so that calls may be cascaded.
110: */
111: public Container add(char o);
112:
113: /** Add a new value to a container.
114: *
115: * <p>The size of the container is extended by 1 and the new value is added as
116: * the last element of the container.</p>
117: * @param o The value to be added.
118:
119: * @return this object so that calls may be cascaded.
120: */
121: public Container add(float o);
122:
123: /** Add a new value to a container.
124: *
125: * <p>The size of the container is extended by 1 and the new value is added as
126: * the last element of the container.</p>
127: * @param o The value to be added.
128:
129: * @return this object so that calls may be cascaded.
130: */
131: public Container add(double o);
132:
133: /** Add a new value to a container.
134: *
135: * <p>The size of the container is extended by 1 and the new value is added as
136: * the last element of the container.</p>
137: * @param o The value to be added.
138:
139: * @return this object so that calls may be cascaded.
140: */
141: public Container add(String o);
142:
143: /** Add a new value to a container.
144: *
145: * <p>The size of the container is extended by 1 and the new value is added as
146: * the last element of the container.</p>
147: * @param o The value to be added.
148: * @param l The language of the string to be added
149:
150: * @return this object so that calls may be cascaded.
151: */
152: public Container add(String o, String l);
153:
154: /** Add a new value to a container.
155: *
156: * <p>The size of the container is extended by 1 and the new value is added as
157: * the last element of the container.</p>
158: * @param o The value to be added.
159:
160: * @return this object so that calls may be cascaded.
161: */
162: public Container add(Object o);
163:
164: /** Determine whether the container contains a value
165: * @param o the value being tested for
166:
167: * @return true if and only if the container contains o
168: */
169: public boolean contains(RDFNode o);
170:
171: /** Determine whether the container contains a value
172: * @param o the value being tested for
173:
174: * @return true if and only if the container contains o
175: */
176: public boolean contains(boolean o);
177:
178: /** Determine whether the container contains a value
179: * @param o the value being tested for
180:
181: * @return true if and only if the container contains o
182: */
183: public boolean contains(long o);
184:
185: /** Determine whether the container contains a value
186: * @param o the value being tested for
187:
188: * @return true if and only if the container contains o
189: */
190: public boolean contains(char o);
191:
192: /** Determine whether the container contains a value
193: * @param o the value being tested for
194:
195: * @return true if and only if the container contains o
196: */
197: public boolean contains(float o);
198:
199: /** Determine whether the container contains a value
200: * @param o the value being tested for
201:
202: * @return true if and only if the container contains o
203: */
204: public boolean contains(double o);
205:
206: /** Determine whether the container contains a value
207: * @param o the value being tested for
208:
209: * @return true if and only if the container contains o
210: */
211: public boolean contains(String o);
212:
213: /** Determine whether the container contains a value
214: * @param o the value being tested for
215: * @param l the language of the string tested
216:
217: * @return true if and only if the container contains o
218: */
219: public boolean contains(String o, String l);
220:
221: /** Determine whether the container contains a value
222: * @param o the value being tested for
223:
224: * @return true if and only if the container contains o
225: */
226: public boolean contains(Object o);
227:
228: /** Remove a value from the container.
229: *
230: * <p>The predicate of the statement <CODE>s</CODE> identifies the
231: * ordinal of the value to be removed. Once removed, the values in the
232: * container with a higher ordinal value are renumbered. The renumbering
233: * algorithm depends on the type of container.<p>
234: * @param s The statement to be removed from the model.
235:
236: * @return this container to enable cascading calls.
237: */
238: public Container remove(Statement s);
239:
240: /** Return an iterator over the values.
241: *
242: * <p><B>Note</B> the interator returned is not a standard java.util.iterator.
243: * It has a <CODE>close</CODE> method which SHOULD be called if the
244: * application has not completed the iteration, but no longer requires
245: * the iterator. This will enable the freeing of resources in, for
246: * example, implementations which store their models in a database.</p>
247: .
248: * @return Return an iterator over the values.
249: */
250: public NodeIterator iterator();
251:
252: /** return the number values in the container.
253:
254: * @return the number of values int the container.
255: */
256: public int size();
257: }
|