01: /*
02: * Copyright 2006 Giordano Maestro (giordano.maestro@assetdata.it) Licensed
03: * under the Apache License, Version 2.0 (the "License"); you may not use this
04: * file except in compliance with the License. You may obtain a copy of the
05: * License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
06: * applicable law or agreed to in writing, software distributed under the
07: * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
08: * OF ANY KIND, either express or implied. See the License for the specific
09: * language governing permissions and limitations under the License.
10: */
11: package org.romaframework.module.designer.serializer.xml;
12:
13: import java.util.HashMap;
14: import java.util.Map;
15: import org.apache.xmlbeans.XmlObject;
16: import org.apache.xmlbeans.XmlOptions;
17: import org.romaframework.aspect.view.echo2.screen.ConfigurableScreen;
18: import org.romaframework.core.serializer.RomaObjectSerializer;
19: import org.romaframework.core.serializer.RomaSerializationException;
20: import org.romaframework.core.serializer.RomaSerializerComponent;
21: import org.romaframework.xml.config.XmlConfigAreaType;
22: import org.romaframework.xml.config.XmlConfigScreenDocument;
23:
24: class AreaSerializerScreenXml extends RomaObjectSerializer {
25: protected final static AreaSerializerScreenXml instance = new AreaSerializerScreenXml();
26:
27: public static RomaObjectSerializer getInstace() {
28: return instance;
29: }
30:
31: AreaSerializerScreenXml() {
32: }
33:
34: @Override
35: public XmlObject serialize(Object object)
36: throws RomaSerializationException {
37: HashMap map = new HashMap();
38: map.put("", "http://www.romaframework.org/xml/roma");
39: ConfigurableScreen screen = (ConfigurableScreen) object;
40: XmlOptions options = new XmlOptions();
41: options.setCharacterEncoding("UTF-8");
42: options.setUseDefaultNamespace();
43: XmlConfigScreenDocument document = XmlConfigScreenDocument.Factory
44: .newInstance(options);
45: document.addNewScreen().setArea(
46: (XmlConfigAreaType) RomaSerializerComponent
47: .getInstance().serialize(screen.getRootArea()));
48: return document;
49: }
50:
51: @Override
52: public XmlObject serialize(Object iToSerialize,
53: Map<String, Object> options)
54: throws RomaSerializationException {
55: return serialize(iToSerialize);
56: }
57: }
|