01: /*
02: (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP, all rights reserved.
03: [See end of file]
04: $Id: ValuatorSet.java,v 1.11 2008/01/02 12:07:57 andy_seaborne Exp $
05: */
06:
07: package com.hp.hpl.jena.graph.query;
08:
09: import java.util.*;
10:
11: import com.hp.hpl.jena.util.CollectionFactory;
12:
13: /**
14: ValuatorSet - a set of Valuators, which can be added to and evaluated [only].
15:
16: @author kers
17: */
18: public class ValuatorSet {
19: private Set valuators = CollectionFactory.createHashedSet();
20:
21: public ValuatorSet() {
22: }
23:
24: /**
25: Answer true iff evaluating this ValuatorSet runs some Valuators.
26: */
27: public boolean isNonTrivial() {
28: return valuators.size() > 0;
29: }
30:
31: /**
32: Answer this ValuatorSet after adding the Valuator <code>e</code> to it.
33: */
34: public ValuatorSet add(Valuator e) {
35: valuators.add(e);
36: return this ;
37: }
38:
39: /**
40: Answer true iff no Valuator in this set evaluates to <code>false</code>. The
41: Valuators are evaluated in an unspecified order, and evaluation ceases as
42: soon as any Valuator has returned false.
43: */
44: public boolean evalBool(IndexValues vv) {
45: Iterator it = valuators.iterator();
46: while (it.hasNext())
47: if (((Valuator) it.next()).evalBool(vv) == false)
48: return false;
49: return true;
50: }
51:
52: }
53:
54: /*
55: (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
56: All rights reserved.
57:
58: Redistribution and use in source and binary forms, with or without
59: modification, are permitted provided that the following conditions
60: are met:
61:
62: 1. Redistributions of source code must retain the above copyright
63: notice, this list of conditions and the following disclaimer.
64:
65: 2. Redistributions in binary form must reproduce the above copyright
66: notice, this list of conditions and the following disclaimer in the
67: documentation and/or other materials provided with the distribution.
68:
69: 3. The name of the author may not be used to endorse or promote products
70: derived from this software without specific prior written permission.
71:
72: THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
73: IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
74: OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
75: IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
76: INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
77: NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
78: DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
79: THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
80: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
81: THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
82: */
|