Source Code Cross Referenced for BaseNode.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:        /**
020:         * The base class for all Rete nodes.
021:         * 
022:         * @author <a href="mailto:mark.proctor@jboss.com">Mark Proctor</a>
023:         * @author <a href="mailto:bob@werken.com">Bob McWhirter</a>
024:         *
025:         */
026:        public abstract class BaseNode implements  NetworkNode {
027:            protected final int id;
028:
029:            protected boolean hasMemory = false;
030:
031:            protected int sharedCount = 0;
032:
033:            /**
034:             * All nodes have a unique id, set in the constructor.
035:             * 
036:             * @param id
037:             *      The unique id
038:             */
039:            public BaseNode(final int id) {
040:                super ();
041:                this .id = id;
042:            }
043:
044:            /* (non-Javadoc)
045:             * @see org.drools.spi.ReteooNode#getId()
046:             */
047:            public int getId() {
048:                return this .id;
049:            }
050:
051:            /**
052:             * Specifies with the node has any memory.
053:             * 
054:             * @param hasMemory
055:             */
056:            protected void setHasMemory(final boolean hasMemory) {
057:                this .hasMemory = hasMemory;
058:            }
059:
060:            /**
061:             * 
062:             * Indicates whether the node has any memory.
063:             * @return
064:             */
065:            public boolean hasMemory() {
066:                return this .hasMemory;
067:            }
068:
069:            /**
070:             * Attaches the node into the network. Usually to the parent <code>ObjectSource</code> or <code>TupleSource</code>
071:             */
072:            public abstract void attach();
073:
074:            public abstract void attach(InternalWorkingMemory[] workingMemories);
075:
076:            /**
077:             * Removes the node from teh network. Usually from the parent <code>ObjectSource</code> or <code>TupleSource</code>
078:             *
079:             */
080:            public abstract void remove(BaseNode node,
081:                    InternalWorkingMemory[] workingMemories);
082:
083:            //    /**
084:            //     * When nodes are added to the network that already has data. that existing data must be repropagated to the new node.
085:            //     * This new propagation may result in one or more assertions, so a PropagationContext and the workingMemory for the facts
086:            //     * must be provided.
087:            //     * 
088:            //     * @param workingMemory
089:            //     *      The WorkingMemory
090:            //     * @param context
091:            //     *      The PropagationContext
092:            //     *      
093:            //     */
094:            //    public abstract void updateNewNode(InternalWorkingMemory workingMemory,
095:            //                                       PropagationContext context);    
096:
097:            /**
098:             * Each time a node is shared a counter is increased.
099:             *
100:             */
101:            public void addShare() {
102:                ++this .sharedCount;
103:            }
104:
105:            /**
106:             * Each time a node is unshared a counter is decreased.
107:             *
108:             */
109:            public void removeShare() {
110:                --this .sharedCount;
111:            }
112:
113:            /**
114:             * Indicates whether the node is shared.
115:             * @return
116:             */
117:            public boolean isShared() {
118:                return this .sharedCount > 0;
119:            }
120:
121:            /**
122:             * Returns true in case the current node is in use (is referenced by any other node)
123:             * @return
124:             */
125:            public boolean isInUse() {
126:                return this .sharedCount >= 0;
127:            }
128:
129:            /**
130:             * Returns the number of times the node is shared
131:             * @return
132:             *      int value indicating the share count.
133:             */
134:            public int getSharedCount() {
135:                return this .sharedCount;
136:            }
137:
138:            /** 
139:             * The hashCode return is simply the unique id of the node. It is expected that base classes will also implement equals(Object object). 
140:             */
141:            public int hashCode() {
142:                return this .id;
143:            }
144:
145:            public String toString() {
146:                return "[" + this .getClass().getName() + "(" + this .id + ")]";
147:            }
148:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.