1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.exolab.castor.xml.wls8;
16
17 import java.lang.reflect.Method;
18
19
20
21
22
23
24
25
26 public class WeblogicXercesOutputFormat extends WeblogicXercesImplementation implements org.exolab.castor.xml.OutputFormat {
27
28 private static Class outputFormatClass;
29 private static Method setDoctype;
30 private static Method setEncoding;
31 private static Method setVersion;
32 private static Method setIndenting;
33 private static Method setMethod;
34 private static Method setOmitDocumentType;
35 private static Method setOmitXMLDeclaration;
36 private static Method setPreserveSpace;
37
38 private Object outputFormat;
39
40 static {
41
42
43
44 String wlsOutputFormatClassFqcn = "weblogic.apache.xml.serialize.OutputFormat";
45 try {
46 outputFormatClass = Class.forName(wlsOutputFormatClassFqcn);
47 }
48 catch (ClassNotFoundException e) {
49 handleStaticInitException("Could find class " + wlsOutputFormatClassFqcn, e);
50 }
51
52
53 setDoctype = getMethod(outputFormatClass, "setDoctype", new Class[] { String.class, String.class });
54
55
56 setEncoding = getMethod(outputFormatClass, "setEncoding", new Class[] { String.class });
57
58
59 setEncoding = getMethod(outputFormatClass, "setVersion", new Class[] { String.class });
60
61
62 setIndenting = getMethod(outputFormatClass, "setIndenting", new Class[] { boolean.class });
63
64
65 setMethod = getMethod(outputFormatClass, "setMethod", new Class[] { String.class });
66
67
68 setOmitDocumentType = getMethod(outputFormatClass, "setOmitDocumentType", new Class[] { boolean.class });
69
70
71 setOmitXMLDeclaration = getMethod(outputFormatClass, "setOmitXMLDeclaration", new Class[] { boolean.class });
72
73
74 setPreserveSpace = getMethod(outputFormatClass, "setPreserveSpace", new Class[] { boolean.class });
75
76 }
77
78
79
80
81 public WeblogicXercesOutputFormat() {
82 try {
83 outputFormat = outputFormatClass.newInstance();
84 }
85 catch (InstantiationException e) {
86 throw new RuntimeException(e.toString());
87 }
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 = {new Boolean(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 }