KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > rdf > model > impl > SelectorImpl


1 /*
2  * (c) Copyright 2000, 2001, 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. The name of the author may not be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  *
27  * SimpleSelector.java
28  *
29  * Created on 25 August 2000, 10:12
30  */

31
32 package com.hp.hpl.jena.rdf.model.impl;
33
34 import com.hp.hpl.jena.rdf.model.*;
35
36 /** A general selector class for use when querying models.
37  *
38  * <p>OBSOLETE: use SimpleSelector. This implementation is a stub that provides
39  * only constructors.
40  *
41  * <p>An instance of this class is passed with query calls to models. The model
42  * will use the <CODE>test</CODE> method of this class to decide whether
43  * a statement should be included in the selection.</p>
44  * <p>Instances of this class can be provided with subject, predicate and object
45  * constraints. If a subject, a predicate or an object are provided,
46  * the model implementation <b>may</b> restrict the statements that it tests
47  * to statements whose subject, predicate and object match those provided in
48  * the constructor. This can provide for considerably more efficient
49  * searching. However, the model implementation is not required to do this.
50  * If no subject, predicate or object are provided in
51  * the constructor, then all statements in the model must be tested.</p>
52  * <p>This class is designed to be subclassed by the application, defining
53  * defining further selection criteria of its own by providing its own
54  * <CODE>selects</CODE> method.</p>
55  * <p>The <CODE>test</CODE> method first verifies that a statement satisfies
56  * any subject, predicate or object constraints and the calls the <CODE>
57  * selects</CODE> method to test for any application supplied constraint. The
58  * default <CODE>selects</CODE> method simply returns true.</p>
59  * @author bwm, kers
60  * @version Release='$Name: $ $Revision: 1.6 $ $Date: 2005/02/21 12:14:54 $
61  */

