KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gnu > lists > UnescapedData


1 // Copyright (c) 2002, 2003 Per M.A. Bothner.
2
// This is free software; for terms and warranty disclaimer see ./COPYING.
3

4 package gnu.lists;
5 import java.io.*;
6
7 /** Used for text that is supposed to be written out verbatim.
8  * For example, the the output format is XML, can be used to write
9  * a literal '<' as a plain "<", instead of being escaped as "&lt;".
10  */

11
12 public class UnescapedData implements Externalizable
13 {
14   String JavaDoc data;
15
16   public UnescapedData ()
17   {
18   }
19
20   public UnescapedData (String JavaDoc data)
21   {
22     this.data = data;
23   }
24
25   public final String JavaDoc getData() { return data; }
26
27   public final String JavaDoc toString() { return data; }
28
29   public final boolean equals(Object JavaDoc other)
30   {
31     return other instanceof UnescapedData
32       && data.equals(other.toString());
33   }
34
35   public final int hashCode() { return data == null ? 0 : data.hashCode(); }
36
37   /**
38    * @serialData Write 'data' (using writeObject).
39    */

40   public void writeExternal(ObjectOutput out) throws IOException
41   {
42     out.writeObject(data);
43   }
44
45   public void readExternal(ObjectInput in)
46     throws IOException, ClassNotFoundException JavaDoc
47   {
48     data = (String JavaDoc) in.readObject();
49   }
50 }
51
Popular Tags