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:de.pro.dbw.file.reflection.api.ReflectionModel.java

@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    this.setId(in.readLong());
    this.setReflectionCommentModels((List<ReflectionCommentModel>) in.readObject());
    this.setGenerationTime(in.readLong());
    this.setSource(String.valueOf(in.readObject()));
    this.setText(String.valueOf(in.readObject()));
    this.setTitle(String.valueOf(in.readObject()));
}

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

/**
 * Serialize an instance, restore it, and check for equality.
 *//*from  www . j av  a2s  .  co m*/
public void testSerialization() {
    Millisecond m1 = new Millisecond();
    Millisecond 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 = (Millisecond) in.readObject();
        in.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
    assertEquals(m1, m2);
}

From source file:com.conwet.silbops.model.ContextFunction.java

@Override
public void readExternal(ObjectInput input) throws IOException, ClassNotFoundException {

    Map<Key, Value> map = new HashMap<>();
    int size = input.readInt();

    for (int i = 0; i < size; i++) {

        Key key = (Key) input.readObject();
        Value value = valueExt.readExternal(input, key.subscriptionAttribute.getType());
        map.put(key, value);//from   w  w w  .j  a v  a2  s . co m
    }

    constraint = map;
}

From source file:com.github.naoghuman.cm.model.category.CategoryModel.java

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

From source file:com.bah.bahdit.main.plugins.imageindex.ImageIndex.java

/**
 * Loads the necessary files from the properties file
 * called from FullTextIndex.configure//from w ww.  ja  v a 2s.  c  om
 * 
 * @param context - passed from the servlet
 */
@SuppressWarnings("unchecked")
private void loadResources(ServletContext context) {
    try {
        // get the sample table from resources
        InputStream sample = context.getResourceAsStream(properties.getProperty(IMG_TAG_SAMPLE_TABLE));
        InputStream samplebuffer = new BufferedInputStream(sample);
        ObjectInput objectsample;
        objectsample = new ObjectInputStream(samplebuffer);
        tagSampleTable = (HashMap<String, Integer>) objectsample.readObject();

        tagSpellChecker = LevenshteinDistance.createSpellChecker(context, tagSampleTable);

    } catch (IOException e) {
        log.warn(e.getMessage());
    } catch (ClassNotFoundException e) {
        log.warn(e.getMessage());
    }
}

From source file:edu.wustl.cab2b.admin.flex.DAGNode.java

/**
 * It reads serialized data coming from flex client
 * //  w  ww.j av a  2s  . c o  m
 * @param in
 * @throws IOException
 * @throws ClassNotFoundException
 */
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    nodeName = in.readUTF();
    toolTip = in.readUTF();
    nodeId = in.readInt();
    operatorBetweenAttrAndAssociation = in.readUTF();
    nodeType = in.readUTF();
    associationList = (List<DAGNode>) in.readObject();
    operatorList = (List<String>) in.readObject();
    dagpathList = (List<DAGLink>) in.readObject();
    errorMsg = in.readUTF();
    xCordinate = in.readInt();
    yCordinate = in.readInt();
    entityId = in.readInt();
    attributesList = (List<String>) in.readObject();

    CategoryDagPanel categoryDagPanel = (CategoryDagPanel) session
            .getAttribute(AdminConstants.CATEGORY_INSTANCE);
    for (DAGNode dagNode : categoryDagPanel.getDagNodeSet()) {
        if (dagNode.getNodeId() == nodeId) {
            dagNode.xCordinate = xCordinate;
            dagNode.yCordinate = yCordinate;
        }
    }
}

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

/**
 * Serialize an instance, restore it, and check for equality.
 */// w w w.  java2 s.  c om
public void testSerialization() {
    Hour h1 = new Hour();
    Hour h2 = null;

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

        ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
        h2 = (Hour) in.readObject();
        in.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
    assertEquals(h1, h2);
}

From source file:com.almende.eve.state.file.ConcurrentSerializableFileState.java

/**
 * read properties from disk./*from w w  w  .  j a  v  a  2  s.c  o  m*/
 * 
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 * @throws ClassNotFoundException
 *             the class not found exception
 */
@SuppressWarnings("unchecked")
private void read() throws IOException, ClassNotFoundException {
    try {
        if (channel != null) {
            channel.position(0);
        }

        properties.clear();
        final ObjectInput in = new ObjectInputStream(fis);

        properties.putAll((Map<String, Serializable>) in.readObject());

    } catch (final EOFException eof) {
        // empty file, new agent?
    }
}

From source file:LinkedList.java

public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    firstNode = (LinkedListNode) in.readObject();
    lastNode = (LinkedListNode) in.readObject();
    size = in.readInt();//from w ww .j a  va 2  s.  co m
    iterator = (LinkedListIterator) in.readObject();
}

From source file:com.exadel.flamingo.flex.messaging.amf.io.AMF0Deserializer.java

/**
 * Reads object/* w  ww.jav  a  2  s.  c o  m*/
 *
 * @return
 */
protected Object readAMF3Data() throws IOException {
    ObjectInput amf3 = new AMF3Deserializer(inputStream);

    try {
        return amf3.readObject();
    } catch (ClassNotFoundException e) {
        throw new RuntimeException(e);
    }
}