Java 类java.io.ObjectInput 实例源码

项目:myfaces-trinidad    文件:StampState.java   
@SuppressWarnings("unchecked")
public void readExternal(ObjectInput in)
  throws IOException, ClassNotFoundException
{
  int size = in.readInt();

  if (size > 0)
  _rows = (Map<DualKey, Object>) in.readObject();

  if (_LOG.isFinest())
  {
    for(Map.Entry<DualKey, Object> entry : _rows.entrySet())
    {
      _LOG.finest("Restoring " + entry.getKey() + ", " + entry.getValue());
    }
  }
}
项目:parabuild-ci    文件:DialValueIndicatorTests.java   
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {
    // test a default instance
    DialValueIndicator i1 = new DialValueIndicator(0, "Label");
    DialValueIndicator i2 = null;

    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(i1);
        out.close();

        ObjectInput in = new ObjectInputStream(
                new ByteArrayInputStream(buffer.toByteArray()));
        i2 = (DialValueIndicator) in.readObject();
        in.close();
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    assertEquals(i1, i2);

    // test a custom instance
}
项目:parabuild-ci    文件:VectorRendererTests.java   
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {
    VectorRenderer r1 = new VectorRenderer();
    VectorRenderer r2 = null;
    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(r1);
        out.close();

        ObjectInput in = new ObjectInputStream(
                new ByteArrayInputStream(buffer.toByteArray()));
        r2 = (VectorRenderer) in.readObject();
        in.close();
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    assertEquals(r1, r2);
}
项目:parabuild-ci    文件:StandardXYLabelGeneratorTests.java   
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {

    StandardXYLabelGenerator g1 = new StandardXYLabelGenerator();
    StandardXYLabelGenerator g2 = null;

    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(g1);
        out.close();

        ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
        g2 = (StandardXYLabelGenerator) in.readObject();
        in.close();
    }
    catch (Exception e) {
        System.out.println(e.toString());
    }
    assertEquals(g1, g2);

}
项目:xcc    文件:TCharLinkedList.java   
/** {@inheritDoc} */
public void readExternal(ObjectInput in)
        throws IOException, ClassNotFoundException {

    // VERSION
    in.readByte();

    // NO_ENTRY_VALUE
    no_entry_value = in.readChar();

    // ENTRIES
    int len = in.readInt();
    for (int i = 0; i < len; i++) {
        add(in.readChar());
    }
}
项目:incubator-netbeans    文件:NbObjectInputStream.java   
/** Reads an object from the given object input.
* The object had to be saved by the {@link NbObjectOutputStream#writeSafely} method.
*
* @param oi object input
* @return the read object
* @exception IOException if IO error occured
* @exception SafeException if the operation failed but the stream is ok
*    for further reading
*/
public static Object readSafely(ObjectInput oi) throws IOException {
    int size = oi.readInt();
    byte[] byteArray = new byte[size];
    oi.readFully(byteArray, 0, size);

    try {
        ByteArrayInputStream bis = new ByteArrayInputStream(byteArray);
        NbObjectInputStream ois = new NbObjectInputStream(bis);
        Object obj = ois.readObject();
        bis.close();

        return obj;
    } catch (Exception exc) {
        // encapsulate all exceptions into safe exception
        throw new SafeException(exc);
    } catch (LinkageError le) {
        throw new SafeException(new InvocationTargetException(le));
    }
}
项目:unitimes    文件:XReservation.java   
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    super.readExternal(in);
    iExpirationDate = (in.readBoolean() ? new Date(in.readLong()) : null);

    int nrConfigs = in.readInt();
    iConfigs.clear();
    for (int i = 0; i < nrConfigs; i++)
        iConfigs.add(in.readLong());

    int nrSubparts = in.readInt();
    iSections.clear(); 
    for (int i = 0; i < nrSubparts; i++) {
        Set<Long> sections = new HashSet<Long>();
        iSections.put(in.readLong(), sections);
        int nrSection = in.readInt();
        for (int j = 0; j < nrSection; j++) {
            sections.add(in.readLong());
        }
    }
    iLimitCap = in.readInt();
    iRestrictivity = in.readDouble();
    iPriority = in.readInt();
    iFlags = in.readInt();
}
项目:parabuild-ci    文件:IntervalCategoryLabelGeneratorTests.java   
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {

    IntervalCategoryLabelGenerator g1
        = new IntervalCategoryLabelGenerator("{3} - {4}", DateFormat.getInstance());
    IntervalCategoryLabelGenerator g2 = null;

    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(g1);
        out.close();

        ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
        g2 = (IntervalCategoryLabelGenerator) in.readObject();
        in.close();
    }
    catch (Exception e) {
        System.out.println(e.toString());
    }
    assertEquals(g1, g2);

}
项目:HCFCore    文件:TCharArrayList.java   
public void readExternal( ObjectInput in )
    throws IOException, ClassNotFoundException {

    // VERSION
    in.readByte();

    // POSITION
    _pos = in.readInt();

    // NO_ENTRY_VALUE
    no_entry_value = in.readChar();

    // ENTRIES
    int len = in.readInt();
    _data = new char[ len ];
    for( int i = 0; i < len; i++ ) {
        _data[ i ] = in.readChar();
    }
}
项目:directory-ldap-api    文件:Unicode.java   
/**
 *
 * Reads in a string that has been encoded using a modified UTF-8  format. The general contract of readUTF  is
 * that it reads a representation of a Unicode character string encoded in modified UTF-8 format; this string of
 * characters is then returned as a String.
 *
 * First, four bytes are read (readInt) and used to construct an unsigned 16-bit integer in exactly the manner
 * of the readUnsignedShort  method . This integer value is called the UTF length and specifies the number of
 * additional bytes to be read. These bytes are then converted to characters by considering them in groups. The
 * length of each group is computed from the value of the first byte of the group. The byte following a group, if
 * any, is the first byte of the next group.
 *
 *See also {@link java.io.DataInput#readUTF()}.
 *
 * @param objectInput The objectInput to read from
 * @return The read string
 * @throws java.io.IOException If the value can't be read
 */
