Source Code Cross Referenced for ObjectHandler.java in  » Swing-Library » abeille-forms-designer » com » jeta » forms » store » xml » parser » 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 » Swing Library » abeille forms designer » com.jeta.forms.store.xml.parser 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.jeta.forms.store.xml.parser;
002:
003:        import java.util.HashMap;
004:
005:        import org.xml.sax.SAXException;
006:
007:        import com.jeta.forms.store.jml.dom.JMLAttributes;
008:        import com.jeta.forms.store.xml.XMLUtils;
009:
010:        public class ObjectHandler implements  XMLHandler {
011:
012:            private Object m_object = null;
013:            private HashMap m_properties = new HashMap();
014:            /** for debugging */
015:            private String m_classname;
016:
017:            /**
018:             * Handler that represents the properties for any superclasses of the object
019:             * we are persisting.
020:             */
021:            private ObjectHandler m_super ClassHandler;
022:
023:            public Object getProperty(String propName) {
024:                return m_properties.get(propName);
025:            }
026:
027:            protected void setProperty(Object name, Object value,
028:                    JMLAttributes attribs) throws SAXException {
029:                if ("version".equalsIgnoreCase(name.toString())) {
030:                    try {
031:                        int ival = Integer.parseInt(value.toString());
032:                    } catch (Exception e) {
033:                        System.out
034:                                .println("ObjectHandler version failed!!!   Classname: "
035:                                        + m_classname);
036:                        e.printStackTrace();
037:                    }
038:                }
039:
040:                if (m_properties.containsKey(name)) {
041:                    System.out.println("ObjectHandler already has property: "
042:                            + name + "  oldvalue: " + m_properties.get(name));
043:                }
044:
045:                m_properties.put(name, value);
046:            }
047:
048:            public void startElement(XMLNodeContext ctx) throws SAXException {
049:
050:                if ("object".equalsIgnoreCase(ctx.getQualifiedName())) {
051:                    if (m_classname != null) {
052:                        System.out
053:                                .println("Found non-null class name in ObjectHandler.startElement  existing name: "
054:                                        + m_classname
055:                                        + "   new name: "
056:                                        + ctx.getAttributes().getValue(
057:                                                "classname"));
058:                        assert (false);
059:                    }
060:                    assert (m_object == null);
061:                    m_classname = ctx.getAttributes().getValue("classname");
062:                    ctx.push(this );
063:                    try {
064:                        m_object = instantiateObject(XMLUtils
065:                                .toJMLAttributes(ctx.getAttributes()));
066:                    } catch (Exception e) {
067:                        throw new SAXException(
068:                                e.getMessage()
069:                                        + " - ObjectHandler unable to instantiate object for classname: "
070:                                        + ctx.getAttributes().getValue(
071:                                                "classname"), e);
072:                    }
073:                } else if ("super".equalsIgnoreCase(ctx.getQualifiedName())) {
074:                    assert (m_super ClassHandler == null);
075:                    m_super ClassHandler = new JETAPersistableHandler();
076:                    ctx.push(m_super ClassHandler);
077:                    // don't call start element for <super>
078:                } else if ("at".equalsIgnoreCase(ctx.getQualifiedName())) {
079:                    PropertyHandler phandler = new PropertyHandler(this );
080:                    phandler.startElement(ctx);
081:                } else {
082:                    throw new SAXException(
083:                            "Invalid tag.  Expecting <object classname=\"...\">.  Got instead: "
084:                                    + ctx.getQualifiedName());
085:                }
086:            }
087:
088:            protected Object instantiateObject(JMLAttributes attribs)
089:                    throws InstantiationException, IllegalAccessException,
090:                    ClassNotFoundException {
091:                String value = attribs.getValue("classname");
092:                if ("null".equalsIgnoreCase(value) || value.length() == 0)
093:                    return null;
094:                else
095:                    return Class.forName(value).newInstance();
096:            }
097:
098:            public void endElement(XMLNodeContext ctx) throws SAXException {
099:                if ("object".equalsIgnoreCase(ctx.getQualifiedName())) {
100:                    ctx.pop(this );
101:                } else if ("super".equalsIgnoreCase(ctx.getQualifiedName())) {
102:                    ctx.pop(this );
103:                } else {
104:                    throw new SAXException(
105:                            "Invalid tag.  Expecting <object classname=\"...\">.  Got instead: "
106:                                    + ctx.getQualifiedName());
107:                }
108:            }
109:
110:            public Object getObject() {
111:                return m_object;
112:            }
113:
114:            public ObjectHandler getSuperClassHandler() {
115:                return m_super ClassHandler == null ? this  : m_super ClassHandler;
116:            }
117:
118:            public void characters(char[] ch, int start, int length)
119:                    throws SAXException {
120:                // ignore
121:            }
122:
123:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.