KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > graph > query > ExpressionSet


1 /*
2   (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP, all rights reserved.
3   [See end of file]
4   $Id: ExpressionSet.java,v 1.14 2005/02/21 11:52:15 andy_seaborne Exp $
5 */

6
7 package com.hp.hpl.jena.graph.query;
8
9 import java.util.*;
10
11 import com.hp.hpl.jena.util.CollectionFactory;
12
13 /**
14     ExpressionSet: represent a set of (boolean) expressions ANDed together.
15
16     @author kers
17 */

18 public class ExpressionSet
19     {
20     private Set expressions = CollectionFactory.createHashedSet();
21     /**
22         Initialise an expression set with no members.
23     */

24     public ExpressionSet()
25         {}
26     
27     /**
28         Answer this expressionset after e has been anded into it.
29         @param e the expression to and into the set
30         @return this ExpressionSet
31     */

32     public ExpressionSet add( Expression e )
33         {
34         expressions.add( e );
35         return this;
36         }
37
38     /**
39          Answer true iff this ExpressionSet is non-trivial (ie non-empty).
40     */

41     public boolean isComplex()
42         { return !expressions.isEmpty(); }
43     
44 // /**
45
// Evaluate this expression set, delivering true iff no member of the set evaluates
46
// to false.
47
//
48
// @param vv the mapping from variables to values
49
// @return true iff no member evaluates to false
50
// */
51
// public boolean evalBool( VariableValues vv )
52
// {
53
// Iterator it = expressions.iterator();
54
// while (it.hasNext())
55
// if (((Expression) it.next()).evalBool( vv ) == false) return false;
56
// return true;
57
// }
58

59     /**
60          Answer a ValuatorSet which contains exactly the valuators for each
61          Expression in this ExpressionSet, prepared against the VariableIndexes vi.
62     */

63     public ValuatorSet prepare( VariableIndexes vi )
64         {
65         ValuatorSet result = new ValuatorSet();
66         Iterator it = expressions.iterator();
67         while (it.hasNext()) result.add( ((Expression) it.next()).prepare( vi ) );
68         return result;
69         }
70     
71     /**
72          Answer an iterator over all the Expressions in this ExpressionSet.
73     */

74     public Iterator iterator()
75         { return expressions.iterator(); }
76     
77     /**
78          Answer a string representing this ExpressionSet for human consumption.
79     */

80     public String JavaDoc toString()
81         { return expressions.toString(); }
82     }
83
84 /*
85     (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
86     All rights reserved.
87
88     Redistribution and use in source and binary forms, with or without
89     modification, are permitted provided that the following conditions
90     are met:
91
92     1. Redistributions of source code must retain the above copyright
93        notice, this list of conditions and the following disclaimer.
94
95     2. Redistributions in binary form must reproduce the above copyright
96        notice, this list of conditions and the following disclaimer in the
97        documentation and/or other materials provided with the distribution.
98
99     3. The name of the author may not be used to endorse or promote products
100        derived from this software without specific prior written permission.
101
102     THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
103     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
104     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
105     IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
106     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
107     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
108     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
109     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
110     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
111     THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
112 */
Popular Tags