Source Code Cross Referenced for SchemaFieldSerializer.java in  » Web-Framework » roma-webwizard » org » romaframework » module » designer » serializer » xml » 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 » Web Framework » roma webwizard » org.romaframework.module.designer.serializer.xml 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2006 Giordano Maestro (luca.garulli@assetdata.it) Licensed under
003:         * the Apache License, Version 2.0 (the "License"); you may not use this file
004:         * except in compliance with the License. You may obtain a copy of the License
005:         * at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable
006:         * law or agreed to in writing, software distributed under the License is
007:         * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
008:         * KIND, either express or implied. See the License for the specific language
009:         * governing permissions and limitations under the License.
010:         */
011:        package org.romaframework.module.designer.serializer.xml;
012:
013:        import java.util.Map;
014:        import java.util.Map.Entry;
015:
016:        import org.apache.xmlbeans.XmlObject;
017:        import org.romaframework.aspect.core.CoreAspect;
018:        import org.romaframework.aspect.core.annotation.CoreField;
019:        import org.romaframework.aspect.monitoring.MonitoringAspect;
020:        import org.romaframework.aspect.monitoring.annotation.MonitoringField;
021:        import org.romaframework.aspect.persistence.PersistenceAspect;
022:        import org.romaframework.aspect.reporting.ReportingAspect;
023:        import org.romaframework.aspect.view.ViewAspect;
024:        import org.romaframework.aspect.view.annotation.ViewField;
025:        import org.romaframework.aspect.view.feature.ViewFieldFeatures;
026:        import org.romaframework.core.schema.SchemaField;
027:        import org.romaframework.core.serializer.RomaObjectSerializer;
028:        import org.romaframework.core.serializer.RomaSerializationException;
029:        import org.romaframework.core.serializer.RomaSerializerComponent;
030:        import org.romaframework.xml.config.XmlConfigAspectFieldTypeCore;
031:        import org.romaframework.xml.config.XmlConfigAspectFieldTypeMonitoring;
032:        import org.romaframework.xml.config.XmlConfigAspectFieldTypeReporting;
033:        import org.romaframework.xml.config.XmlConfigAspectFieldTypeView;
034:        import org.romaframework.xml.config.XmlConfigAspectTypePersistence;
035:        import org.romaframework.xml.config.XmlConfigFieldType;
036:        import org.romaframework.xml.config.XmlConfigFieldType.Aspects;
037:
038:        class SchemaFieldSerializer extends AbstractSchemaSerializer {
039:            protected final static SchemaFieldSerializer instance = new SchemaFieldSerializer();
040:
041:            public static RomaObjectSerializer getInstace() {
042:                return instance;
043:            }
044:
045:            @Override
046:            public XmlObject serialize(Object iToSerialize,
047:                    Map<String, Object> options)
048:                    throws RomaSerializationException {
049:                SchemaField toSerialize = (SchemaField) iToSerialize;
050:                XmlConfigFieldType field = XmlConfigFieldType.Factory
051:                        .newInstance();
052:                field.setName(toSerialize.getName());
053:                Aspects aspects = Aspects.Factory.newInstance();
054:                XmlConfigAspectFieldTypeCore core = XmlConfigAspectFieldTypeCore.Factory
055:                        .newInstance();
056:                createAspectXml(CoreAspect.ASPECT_NAME, toSerialize
057:                        .getFeatures(CoreAspect.ASPECT_NAME), core);
058:
059:                if (isNotEndElement(core))
060:                    aspects.addNewCore().set(core);
061:
062:                // TODO: Manage Module configuration: XmlConfigAspectElementTypeModule
063:                // module XmlConfigAspectElementTypeModule module = aspects.addNewModule();
064:                XmlConfigAspectFieldTypeMonitoring monitoring = XmlConfigAspectFieldTypeMonitoring.Factory
065:                        .newInstance();
066:                createAspectXml(MonitoringAspect.ASPECT_NAME, toSerialize
067:                        .getFeatures(MonitoringAspect.ASPECT_NAME), monitoring);
068:                if (isNotEndElement(monitoring))
069:                    aspects.addNewMonitoring().set(monitoring);
070:                XmlConfigAspectFieldTypeView view = XmlConfigAspectFieldTypeView.Factory
071:                        .newInstance();
072:
073:                createAspectXml(ViewAspect.ASPECT_NAME, toSerialize
074:                        .getFeatures(ViewAspect.ASPECT_NAME), view);
075:
076:                XmlConfigAspectTypePersistence persistence = XmlConfigAspectTypePersistence.Factory
077:                        .newInstance();
078:                createAspectXml(PersistenceAspect.ASPECT_NAME, toSerialize
079:                        .getFeatures(PersistenceAspect.ASPECT_NAME),
080:                        persistence);
081:                if (isNotEndElement(persistence)) {
082:                    aspects.addNewPersistence().set(persistence);
083:                }
084:
085:                XmlConfigAspectFieldTypeReporting reporting = XmlConfigAspectFieldTypeReporting.Factory
086:                        .newInstance();
087:                createAspectXml(ReportingAspect.ASPECT_NAME, toSerialize
088:                        .getFeatures(ReportingAspect.ASPECT_NAME), reporting);
089:
090:                if (isNotEndElement(reporting)) {
091:                    aspects.addNewReporting().set(reporting);
092:                }
093:
094:                if (isNotEndElement(view))
095:                    aspects.addNewView().set(view);
096:                if (isNotEndElement(aspects))
097:                    field.addNewAspects().set(aspects);
098:                /**
099:                 * The schemaClass
100:                 */
101:                if (serializeNextLevel(options)) {
102:                    if (toSerialize.getComplexClass() != null) {
103:                        field.addNewClass1().set(
104:                                RomaSerializerComponent.getInstance()
105:                                        .serialize(
106:                                                toSerialize.getComplexClass(),
107:                                                options));
108:                    }
109:                }
110:                return field;
111:            }
112:
113:            /**
114:             * It converts the Object in the schema to the Object of XmlBeans
115:             * 
116:             * @param entry
117:             * @param iToSet
118:             * @return the object to set in Xml fragment
119:             */
120:            @Override
121:            protected Object getValueToSet(Entry<String, Object> entry,
122:                    XmlObject iToSet) {
123:                if (entry.getKey().equals("embeddedType")) {
124:                    return null;
125:                } else if (entry.getKey().equals("selectionMode")) {
126:                    if (entry.getValue().equals(
127:                            ViewFieldFeatures.SELECTION_MODE_INDEX)) {
128:                        return XmlConfigAspectFieldTypeView.SelectionMode.INDEX;
129:                    } else {
130:                        return XmlConfigAspectFieldTypeView.SelectionMode.VALUE;
131:                    }
132:                } else {
133:                    return entry.getValue();
134:                }
135:            }
136:
137:            @Override
138:            protected boolean isDefaultValue(String aspectName,
139:                    Entry<String, Object> entry) throws Exception {
140:                Class annotation = null;
141:                if (aspectName.equals(ViewAspect.ASPECT_NAME)) {
142:                    annotation = ViewField.class;
143:                } else if (aspectName.equals(MonitoringAspect.ASPECT_NAME)) {
144:                    annotation = MonitoringField.class;
145:                } else if (aspectName.equals(CoreAspect.ASPECT_NAME)) {
146:                    annotation = CoreField.class;
147:                }
148:                if (annotation == null) {
149:                    return false;
150:                }
151:                Object defaultValue = getAnnotationDefaultValue(entry,
152:                        annotation);
153:                // entry.getValue().equals(defaultValues.get(entry.getKey()))
154:                if (entry.getValue().equals(defaultValue)) {
155:                    return true;
156:                }
157:                return false;
158:            }
159:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.