1 package net.sourceforge.harness.xml.jaxb;
2
3 import java.io.IOException;
4 import java.io.InputStream;
5
6 import javax.xml.bind.ConversionException;
7 import javax.xml.bind.Dispatcher;
8 import javax.xml.bind.Element;
9 import javax.xml.bind.InvalidAttributeException;
10 import javax.xml.bind.LocalValidationException;
11 import javax.xml.bind.MarshallableObject;
12 import javax.xml.bind.Marshaller;
13 import javax.xml.bind.StructureValidationException;
14 import javax.xml.bind.UnmarshalException;
15 import javax.xml.bind.Unmarshaller;
16 import javax.xml.bind.Validator;
17 import javax.xml.marshal.XMLScanner;
18 import javax.xml.marshal.XMLWriter;
19
20
21 public class Author extends MarshallableObject implements Element {
22 private String _Content;
23
24 public String getContent() {
25 return _Content;
26 }
27
28 public void setContent(String _Content) {
29 this._Content = _Content;
30
31 if (_Content == null) {
32 invalidate();
33 }
34 }
35
36 public void validateThis() throws LocalValidationException {
37 }
38
39 public void validate(Validator v) throws StructureValidationException {
40 }
41
42 public void marshal(Marshaller m) throws IOException {
43 XMLWriter w = m.writer();
44 w.start("author");
45
46 if (_Content != null) {
47 w.chars(_Content.toString());
48 }
49
50 w.end("author");
51 }
52
53 public void unmarshal(Unmarshaller u) throws UnmarshalException {
54 XMLScanner xs = u.scanner();
55 Validator v = u.validator();
56 xs.takeStart("author");
57
58 while (xs.atAttribute()) {
59 String an = xs.takeAttributeName();
60 throw new InvalidAttributeException(an);
61 }
62
63 {
64 String s;
65
66 if (xs.atChars(XMLScanner.WS_COLLAPSE)) {
67 s = xs.takeChars(XMLScanner.WS_COLLAPSE);
68 } else {
69 s = "";
70 }
71
72 try {
73 _Content = String.valueOf(s);
74 } catch (Exception x) {
75 throw new ConversionException("content", x);
76 }
77 }
78
79 xs.takeEnd("author");
80 }
81
82 public static Author unmarshal(InputStream in) throws UnmarshalException {
83 return unmarshal(XMLScanner.open(in));
84 }
85
86 public static Author unmarshal(XMLScanner xs) throws UnmarshalException {
87 return unmarshal(xs, newDispatcher());
88 }
89
90 public static Author unmarshal(XMLScanner xs, Dispatcher d)
91 throws UnmarshalException {
92 return ((Author) d.unmarshal(xs, (Author.class)));
93 }
94
95 public boolean equals(Object ob) {
96 if (this == ob) {
97 return true;
98 }
99
100 if (!(ob instanceof Author)) {
101 return false;
102 }
103
104 Author tob = ((Author) ob);
105
106 if (_Content != null) {
107 if (tob._Content == null) {
108 return false;
109 }
110
111 if (!_Content.equals(tob._Content)) {
112 return false;
113 }
114 } else {
115 if (tob._Content != null) {
116 return false;
117 }
118 }
119
120 return true;
121 }
122
123 public int hashCode() {
124 int h = 0;
125 h = ((127 * h) + ((_Content != null) ? _Content.hashCode() : 0));
126
127 return h;
128 }
129
130 public String toString() {
131 StringBuffer sb = new StringBuffer("<<author");
132
133 if (_Content != null) {
134 sb.append(" content=");
135 sb.append(_Content.toString());
136 }
137
138 sb.append(">>");
139
140 return sb.toString();
141 }
142
143 public static Dispatcher newDispatcher() {
144 Dispatcher d = new Dispatcher();
145 d.register("author", (Author.class));
146 d.register("call", (Call.class));
147 d.register("check", (Check.class));
148 d.register("classPath", (ClassPath.class));
149 d.register("commandLine", (CommandLine.class));
150 d.register("description", (Description.class));
151 d.register("error", (Error.class));
152 d.register("execution", (Execution.class));
153 d.register("harness-input", (HarnessInput.class));
154 d.register("harness-output", (HarnessOutput.class));
155 d.register("info", (Info.class));
156 d.register("java", (Java.class));
157 d.register("javaOptions", (JavaOptions.class));
158 d.register("messages", (Messages.class));
159 d.register("os", (Os.class));
160 d.register("param", (Param.class));
161 d.register("pathElement", (PathElement.class));
162 d.register("project", (Project.class));
163 d.register("property", (Property.class));
164 d.register("runtime", (Runtime.class));
165 d.register("stackTrace", (StackTrace.class));
166 d.register("testCase", (TestCase.class));
167 d.register("testRun", (TestRun.class));
168 d.register("testSuite", (TestSuite.class));
169 d.register("user", (User.class));
170 d.freezeElementNameMap();
171
172 return d;
173 }
174 }