Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 7 8 9 package javax.print.attribute; 10 11 import java.io.InvalidObjectException ; 12 import java.io.ObjectStreamException ; 13 import java.io.Serializable ; 14 15 92 public abstract class EnumSyntax implements Serializable , Cloneable { 93 94 private static final long serialVersionUID = -2739521845085831642L; 95 96 100 private int value; 101 102 107 protected EnumSyntax(int value) { 108 this.value = value; 109 } 110 111 115 public int getValue() { 116 return value; 117 } 118 119 124 public Object clone() { 125 return this; 126 } 127 128 132 public int hashCode() { 133 return value; 134 } 135 136 139 public String toString() { 140 141 String [] theTable = getStringTable(); 142 int theIndex = value - getOffset(); 143 return 144 theTable != null && theIndex >= 0 && theIndex < theTable.length ? 145 theTable[theIndex] : 146 Integer.toString (value); 147 } 148 149 170 protected Object readResolve() throws ObjectStreamException { 171 172 EnumSyntax [] theTable = getEnumValueTable(); 173 174 if (theTable == null) { 175 throw new InvalidObjectException ( 176 "Null enumeration value table for class " + 177 getClass()); 178 } 179 180 int theOffset = getOffset(); 181 int theIndex = value - theOffset; 182 183 if (0 > theIndex || theIndex >= theTable.length) { 184 throw new InvalidObjectException  185 ("Integer value = " + value + " not in valid range " + 186 theOffset + ".." + (theOffset + theTable.length - 1) + 187 "for class " + getClass()); 188 } 189 190 EnumSyntax result = theTable[theIndex]; 191 if (result == null) { 192 throw new InvalidObjectException  193 ("No enumeration value for integer value = " + 194 value + "for class " + getClass()); 195 } 196 return result; 197 } 198 199 201 220 protected String [] getStringTable() { 221 return null; 222 } 223 224 246 protected EnumSyntax [] getEnumValueTable() { 247 return null; 248 } 249 250 259 protected int getOffset() { 260 return 0; 261 } 262 263 } 264
| Popular Tags
|