public static String readUTF( ObjectInput objectInput ) throws IOException
{
    // Read length of the string
    int strLength = objectInput.readInt();

    // Start reading the string
    StringBuilder strBuf = new StringBuilder( objectInput.readUTF() );

    if ( ( strLength == 0 ) && ( "null".equals( strBuf.toString() ) ) ) 
    {
        // The special case of a 'null' string
        return null;
    }
    else
    {
        while ( strLength > strBuf.length() )
        {
            strBuf.append( objectInput.readUTF() );
        }
        return strBuf.toString();
    }
}
项目:parabuild-ci    文件:SimpleDialFrameTests.java   
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {
    SimpleDialFrame f1 = new SimpleDialFrame();
    SimpleDialFrame f2 = null;

    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(f1);
        out.close();

        ObjectInput in = new ObjectInputStream(
                new ByteArrayInputStream(buffer.toByteArray()));
        f2 = (SimpleDialFrame) in.readObject();
        in.close();
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    assertEquals(f1, f2);
}
项目:parabuild-ci    文件:SignalRendererTests.java   
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {

    SignalRenderer r1 = new SignalRenderer();
    SignalRenderer r2 = null;

    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(r1);
        out.close();

        ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
        r2 = (SignalRenderer) in.readObject();
        in.close();
    }
    catch (Exception e) {
        System.out.println(e.toString());
    }
    assertEquals(r1, r2);

}
项目:unitimes    文件:XSubpart.java   
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    iUniqueId = in.readLong();
    iInstructionalType = (String)in.readObject();
    iName = (String)in.readObject();

    int nrSections = in.readInt();
    iSections.clear();
    for (int i = 0; i < nrSections; i++)
        iSections.add(new XSection(in));

    iConfigId = in.readLong();
    iParentId = in.readLong();
    if (iParentId < 0) iParentId = null;

    iCredit = (in.readBoolean() ? new XCredit(in) : null);

    iAllowOverlap = in.readBoolean();

    int nrCredits = in.readInt();
    iCreditByCourse.clear();
    for (int i = 0; i < nrCredits; i++)
        iCreditByCourse.put(in.readLong(), new XCredit(in));
}
项目:xcc    文件:TByteLinkedList.java   
/** {@inheritDoc} */
public void readExternal(ObjectInput in)
        throws IOException, ClassNotFoundException {

    // VERSION
    in.readByte();

    // NO_ENTRY_VALUE
    no_entry_value = in.readByte();

    // ENTRIES
    int len = in.readInt();
    for (int i = 0; i < len; i++) {
        add(in.readByte());
    }
}
项目:hashsdn-controller    文件:MetadataShardDataTreeSnapshot.java   
@Override
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
    final int metaSize = in.readInt();
    Preconditions.checkArgument(metaSize >= 0, "Invalid negative metadata map length %s", metaSize);

    // Default pre-allocate is 4, which should be fine
    final Builder<Class<? extends ShardDataTreeSnapshotMetadata<?>>, ShardDataTreeSnapshotMetadata<?>>
            metaBuilder = ImmutableMap.builder();
    for (int i = 0; i < metaSize; ++i) {
        final ShardDataTreeSnapshotMetadata<?> m = (ShardDataTreeSnapshotMetadata<?>) in.readObject();
        if (m != null) {
            metaBuilder.put(m.getType(), m);
        } else {
            LOG.warn("Skipping null metadata");
        }
    }

    metadata = metaBuilder.build();
    rootNode = Verify.verifyNotNull(SerializationUtils.deserializeNormalizedNode(in));
}
项目:happylifeplat-transaction    文件:JavaSerializer.java   
@Override
public <T> T deSerialize(byte[] param, Class<T> clazz) throws TransactionException {
    ByteArrayInputStream arrayInputStream = new ByteArrayInputStream(param);
    try {
        ObjectInput input = new ObjectInputStream(arrayInputStream);
        return (T) input.readObject();
    } catch (IOException | ClassNotFoundException e) {
        throw new TransactionException("JAVA deSerialize error " + e.getMessage());
    }
}
项目:xcc    文件:TDoubleDoubleHash.java   
/** {@inheritDoc} */
public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException {
    // VERSION
    in.readByte();

    // SUPER
    super.readExternal( in );

    // NO_ENTRY_KEY
    no_entry_key = in.readDouble();

    // NO_ENTRY_VALUE
    no_entry_value = in.readDouble();
}
项目:hashsdn-controller    文件:ConnectClientSuccessProxyV1.java   
@Override
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
    super.readExternal(in);

    backend = JavaSerializer.currentSystem().value().provider().resolveActorRef((String) in.readObject());
    maxMessages = in.readInt();

    final int alternatesSize = in.readInt();
    alternates = new ArrayList<>(alternatesSize);
    for (int i = 0; i < alternatesSize; ++i) {
        alternates.add(ActorSelection.apply(ActorRef.noSender(), (String)in.readObject()));
    }
}
项目:jdk8u-jdk    文件:UnicastServerRef.java   
/**
 * Unmarshal parameters for the given method of the given instance over
 * the given marshalinputstream. Do not perform any additional checks.
 */
