下面列出了怎么用java.io.ObjectStreamException的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* Ensures that serialization returns the unique instances.
*
* @return The object.
*
* @throws ObjectStreamException if there is a problem.
*/
private Object readResolve() throws ObjectStreamException {
if (this.equals(AxisLocation.TOP_OR_RIGHT)) {
return AxisLocation.TOP_OR_RIGHT;
}
else if (this.equals(AxisLocation.BOTTOM_OR_RIGHT)) {
return AxisLocation.BOTTOM_OR_RIGHT;
}
else if (this.equals(AxisLocation.TOP_OR_LEFT)) {
return AxisLocation.TOP_OR_LEFT;
}
else if (this.equals(AxisLocation.BOTTOM_OR_LEFT)) {
return AxisLocation.BOTTOM_OR_LEFT;
}
return null;
}
/**
* Ensures that serialization returns the unique instances.
*
* @return The object.
*
* @throws ObjectStreamException if there is a problem.
*/
private Object readResolve() throws ObjectStreamException {
if (this.equals(DateTickUnitType.YEAR)) {
return DateTickUnitType.YEAR;
}
else if (this.equals(DateTickUnitType.MONTH)) {
return DateTickUnitType.MONTH;
}
else if (this.equals(DateTickUnitType.DAY)) {
return DateTickUnitType.DAY;
}
else if (this.equals(DateTickUnitType.HOUR)) {
return DateTickUnitType.HOUR;
}
else if (this.equals(DateTickUnitType.MINUTE)) {
return DateTickUnitType.MINUTE;
}
else if (this.equals(DateTickUnitType.SECOND)) {
return DateTickUnitType.SECOND;
}
else if (this.equals(DateTickUnitType.MILLISECOND)) {
return DateTickUnitType.MILLISECOND;
}
return null;
}
/**
* Replaces this object with a SingletonTargetSource on serialization.
* Protected as otherwise it won't be invoked for subclasses.
* (The {@code writeReplace()} method must be visible to the class
* being serialized.)
* <p>With this implementation of this method, there is no need to mark
* non-serializable fields in this class or subclasses as transient.
*/
protected Object writeReplace() throws ObjectStreamException {
if (logger.isDebugEnabled()) {
logger.debug("Disconnecting TargetSource [" + this + "]");
}
try {
// Create disconnected SingletonTargetSource/EmptyTargetSource.
Object target = getTarget();
return (target != null ? new SingletonTargetSource(target) :
EmptyTargetSource.forClass(getTargetClass()));
}
catch (Exception ex) {
String msg = "Cannot get target for disconnecting TargetSource [" + this + "]";
logger.error(msg, ex);
throw new NotSerializableException(msg + ": " + ex);
}
}
/**
* Replaces the object to be serialized with an InetAddress object.
*
* @return the alternate object to be serialized.
*
* @throws ObjectStreamException if a new object replacing this
* object could not be created
*/
private Object writeReplace() throws ObjectStreamException {
// will replace the to be serialized 'this' object
InetAddress inet = new InetAddress();
inet.holder().hostName = holder().getHostName();
inet.holder().address = holder().getAddress();
/**
* Prior to 1.4 an InetAddress was created with a family
* based on the platform AF_INET value (usually 2).
* For compatibility reasons we must therefore write the
* the InetAddress with this family.
*/
inet.holder().family = 2;
return inet;
}
/**
* Replaces the de-serialized object with an URL object.
*
* @return a newly created object from the deserialzed state.
*
* @throws ObjectStreamException if a new object replacing this
* object could not be created
*/
private Object readResolve() throws ObjectStreamException {
URLStreamHandler handler = null;
// already been checked in readObject
handler = getURLStreamHandler(tempState.getProtocol());
URL replacementURL = null;
if (isBuiltinStreamHandler(handler.getClass().getName())) {
replacementURL = fabricateNewURL();
} else {
replacementURL = setDeserializedFields(handler);
}
return replacementURL;
}
/**
* Replaces the de-serialized object with an URL object.
*
* @return a newly created object from the deserialzed state.
*
* @throws ObjectStreamException if a new object replacing this
* object could not be created
*/
private Object readResolve() throws ObjectStreamException {
URLStreamHandler handler = null;
// already been checked in readObject
handler = getURLStreamHandler(tempState.getProtocol());
URL replacementURL = null;
if (isBuiltinStreamHandler(handler.getClass().getName())) {
replacementURL = fabricateNewURL();
} else {
replacementURL = setDeserializedFields(handler);
}
return replacementURL;
}
/**
* Replaces the object to be serialized with an InetAddress object.
*
* @return the alternate object to be serialized.
*
* @throws ObjectStreamException if a new object replacing this
* object could not be created
*/
private Object writeReplace() throws ObjectStreamException {
// will replace the to be serialized 'this' object
InetAddress inet = new InetAddress();
inet.holder().hostName = holder().getHostName();
inet.holder().address = holder().getAddress();
/**
* Prior to 1.4 an InetAddress was created with a family
* based on the platform AF_INET value (usually 2).
* For compatibility reasons we must therefore write the
* the InetAddress with this family.
*/
inet.holder().family = 2;
return inet;
}
/**
* Replaces the de-serialized object with an URL object.
*
* @return a newly created object from the deserialzed state.
*
* @throws ObjectStreamException if a new object replacing this
* object could not be created
*/
private Object readResolve() throws ObjectStreamException {
URLStreamHandler handler = null;
// already been checked in readObject
handler = getURLStreamHandler(tempState.getProtocol());
URL replacementURL = null;
if (isBuiltinStreamHandler(handler.getClass().getName())) {
replacementURL = fabricateNewURL();
} else {
replacementURL = setDeserializedFields(handler);
}
return replacementURL;
}
/**
* Replaces the object to be serialized with an InetAddress object.
*
* @return the alternate object to be serialized.
*
* @throws ObjectStreamException if a new object replacing this
* object could not be created
*/
private Object writeReplace() throws ObjectStreamException {
// will replace the to be serialized 'this' object
InetAddress inet = new InetAddress();
inet.holder().hostName = holder().getHostName();
inet.holder().address = holder().getAddress();
/**
* Prior to 1.4 an InetAddress was created with a family
* based on the platform AF_INET value (usually 2).
* For compatibility reasons we must therefore write the
* the InetAddress with this family.
*/
inet.holder().family = 2;
return inet;
}
@Override
public Object readResolve() throws ObjectStreamException
{
AsyncFSStorageAgent asyncFSStorageAgent = new AsyncFSStorageAgent(this.path, null);
asyncFSStorageAgent.setSyncCheckpoint(syncCheckpoint);
return asyncFSStorageAgent;
}
/**
* Ensures that serialization returns the unique instances.
*
* @return The object.
*
* @throws ObjectStreamException if there is a problem.
*/
private Object readResolve() throws ObjectStreamException {
Object result = null;
if (this.equals(AreaRendererEndType.LEVEL)) {
result = AreaRendererEndType.LEVEL;
}
else if (this.equals(AreaRendererEndType.TAPER)) {
result = AreaRendererEndType.TAPER;
}
else if (this.equals(AreaRendererEndType.TRUNCATE)) {
result = AreaRendererEndType.TRUNCATE;
}
return result;
}
/**
* Ensures that serialization returns the unique instances.
*
* @return The object.
*
* @throws ObjectStreamException if there is a problem.
*/
private Object readResolve() throws ObjectStreamException {
if (this.equals(LengthConstraintType.NONE)) {
return LengthConstraintType.NONE;
}
else if (this.equals(LengthConstraintType.RANGE)) {
return LengthConstraintType.RANGE;
}
else if (this.equals(LengthConstraintType.FIXED)) {
return LengthConstraintType.FIXED;
}
return null;
}
/**
* Ensures that serialization returns the unique instances.
*
* @return The object.
*
* @throws ObjectStreamException if there is a problem.
*/
private Object readResolve() throws ObjectStreamException {
if (this.equals(LegendRenderingOrder.STANDARD)) {
return LegendRenderingOrder.STANDARD;
}
else if (this.equals(LegendRenderingOrder.REVERSE)) {
return LegendRenderingOrder.REVERSE;
}
return null;
}
/**
* Ensures that serialization returns the unique instances.
*
* @return The object.
*
* @throws ObjectStreamException if there is a problem.
*/
private Object readResolve() throws ObjectStreamException {
Object result = null;
if (this.equals(PlotOrientation.HORIZONTAL)) {
result = PlotOrientation.HORIZONTAL;
}
else if (this.equals(PlotOrientation.VERTICAL)) {
result = PlotOrientation.VERTICAL;
}
return result;
}
/**
* Ensures that serialization returns the unique instances.
*
* @return The object.
*
* @throws ObjectStreamException if there is a problem.
*/
private Object readResolve() throws ObjectStreamException {
if (this.equals(SeriesRenderingOrder.FORWARD)) {
return SeriesRenderingOrder.FORWARD;
}
else if (this.equals(SeriesRenderingOrder.REVERSE)) {
return SeriesRenderingOrder.REVERSE;
}
return null;
}
/**
* Ensures that serialization returns the unique instances.
*
* @return The object.
*
* @throws ObjectStreamException if there is a problem.
*/
private Object readResolve() throws ObjectStreamException {
Object result = null;
if (this.equals(PieLabelLinkStyle.STANDARD)) {
result = PieLabelLinkStyle.STANDARD;
}
else if (this.equals(PieLabelLinkStyle.QUAD_CURVE)) {
result = PieLabelLinkStyle.QUAD_CURVE;
}
else if (this.equals(PieLabelLinkStyle.CUBIC_CURVE)) {
result = PieLabelLinkStyle.CUBIC_CURVE;
}
return result;
}
/**
* Ensures that serialization returns the unique instances.
*
* @return The object.
*
* @throws ObjectStreamException if there is a problem.
*/
private Object readResolve() throws ObjectStreamException {
if (this.equals(PolarAxisLocation.NORTH_RIGHT)) {
return PolarAxisLocation.NORTH_RIGHT;
}
else if (this.equals(PolarAxisLocation.NORTH_LEFT)) {
return PolarAxisLocation.NORTH_LEFT;
}
else if (this.equals(PolarAxisLocation.SOUTH_RIGHT)) {
return PolarAxisLocation.SOUTH_RIGHT;
}
else if (this.equals(PolarAxisLocation.SOUTH_LEFT)) {
return PolarAxisLocation.SOUTH_LEFT;
}
else if (this.equals(PolarAxisLocation.EAST_ABOVE)) {
return PolarAxisLocation.EAST_ABOVE;
}
else if (this.equals(PolarAxisLocation.EAST_BELOW)) {
return PolarAxisLocation.EAST_BELOW;
}
else if (this.equals(PolarAxisLocation.WEST_ABOVE)) {
return PolarAxisLocation.WEST_ABOVE;
}
else if (this.equals(PolarAxisLocation.WEST_BELOW)) {
return PolarAxisLocation.WEST_BELOW;
}
return null;
}
/**
* Ensures that serialization returns the unique instances.
*
* @return The object.
*
* @throws ObjectStreamException if there is a problem.
*/
private Object readResolve() throws ObjectStreamException {
if (this.equals(DatasetRenderingOrder.FORWARD)) {
return DatasetRenderingOrder.FORWARD;
}
else if (this.equals(DatasetRenderingOrder.REVERSE)) {
return DatasetRenderingOrder.REVERSE;
}
return null;
}
/**
* Ensures that serialization returns the unique instances.
*
* @return The object.
*
* @throws ObjectStreamException if there is a problem.
*/
private Object readResolve() throws ObjectStreamException {
if (this.equals(DialShape.CIRCLE)) {
return DialShape.CIRCLE;
}
else if (this.equals(DialShape.CHORD)) {
return DialShape.CHORD;
}
else if (this.equals(DialShape.PIE)) {
return DialShape.PIE;
}
return null;
}
/**
* Ensures that serialization returns the unique instances.
*
* @return The object.
*
* @throws ObjectStreamException if there is a problem.
*/
private Object readResolve() throws ObjectStreamException {
if (this.equals(ChartChangeEventType.GENERAL)) {
return ChartChangeEventType.GENERAL;
}
else if (this.equals(ChartChangeEventType.NEW_DATASET)) {
return ChartChangeEventType.NEW_DATASET;
}
else if (this.equals(ChartChangeEventType.DATASET_UPDATED)) {
return ChartChangeEventType.DATASET_UPDATED;
}
return null;
}
/**
* Ensures that serialization returns the unique instances.
*
* @return The object.
*
* @throws ObjectStreamException if there is a problem.
*/
private Object readResolve() throws ObjectStreamException {
if (this.equals(AxisLabelLocation.HIGH_END)) {
return AxisLabelLocation.HIGH_END;
}
if (this.equals(AxisLabelLocation.MIDDLE)) {
return AxisLabelLocation.MIDDLE;
}
if (this.equals(AxisLabelLocation.LOW_END)) {
return AxisLabelLocation.LOW_END;
}
return null;
}
/**
* Ensures that serialization returns the unique instances.
*
* @return The object.
*
* @throws ObjectStreamException if there is a problem.
*/
private Object readResolve() throws ObjectStreamException {
if (this.equals(CategoryLabelWidthType.CATEGORY)) {
return CategoryLabelWidthType.CATEGORY;
}
else if (this.equals(CategoryLabelWidthType.RANGE)) {
return CategoryLabelWidthType.RANGE;
}
return null;
}
/**
* Ensures that serialization returns the unique instances.
*
* @return The object.
*
* @throws ObjectStreamException if there is a problem.
*/
private Object readResolve() throws ObjectStreamException {
if (this.equals(CategoryAnchor.START)) {
return CategoryAnchor.START;
}
else if (this.equals(CategoryAnchor.MIDDLE)) {
return CategoryAnchor.MIDDLE;
}
else if (this.equals(CategoryAnchor.END)) {
return CategoryAnchor.END;
}
return null;
}
/**
* Ensures that serialization returns the unique instances.
*
* @return The object.
*
* @throws ObjectStreamException if there is a problem.
*/
private Object readResolve() throws ObjectStreamException {
if (this.equals(DateTickMarkPosition.START)) {
return DateTickMarkPosition.START;
}
else if (this.equals(DateTickMarkPosition.MIDDLE)) {
return DateTickMarkPosition.MIDDLE;
}
else if (this.equals(DateTickMarkPosition.END)) {
return DateTickMarkPosition.END;
}
return null;
}
/**
* Ensures that serialization returns the unique instances.
*
* @return The object.
*
* @throws ObjectStreamException if there is a problem.
*/
private Object readResolve() throws ObjectStreamException {
Object result = null;
if (this.equals(TickType.MAJOR)) {
result = TickType.MAJOR;
}
else if (this.equals(TickType.MINOR)) {
result = TickType.MINOR;
}
return result;
}
/**
* 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;
}
/**
* Ensures that serialization returns the unique instances.
*
* @return The object.
*
* @throws ObjectStreamException if there is a problem.
*/
private Object readResolve() throws ObjectStreamException {
if (this.equals(TimePeriodAnchor.START)) {
return TimePeriodAnchor.START;
}
else if (this.equals(TimePeriodAnchor.MIDDLE)) {
return TimePeriodAnchor.MIDDLE;
}
else if (this.equals(TimePeriodAnchor.END)) {
return TimePeriodAnchor.END;
}
return null;
}
protected Object writeReplace() throws ObjectStreamException {
if (this.serializationId != null) {
return new SerializedBeanFactoryReference(this.serializationId);
}
else {
throw new NotSerializableException("DefaultListableBeanFactory has no serialization id");
}
}
/**
* Ensures that serialization returns the unique instances.
*
* @return The object.
*
* @throws ObjectStreamException if there is a problem.
*/
private Object readResolve() throws ObjectStreamException {
if (this.equals(HistogramType.FREQUENCY)) {
return HistogramType.FREQUENCY;
}
else if (this.equals(HistogramType.RELATIVE_FREQUENCY)) {
return HistogramType.RELATIVE_FREQUENCY;
}
else if (this.equals(HistogramType.SCALE_AREA_TO_1)) {
return HistogramType.SCALE_AREA_TO_1;
}
return null;
}
/**
* Ensures that serialization returns the unique instances.
*
* @return The object.
*
* @throws ObjectStreamException if there is a problem.
*/
private Object readResolve() throws ObjectStreamException {
if (this.equals(DomainOrder.ASCENDING)) {
return DomainOrder.ASCENDING;
}
else if (this.equals(DomainOrder.DESCENDING)) {
return DomainOrder.DESCENDING;
}
else if (this.equals(DomainOrder.NONE)) {
return DomainOrder.NONE;
}
return null;
}