Source Code Cross Referenced for JSymmetricClauseSet.java in  » Rule-Engine » Mandarax » org » mandarax » kernel » meta » 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 » Mandarax » org.mandarax.kernel.meta 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (C) 1999-2004 <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</a>
003:         *
004:         * This library is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU Lesser General Public
006:         * License as published by the Free Software Foundation; either
007:         * version 2 of the License, or (at your option) any later version.
008:         *
009:         * This library is distributed in the hope that it will be useful,
010:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
012:         * Lesser General Public License for more details.
013:         *
014:         * You should have received a copy of the GNU Lesser General Public
015:         * License along with this library; if not, write to the Free Software
016:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
017:         */
018:        package org.mandarax.kernel.meta;
019:
020:        import java.util.Collection;
021:        import java.util.Iterator;
022:        import java.util.List;
023:        import java.util.Vector;
024:
025:        import org.mandarax.kernel.Clause;
026:        import org.mandarax.util.DataSource;
027:        import org.mandarax.util.StaticDataSource;
028:
029:        /**
030:         * Clause set for symmetric predicates such as <code>equals()</code>.
031:         * E.g.,in case a equals b, only one of the facts equals(a,b) and equals(b,a) is in the set
032:         * because it is known (from the semantic of the method) that <code>a.equals(b)</code>
033:         * yields true if and only if <code>b.equals(a)</code> is yields true.
034:         * @see org.mandarax.util.AutoFacts
035:         * @author <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</A>
036:         * @version 3.4 <7 March 05>
037:         * @since 1.0
038:         * @deprecated it is recommended to use the more general class org.mandarax.util.AutoFacts instead
039:         */
040:        public class JSymmetricClauseSet extends AbstractClauseSet {
041:
042:            private DataSource argumentSet = null;
043:
044:            /**
045:             * Constructor.
046:             * @param aPredicate a predicate
047:             * @param argumentSets the collections of objects
048:             * @throws java.lang.IllegalAccessException Thrown if the method wrapped by the predicate is not public.
049:             * @throws java.lang.IllegalArgumentException Thrown if the return type of the method wrapped by the predicate is not boolean or if the number of argument sets does not match.
050:             */
051:            public JSymmetricClauseSet(JPredicate aPredicate,
052:                    Collection argumentSet) throws NullPointerException,
053:                    IllegalAccessException, IllegalArgumentException {
054:                super ();
055:
056:                initialize(aPredicate, new StaticDataSource(argumentSet));
057:            }
058:
059:            /**
060:             * Constructor.
061:             * @param aPredicate a predicate
062:             * @param argumentSets the collections of objects
063:             * @param isNegated true if the set should be negated, false otherwise
064:             * @throws java.lang.IllegalAccessException Thrown if the method wrapped by the predicate is not public.
065:             * @throws java.lang.IllegalArgumentException Thrown if the return type of the method wrapped by the predicate is not boolean or if the number of argument sets does not match.
066:             */
067:            public JSymmetricClauseSet(JPredicate aPredicate,
068:                    Collection argumentSet, boolean isNegated)
069:                    throws NullPointerException, IllegalAccessException,
070:                    IllegalArgumentException {
071:                super (isNegated);
072:
073:                initialize(aPredicate, new StaticDataSource(argumentSet));
074:            }
075:
076:            /**
077:             * Constructor.
078:             * @param aPredicate a predicate
079:             * @param argumentSets the data sources (kind of dynamic collections)
080:             * @throws java.lang.IllegalAccessException Thrown if the method wrapped by the predicate is not public.
081:             * @throws java.lang.IllegalArgumentException Thrown if the return type of the method wrapped by the predicate is not boolean or if the number of argument sets does not match.
082:             */
083:            public JSymmetricClauseSet(JPredicate aPredicate,
084:                    DataSource argumentSet) throws NullPointerException,
085:                    IllegalAccessException, IllegalArgumentException {
086:                super ();
087:
088:                initialize(aPredicate, argumentSet);
089:            }
090:
091:            /**
092:             * Constructor.
093:             * @param aPredicate a predicate
094:             * @param argumentSets the data sources (kind of dynamic collections)
095:             * @param isNegated true if the set should be negated, false otherwise
096:             * @throws java.lang.IllegalAccessException Thrown if the method wrapped by the predicate is not public.
097:             * @throws java.lang.IllegalArgumentException Thrown if the return type of the method wrapped by the predicate is not boolean or if the number of argument sets does not match.
098:             */
099:            public JSymmetricClauseSet(JPredicate aPredicate,
100:                    DataSource argumentSet, boolean isNegated)
101:                    throws NullPointerException, IllegalAccessException,
102:                    IllegalArgumentException {
103:                super (isNegated);
104:
105:                initialize(aPredicate, argumentSet);
106:            }
107:
108:            /**
109:             * Build the collection of facts.
110:             * @return the collection of facts built
111:             */
112:            protected Collection buildFacts() {
113:                Collection collData = argumentSet.getData();
114:                List data = null;
115:
116:                // cast to or build a list since looping with an index is easier here
117:                if (collData instanceof  List) {
118:                    data = (List) collData;
119:                } else {
120:                    Vector v = new Vector(collData.size());
121:
122:                    for (Iterator it = collData.iterator(); it.hasNext();) {
123:                        v.add(it.next());
124:                    }
125:
126:                    data = v;
127:                }
128:
129:                int n = data.size();
130:                Clause f = null;
131:                Vector coll = new Vector(n * (n + 1) / 2);
132:                Object[] par = new Object[1];
133:
134:                for (int i = 0; i < data.size(); i++) {
135:                    for (int j = 0; j <= i; j++) {
136:                        par[0] = data.get(j);
137:                        f = buildFact(data.get(i), par);
138:
139:                        if (f != null) {
140:                            coll.add(f);
141:                        }
142:                    }
143:                }
144:
145:                return coll;
146:            }
147:
148:            /**
149:             * Validate the parameters provided to set up the set.
150:             * @param aPredicate the predicate
151:             * @param argSet the data source
152:             * @throws java.lang.IllegalAccessException Thrown if the method wrapped by the predicate is not public.
153:             * @throws java.lang.IllegalArgumentException Thrown if the return type of the method wrapped by the predicate is not boolean or if the number of argument sets does not match.
154:             */
155:            private void initialize(JPredicate aPredicate, DataSource argSet)
156:                    throws NullPointerException, IllegalAccessException,
157:                    IllegalArgumentException {
158:                if (argSet == null) {
159:                    throw new NullPointerException(
160:                            "The argument sets cannot be null");
161:                }
162:
163:                initialize(aPredicate);
164:
165:                argumentSet = argSet;
166:            }
167:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.