private Object[] unmarshalParametersUnchecked(Method method, ObjectInput in)
throws IOException, ClassNotFoundException {
    Class<?>[] types = method.getParameterTypes();
    Object[] params = new Object[types.length];
    for (int i = 0; i < types.length; i++) {
        params[i] = unmarshalValue(types[i], in);
    }
    return params;
}
项目:knime-activelearning    文件:MultiClassKNFST.java   
@Override
public void readExternal(final ObjectInput arg0)
        throws IOException, ClassNotFoundException {
    // call super method
    super.readExternal(arg0);

    // read labels
    m_labels = new String[arg0.readInt()];
    for (int l = 0; l < m_labels.length; l++) {
        m_labels[l] = arg0.readUTF();
    }

}
项目:incubator-netbeans    文件:HtmlBrowserComponent.java   
@Override
public void readExternal (ObjectInput in)
throws IOException, ClassNotFoundException {
    super.readExternal (in);
    setStatusLineVisible (in.readBoolean ());
    setToolbarVisible (in.readBoolean ());
    browserComponent.setURL ((URL) in.readObject ());
}
项目:xcc    文件:TDoubleHashSet.java   
/** {@inheritDoc} */
public void readExternal( ObjectInput in )
    throws IOException, ClassNotFoundException {

    // VERSION
    int version = in.readByte();

    // SUPER
    super.readExternal( in );

    // NUMBER OF ENTRIES
    int size = in.readInt();

    if ( version >= 1 ) {
        // LOAD FACTOR
        _loadFactor = in.readFloat();

        // NO ENTRY VALUE
        no_entry_value = in.readDouble();
        //noinspection RedundantCast
        if ( no_entry_value != ( double ) 0 ) {
            Arrays.fill( _set, no_entry_value );
        }
    }

    // ENTRIES
    setUp( size );
    while ( size-- > 0 ) {
        double val = in.readDouble();
        add( val );
    }
}
项目:keyboard-light-composer    文件:KlcColor.java   
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    double red = (double) in.readObject();
    double green = (double) in.readObject();
    double blue = (double) in.readObject();
    double opacity = (double) in.readObject();
    color = new Color(red, green, blue, opacity);
}
项目:HCFCore    文件:TLongHashSet.java   
/** {@inheritDoc} */
public void readExternal( ObjectInput in )
    throws IOException, ClassNotFoundException {

    // VERSION
    int version = in.readByte();

    // SUPER
    super.readExternal( in );

    // NUMBER OF ENTRIES
    int size = in.readInt();

    if ( version >= 1 ) {
        // LOAD FACTOR
        _loadFactor = in.readFloat();

        // NO ENTRY VALUE
        no_entry_value = in.readLong();
        //noinspection RedundantCast
        if ( no_entry_value != ( long ) 0 ) {
            Arrays.fill( _set, no_entry_value );
        }
    }

    // ENTRIES
    setUp( size );
    while ( size-- > 0 ) {
        long val = in.readLong();
        add( val );
    }
}
项目:HCFCore    文件:TDoubleShortHash.java   
/** {@inheritDoc} */
public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException {
    // VERSION
    in.readByte();

    // SUPER
    super.readExternal( in );

    // NO_ENTRY_KEY
    no_entry_key = in.readDouble();

    // NO_ENTRY_VALUE
    no_entry_value = in.readShort();
}
项目:unitimes    文件:XRequest.java   
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    iRequestId = in.readLong();
    iPriority = in.readInt();
    iAlternative = in.readBoolean();
    iStudentId = in.readLong();
}
项目:xcc    文件:TShortDoubleHash.java   
/** {@inheritDoc} */
public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException {
    // VERSION
    in.readByte();

    // SUPER
    super.readExternal( in );

    // NO_ENTRY_KEY
    no_entry_key = in.readShort();

    // NO_ENTRY_VALUE
    no_entry_value = in.readDouble();
}
项目:xcc    文件:TDoubleShortHash.java   
/** {@inheritDoc} */
public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException {
    // VERSION
    in.readByte();

    // SUPER
    super.readExternal( in );

    // NO_ENTRY_KEY
    no_entry_key = in.readDouble();

    // NO_ENTRY_VALUE
    no_entry_value = in.readShort();
}
项目:incubator-netbeans    文件:CloneableTopComponent.java   
public void readExternal(ObjectInput oi) throws IOException, ClassNotFoundException {
    super.readExternal(oi);

    if (serialVersion != 0) {
        // since serialVersion > 0
        // the reference object is also stored
        Ref ref = (Ref) oi.readObject();

        if (ref != null) {
            setReference(ref);
        }
    }
}
项目:HCFCore    文件:TDoubleListDecorator.java   
public void readExternal( ObjectInput in )
    throws IOException, ClassNotFoundException {

    // VERSION
    in.readByte();

    // LIST
    list = ( TDoubleList ) in.readObject();
}
项目:incubator-netbeans    文件:ImageViewer.java   
/** Deserialize this top component.
 * Reads its data object and initializes itself in addition
 * to common superclass behaviour.
 * @param in the stream to deserialize from
 */
