1 2 17 18 19 package org.apache.poi.poifs.filesystem; 20 21 27 28 public class DocumentDescriptor 29 { 30 private POIFSDocumentPath path; 31 private String name; 32 private int hashcode = 0; 33 34 40 41 public DocumentDescriptor(final POIFSDocumentPath path, final String name) 42 { 43 if (path == null) 44 { 45 throw new NullPointerException ("path must not be null"); 46 } 47 if (name == null) 48 { 49 throw new NullPointerException ("name must not be null"); 50 } 51 if (name.length() == 0) 52 { 53 throw new IllegalArgumentException ("name cannot be empty"); 54 } 55 this.path = path; 56 this.name = name; 57 } 58 59 67 68 public boolean equals(final Object o) 69 { 70 boolean rval = false; 71 72 if ((o != null) && (o.getClass() == this.getClass())) 73 { 74 if (this == o) 75 { 76 rval = true; 77 } 78 else 79 { 80 DocumentDescriptor descriptor = ( DocumentDescriptor ) o; 81 82 rval = this.path.equals(descriptor.path) 83 && this.name.equals(descriptor.name); 84 } 85 } 86 return rval; 87 } 88 89 94 95 public int hashCode() 96 { 97 if (hashcode == 0) 98 { 99 hashcode = path.hashCode() ^ name.hashCode(); 100 } 101 return hashcode; 102 } 103 104 public String toString() 105 { 106 StringBuffer buffer = new StringBuffer (40 * (path.length() + 1)); 107 108 for (int j = 0; j < path.length(); j++) 109 { 110 buffer.append(path.getComponent(j)).append("/"); 111 } 112 buffer.append(name); 113 return buffer.toString(); 114 } 115 } 117 | Popular Tags |