Source Code Cross Referenced for Rule.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:        /**
004:         * <p><b>Title:</b> Rule
005:         * <p><b>Description:</b> None
006:         * <p>Copyright (c) 1999 Steven J. Metsker.
007:         * <p>Copyright (c) 2001 The Open For Business Project - www.ofbiz.org
008:         *
009:         * <p>Permission is hereby granted, free of charge, to any person obtaining a
010:         *  copy of this software and associated documentation files (the "Software"),
011:         *  to deal in the Software without restriction, including without limitation
012:         *  the rights to use, copy, modify, merge, publish, distribute, sublicense,
013:         *  and/or sell copies of the Software, and to permit persons to whom the
014:         *  Software is furnished to do so, subject to the following conditions:
015:         *
016:         * <p>The above copyright notice and this permission notice shall be included
017:         *  in all copies or substantial portions of the Software.
018:         *
019:         * <p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
020:         *  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
021:         *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
022:         *  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
023:         *  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
024:         *  OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
025:         *  THE USE OR OTHER DEALINGS IN THE SOFTWARE.
026:         *
027:         * <br>
028:         * <p>A Rule represents a logic statement that a structure is true
029:         * if a following series of other structures are true.
030:         * <p>
031:         * For example,
032:         * <blockquote><pre>
033:         *     bachelor(X) :- male(X), unmarried(X);
034:         * </pre></blockquote>
035:         * <p>
036:         * is a logical rule.
037:         * <p>
038:         * A rule can make a provable version of itself, a DynamicRule,
039:         * that is a essentially a copy of the structures in the rule,
040:         * with a new scope and with a program to consult for other
041:         * rules.
042:         *
043:         * @author Steven J. Metsker
044:         * @version 1.0
045:         */
046:        public class Rule implements  Axiom {
047:            protected Structure[] structures;
048:
049:            /**
050:             * Construct rule from the given structures.
051:             *
052:             * @param Structure[] the structures that make up this rule.
053:             *
054:             */
055:            public Rule(Structure[] structures) {
056:                this .structures = structures;
057:            }
058:
059:            /**
060:             * Construct a one-structure rule from the given structure.
061:             *
062:             * @param Structure the structure that makes up this rule.
063:             *
064:             */
065:            public Rule(Structure s) {
066:                this (new Structure[] { s });
067:            }
068:
069:            /**
070:             * Return a provable version of this rule.
071:             *
072:             * @return a provable version of this rule
073:             */
074:            public DynamicAxiom dynamicAxiom(AxiomSource as) {
075:                return new DynamicRule(as, new Scope(), this );
076:            }
077:
078:            /**
079:             * Returns true if the supplied object is an equivalent
080:             * rule.
081:             *
082:             * @param   object   the object to compare
083:             *
084:             * @return   true, if the supplied object's structures equal
085:             *           this rule's structures
086:             */
087:            public boolean equals(Object o) {
088:                if (!(o instanceof  Rule))
089:                    return false;
090:                Rule r = (Rule) o;
091:
092:                if (!(structures.length == r.structures.length)) {
093:                    return false;
094:                }
095:                for (int i = 0; i < structures.length; i++) {
096:                    if (!(structures[i].equals(r.structures[i]))) {
097:                        return false;
098:                    }
099:                }
100:                return true;
101:            }
102:
103:            /**
104:             * Return the first structure in this rule.
105:             *
106:             * @return the first structure in this rule
107:             */
108:            public Structure head() {
109:                return structures[0];
110:            }
111:
112:            /**
113:             * Returns a string representation of this rule.
114:             *
115:             * @return a string representation of this rule.
116:             */
117:            public String toString() {
118:                StringBuffer buf = new StringBuffer();
119:
120:                for (int i = 0; i < structures.length; i++) {
121:                    if (i == 1) {
122:                        buf.append(" :- ");
123:                    }
124:                    if (i > 1) {
125:                        buf.append(", ");
126:                    }
127:                    buf.append(structures[i].toString());
128:                }
129:                return buf.toString();
130:            }
131:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.