1 package org.apache.torque.om; 2 3 21 22 30 public class StringKey extends SimpleKey 31 { 32 35 private static final long serialVersionUID = 5109588772086713341L; 36 37 41 public StringKey() 42 { 43 } 44 45 50 public StringKey(String key) 51 { 52 this.key = key; 53 } 54 55 60 public StringKey(StringKey key) 61 { 62 if (key != null) 63 { 64 this.key = key.getValue(); 65 } 66 else 67 { 68 this.key = null; 69 } 70 } 71 72 77 public void setValue(String key) 78 { 79 this.key = key; 80 } 81 82 87 public void setValue(StringKey key) 88 { 89 if (key != null) 90 { 91 this.key = key.getValue(); 92 } 93 else 94 { 95 this.key = null; 96 } 97 } 98 99 104 public String getString() 105 { 106 return (String ) key; 107 } 108 109 117 public boolean equals(Object keyObj) 118 { 119 boolean isEqual = false; 120 121 if (key != null) 122 { 123 if (keyObj instanceof String ) 124 { 125 isEqual = keyObj.equals(key); 126 } 127 else if (keyObj instanceof StringKey) 130 { 131 Object obj = ((StringKey) keyObj).getValue(); 132 isEqual = key.equals(obj); 133 } 134 } 135 return isEqual; 136 } 137 138 143 public String toString() 144 { 145 if (key != null) 146 { 147 return (String ) key; 148 } 149 return ""; 150 } 151 } 152 | Popular Tags |