Example usage for java.io ObjectInput readObject

List of usage examples for java.io ObjectInput readObject

Introduction

In this page you can find the example usage for java.io ObjectInput readObject.

Prototype

public Object readObject() throws ClassNotFoundException, IOException;

Source Link

Document

Read and return an object.

Usage

From source file:com.github.naoghuman.abclist.model.Term.java

@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    this.setId(in.readLong());
    this.setGenerationTime(in.readLong());
    this.setDescription(String.valueOf(in.readObject()));
    this.setTitle(String.valueOf(in.readObject()));
}

From source file:com.github.naoghuman.cm.model.glossary.GlossaryModel.java

@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    this.setId(in.readLong());
    this.setGenerationTime(in.readLong());
    this.setTitle(StringEscapeUtils.unescapeHtml4(String.valueOf(in.readObject())));
    this.setDescription(StringEscapeUtils.unescapeHtml4(String.valueOf(in.readObject())));
    this.setNotes(StringEscapeUtils.unescapeHtml4(String.valueOf(in.readObject())));
}

From source file:xbird.util.collections.IndexedSet.java

@SuppressWarnings("unchecked")
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    final int size = in.readInt();
    final Map<E, Integer> map = new HashMap<E, Integer>(size);
    final ArrayList<E> list = new ArrayList<E>(size);
    for(int i = 0; i < size; i++) {
        E e = (E) in.readObject();
        list.add(e);//from www .j a  v a 2s .c om
        map.put(e, i);
    }
    this._map = map;
    this._list = list;
}

From source file:org.jfree.data.time.junit.SecondTest.java

/**
 * Serialize an instance, restore it, and check for equality.
 *///from   ww w  .j av  a2  s. c o  m
public void testSerialization() {
    Second s1 = new Second();
    Second s2 = null;
    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(s1);
        out.close();

        ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
        s2 = (Second) in.readObject();
        in.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
    assertEquals(s1, s2);
}

From source file:com.github.naoghuman.cm.model.notes.NotesModel.java

@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    this.setId(in.readLong());
    this.setMatrixId(in.readLong());
    this.setGenerationTime(in.readLong());
    this.setNotes(StringEscapeUtils.unescapeHtml4(String.valueOf(in.readObject())));
}

From source file:org.opencms.util.CmsUUID.java

/**
 * @see java.io.Externalizable#readExternal(java.io.ObjectInput)
 *//*from   ww  w. j a  va 2 s .  c  o m*/
public void readExternal(ObjectInput in) {

    Object o = null;
    try {
        o = in.readObject();
    } catch (Throwable e) {
        // there are 2 development version of OpenCms (6.1.7 and 6.1.8) which had a different format, 
        // here the Object was preceded by a Long 
        try {
            // first read the long, we don't really need it but it must be removed from the stream
            in.readLong();
            o = in.readObject();
        } catch (Throwable t) {
            if (LOG.isDebugEnabled()) {
                LOG.debug(Messages.get().getBundle().key(Messages.LOG_READ_UUID_OLD_1, o), t);
            }
        }
    }

    if (o instanceof String) {
        // this UUID has been serialized using the new method
        if (LOG.isDebugEnabled()) {
            LOG.debug(Messages.get().getBundle().key(Messages.LOG_READ_UUID_1, o));
        }
        m_uuid = new UUID((String) o);
    }

    // log an error if the uuid could not be deserialized
    if (m_uuid == null) {
        // UUID cannot be deserialized
        if (LOG.isDebugEnabled()) {
            LOG.debug(Messages.get().getBundle().key(Messages.LOG_ERR_READ_UUID_0));
        }
    }
}

From source file:net.lightbody.bmp.proxy.jetty.http.HashUserRealm.java

public void readExternal(java.io.ObjectInput in) throws java.io.IOException, ClassNotFoundException {
    _realmName = (String) in.readObject();
    _config = (String) in.readObject();
    if (_config != null)
        load(_config);/*from w w w .  jav a2  s  .  c o m*/
}

From source file:xbird.engine.remote.RemoteFocus.java

public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    this._proxy = (IRemoteFocusProxy) in.readObject();
    this._fetchSize = in.readInt();
    this._fetchGrow = in.readFloat();
    this._fetchWatermark = in.readInt();
    this._fetchMethod = (FetchMethod) in.readObject();
}

From source file:org.jfree.data.time.junit.MinuteTest.java

/**
 * Serialize an instance, restore it, and check for equality.
 *//* w w w  .  ja v  a 2  s.c  o  m*/
public void testSerialization() {
    Minute m1 = new Minute();
    Minute m2 = null;

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

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

From source file:org.photovault.replication.ValueChange.java

public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    name = (String) in.readObject();
    setValue(in.readObject());/*from  w  w w . ja va  2 s  .c  o  m*/
}