public void readExternal (ObjectInput in)
throws IOException, ClassNotFoundException {
    super.readExternal(in);
    storedObject = (ImageDataObject)in.readObject();
    // to reset the listener for FileObject changes
    ((ImageOpenSupport)storedObject.getCookie(ImageOpenSupport.class)).prepareViewer();
    initialize(storedObject);
}
项目:lams    文件:MethodExpressionImpl.java   
public void readExternal(ObjectInput in) throws IOException,
        ClassNotFoundException {
    this.expr = in.readUTF();
    String type = in.readUTF();
    if (!"".equals(type)) {
        this.expectedType = ReflectionUtil.forName(type);
    }
    this.paramTypes = ReflectionUtil.toTypeArray(((String[]) in
            .readObject()));
    this.fnMapper = (FunctionMapper) in.readObject();
    this.varMapper = (VariableMapper) in.readObject();
}
项目:support-rulesengine    文件:ZeroMQEventSubscriber.java   
private static Event toEvent(byte[] eventBytes) throws IOException, ClassNotFoundException {
  try {
    Gson gson = new Gson();
    String json = new String(eventBytes);
    return gson.fromJson(json, Event.class);
  } catch (Exception e) {
    // Try to degrade to deprecated serialization functionality gracefully
    ByteArrayInputStream bis = new ByteArrayInputStream(eventBytes);
    ObjectInput in = new ObjectInputStream(bis);
    Event event = (Event) in.readObject();
    return event;
  }
}
项目:hashsdn-controller    文件:LocalHistoryIdentifier.java   
@Override
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
    clientId = ClientIdentifier.readFrom(in);

    final byte header = WritableObjects.readLongHeader(in);
    historyId = WritableObjects.readFirstLong(in, header);
    cookie = WritableObjects.readSecondLong(in, header);
}
项目:VASSAL-src    文件:IOUtils.java   
/**
 * Close an {@link ObjectInput} unconditionally. Equivalent to
 * calling <code>o.close()</code> when <code>o</code> is nonnull.
 * {@link IOException}s are swallowed, as there is generally
 * nothing that can be done about exceptions on closing.
 *
 * @param o a (possibly <code>null</code>) <code>ObjectInput</code>
 */
