/**
* During object input, convert this deserialized enumeration instance to
* the proper enumeration value defined in the enumeration attribute class.
*
* @return The enumeration singleton value stored at index
* <I>i</I>-<I>L</I> in the enumeration value table returned by
* {@link #getEnumValueTable() getEnumValueTable()},
* where <I>i</I> is this enumeration value's integer value and
* <I>L</I> is the value returned by {@link #getOffset()
* getOffset()}.
*
* @throws ObjectStreamException if the stream can't be deserialised
* @throws InvalidObjectException
* Thrown if the enumeration value table is null, this enumeration
* value's integer value does not correspond to an element in the
* enumeration value table, or the corresponding element in the
* enumeration value table is null. (Note: {@link
* java.io.InvalidObjectException InvalidObjectException} is a subclass
* of {@link java.io.ObjectStreamException ObjectStreamException}, which
* <CODE>readResolve()</CODE> is declared to throw.)
*/
protected Object readResolve() throws ObjectStreamException {
EnumSyntax[] theTable = getEnumValueTable();
if (theTable == null) {
throw new InvalidObjectException(
"Null enumeration value table for class " +
getClass());
}
int theOffset = getOffset();
int theIndex = value - theOffset;
if (0 > theIndex || theIndex >= theTable.length) {
throw new InvalidObjectException
("Integer value = " + value + " not in valid range " +
theOffset + ".." + (theOffset + theTable.length - 1) +
"for class " + getClass());
}
EnumSyntax result = theTable[theIndex];
if (result == null) {
throw new InvalidObjectException
("No enumeration value for integer value = " +
value + "for class " + getClass());
}
return result;
}
EnumSyntax.java 文件源码
java
阅读 23
收藏 0
点赞 0
评论 0
项目:jdk8u-jdk
作者:
评论列表
文章目录