001: package org.ontoware.rdfreactor.runtime;
002:
003: import org.ontoware.rdf2go.exception.ModelRuntimeException;
004: import org.ontoware.rdf2go.model.Model;
005: import org.ontoware.rdf2go.model.node.URI;
006:
007: /**
008: * <b>ReactorBase</b> is the Interface which has to be implemented by all
009: * classes used to represent the RDFS or OWL ontology.
010: *
011: * @author mvo
012: */
013: public interface ReactorBase extends ResourceEntity {
014: // TODO re-enable after refactoring, Mappable<URI, Object> {
015:
016: /**
017: * @return the model for which this instance acts as a view
018: */
019: public Model getModel();
020:
021: /**
022: * This method is useful for functional properties.
023: *
024: * @param prop
025: * @return the first x in (this, prop, x) if such a statement is in the
026: * model. Null otherwise.
027: * @throws RDFDataException
028: * if multiple values are present
029: */
030: public Object get(URI prop, java.lang.Class<?> returnType)
031: throws RDFDataException;
032:
033: /**
034: * Get all predicates x of triples matching (this, prop, x)
035: *
036: * @param prop
037: * @return an array of x with (this, prop, x) if such statements are in the
038: * model. Empty array otherwise.
039: */
040: public Object[] getAll(URI prop, java.lang.Class<?> returnType);
041:
042: /**
043: * Removes all statements (this, prop, x) and set one anew: (this, prop, o).
044: *
045: * @param prop
046: * @param o
047: */
048: public void set(URI prop, Object o);
049:
050: /**
051: * Removes all statements (this, prop, x) and sets anew: (this, prop, o[0]),
052: * (this, prop, o[1]), ...
053: *
054: * @param prop
055: * @param o
056: * @throws Exception
057: */
058: public void setAll(URI prop, Object[] o)
059: throws ModelRuntimeException;
060:
061: /**
062: * Removes all statements (this, prop, x) and sets anew: (this, prop, o[0]),
063: * (this, prop, o[1]), ... But only if the number of objects in o[] is less
064: * than or equal to maxCard
065: *
066: *
067: * @param prop
068: * @param o
069: * @param maxCard
070: * is the maximum number of triples allowed to match (this, prop,
071: * x)
072: * @throws Exception
073: * @throws CardinalityException
074: */
075: public void setAll(URI prop, Object[] o, int maxCard)
076: throws ModelRuntimeException, CardinalityException;
077:
078: /**
079: * Looks for a statement (this, prop, oldValue) and replaces it by a new
080: * statement (this, prop, newValue). If the first cannot be found, false is
081: * returned, true otherwise.
082: *
083: * @param prop
084: * @param oldValue
085: * @param newValue
086: * @return true, if old value was found in the model
087: * @throws Exception
088: */
089: public boolean update(URI prop, Object oldValue, Object newValue)
090: throws ModelRuntimeException;
091:
092: /**
093: * Adds a statement (this, prop, o).
094: *
095: * @param prop
096: * @param o
097: * @return true if value was already in the model
098: * @throws Exception
099: */
100: public boolean add(URI prop, Object o) throws ModelRuntimeException;
101:
102: /**
103: * Adds a statement (this, prop, o) if the number of statements matching
104: * (this, prop, x) is less then maxCard
105: *
106: * @param property
107: * @param object
108: * @param maxCard,
109: * number of occurences of (this, prop, x) allowed in the model
110: * @return true if value was already preset
111: * @throws CardinalityException
112: */
113:
114: public boolean add(URI prop, Object o, int maxCard)
115: throws CardinalityException, ModelRuntimeException;
116:
117: /**
118: * Tries to remove a statement (this, prop, o).
119: *
120: * @param prop
121: * @param o
122: * @return true if old value was found
123: */
124: public boolean remove(URI prop, Object o);
125:
126: /**
127: * Tries to remove a statement (this, prop, o) if the number of statements
128: * matching (this, prop, x) in the model is less then minCard
129: *
130: * @param prop
131: * @param o
132: * @param minCard,
133: * number of occurences of (this, prop, x) needed in the model
134: * @return true if value was found
135: * @throws CardinalityException
136: */
137: public boolean remove(URI prop, Object o, int minCard)
138: throws CardinalityException;
139:
140: /**
141: * Remove all values of this property (same as remove(this, prop, *)
142: *
143: * @param prop
144: * the URI to be removed
145: * @return true if at least on value was found and removed
146: */
147: public boolean removeAll(URI prop);
148:
149: // /**
150: // * @deprecated not needed
151: // * @param uri
152: // * property URI
153: // * @param o
154: // * must be an instance of RDFBase (thus has a URI)
155: // * @return a statement (this, uri, object) and thus bridges the gap
156: // between
157: // * the OO and RDF worlds.
158: // */
159: // public Statement getStatement(URI uri, ReactorBase o);
160: //
161: // /**
162: // * @deprecated not needed
163: // * @param uri
164: // * property URI
165: // * @param o
166: // * must be a unique literal
167: // * @return a statement (this, uri, object) and thus bridges the gap
168: // between
169: // * the OO and RDF worlds.
170: // */
171: // public Statement getStatement(URI uri, String o);
172:
173: /**
174: * remove all (this, rdf:type, ANY) statements
175: */
176: public void delete();
177:
178: // ////////////////////////////////////////
179: // queries
180:
181: /**
182: * @return the URI of the rdfs:Class, as which this resource is viewed
183: */
184: public URI getRDFSClassURI();
185:
186: public boolean isInstanceof(URI classURI)
187: throws ModelRuntimeException;
188:
189: /**
190: * @deprecated not needed
191: * @param javaClass
192: * @return true iff the given Object is of type javaClass
193: * @throws Exception
194: */
195: public boolean isInstanceof(java.lang.Class<?> javaClass)
196: throws ModelRuntimeException;
197:
198: /**
199: *
200: * @param targetType
201: * any java class that extends ReactorBase directly or indirectly
202: * @return a reference to a new object seeing this object as a 'targetType'
203: */
204: public Object castTo(java.lang.Class<?> targetType);
205:
206: /**
207: * @param model
208: * and RDG2GO model
209: * @return true, iff this resource is contained in any statement of the
210: * model
211: */
212: public boolean in(Model model);
213:
214: }
|