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


001:        /*
002:         * Copyright 2006 JBoss Inc
003:         * 
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         * 
008:         *      http://www.apache.org/licenses/LICENSE-2.0
009:         * 
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:
017:        package org.drools.lang.dsl;
018:
019:        import java.util.List;
020:        import java.util.Map;
021:        import java.util.regex.Pattern;
022:
023:        /**
024:         * A single entry in a DSL mapping file
025:         * 
026:         * @author etirelli
027:         */
028:        public interface DSLMappingEntry {
029:
030:            public static final Section KEYWORD = new KeywordSection();
031:            public static final Section CONDITION = new ConditionSection();
032:            public static final Section CONSEQUENCE = new ConsequenceSection();
033:            public static final Section ANY = new AnySection();
034:            public static final MetaData EMPTY_METADATA = new DefaultDSLEntryMetaData(
035:                    "");
036:
037:            /**
038:             * Returns the section this mapping entry refers to
039:             * 
040:             * @return
041:             */
042:            public DSLMappingEntry.Section getSection();
043:
044:            /**
045:             * Returns the meta data info about this mapping entry
046:             * 
047:             * @return
048:             */
049:            public DSLMappingEntry.MetaData getMetaData();
050:
051:            /**
052:             * Returns the key of this mapping, i.e., the source
053:             * that needs to be translated
054:             * 
055:             * @return
056:             */
057:            public String getMappingKey();
058:
059:            /**
060:             * Returns the result of the translation
061:             * 
062:             * @return
063:             */
064:            public String getMappingValue();
065:
066:            /**
067:             * Returns the compiled pattern based on the given MappingKey
068:             * @return the keyPattern
069:             */
070:            public Pattern getKeyPattern();
071:
072:            /**
073:             * Returns the transformed mapping value using place holders for variables 
074:             * @return the valuePattern
075:             */
076:            public String getValuePattern();
077:
078:            /**
079:             * Returns the list of variables found in the given pattern key
080:             * @return the variables
081:             */
082:            public Map getVariables();
083:
084:            /**
085:             * @param key the key to set
086:             */
087:            public void setMappingKey(String key);
088:
089:            /**
090:             * @param section the section to set
091:             */
092:            public void setSection(Section section);
093:
094:            /**
095:             * @param value the value to set
096:             */
097:            public void setMappingValue(String value);
098:
099:            /**
100:             * @param metadata the metadata to set
101:             */
102:            public void setMetaData(MetaData metadata);
103:
104:            /**
105:             * Returns a list of errors found in this mapping
106:             * @return
107:             */
108:            public List getErrors();
109:
110:            /**
111:             * An inner interface for DSL mapping sections
112:             * @author etirelli
113:             *
114:             */
115:            public static interface Section extends Comparable {
116:                public String getSymbol();
117:            }
118:
119:            /**
120:             * An inner interface to represent any metadata
121:             * associated with this entry. It is obviously
122:             * implementation dependent.
123:             * 
124:             * @author etirelli
125:             *
126:             */
127:            public static interface MetaData extends Comparable {
128:                public String toString();
129:
130:                public String getMetaData();
131:            }
132:
133:            /**
134:             * The keyword section, to allow mapping of keywords
135:             * 
136:             * @author etirelli
137:             */
138:            public static class KeywordSection implements  Section {
139:                private static final String symbol = "[keyword]";
140:
141:                private KeywordSection() {
142:                }
143:
144:                public String getSymbol() {
145:                    return symbol;
146:                }
147:
148:                public String toString() {
149:                    return symbol;
150:                }
151:
152:                public int hashCode() {
153:                    final int PRIME = 31;
154:                    int result = 1;
155:                    result = PRIME * result
156:                            + ((symbol == null) ? 0 : symbol.hashCode());
157:                    return result;
158:                }
159:
160:                public boolean equals(final Object obj) {
161:                    if (this  == obj) {
162:                        return true;
163:                    }
164:                    if (obj == null) {
165:                        return false;
166:                    }
167:                    if (getClass() != obj.getClass()) {
168:                        return false;
169:                    }
170:                    final KeywordSection other = (KeywordSection) obj;
171:                    if (symbol == null) {
172:                        if (other.getSymbol() != null) {
173:                            return false;
174:                        }
175:                    } else if (!symbol.equals(other.getSymbol())) {
176:                        return false;
177:                    }
178:                    return true;
179:                }
180:
181:                public int compareTo(final Object arg0) {
182:                    return this .toString().compareTo(arg0.toString());
183:                }
184:            }
185:
186:            /**
187:             * The condition section, to allow mapping of the conditions
188:             * 
189:             * @author etirelli
190:             */
191:            public static class ConditionSection implements  Section {
192:                private static final String symbol = "[condition]";
193:
194:                private ConditionSection() {
195:                }
196:
197:                public String getSymbol() {
198:                    return symbol;
199:                }
200:
201:                public String toString() {
202:                    return symbol;
203:                }
204:
205:                public int hashCode() {
206:                    final int PRIME = 31;
207:                    int result = 1;
208:                    result = PRIME * result
209:                            + ((symbol == null) ? 0 : symbol.hashCode());
210:                    return result;
211:                }
212:
213:                public boolean equals(final Object obj) {
214:                    if (this  == obj) {
215:                        return true;
216:                    }
217:                    if (obj == null) {
218:                        return false;
219:                    }
220:                    if (getClass() != obj.getClass()) {
221:                        return false;
222:                    }
223:                    final KeywordSection other = (KeywordSection) obj;
224:                    if (symbol == null) {
225:                        if (other.getSymbol() != null) {
226:                            return false;
227:                        }
228:                    } else if (!symbol.equals(other.getSymbol())) {
229:                        return false;
230:                    }
231:                    return true;
232:                }
233:
234:                public int compareTo(final Object arg0) {
235:                    return this .toString().compareTo(arg0.toString());
236:                }
237:            }
238:
239:            /**
240:             * The consequence section to allow the mapping 
241:             * of consequence elements
242:             * 
243:             * @author etirelli
244:             */
245:            public static class ConsequenceSection implements  Section {
246:                private static final String symbol = "[consequence]";
247:
248:                private ConsequenceSection() {
249:                }
250:
251:                public String getSymbol() {
252:                    return symbol;
253:                }
254:
255:                public String toString() {
256:                    return symbol;
257:                }
258:
259:                public int hashCode() {
260:                    final int PRIME = 31;
261:                    int result = 1;
262:                    result = PRIME * result
263:                            + ((symbol == null) ? 0 : symbol.hashCode());
264:                    return result;
265:                }
266:
267:                public boolean equals(final Object obj) {
268:                    if (this  == obj) {
269:                        return true;
270:                    }
271:                    if (obj == null) {
272:                        return false;
273:                    }
274:                    if (getClass() != obj.getClass()) {
275:                        return false;
276:                    }
277:                    final KeywordSection other = (KeywordSection) obj;
278:                    if (symbol == null) {
279:                        if (other.getSymbol() != null) {
280:                            return false;
281:                        }
282:                    } else if (!symbol.equals(other.getSymbol())) {
283:                        return false;
284:                    }
285:                    return true;
286:                }
287:
288:                public int compareTo(final Object arg0) {
289:                    return this .toString().compareTo(arg0.toString());
290:                }
291:            }
292:
293:            /**
294:             * An element to indicate the mapping should be applicable
295:             * to any section
296:             *  
297:             * @author etirelli
298:             */
299:            public static class AnySection implements  Section {
300:
301:                private static final String symbol = "[*]";
302:
303:                private AnySection() {
304:                }
305:
306:                public String getSymbol() {
307:                    return symbol;
308:                }
309:
310:                public String toString() {
311:                    return symbol;
312:                }
313:
314:                public int hashCode() {
315:                    final int PRIME = 31;
316:                    int result = 1;
317:                    result = PRIME * result
318:                            + ((symbol == null) ? 0 : symbol.hashCode());
319:                    return result;
320:                }
321:
322:                public boolean equals(final Object obj) {
323:                    if (this  == obj) {
324:                        return true;
325:                    }
326:                    if (obj == null) {
327:                        return false;
328:                    }
329:                    if (getClass() != obj.getClass()) {
330:                        return false;
331:                    }
332:                    final KeywordSection other = (KeywordSection) obj;
333:                    if (symbol == null) {
334:                        if (other.getSymbol() != null) {
335:                            return false;
336:                        }
337:                    } else if (!symbol.equals(other.getSymbol())) {
338:                        return false;
339:                    }
340:                    return true;
341:                }
342:
343:                public int compareTo(final Object arg0) {
344:                    return this .toString().compareTo(arg0.toString());
345:                }
346:            }
347:
348:            public static class DefaultDSLEntryMetaData implements 
349:                    DSLMappingEntry.MetaData {
350:
351:                private String metadata;
352:
353:                public DefaultDSLEntryMetaData(final String metadata) {
354:                    this .metadata = metadata;
355:                }
356:
357:                public String getMetaData() {
358:                    return this .metadata;
359:                }
360:
361:                public String toString() {
362:                    return (this .metadata == null) ? "" : this .metadata;
363:                }
364:
365:                public int compareTo(final Object arg0) {
366:                    return this.toString().compareTo(arg0.toString());
367:                }
368:            }
369:
370:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.