01: // Copyright (c) 2002, 2003 Per M.A. Bothner.
02: // This is free software; for terms and warranty disclaimer see ./COPYING.
03:
04: package gnu.lists;
05:
06: import java.io.*;
07:
08: /** Used for text that is supposed to be written out verbatim.
09: * For example, the the output format is XML, can be used to write
10: * a literal '<' as a plain "<", instead of being escaped as "<".
11: */
12:
13: public class UnescapedData implements Externalizable {
14: String data;
15:
16: public UnescapedData() {
17: }
18:
19: public UnescapedData(String data) {
20: this .data = data;
21: }
22:
23: public final String getData() {
24: return data;
25: }
26:
27: public final String toString() {
28: return data;
29: }
30:
31: public final boolean equals(Object other) {
32: return other instanceof UnescapedData
33: && data.equals(other.toString());
34: }
35:
36: public final int hashCode() {
37: return data == null ? 0 : data.hashCode();
38: }
39:
40: /**
41: * @serialData Write 'data' (using writeObject).
42: */
43: public void writeExternal(ObjectOutput out) throws IOException {
44: out.writeObject(data);
45: }
46:
47: public void readExternal(ObjectInput in) throws IOException,
48: ClassNotFoundException {
49: data = (String) in.readObject();
50: }
51: }
|