1
2
3
4
5
6
7
8
9
10
11
12
13 package org.exolab.castor.xml.wls8;
14
15 import java.lang.reflect.Method;
16
17
18
19
20
21
22
23
24 public class WeblogicXercesOutputFormat extends WeblogicXercesImplementation
25 implements org.exolab.castor.xml.OutputFormat {
26
27 private static Class outputFormatClass;
28 private static Method setDoctype;
29 private static Method setEncoding;
30 private static Method setVersion;
31 private static Method setIndenting;
32 private static Method setMethod;
33 private static Method setOmitDocumentType;
34 private static Method setOmitXMLDeclaration;
35 private static Method setPreserveSpace;
36
37 private Object outputFormat;
38
39 static {
40
41
42
43 String wlsOutputFormatClassFqcn = "weblogic.apache.xml.serialize.OutputFormat";
44 try {
45 outputFormatClass = Class.forName(wlsOutputFormatClassFqcn);
46 } catch (ClassNotFoundException e) {
47 handleStaticInitException("Could find class " + wlsOutputFormatClassFqcn, e);
48 }
49
50
51 setDoctype =
52 getMethod(outputFormatClass, "setDoctype", new Class[] {String.class, String.class});
53
54
55 setEncoding = getMethod(outputFormatClass, "setEncoding", new Class[] {String.class});
56
57
58 setEncoding = getMethod(outputFormatClass, "setVersion", new Class[] {String.class});
59
60
61 setIndenting = getMethod(outputFormatClass, "setIndenting", new Class[] {boolean.class});
62
63
64 setMethod = getMethod(outputFormatClass, "setMethod", new Class[] {String.class});
65
66
67 setOmitDocumentType =
68 getMethod(outputFormatClass, "setOmitDocumentType", new Class[] {boolean.class});
69
70
71 setOmitXMLDeclaration =
72 getMethod(outputFormatClass, "setOmitXMLDeclaration", new Class[] {boolean.class});
73
74
75 setPreserveSpace =
76 getMethod(outputFormatClass, "setPreserveSpace", new Class[] {boolean.class});
77
78 }
79
80
81
82
83 public WeblogicXercesOutputFormat() {
84 try {
85 outputFormat = outputFormatClass.newInstance();
86 } catch (InstantiationException e) {
87 throw new RuntimeException(e.toString());
88 } catch (IllegalAccessException e) {
89 throw new RuntimeException(e.toString());
90 }
91 }
92
93 public void setMethod(String method) {
94 Object[] params = {method};
95 invoke(setMethod, params);
96 }
97
98 public Object getFormat() {
99 return outputFormat;
100 }
101
102 public void setIndenting(boolean indent) {
103
104
105 Boolean[] params = {Boolean.valueOf(indent)};
106 invoke(setIndenting, params);
107 }
108
109 public void setPreserveSpace(boolean preserveSpace) {
110 Boolean[] params = {Boolean.valueOf(preserveSpace)};
111 invoke(setPreserveSpace, params);
112 }
113
114 public void setDoctype(String type1, String type2) {
115 Object[] params = {type1, type2};
116 invoke(setDoctype, params);
117 }
118
119 public void setOmitXMLDeclaration(boolean omitXMLDeclaration) {
120 Boolean[] params = {Boolean.valueOf(omitXMLDeclaration)};
121 invoke(setOmitXMLDeclaration, params);
122 }
123
124 public void setOmitDocumentType(boolean omitDocumentType) {
125 Boolean[] params = {Boolean.valueOf(omitDocumentType)};
126 invoke(setOmitDocumentType, params);
127 }
128
129 public void setEncoding(String encoding) {
130 String[] params = {encoding};
131 invoke(setEncoding, params);
132 }
133
134 public void setVersion(String version) {
135 String[] params = {version};
136 invoke(setEncoding, params);
137 }
138
139 private Object invoke(Method method, Object[] params) {
140 return invoke(outputFormat, method, params);
141 }
142
143 }