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