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


001:        package org.drools.base.extractors;
002:
003:        import java.lang.reflect.Method;
004:
005:        import org.drools.RuntimeDroolsException;
006:        import org.drools.base.BaseClassFieldExtractor;
007:        import org.drools.base.ValueType;
008:        import org.drools.common.InternalWorkingMemory;
009:
010:        public abstract class BaseObjectClassFieldExtractor extends
011:                BaseClassFieldExtractor {
012:
013:            private static final long serialVersionUID = 400L;
014:
015:            protected BaseObjectClassFieldExtractor(final int index,
016:                    final Class fieldType, final ValueType valueType) {
017:                super (index, fieldType, valueType);
018:            }
019:
020:            public BaseObjectClassFieldExtractor(final Class clazz,
021:                    final String fieldName) {
022:                super (clazz, fieldName);
023:            }
024:
025:            public abstract Object getValue(
026:                    InternalWorkingMemory workingMemory, Object object);
027:
028:            public boolean getBooleanValue(InternalWorkingMemory workingMemory,
029:                    final Object object) {
030:                // this can be improved by generating specific 
031:                // bytecode generation in the subclass, avoiding the if instanceof
032:                final Object value = getValue(workingMemory, object);
033:
034:                if (value instanceof  Boolean) {
035:                    return ((Boolean) value).booleanValue();
036:                }
037:                throw new RuntimeDroolsException(
038:                        "Conversion to boolean not supported from "
039:                                + value.getClass().getName());
040:            }
041:
042:            public byte getByteValue(InternalWorkingMemory workingMemory,
043:                    final Object object) {
044:                // this can be improved by generating specific 
045:                // bytecode generation in the subclass, avoiding the if instanceof
046:                final Object value = getValue(workingMemory, object);
047:
048:                if (value instanceof  Number) {
049:                    return ((Number) value).byteValue();
050:                }
051:                throw new RuntimeDroolsException(
052:                        "Conversion to byte not supported from "
053:                                + value.getClass().getName());
054:            }
055:
056:            public char getCharValue(InternalWorkingMemory workingMemory,
057:                    final Object object) {
058:                // this can be improved by generating specific 
059:                // bytecode generation in the subclass, avoiding the if instanceof
060:                final Object value = getValue(workingMemory, object);
061:
062:                if (value instanceof  Character) {
063:                    return ((Character) value).charValue();
064:                } else if (value instanceof  String
065:                        && ((String) value).length() == 1) {
066:                    return ((String) value).charAt(0);
067:                }
068:                throw new RuntimeDroolsException(
069:                        "Conversion to char not supported from "
070:                                + value.getClass().getName());
071:            }
072:
073:            public double getDoubleValue(InternalWorkingMemory workingMemory,
074:                    final Object object) {
075:                // this can be improved by generating specific 
076:                // bytecode generation in the subclass, avoiding the if instanceof
077:                final Object value = getValue(workingMemory, object);
078:
079:                if (value instanceof  Number) {
080:                    return ((Number) value).doubleValue();
081:                }
082:                throw new RuntimeDroolsException(
083:                        "Conversion to double not supported from "
084:                                + value.getClass().getName());
085:            }
086:
087:            public float getFloatValue(InternalWorkingMemory workingMemory,
088:                    final Object object) {
089:                // this can be improved by generating specific 
090:                // bytecode generation in the subclass, avoiding the if instanceof
091:                final Object value = getValue(workingMemory, object);
092:
093:                if (value instanceof  Number) {
094:                    return ((Number) value).floatValue();
095:                }
096:                throw new RuntimeDroolsException(
097:                        "Conversion to float not supported from "
098:                                + value.getClass().getName());
099:            }
100:
101:            public int getIntValue(InternalWorkingMemory workingMemory,
102:                    final Object object) {
103:                // this can be improved by generating specific 
104:                // bytecode generation in the subclass, avoiding the if instanceof
105:                final Object value = getValue(workingMemory, object);
106:
107:                if (value instanceof  Number) {
108:                    return ((Number) value).intValue();
109:                }
110:                throw new RuntimeDroolsException(
111:                        "Conversion to int not supported from "
112:                                + value.getClass().getName());
113:            }
114:
115:            public long getLongValue(InternalWorkingMemory workingMemory,
116:                    final Object object) {
117:                // this can be improved by generating specific 
118:                // bytecode generation in the subclass, avoiding the if instanceof
119:                final Object value = getValue(workingMemory, object);
120:
121:                if (value instanceof  Number) {
122:                    return ((Number) value).longValue();
123:                }
124:                throw new RuntimeDroolsException(
125:                        "Conversion to long not supported from "
126:                                + value.getClass().getName());
127:            }
128:
129:            public short getShortValue(InternalWorkingMemory workingMemory,
130:                    final Object object) {
131:                // this can be improved by generating specific 
132:                // bytecode generation in the subclass, avoiding the if instanceof
133:                final Object value = getValue(workingMemory, object);
134:
135:                if (value instanceof  Number) {
136:                    return ((Number) value).shortValue();
137:                }
138:                throw new RuntimeDroolsException(
139:                        "Conversion to short not supported from "
140:                                + value.getClass().getName());
141:            }
142:
143:            public boolean isNullValue(InternalWorkingMemory workingMemory,
144:                    final Object object) {
145:                if (object == null) {
146:                    return true;
147:                } else {
148:                    return getValue(workingMemory, object) == null;
149:                }
150:            }
151:
152:            public Method getNativeReadMethod() {
153:                try {
154:                    return this .getClass().getDeclaredMethod(
155:                            "getValue",
156:                            new Class[] { InternalWorkingMemory.class,
157:                                    Object.class });
158:                } catch (final Exception e) {
159:                    throw new RuntimeDroolsException(
160:                            "This is a bug. Please report to development team: "
161:                                    + e.getMessage(), e);
162:                }
163:            }
164:
165:            public int getHashCode(InternalWorkingMemory workingMemory,
166:                    final Object object) {
167:                final Object value = getValue(workingMemory, object);
168:                return (value != null) ? value.hashCode() : 0;
169:            }
170:
171:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.