001: /*
002: * (c) Copyright 2000, 2001, 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: * SimpleSelector.java
028: *
029: * Created on 25 August 2000, 10:12
030: */
031:
032: package com.hp.hpl.jena.rdf.model.impl;
033:
034: import com.hp.hpl.jena.rdf.model.*;
035:
036: /** A general selector class for use when querying models.
037: *
038: * <p>OBSOLETE: use SimpleSelector. This implementation is a stub that provides
039: * only constructors.
040: *
041: * <p>An instance of this class is passed with query calls to models. The model
042: * will use the <CODE>test</CODE> method of this class to decide whether
043: * a statement should be included in the selection.</p>
044: * <p>Instances of this class can be provided with subject, predicate and object
045: * constraints. If a subject, a predicate or an object are provided,
046: * the model implementation <b>may</b> restrict the statements that it tests
047: * to statements whose subject, predicate and object match those provided in
048: * the constructor. This can provide for considerably more efficient
049: * searching. However, the model implementation is not required to do this.
050: * If no subject, predicate or object are provided in
051: * the constructor, then all statements in the model must be tested.</p>
052: * <p>This class is designed to be subclassed by the application, defining
053: * defining further selection criteria of its own by providing its own
054: * <CODE>selects</CODE> method.</p>
055: * <p>The <CODE>test</CODE> method first verifies that a statement satisfies
056: * any subject, predicate or object constraints and the calls the <CODE>
057: * selects</CODE> method to test for any application supplied constraint. The
058: * default <CODE>selects</CODE> method simply returns true.</p>
059: * @author bwm, kers
060: * @version Release='$Name: $ $Revision: 1.9 $ $Date: 2008/01/02 12:05:03 $
061: */
062:
063: public final class SelectorImpl extends SimpleSelector {
064:
065: /** Create a selector. Since no subject, predicate or object constraints are
066: * specified a model will test all statements.
067: */
068: public SelectorImpl() {
069: super ();
070: }
071:
072: /** Create a selector. A model <b>may</b> restrict statements that are tested using
073: * the <CODE>selects</CODE> method to those whose subject matches the
074: * subject parameter, whose predicate matches the predicate parameter and whose
075: * object matches the object paramater. Any null parameter is considered to
076: * match anything.
077: * @param subject if not null, the subject of selected statements
078: * must equal this argument.
079: * @param predicate if not null, the predicate of selected statements
080: * must equal this argument.
081: * @param object if not null, the object of selected statements
082: * must equal this argument.
083: */
084: public SelectorImpl(Resource subject, Property predicate,
085: RDFNode object) {
086: super (subject, predicate, object);
087: }
088:
089: /** Create a selector. A model <b>may</b> restrict statements that are tested using
090: * the <CODE>selects</CODE> method to those whose subject matches the
091: * subject parameter, whose predicate matches the predicate parameter and whose
092: * object matches the object paramater. Any null parameter is considered to
093: * match anything.
094: * @param subject if not null, the subject of selected statements
095: * must equal this argument.
096: * @param predicate if not null, the predicate of selected statements
097: * must equal this argument.
098: * @param object if not null, the object of selected statements
099: * must equal this argument.
100: */
101: public SelectorImpl(Resource subject, Property predicate,
102: boolean object) {
103: this (subject, predicate, String.valueOf(object));
104: }
105:
106: /** Create a selector. A model <b>may</b> restrict statements that are tested using
107: * the <CODE>selects</CODE> method to those whose subject matches the
108: * subject parameter, whose predicate matches the predicate parameter and whose
109: * object matches the object paramater. Any null parameter is considered to
110: * match anything.
111: * @param subject if not null, the subject of selected statements
112: * must equal this argument.
113: * @param predicate if not null, the predicate of selected statements
114: * must equal this argument.
115: * @param object the object of selected statements
116: * must equal this argument.
117: */
118: public SelectorImpl(Resource subject, Property predicate,
119: long object) {
120: this (subject, predicate, String.valueOf(object));
121: }
122:
123: /** Create a selector. A model <b>may</b> restrict statements that are tested using
124: * the <CODE>selects</CODE> method to those whose subject matches the
125: * subject parameter, whose predicate matches the predicate parameter and whose
126: * object matches the object paramater. Any null parameter is considered to
127: * match anything.
128: * @param subject if not null, the subject of selected statements
129: * must equal this argument.
130: * @param predicate if not null, the predicate of selected statements
131: * must equal this argument.
132: * @param object the object of selected statements
133: * must equal this argument.
134: */
135: public SelectorImpl(Resource subject, Property predicate,
136: char object) {
137: this (subject, predicate, String.valueOf(object));
138: }
139:
140: /** Create a selector. A model <b>may</b> restrict statements that are tested using
141: * the <CODE>selects</CODE> method to those whose subject matches the
142: * subject parameter, whose predicate matches the predicate parameter and whose
143: * object matches the object paramater. Any null parameter is considered to
144: * match anything.
145: * @param subject if not null, the subject of selected statements
146: * must equal this argument.
147: * @param predicate if not null, the predicate of selected statements
148: * must equal this argument.
149: * @param object the object of selected statements
150: * must equal this argument.
151: */
152: public SelectorImpl(Resource subject, Property predicate,
153: float object) {
154: this (subject, predicate, String.valueOf(object));
155: }
156:
157: /** Create a selector. A model <b>may</b> restrict statements that are tested using
158: * the <CODE>selects</CODE> method to those whose subject matches the
159: * subject parameter, whose predicate matches the predicate parameter and whose
160: * object matches the object paramater. Any null parameter is considered to
161: * match anything.
162: * @param subject if not null, the subject of selected statements
163: * must equal this argument.
164: * @param predicate if not null, the predicate of selected statements
165: * must equal this argument.
166: * @param object the object of selected statements
167: * must equal this argument.
168: */
169: public SelectorImpl(Resource subject, Property predicate,
170: double object) {
171: this (subject, predicate, String.valueOf(object));
172: }
173:
174: /** Create a selector. A model <b>may</b> restrict statements that are tested using
175: * the <CODE>selects</CODE> method to those whose subject matches the
176: * subject parameter, whose predicate matches the predicate parameter and whose
177: * object matches the object paramater. Any null parameter is considered to
178: * match anything.
179: * @param subject if not null, the subject of selected statements
180: * must equal this argument.
181: * @param predicate if not null, the predicate of selected statements
182: * must equal this argument.
183: * @param object the object of selected statements
184: * must equal this argument - a null string matches the empty string
185: */
186: public SelectorImpl(Resource subject, Property predicate,
187: String object) {
188: this (subject, predicate, object, "");
189: }
190:
191: /** Create a selector. A model <b>may</b> restrict statements that are tested using
192: * the <CODE>selects</CODE> method to those whose subject matches the
193: * subject parameter, whose predicate matches the predicate parameter and whose
194: * object matches the object paramater. Any null parameter is considered to
195: * match anything.
196: * @param subject if not null, the subject of selected statements
197: * must equal this argument.
198: * @param predicate if not null, the predicate of selected statements
199: * must equal this argument.
200: * @param object the object of selected statements
201: * must equal this argument - the null string matches the empty string
202: * @param language the language of the object constraint
203: */
204: public SelectorImpl(Resource subject, Property predicate,
205: String object, String language) {
206: super (subject, predicate, object, language);
207: }
208:
209: /** Create a selector. A model <b>may</b> restrict statements that are tested using
210: * the <CODE>selects</CODE> method to those whose subject matches the
211: * subject parameter, whose predicate matches the predicate parameter and whose
212: * object matches the object paramater. Any null parameter is considered to
213: * match anything.
214: * @param subject if not null, the subject of selected statements
215: * must equal this argument.
216: * @param predicate if not null, the predicate of selected statements
217: * must equal this argument.
218: * @param object if not null, the object of selected statements
219: * must equal this argument.
220: */
221: public SelectorImpl(Resource subject, Property predicate,
222: Object object) {
223: super (subject, predicate, object);
224: }
225:
226: /**
227: Answer true to the question "is this a simple selector". Otherwise the default for
228: SimpleSelector subclasses, false, would apply.
229: */
230: public boolean isSimple() {
231: return true;
232: }
233:
234: }
|