Source Code Cross Referenced for DRLInfo.java in  » Rule-Engine » drolls-Rule-Engine » org » drools » eclipse » 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.eclipse 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.drools.eclipse;
002:
003:        import java.util.ArrayList;
004:        import java.util.Collections;
005:        import java.util.Iterator;
006:        import java.util.List;
007:
008:        import org.drools.compiler.Dialect;
009:        import org.drools.compiler.DroolsError;
010:        import org.drools.lang.descr.FunctionDescr;
011:        import org.drools.lang.descr.PackageDescr;
012:        import org.drools.lang.descr.RuleDescr;
013:        import org.drools.rule.LineMappings;
014:        import org.drools.rule.Package;
015:        import org.drools.rule.PackageCompilationData;
016:
017:        public class DRLInfo {
018:
019:            private static final DroolsError[] EMPTY_DROOLS_ERROR_ARRAY = new DroolsError[0];
020:            private static final List EMPTY_LIST = Collections
021:                    .unmodifiableList(Collections.EMPTY_LIST);
022:
023:            private String sourcePathName;
024:            private PackageDescr packageDescr;
025:            private List parserErrors;
026:            private Package compiledPackage;
027:            private DroolsError[] builderErrors;
028:            // cached entry
029:            private transient RuleInfo[] ruleInfos;
030:            private transient FunctionInfo[] functionInfos;
031:
032:            public DRLInfo(String sourcePathName, PackageDescr packageDescr,
033:                    List parserErrors) {
034:                if (sourcePathName == null || "".equals(sourcePathName)) {
035:                    throw new IllegalArgumentException(
036:                            "Invalid sourcePathName " + sourcePathName);
037:                }
038:                if (packageDescr == null) {
039:                    throw new IllegalArgumentException("Null packageDescr");
040:                }
041:                this .sourcePathName = sourcePathName;
042:                this .packageDescr = packageDescr;
043:                this .parserErrors = parserErrors == null ? EMPTY_LIST
044:                        : Collections.unmodifiableList(parserErrors);
045:                this .builderErrors = EMPTY_DROOLS_ERROR_ARRAY;
046:            }
047:
048:            public DRLInfo(String pathName, PackageDescr packageDescr,
049:                    List parserErrors, Package compiledPackage,
050:                    DroolsError[] builderErrors) {
051:                this (pathName, packageDescr, parserErrors);
052:                if (compiledPackage == null) {
053:                    throw new IllegalArgumentException("Null package");
054:                }
055:                this .compiledPackage = compiledPackage;
056:                this .builderErrors = builderErrors == null ? EMPTY_DROOLS_ERROR_ARRAY
057:                        : builderErrors;
058:            }
059:
060:            public String getSourcePathName() {
061:                return sourcePathName;
062:            }
063:
064:            public PackageDescr getPackageDescr() {
065:                return packageDescr;
066:            }
067:
068:            public List getParserErrors() {
069:                return parserErrors;
070:            }
071:
072:            public Package getPackage() {
073:                return compiledPackage;
074:            }
075:
076:            public DroolsError[] getBuilderErrors() {
077:                return builderErrors;
078:            }
079:
080:            public String getPackageName() {
081:                return packageDescr.getName();
082:            }
083:
084:            public boolean isCompiled() {
085:                return compiledPackage != null;
086:            }
087:
088:            public RuleInfo[] getRuleInfos() {
089:                if (ruleInfos == null) {
090:                    List ruleInfosList = new ArrayList();
091:                    for (Iterator rules = packageDescr.getRules().iterator(); rules
092:                            .hasNext();) {
093:                        RuleDescr ruleDescr = (RuleDescr) rules.next();
094:                        RuleInfo ruleInfo = new RuleInfo(ruleDescr);
095:                        ruleInfosList.add(ruleInfo);
096:                    }
097:                    ruleInfos = (RuleInfo[]) ruleInfosList
098:                            .toArray(new RuleInfo[0]);
099:                }
100:                return ruleInfos;
101:            }
102:
103:            public RuleInfo getRuleInfo(int drlLineNumber) {
104:                RuleInfo[] ruleInfos = getRuleInfos();
105:
106:                int ruleLine = -1;
107:                RuleInfo result = null;
108:                for (int i = 0; i < ruleInfos.length; i++) {
109:                    int ruleDrlLineNumber = ruleInfos[i].getDrlLineNumber();
110:                    if (ruleDrlLineNumber > ruleLine
111:                            && ruleDrlLineNumber <= drlLineNumber + 1) {
112:                        ruleLine = ruleDrlLineNumber;
113:                        result = ruleInfos[i];
114:                    }
115:                }
116:                return result;
117:            }
118:
119:            public class RuleInfo {
120:
121:                private final RuleDescr ruleDescr;
122:                // cached entries
123:                private transient String className;
124:                private transient int consequenceJavaLineNumber = -1;
125:
126:                public RuleInfo(RuleDescr ruleDescr) {
127:                    if (ruleDescr == null) {
128:                        throw new IllegalArgumentException("Null ruleDescr");
129:                    }
130:                    this .ruleDescr = ruleDescr;
131:                }
132:
133:                public Dialect getDialect() {
134:                    return ruleDescr.getDialect();
135:                }
136:
137:                public String getSourcePathName() {
138:                    return DRLInfo.this .getSourcePathName();
139:                }
140:
141:                public String getClassName() {
142:                    // ruleDescr is only filled in during compilation
143:                    if (!isCompiled()) {
144:                        throw new IllegalArgumentException(
145:                                "Package has not been compiled");
146:                    }
147:                    if (className == null) {
148:                        className = getPackageName() + "."
149:                                + ruleDescr.getClassName();
150:                    }
151:                    return className;
152:                }
153:
154:                public int getDrlLineNumber() {
155:                    return ruleDescr.getLine();
156:                }
157:
158:                public int getConsequenceDrlLineNumber() {
159:                    return ruleDescr.getConsequenceLine();
160:                }
161:
162:                public int getConsequenceJavaLineNumber() {
163:                    if (consequenceJavaLineNumber == -1) {
164:                        if (!isCompiled()) {
165:                            throw new IllegalArgumentException(
166:                                    "Package has not been compiled");
167:                        }
168:                        PackageCompilationData data = compiledPackage
169:                                .getPackageCompilationData();
170:
171:                        LineMappings mappings = data.getLineMappings(className);
172:                        consequenceJavaLineNumber = mappings.getOffset();
173:
174:                    }
175:                    return consequenceJavaLineNumber;
176:                }
177:
178:                public String getPackageName() {
179:                    return packageDescr.getName();
180:                }
181:
182:                public String getRuleName() {
183:                    return ruleDescr.getName();
184:                }
185:            }
186:
187:            public FunctionInfo[] getFunctionInfos() {
188:                if (functionInfos == null) {
189:                    List functionInfosList = new ArrayList();
190:                    for (Iterator functions = packageDescr.getFunctions()
191:                            .iterator(); functions.hasNext();) {
192:                        FunctionDescr functionDescr = (FunctionDescr) functions
193:                                .next();
194:                        FunctionInfo functionInfo = new FunctionInfo(
195:                                functionDescr);
196:                        functionInfosList.add(functionInfo);
197:                    }
198:                    functionInfos = (FunctionInfo[]) functionInfosList
199:                            .toArray(new FunctionInfo[0]);
200:                }
201:                return functionInfos;
202:            }
203:
204:            public FunctionInfo getFunctionInfo(int drlLineNumber) {
205:                FunctionInfo[] functionInfos = getFunctionInfos();
206:                int functionLine = -1;
207:                FunctionInfo result = null;
208:                for (int i = 0; i < functionInfos.length; i++) {
209:                    int functionDrlLineNumber = functionInfos[i]
210:                            .getDrlLineNumber();
211:                    if (functionDrlLineNumber > functionLine
212:                            && functionDrlLineNumber <= drlLineNumber + 1) {
213:                        functionLine = functionDrlLineNumber;
214:                        result = functionInfos[i];
215:                    }
216:                }
217:                return result;
218:            }
219:
220:            public class FunctionInfo {
221:
222:                private FunctionDescr functionDescr;
223:                // cached entries
224:                private transient String className;
225:                private transient int javaLineNumber = -1;
226:
227:                public FunctionInfo(FunctionDescr functionDescr) {
228:                    if (functionDescr == null) {
229:                        throw new IllegalArgumentException("Null functionDescr");
230:                    }
231:                    this .functionDescr = functionDescr;
232:                }
233:
234:                public String getSourcePathName() {
235:                    return DRLInfo.this .getSourcePathName();
236:                }
237:
238:                public String getClassName() {
239:                    // functionDescr is only filled in during compilation
240:                    if (!isCompiled()) {
241:                        throw new IllegalArgumentException(
242:                                "Package has not been compiled");
243:                    }
244:                    if (className == null) {
245:                        className = functionDescr.getClassName();
246:                    }
247:                    return className;
248:                }
249:
250:                public int getDrlLineNumber() {
251:                    return functionDescr.getLine();
252:                }
253:
254:                public int getJavaLineNumber() {
255:                    if (javaLineNumber == -1) {
256:                        if (!isCompiled()) {
257:                            throw new IllegalArgumentException(
258:                                    "Package has not been compiled");
259:                        }
260:                        javaLineNumber = compiledPackage
261:                                .getPackageCompilationData().getLineMappings(
262:                                        className).getOffset();
263:                    }
264:                    return javaLineNumber;
265:                }
266:
267:                public String getPackageName() {
268:                    return packageDescr.getName();
269:                }
270:
271:                public String getFunctionName() {
272:                    return functionDescr.getName();
273:                }
274:            }
275:
276:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.