1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.portals.applications.springmvc;
18
19 import java.io.Serializable;
20 import java.lang.Comparable;
21
22 public class DOMTree implements Comparable, Serializable
23 {
24 private static final long serialVersionUID = 1L;
25
26 private String name;
27 private String path;
28 private org.w3c.dom.Document doc;
29 private String message;
30
31 private int hashCode = Integer.MIN_VALUE;
32
33
34 public DOMTree()
35 {
36 super();
37 }
38
39 public DOMTree( String name, String path )
40 {
41 super();
42 setName( name );
43 setPath( path );
44 }
45
46 public String getName()
47 {
48 return name;
49 }
50
51 public void setName( String name )
52 {
53 if (name == null) name = "";
54 this.name = name;
55 this.hashCode = Integer.MIN_VALUE;
56 }
57
58 public String getPath()
59 {
60 return path;
61 }
62
63 public void setPath( String path )
64 {
65 if (path == null) path = "";
66 this.path = path;
67 this.hashCode = Integer.MIN_VALUE;
68 }
69
70 public void setParsedDocument( org.w3c.dom.Document doc )
71 {
72 this.doc = doc;
73 }
74 public org.w3c.dom.Document getParsedDocument()
75 {
76 return doc;
77 }
78
79 public String getMessage()
80 {
81 return message;
82 }
83
84 public void setMessage( String message )
85 {
86 this.message = message;
87 }
88
89 public int compareTo(Object obj)
90 {
91 if (obj == null) throw new NullPointerException( "Cannot compare to null object" );
92 if (!(obj instanceof DOMTree)) throw new ClassCastException( "Can only compare to class" + this.getClass().getName() );
93 if (this.name == null || this.path == null) throw new NullPointerException( "This object is not initialized yet" );
94 if (this.equals(obj)) return 0;
95 DOMTree dt = (DOMTree)obj;
96 int res = getName().compareTo(dt.getName());
97 if (res != 0) return res;
98 return getPath().compareTo(dt.getPath());
99 }
100
101 public boolean equals(Object obj)
102 {
103 if ( obj == null ) return false;
104 if ( !(obj instanceof DOMTree) ) return false;
105 if ( this.name == null || this.path == null ) return false;
106 DOMTree dt = (DOMTree)obj;
107 return (this.name.equals(dt.getName()) &&
108 this.path.equals(dt.getPath()));
109 }
110
111 public int hashCode()
112 {
113 if (Integer.MIN_VALUE == this.hashCode)
114 {
115 String hashStr = this.getClass().getName() + ":" + this.toString();
116 this.hashCode = hashStr.hashCode();
117 }
118 return this.hashCode;
119 }
120
121 public String toString()
122 {
123 return this.name + ":" + this.path;
124 }
125
126 }