public static void closeQuietly(ObjectInput o) {
  if (o == null) return;

  try {
    o.close();
  }
  catch (IOException e) {
    // ignore
  }
}
项目:VASSAL-src    文件:IPCMessageReceiverTest.java   
@Test
public void testRun() throws ClassNotFoundException, IOException {
  final IPCMessage[] msg = new IPCMessage[100];
  for (int i = 0; i < msg.length; ++i) {
    msg[i] = new SimpleIPCMessage();
    msg[i].setId(i);
  }

  final Fin fin = new Fin();
  fin.setId(msg.length);

  final ObjectInput in = context.mock(ObjectInput.class);

  final MultiEventListenerSupport lsup =
    context.mock(MultiEventListenerSupport.class);

  context.checking(new Expectations() {
    {
      for (IPCMessage m : msg) {
        oneOf(in).readObject(); will(returnValue(m));
        oneOf(lsup).notify(with(equal(m)));
      }

      oneOf(in).readObject(); will(returnValue(fin));
      oneOf(lsup).notify(with(equal(fin)));

      exactly(2).of(in).close();
    }
  });

  final IPCMessageReceiver rec = new IPCMessageReceiver(in, lsup);
  rec.run();
}
项目:HCFCore    文件:TByteListDecorator.java   
public void readExternal( ObjectInput in )
    throws IOException, ClassNotFoundException {

    // VERSION
    in.readByte();

    // LIST
    list = ( TByteList ) in.readObject();
}
项目:xcc    文件:TByteIntHash.java   
/** {@inheritDoc} */
public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException {
    // VERSION
    in.readByte();

    // SUPER
    super.readExternal( in );

    // NO_ENTRY_KEY
    no_entry_key = in.readByte();

    // NO_ENTRY_VALUE
    no_entry_value = in.readInt();
}
项目:xcc    文件:TLongListDecorator.java   
public void readExternal( ObjectInput in )
    throws IOException, ClassNotFoundException {

    // VERSION
    in.readByte();

    // LIST
    list = ( TLongList ) in.readObject();
}
项目:xcc    文件:TCharFloatHash.java   
/** {@inheritDoc} */
public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException {
    // VERSION
    in.readByte();

    // SUPER
    super.readExternal( in );

    // NO_ENTRY_KEY
    no_entry_key = in.readChar();

    // NO_ENTRY_VALUE
    no_entry_value = in.readFloat();
}