1 23 package org.apache.slide.common; 24 25 import org.apache.slide.content.NodeProperty; 27 28 34 public class PropertyName { 35 36 39 protected String name = null; 40 41 44 protected String namespace = null; 45 46 47 53 public PropertyName(String name) { 54 this(name, NodeProperty.DEFAULT_NAMESPACE); 55 } 56 57 63 public PropertyName(String name, String namespace) { 64 this.name = name; 65 this.namespace = namespace; 66 } 67 68 73 public String getName() { 74 return name; 75 } 76 77 82 public String getNamespace() { 83 return namespace; 84 } 85 86 94 public boolean equals(Object other) { 95 96 boolean equal = false; 97 if (other instanceof PropertyName) { 98 PropertyName otherPropertyName = (PropertyName)other; 99 if (getName() == null) { 100 equal = (otherPropertyName.getName() == null); 101 } 102 else { 103 equal = getName().equals(otherPropertyName.getName()); 104 } 105 if (getNamespace() == null) { 106 equal &= (otherPropertyName.getNamespace() == null); 107 } 108 else { 109 equal &= getNamespace().equals(otherPropertyName.getNamespace()); 110 } 111 } 112 return equal; 113 } 114 115 121 public int hashCode() { 122 123 int hash = 0; 124 if (getName() != null) { 125 hash = getName().hashCode(); 126 } 127 if (getNamespace() != null) { 128 hash += 13 * getNamespace().hashCode(); 129 } 130 return hash; 131 } 132 133 138 public String toString() { 139 if (getNamespace() == null) { 140 return getName(); 141 } 142 else { 143 StringBuffer buffer = new StringBuffer (getNamespace()); 144 buffer.append(":"); 145 if (getName() != null) { 146 buffer.append(getName()); 147 } 148 return buffer.toString(); 149 } 150 } 151 } 152 153 | Popular Tags |