java.io.ObjectStreamException Java Examples

The following examples show how to use java.io.ObjectStreamException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: openstock   Author: lcmeyer37   File: AxisLocation.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #2
Source Project: openstock   Author: lcmeyer37   File: DateTickUnitType.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #3
Source Project: spring-analysis-note   Author: Vip-Augus   File: AbstractPrototypeBasedTargetSource.java    License: MIT License 6 votes vote down vote up
/**
 * 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);
	}
}
 
Example #4
Source Project: TencentKona-8   Author: Tencent   File: Inet4Address.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #5
Source Project: TencentKona-8   Author: Tencent   File: URL.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
  * 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;
 }
 
Example #6
Source Project: jdk1.8-source-analysis   Author: raysonfang   File: URL.java    License: Apache License 2.0 6 votes vote down vote up
/**
  * 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;
 }
 
Example #7
Source Project: jdk1.8-source-analysis   Author: raysonfang   File: Inet4Address.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #8
Source Project: dragonwell8_jdk   Author: alibaba   File: URL.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
  * 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;
 }
 
Example #9
Source Project: dragonwell8_jdk   Author: alibaba   File: Inet4Address.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #10
Source Project: Bats   Author: lealone   File: AsyncFSStorageAgent.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Object readResolve() throws ObjectStreamException
{
  AsyncFSStorageAgent asyncFSStorageAgent = new AsyncFSStorageAgent(this.path, null);
  asyncFSStorageAgent.setSyncCheckpoint(syncCheckpoint);
  return asyncFSStorageAgent;
}
 
Example #11
Source Project: openstock   Author: lcmeyer37   File: AreaRendererEndType.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #12
Source Project: openstock   Author: lcmeyer37   File: LengthConstraintType.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #13
Source Project: openstock   Author: lcmeyer37   File: LegendRenderingOrder.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #14
Source Project: openstock   Author: lcmeyer37   File: PlotOrientation.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #15
Source Project: openstock   Author: lcmeyer37   File: SeriesRenderingOrder.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #16
Source Project: openstock   Author: lcmeyer37   File: PieLabelLinkStyle.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #17
Source Project: openstock   Author: lcmeyer37   File: PolarAxisLocation.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #18
Source Project: openstock   Author: lcmeyer37   File: DatasetRenderingOrder.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #19
Source Project: openstock   Author: lcmeyer37   File: DialShape.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #20
Source Project: openstock   Author: lcmeyer37   File: ChartChangeEventType.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #21
Source Project: openstock   Author: lcmeyer37   File: AxisLabelLocation.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #22
Source Project: openstock   Author: lcmeyer37   File: CategoryLabelWidthType.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #23
Source Project: openstock   Author: lcmeyer37   File: CategoryAnchor.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #24
Source Project: openstock   Author: lcmeyer37   File: DateTickMarkPosition.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #25
Source Project: openstock   Author: lcmeyer37   File: TickType.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #26
Source Project: TencentKona-8   Author: Tencent   File: EnumSyntax.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #27
Source Project: openstock   Author: lcmeyer37   File: TimePeriodAnchor.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #28
Source Project: java-technology-stack   Author: codeEngraver   File: DefaultListableBeanFactory.java    License: MIT License 5 votes vote down vote up
protected Object writeReplace() throws ObjectStreamException {
	if (this.serializationId != null) {
		return new SerializedBeanFactoryReference(this.serializationId);
	}
	else {
		throw new NotSerializableException("DefaultListableBeanFactory has no serialization id");
	}
}
 
Example #29
Source Project: openstock   Author: lcmeyer37   File: HistogramType.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #30
Source Project: openstock   Author: lcmeyer37   File: DomainOrder.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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;
}