Source Code Cross Referenced for SQLLvalueTerm.java in  » Workflow-Engines » obe-1.0 » org » obe » sql » 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 » Workflow Engines » obe 1.0 » org.obe.sql 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


01:        package org.obe.sql;
02:
03:        import org.obe.OBERuntimeException;
04:        import org.obe.client.api.repository.RepositoryException;
05:        import org.obe.spi.model.AttributeInstance;
06:        import org.obe.spi.model.AttributedEntity;
07:
08:        import java.beans.BeanInfo;
09:        import java.beans.IntrospectionException;
10:        import java.beans.Introspector;
11:        import java.beans.PropertyDescriptor;
12:        import java.io.IOException;
13:        import java.io.Writer;
14:        import java.lang.reflect.InvocationTargetException;
15:        import java.lang.reflect.Method;
16:        import java.util.ArrayList;
17:        import java.util.List;
18:        import java.util.Map;
19:
20:        /**
21:         * @author Adrian Price
22:         */
23:        public class SQLLvalueTerm extends SimpleNode {
24:            private List path = new ArrayList();
25:
26:            public SQLLvalueTerm(int id) {
27:                super (id);
28:            }
29:
30:            public void addPathElement(String elem) {
31:                path.add(elem);
32:            }
33:
34:            public List getPath() {
35:                return path;
36:            }
37:
38:            public void write(Writer out) throws IOException {
39:                boolean dot = false;
40:                for (int i = 0, n = path.size(); i < n; i++) {
41:                    if (dot)
42:                        out.write('.');
43:                    out.write((String) path.get(i));
44:                    dot = true;
45:                }
46:            }
47:
48:            public Object execute(Object context) {
49:                // For now, we won't support the concept of table.
50:                if (path.size() != 1)
51:                    throw new UnsupportedOperationException(toString() + ": "
52:                            + path);
53:
54:                // The semantics of SQLvalueTerm is essentially that of retrieving the
55:                // value of a row, optionally qualified with a table name.  Mapping the
56:                // former concept from SQL to JavaBeans suggests the retrieval of a
57:                // JavaBean property from the context bean.  The latter concept is
58:                // beyond the scope of the current SQL evaluator because it implies
59:                // supporting the concept of tables and operations thereon.
60:                try {
61:                    String attrName = (String) path.get(0);
62:
63:                    if (context instanceof  AttributedEntity) {
64:                        AttributedEntity entity = (AttributedEntity) context;
65:                        Map map = entity.getAttributeInstances();
66:                        AttributeInstance attr = (AttributeInstance) map
67:                                .get(attrName);
68:                        return attr == null ? null : attr.getValue();
69:                    } else {
70:                        // TODO: initialize the property descriptors statically.
71:                        Object value = null;
72:                        BeanInfo bi = Introspector.getBeanInfo(context
73:                                .getClass());
74:                        PropertyDescriptor[] propDescs = bi
75:                                .getPropertyDescriptors();
76:                        for (int i = 0; i < propDescs.length; i++) {
77:                            PropertyDescriptor propDesc = propDescs[i];
78:                            if (propDesc.getName().equals(attrName)) {
79:                                Method getter = propDesc.getReadMethod();
80:                                // Cast required to suppress JDK1.5 varargs compiler warning.
81:                                value = getter.invoke(context, (Object[]) null);
82:                                break;
83:                            }
84:                        }
85:                        return value;
86:                    }
87:                } catch (IntrospectionException e) {
88:                    throw new OBERuntimeException(e);
89:                } catch (IllegalAccessException e) {
90:                    throw new OBERuntimeException(e);
91:                } catch (InvocationTargetException e) {
92:                    throw new OBERuntimeException(e);
93:                } catch (RepositoryException e) {
94:                    throw new OBERuntimeException(e);
95:                }
96:            }
97:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.