Source Code Cross Referenced for SmartReflectionXMLSerializerFactory.java in  » Code-Analyzer » beautyJ » de » gulden » util » xml » serializer » smart » 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 » Code Analyzer » beautyJ » de.gulden.util.xml.serializer.smart 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Project: Gulden Utilies
003:         * Class:   de.gulden.util.xml.serializer.smart.SmartReflectionXMLSerializerFactory
004:         * Version: snapshot-beautyj-1.1
005:         *
006:         * Date:    2004-09-29
007:         *
008:         * This is a snapshot version of the Gulden Utilities,
009:         * it is not released as a seperate version.
010:         *  
011:         * Note:    Contains auto-generated Javadoc comments created by BeautyJ.
012:         *  
013:         * This is licensed under the GNU Lesser General Public License (LGPL)
014:         * and comes with NO WARRANTY.
015:         *
016:         * Author:  Jens Gulden
017:         * Email:   amoda@jensgulden.de
018:         */
019:
020:        package de.gulden.util.xml.serializer.smart;
021:
022:        import de.gulden.util.xml.XMLException;
023:        import de.gulden.util.xml.serializer.XMLSerializer;
024:        import de.gulden.util.xml.serializer.XMLSerializerFactory;
025:        import de.gulden.util.xml.serializer.smart.SmartReflectionXMLSerializer;
026:        import java.util.*;
027:        import java.util.Hashtable;
028:
029:        /**
030:         * Class SmartReflectionXMLSerializerFactory.
031:         *  
032:         * @author  Jens Gulden
033:         * @version  snapshot-beautyj-1.1
034:         */
035:        public class SmartReflectionXMLSerializerFactory implements  Cloneable,
036:                XMLSerializerFactory {
037:
038:            // ------------------------------------------------------------------------
039:            // --- fields                                                           ---
040:            // ------------------------------------------------------------------------
041:
042:            /**
043:             * The tagnames to classes.
044:             */
045:            protected Hashtable tagnamesToClasses;
046:
047:            /**
048:             * The classes to tagnames.
049:             */
050:            protected Hashtable classesToTagnames;
051:
052:            /**
053:             * The tagnames to classes.
054:             */
055:            protected TreeSet tagnamesAskClassname;
056:
057:            // ------------------------------------------------------------------------
058:            // --- constructor                                                      ---
059:            // ------------------------------------------------------------------------
060:
061:            /**
062:             * Creates a new instance of SmartReflectionXMLSerializerFactory.
063:             */
064:            public SmartReflectionXMLSerializerFactory() {
065:                tagnamesToClasses = new Hashtable();
066:                classesToTagnames = new Hashtable();
067:                tagnamesAskClassname = new TreeSet();
068:            }
069:
070:            // ------------------------------------------------------------------------
071:            // --- methods                                                          ---
072:            // ------------------------------------------------------------------------
073:
074:            /**
075:             * Creates the x m l serializer.
076:             */
077:            public XMLSerializer createXMLSerializer() {
078:                try {
079:                    return new SmartReflectionXMLSerializer(
080:                            (SmartReflectionXMLSerializerFactory) this .clone());
081:                } catch (CloneNotSupportedException e) {
082:                    throw new Error("internal cloning error");
083:                }
084:            }
085:
086:            public void registerTagname(String tagname, Class serializableClass) {
087:                tagnamesToClasses.put(tagname, serializableClass);
088:                classesToTagnames.put(serializableClass, tagname);
089:            }
090:
091:            public void registerTagname(String tagname,
092:                    Class serializableClass, boolean askClassname) {
093:                registerTagname(tagname, serializableClass);
094:                if (askClassname) {
095:                    tagnamesAskClassname.add(tagname);
096:                }
097:            }
098:
099:            Class mapToClass(String tagname, String classAttribute)
100:                    throws XMLException {
101:                Class cl = (Class) tagnamesToClasses.get(tagname);
102:                if (cl == null) {
103:                    throw new XMLException("tagname '" + tagname
104:                            + "' is not known");
105:                }
106:                if (tagnamesAskClassname.contains(tagname)) {
107:                    if (classAttribute == null || classAttribute.equals("")) {
108:                        throw new XMLException("tagname '" + tagname
109:                                + "' requires a 'class' attribute");
110:                    }
111:                    Class cl2;
112:                    try {
113:                        cl2 = Class.forName(classAttribute);
114:                    } catch (ClassNotFoundException cnfe) {
115:                        throw new XMLException("tagname '" + tagname
116:                                + "' cannot load class '" + classAttribute
117:                                + "' - not found");
118:                    }
119:                    if (!cl.isAssignableFrom(cl2)) {
120:                        throw new XMLException("tagname '" + tagname
121:                                + "' cannot use class '" + classAttribute
122:                                + "' - not compatible with '" + cl.getName()
123:                                + "'");
124:                    }
125:                    return cl2;
126:                } else {
127:                    return cl;
128:                }
129:            }
130:
131:            String mapToTagname(Class serializableClass) {
132:                return (String) classesToTagnames.get(serializableClass);
133:            }
134:
135:        } // end SmartReflectionXMLSerializerFactory
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.