1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.exolab.castor.xml;
17
18 import java.lang.reflect.Method;
19
20
21
22
23
24
25
26 public class BaseXercesOutputFormat implements OutputFormat {
27
28 protected Object _outputFormat;
29
30 public Object getFormat() {
31 return _outputFormat;
32 }
33
34 public void setMethod(final String method) {
35 Method aMethod;
36 try {
37 aMethod = _outputFormat.getClass().getMethod(
38 "setMethod", new Class[] {String.class} );
39 aMethod.invoke(_outputFormat, new Object[] { method });
40 } catch (Exception e) {
41 throw new RuntimeException("Problem invoking OutputFormat.setMethod()", e);
42 }
43 }
44
45 public void setIndenting(final boolean indent) {
46 Method method;
47 try {
48 method = _outputFormat.getClass().getMethod(
49 "setIndenting", new Class[] {boolean.class} );
50 method.invoke(_outputFormat, new Object[] { Boolean.valueOf(indent) });
51 } catch (Exception e) {
52 throw new RuntimeException("Problem invoking OutputFormat.setIndenting()", e);
53 }
54 }
55
56 public void setPreserveSpace(final boolean preserveSpace) {
57 Method method;
58 try {
59 method = _outputFormat.getClass().getMethod(
60 "setPreserveSpace", new Class[] {boolean.class} );
61 method.invoke(_outputFormat, new Object[] { Boolean.valueOf(preserveSpace) });
62 } catch (Exception e) {
63 throw new RuntimeException("Problem invoking OutputFormat.setPreserveSpace()", e);
64 }
65 }
66
67 public void setDoctype(final String type1, final String type2) {
68 Method method;
69 try {
70 method = _outputFormat.getClass().getMethod(
71 "setDoctype", new Class[] {String.class, String.class} );
72 method.invoke(_outputFormat, new Object[] { type1, type2});
73 } catch (Exception e) {
74 throw new RuntimeException("Problem invoking OutputFormat.setDoctype()", e);
75 }
76 }
77
78 public void setOmitXMLDeclaration(final boolean omitXMLDeclaration) {
79 Method method;
80 try {
81 method = _outputFormat.getClass().getMethod(
82 "setOmitXMLDeclaration", new Class[] {boolean.class} );
83 method.invoke(_outputFormat, new Object[] { Boolean.valueOf(omitXMLDeclaration) });
84 } catch (Exception e) {
85 throw new RuntimeException("Problem invoking OutputFormat.setOmitXMLDeclaration()", e);
86 }
87 }
88
89 public void setOmitDocumentType(final boolean omitDocumentType) {
90 Method method;
91 try {
92 method = _outputFormat.getClass().getMethod("setOmitDocumentType",
93 boolean.class);
94 method.invoke(_outputFormat, Boolean.valueOf(omitDocumentType));
95 } catch (Exception e) {
96 throw new RuntimeException("Problem invoking OutputFormat.setOmitDocumentType()", e);
97 }
98 }
99
100 public void setEncoding(final String encoding) {
101 Method method;
102 try {
103 method = _outputFormat.getClass().getMethod("setEncoding",
104 String.class);
105 method.invoke(_outputFormat, encoding);
106 } catch (Exception e) {
107 throw new RuntimeException("Problem invoking OutputFormat.setEncoding()", e);
108 }
109 }
110
111 public void setVersion(final String version) {
112 Method method;
113 try {
114 method = _outputFormat.getClass().getMethod(
115 "setVersion", new Class[] {String.class} );
116 method.invoke(_outputFormat, new Object[] { version });
117 } catch (Exception e) {
118 throw new RuntimeException("Problem invoking OutputFormat.setVersion()", e);
119 }
120 }
121
122 }