Source Code Cross Referenced for Scope.java in  » ERP-CRM-Financial » SourceTap-CRM » org » ofbiz » rules » engine » 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 » ERP CRM Financial » SourceTap CRM » org.ofbiz.rules.engine 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.ofbiz.rules.engine;
002:
003:        import java.util.*;
004:        import org.ofbiz.rules.utensil.*;
005:
006:        /**
007:         * <p><b>Title:</b> Scope
008:         * <p><b>Description:</b> None
009:         * <p>Copyright (c) 1999 Steven J. Metsker.
010:         * <p>Copyright (c) 2001 The Open For Business Project - www.ofbiz.org
011:         *
012:         * <p>Permission is hereby granted, free of charge, to any person obtaining a
013:         *  copy of this software and associated documentation files (the "Software"),
014:         *  to deal in the Software without restriction, including without limitation
015:         *  the rights to use, copy, modify, merge, publish, distribute, sublicense,
016:         *  and/or sell copies of the Software, and to permit persons to whom the
017:         *  Software is furnished to do so, subject to the following conditions:
018:         *
019:         * <p>The above copyright notice and this permission notice shall be included
020:         *  in all copies or substantial portions of the Software.
021:         *
022:         * <p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
023:         *  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
024:         *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
025:         *  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
026:         *  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
027:         *  OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
028:         *  THE USE OR OTHER DEALINGS IN THE SOFTWARE.
029:         *
030:         * <br>
031:         * <p>A scope is a repository for variables. A dynamic rule has
032:         * a scope, which means that variables with the same name
033:         * are the same variable. Consider a rule that describes
034:         * big cities:
035:         *
036:         * <blockquote><pre>
037:         *     bigCity(Name) :- city(Name, Pop), >(Pop, 1000000);
038:         * </pre></blockquote>
039:         *
040:         * This example follows the Prolog convention of using
041:         * capitalized words for variables. The variables <code>Name
042:         * </code> and <code>Pop</code> have scope throughout the rule.
043:         * <p>
044:         * The <code>bigCity</code> rule proves itself by finding
045:         * a city and checking its population. When the <code>city
046:         * </code> structure binds with a city fact in a program, its
047:         * variables take on the values of the fact. For example,
048:         * <code>city</code> might bind with the fact <code>
049:         * city(bigappolis, 8733352) </code>. Then <code>Name</code>
050:         * and <code>Pop</code> will bind to the values "bigappolis"
051:         * and 8733352.
052:         * <p>
053:         * When the comparison proves itself, it will compare <code>
054:         * Pop</code> to 1000000. This is the same variable as <code>
055:         * Pop</code> in the <code>city</code> structure of the rule.
056:         * With this successful comparison, the rule completes a
057:         * successful proof, with <code>Name</code> bound to
058:         * "bigappolis".
059:         *
060:         * @author Steven J. Metsker
061:         * @version 1.0
062:         */
063:        public class Scope implements  PubliclyCloneable {
064:            Hashtable dictionary = new Hashtable();
065:
066:            /**
067:             * Create an empty scope.
068:             */
069:            public Scope() {
070:            }
071:
072:            /**
073:             * Create a scope that uses the variables in the supplied
074:             * terms.
075:             *
076:             * @param Term[] the terms to seed this scope with
077:             */
078:            public Scope(Term terms[]) {
079:                for (int i = 0; i < terms.length; i++) {
080:                    Unification u = terms[i].variables();
081:                    Enumeration e = u.elements();
082:
083:                    while (e.hasMoreElements()) {
084:                        Variable v = (Variable) e.nextElement();
085:
086:                        dictionary.put(v.name, v);
087:                    }
088:                }
089:            }
090:
091:            /**
092:             * Remove all variables from this scope.
093:             */
094:            public void clear() {
095:                dictionary.clear();
096:            }
097:
098:            /**
099:             * Return a copy of this object.
100:             *
101:             * @return a copy of this object
102:             */
103:            public Object clone() {
104:                try {
105:                    Scope clone = (Scope) super .clone();
106:
107:                    clone.dictionary = (Hashtable) dictionary.clone();
108:                    return clone;
109:                } catch (CloneNotSupportedException e) {
110:                    // this shouldn't happen, since we are Cloneable
111:                    throw new InternalError();
112:                }
113:            }
114:
115:            /**
116:             * Returns true if a variable of the given name appears
117:             * in this scope.
118:             *
119:             * @param String the variable name
120:             *
121:             * @return true, if a variable of the given name appears
122:             *         in this scope.
123:             */
124:            public boolean isDefined(String name) {
125:                return dictionary.containsKey(name);
126:            }
127:
128:            /**
129:             * Returns a variable of the given name from this scope.
130:             *
131:             * If the so-named variable is not already in this scope,
132:             * the scope will create it and add the variable to itself.
133:             *
134:             * @param String the variable name
135:             *
136:             * @return a variable of the given name from this scope
137:             */
138:            public Variable lookup(String name) {
139:                Variable v = (Variable) dictionary.get(name);
140:
141:                if (v == null) {
142:                    v = new Variable(name);
143:                    dictionary.put(v.name, v);
144:                }
145:                return v;
146:            }
147:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.