1 package org.drools.reteoo.impl;
2
3 /*
4 $Id: ParameterTuple.java,v 1.3 2002/08/01 18:47:33 bob Exp $
5
6 Copyright 2002 (C) The Werken Company. All Rights Reserved.
7
8 Redistribution and use of this software and associated documentation
9 ("Software"), with or without modification, are permitted provided
10 that the following conditions are met:
11
12 1. Redistributions of source code must retain copyright
13 statements and notices. Redistributions must also contain a
14 copy of this document.
15
16 2. Redistributions in binary form must reproduce the
17 above copyright notice, this list of conditions and the
18 following disclaimer in the documentation and/or other
19 materials provided with the distribution.
20
21 3. The name "drools" must not be used to endorse or promote
22 products derived from this Software without prior written
23 permission of The Werken Company. For written permission,
24 please contact bob@werken.com.
25
26 4. Products derived from this Software may not be called "drools"
27 nor may "drools" appear in their names without prior written
28 permission of The Werken Company. "drools" is a registered
29 trademark of The Werken Company.
30
31 5. Due credit should be given to The Werken Company.
32 (http://drools.werken.com/).
33
34 THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS
35 ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
36 NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
37 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
38 THE WERKEN COMPANY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
39 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
40 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
41 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
42 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
43 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
44 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
45 OF THE POSSIBILITY OF SUCH DAMAGE.
46
47 */
48
49 import org.drools.rule.Declaration;
50
51 import java.util.Set;
52 import java.util.HashSet;
53
54 /*** Implementation of <code>ReteTuple</code> with a single column,
55 * based upon a <i>root fact object parameter</i> of a rule.
56 *
57 * @see ReteTuple
58 * @see ParameterNodeImpl
59 *
60 * @author <a href="mailto:bob@eng.werken.com">bob mcwhirter</a>
61 */
62 class ParameterTuple extends ReteTuple
63 {
64 // ------------------------------------------------------------
65 // Instance members
66 // ------------------------------------------------------------
67
68 /*** The parameter <code>Declaration</code>. */
69 private Declaration declaration;
70
71 /*** The object bound to the parameter. */
72 private Object object;
73
74 // ------------------------------------------------------------
75 // Constructors
76 // ------------------------------------------------------------
77
78 /*** Construct.
79 *
80 * @param declaration The parameter <code>Declaration</code>.
81 * @param object The object bound to the <code>Declaration</code>.
82 */
83 ParameterTuple(Declaration declaration,
84 Object object)
85 {
86 this.declaration = declaration;
87 this.object = object;
88
89 // addRootFactObject( object );
90 }
91
92 // ------------------------------------------------------------
93 // Instance methods
94 // ------------------------------------------------------------
95
96 /*** Retrieve the object for the parameter.
97 *
98 * @return The current value of the parameter.
99 */
100 public Object getParameterObject()
101 {
102 return this.object;
103 }
104
105 /*** Retrieve the root fact object <code>Declaration</code>.
106 *
107 * @return The <code>Declaration</code>.
108 */
109 Declaration getParameterDeclaration()
110 {
111 return this.declaration;
112 }
113
114 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
115 // org.drools.reteoo.ReteTuple
116 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
117
118 /*** Retrieve the value of a particular declaration column.
119 *
120 * @param declaration The declaration.
121 *
122 * @return The value.
123 */
124 public Object get(Declaration declaration)
125 {
126 if ( this.declaration.equals( declaration ) )
127 {
128 return getParameterObject();
129 }
130
131 return super.get( declaration );
132 }
133
134 /*** Retrieve all declarations participating in this tuple.
135 *
136 * @return Set of all declarations.
137 */
138 public Set getDeclarations()
139 {
140 Set decls = new HashSet();
141
142 decls.add( getParameterDeclaration() );
143
144 decls.addAll( super.getDeclarations() );
145
146 return decls;
147 }
148 }
This page was automatically generated by Maven