62
63 public final class SelectorImpl extends SimpleSelector {
64
65     /** Create a selector. Since no subject, predicate or object constraints are
66      * specified a model will test all statements.
67      */

68    public SelectorImpl() {
69         super();
70     }
71     
72     /** Create a selector. A model <b>may</b> restrict statements that are tested using
73      * the <CODE>selects</CODE> method to those whose subject matches the
74      * subject parameter, whose predicate matches the predicate parameter and whose
75      * object matches the object paramater. Any null parameter is considered to
76      * match anything.
77      * @param subject if not null, the subject of selected statements
78      * must equal this argument.
79      * @param predicate if not null, the predicate of selected statements
80      * must equal this argument.
81      * @param object if not null, the object of selected statements
82      * must equal this argument.
83      */

84     public SelectorImpl(Resource subject, Property predicate, RDFNode object) {
85         super( subject, predicate, object );
86     }
87     
88     /** Create a selector. A model <b>may</b> restrict statements that are tested using
89      * the <CODE>selects</CODE> method to those whose subject matches the
90      * subject parameter, whose predicate matches the predicate parameter and whose
91      * object matches the object paramater. Any null parameter is considered to
92      * match anything.
93      * @param subject if not null, the subject of selected statements
94      * must equal this argument.
95      * @param predicate if not null, the predicate of selected statements
96      * must equal this argument.
97      * @param object if not null, the object of selected statements
98      * must equal this argument.
99      */

100     public SelectorImpl(Resource subject, Property predicate, boolean object) {
101         this(subject, predicate, String.valueOf( object ) );
102     }
103     
104     /** Create a selector. A model <b>may</b> restrict statements that are tested using
105      * the <CODE>selects</CODE> method to those whose subject matches the
106      * subject parameter, whose predicate matches the predicate parameter and whose
107      * object matches the object paramater. Any null parameter is considered to
108      * match anything.
109      * @param subject if not null, the subject of selected statements
110      * must equal this argument.
111      * @param predicate if not null, the predicate of selected statements
112      * must equal this argument.
113      * @param object the object of selected statements
114      * must equal this argument.
115      */

116     public SelectorImpl(Resource subject, Property predicate, long object) {
117         this(subject, predicate, String.valueOf( object ) );
118     }
119     
120     /** Create a selector. A model <b>may</b> restrict statements that are tested using
121      * the <CODE>selects</CODE> method to those whose subject matches the
122      * subject parameter, whose predicate matches the predicate parameter and whose
123      * object matches the object paramater. Any null parameter is considered to
124      * match anything.
125      * @param subject if not null, the subject of selected statements
126      * must equal this argument.
127      * @param predicate if not null, the predicate of selected statements
128      * must equal this argument.
129      * @param object the object of selected statements
130      * must equal this argument.
131      */

132     public SelectorImpl(Resource subject, Property predicate, char object) {
133         this(subject, predicate, String.valueOf( object ) );
134     }
135     
136     /** Create a selector. A model <b>may</b> restrict statements that are tested using
137      * the <CODE>selects</CODE> method to those whose subject matches the
138      * subject parameter, whose predicate matches the predicate parameter and whose
139      * object matches the object paramater. Any null parameter is considered to
140      * match anything.
141      * @param subject if not null, the subject of selected statements
142      * must equal this argument.
143      * @param predicate if not null, the predicate of selected statements
144      * must equal this argument.
145      * @param object the object of selected statements
146      * must equal this argument.
147      */

148     public SelectorImpl(Resource subject, Property predicate, float object) {
149         this(subject, predicate, String.valueOf( object ) );
150     }
151     
152     /** Create a selector. A model <b>may</b> restrict statements that are tested using
153      * the <CODE>selects</CODE> method to those whose subject matches the
154      * subject parameter, whose predicate matches the predicate parameter and whose
155      * object matches the object paramater. Any null parameter is considered to
156      * match anything.
157      * @param subject if not null, the subject of selected statements
158      * must equal this argument.
159      * @param predicate if not null, the predicate of selected statements
160      * must equal this argument.
161      * @param object the object of selected statements
162      * must equal this argument.
163      */

164     public SelectorImpl(Resource subject, Property predicate, double object) {
165         this(subject, predicate, String.valueOf( object ) );
166     }
167     
168     /** Create a selector. A model <b>may</b> restrict statements that are tested using
169      * the <CODE>selects</CODE> method to those whose subject matches the
170      * subject parameter, whose predicate matches the predicate parameter and whose
171      * object matches the object paramater. Any null parameter is considered to
172      * match anything.
173      * @param subject if not null, the subject of selected statements
174      * must equal this argument.
175      * @param predicate if not null, the predicate of selected statements
176      * must equal this argument.
177      * @param object the object of selected statements
178      * must equal this argument - a null string matches the empty string
179      */

180     public SelectorImpl(Resource subject, Property predicate, String JavaDoc object) {
181         this( subject, predicate, object, "" );
182     }
183     
184     /** Create a selector. A model <b>may</b> restrict statements that are tested using
185      * the <CODE>selects</CODE> method to those whose subject matches the
186      * subject parameter, whose predicate matches the predicate parameter and whose
187      * object matches the object paramater. Any null parameter is considered to
188      * match anything.
189      * @param subject if not null, the subject of selected statements
190      * must equal this argument.
191      * @param predicate if not null, the predicate of selected statements
192      * must equal this argument.
193      * @param object the object of selected statements
194      * must equal this argument - the null string matches the empty string
195      * @param language the language of the object constraint
196      */

197     public SelectorImpl(Resource subject, Property predicate,
198                       String JavaDoc object, String JavaDoc language) {
199         super( subject, predicate, object, language );
200     }
201     
202     /** Create a selector. A model <b>may</b> restrict statements that are tested using
203      * the <CODE>selects</CODE> method to those whose subject matches the
204      * subject parameter, whose predicate matches the predicate parameter and whose
205      * object matches the object paramater. Any null parameter is considered to
206      * match anything.
207      * @param subject if not null, the subject of selected statements
208      * must equal this argument.
209      * @param predicate if not null, the predicate of selected statements
210      * must equal this argument.
211      * @param object if not null, the object of selected statements
212      * must equal this argument.
213      */

214     public SelectorImpl(Resource subject, Property predicate, Object JavaDoc object) {
215         super( subject, predicate, object );
216     }
217         
218     /**
219         Answer true to the question "is this a simple selector". Otherwise the default for
220         SimpleSelector subclasses, false, would apply.
221     */

222     public boolean isSimple()
223         { return true; }
224     
225 }
Popular Tags