Source Code Cross Referenced for AgendaItem.java in  » Rule-Engine » drolls-Rule-Engine » org » drools » common » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Rule Engine » drolls Rule Engine » org.drools.common 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.drools.common;
002:
003:        /*
004:         * Copyright 2005 JBoss Inc
005:         * 
006:         * Licensed under the Apache License, Version 2.0 (the "License");
007:         * you may not use this file except in compliance with the License.
008:         * You may obtain a copy of the License at
009:         * 
010:         *      http://www.apache.org/licenses/LICENSE-2.0
011:         * 
012:         * Unless required by applicable law or agreed to in writing, software
013:         * distributed under the License is distributed on an "AS IS" BASIS,
014:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015:         * See the License for the specific language governing permissions and
016:         * limitations under the License.
017:         */
018:
019:        import java.io.Serializable;
020:
021:        import org.drools.rule.GroupElement;
022:        import org.drools.rule.Rule;
023:        import org.drools.spi.Activation;
024:        import org.drools.spi.AgendaGroup;
025:        import org.drools.spi.PropagationContext;
026:        import org.drools.spi.Tuple;
027:        import org.drools.util.LinkedList;
028:        import org.drools.util.Queue;
029:        import org.drools.util.Queueable;
030:
031:        /**
032:         * Item entry in the <code>Agenda</code>.
033:         * 
034:         * @author <a href="mailto:mark.proctor@jboss.com">Mark Proctor</a>
035:         * @author <a href="mailto:bob@werken.com">Bob McWhirter</a>
036:         */
037:        public class AgendaItem implements  Activation, Queueable, Serializable {
038:            // ------------------------------------------------------------
039:            // Instance members
040:            // ------------------------------------------------------------
041:
042:            /**
043:             * 
044:             */
045:            private static final long serialVersionUID = 400L;
046:
047:            /** The tuple. */
048:            private final Tuple tuple;
049:
050:            /** The rule. */
051:            private final Rule rule;
052:
053:            /** The salience */
054:            private final int salience;
055:
056:            /** Used for sequential mode */
057:            private int sequenence;
058:
059:            /** The subrule */
060:            private final GroupElement subrule;
061:
062:            /** The propagation context */
063:            private final PropagationContext context;
064:
065:            /** The activation number */
066:            private final long activationNumber;
067:
068:            /** A reference to the PriorityQeue the item is on */
069:            private Queue queue;
070:
071:            private int index;
072:
073:            private LinkedList justified;
074:
075:            private boolean activated;
076:
077:            private InternalAgendaGroup agendaGroup;
078:
079:            private ActivationGroupNode activationGroupNode;
080:
081:            private RuleFlowGroupNode ruleFlowGroupNode;
082:
083:            // ------------------------------------------------------------
084:            // Constructors
085:            // ------------------------------------------------------------
086:
087:            /**
088:             * Construct.
089:             * 
090:             * @param tuple
091:             *            The tuple.
092:             * @param rule
093:             *            The rule.
094:             */
095:            public AgendaItem(final long activationNumber, final Tuple tuple,
096:                    final int salience, final PropagationContext context,
097:                    final Rule rule, final GroupElement subrule) {
098:                this .tuple = tuple;
099:                this .context = context;
100:                this .rule = rule;
101:                this .salience = salience;
102:                this .subrule = subrule;
103:                this .activationNumber = activationNumber;
104:            }
105:
106:            // ------------------------------------------------------------
107:            // Instance methods
108:            // ------------------------------------------------------------
109:            public PropagationContext getPropagationContext() {
110:                return this .context;
111:            }
112:
113:            /**
114:             * Retrieve the rule.
115:             * 
116:             * @return The rule.
117:             */
118:            public Rule getRule() {
119:                return this .rule;
120:            }
121:
122:            /**
123:             * Retrieve the tuple.
124:             * 
125:             * @return The tuple.
126:             */
127:            public Tuple getTuple() {
128:                return this .tuple;
129:            }
130:
131:            public int getSalience() {
132:                return this .salience;
133:            }
134:
135:            public int getSequenence() {
136:                return sequenence;
137:            }
138:
139:            public void setSequenence(int sequenence) {
140:                this .sequenence = sequenence;
141:            }
142:
143:            /*
144:             * (non-Javadoc)
145:             * 
146:             * @see org.drools.spi.Activation#getActivationNumber()
147:             */
148:            public long getActivationNumber() {
149:                return this .activationNumber;
150:            }
151:
152:            public void addLogicalDependency(final LogicalDependency node) {
153:                if (this .justified == null) {
154:                    this .justified = new LinkedList();
155:                }
156:
157:                this .justified.add(node);
158:            }
159:
160:            public LinkedList getLogicalDependencies() {
161:                return this .justified;
162:            }
163:
164:            public void setLogicalDependencies(LinkedList justified) {
165:                this .justified = justified;
166:            }
167:
168:            public boolean isActivated() {
169:                return this .activated;
170:            }
171:
172:            public void setActivated(final boolean activated) {
173:                this .activated = activated;
174:            }
175:
176:            public String toString() {
177:                return "[Activation rule=" + this .rule.getName() + ", tuple="
178:                        + this .tuple + "]";
179:            }
180:
181:            /*
182:             * (non-Javadoc)
183:             * 
184:             * @see java.lang.Object#equals(java.lang.Object)
185:             */
186:            public boolean equals(final Object object) {
187:                if (object == this ) {
188:                    return true;
189:                }
190:
191:                if (object == null || !(object instanceof  AgendaItem)) {
192:                    return false;
193:                }
194:
195:                final AgendaItem otherItem = (AgendaItem) object;
196:
197:                return (this .rule.equals(otherItem.getRule()) && this .tuple
198:                        .equals(otherItem.getTuple()));
199:            }
200:
201:            /**
202:             * Return the hashCode of the
203:             * <code>TupleKey<code> as the hashCode of the AgendaItem
204:             * @return
205:             */
206:            public int hashCode() {
207:                return this .tuple.hashCode();
208:            }
209:
210:            public void enqueued(final Queue queue, final int index) {
211:                this .queue = queue;
212:                this .index = index;
213:            }
214:
215:            public void dequeue() {
216:                if (this .queue != null) {
217:                    // will only be null if the AgendaGroup is locked when the activation add was attempted
218:                    this .queue.dequeue(this .index);
219:                }
220:                this .activated = false;
221:            }
222:
223:            public void remove() {
224:                dequeue();
225:            }
226:
227:            public ActivationGroupNode getActivationGroupNode() {
228:                return this .activationGroupNode;
229:            }
230:
231:            public void setActivationGroupNode(
232:                    final ActivationGroupNode activationNode) {
233:                this .activationGroupNode = activationNode;
234:            }
235:
236:            public AgendaGroup getAgendaGroup() {
237:                return this .agendaGroup;
238:            }
239:
240:            public void setAgendaGroup(final InternalAgendaGroup agendaGroup) {
241:                this .agendaGroup = agendaGroup;
242:            }
243:
244:            public RuleFlowGroupNode getRuleFlowGroupNode() {
245:                return this .ruleFlowGroupNode;
246:            }
247:
248:            public void setRuleFlowGroupNode(
249:                    final RuleFlowGroupNode ruleFlowGroupNode) {
250:                this .ruleFlowGroupNode = ruleFlowGroupNode;
251:            }
252:
253:            public GroupElement getSubRule() {
254:                return this.subrule;
255:            }
256:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.