Example usage for java.io ObjectInputStream readFields

List of usage examples for java.io ObjectInputStream readFields

Introduction

In this page you can find the example usage for java.io ObjectInputStream readFields.

Prototype

public ObjectInputStream.GetField readFields() throws IOException, ClassNotFoundException 

Source Link

Document

Reads the persistent fields from the stream and makes them available by name.

Usage

From source file:Main.java

private String readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {

    ObjectInputStream.GetField gf = in.readFields();

    in.registerValidation(this, 0);

    return (String) gf.get("s", null);
}

From source file:Main.java

private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {

    ObjectInputStream.GetField fields = in.readFields();

    isDefault = fields.defaulted("string");
    string = (String) fields.get("string", null);
}

From source file:net.ripe.ipresource.Asn.java

private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
    ObjectInputStream.GetField gf = in.readFields();
    if (!gf.defaulted("intValue")) {
        this.intValue = gf.get("intValue", 0);
    } else {//from  w  ww.jav  a  2s .  c  o  m
        this.intValue = (int) gf.get("value", 0L);
    }
}

From source file:net.ripe.ipresource.IpResourceSet.java

@SuppressWarnings("unchecked")
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
    ObjectInputStream.GetField gf = in.readFields();
    if (!gf.defaulted("resourcesByEndPoint")) {
        resourcesByEndPoint = (NavigableMap<IpResource, IpResource>) gf.get("resourcesByEndPoint", null);
    } else {/*from   w  w  w. j a v a 2  s. co  m*/
        SortedSet<IpResource> resources = (SortedSet<IpResource>) gf.get("resources", null);
        resourcesByEndPoint = new TreeMap<IpResource, IpResource>();
        for (IpResource resource : resources) {
            resourcesByEndPoint.put(resource.getEnd(), resource);
        }
    }
}

From source file:org.agnitas.actions.ops.SubscribeCustomer.java

/**
 * Reads an Object and puts the read fields into allFields
 * Gets keyColumn, doubleCheck and doubleoptIn from allFields
 * throws IOException or ClassNotFoundException
 *
 * @param in inputstream from Object/*from  w  w w .  j  a va 2 s. c  o m*/
 */
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
    ObjectInputStream.GetField allFields = null;

    allFields = in.readFields();
    this.keyColumn = (String) allFields.get("keyColumn", "email");
    this.doubleCheck = allFields.get("doubleCheck", true);
    this.doubleOptIn = allFields.get("doubleOptIn", false);
}

From source file:facebook4j.FacebookBaseImpl.java

private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
    // http://docs.oracle.com/javase/6/docs/platform/serialization/spec/input.html#2971
    stream.readFields();

    conf = (Configuration) stream.readObject();
    auth = (Authorization) stream.readObject();
    http = new HttpClientWrapper(conf);
    setFactory();/*from   w  w  w  . j av a  2s.  c  om*/
}

From source file:org.kepler.objectmanager.lsid.KeplerLSID.java

/**
 * Custom deserialization method. The serial representation of the
 * KeplerLSID object is simply the toString() representation. This string
 * representation is passed into the initializeFromString method.
 * //from  w ww .ja v  a  2s  . c o  m
 * @param ois
 * @throws IOException
 */
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
    ObjectInputStream.GetField fields = ois.readFields();
    String lsidString = (String) fields.get("lsidString", null);
    try {
        _lsidStr = lsidString;
        initializeLSID();
    } catch (Exception e) {
        throw new IOException("Malformed LSID in serialized representation");
    }
}

From source file:net.sf.jasperreports.engine.fill.JRVirtualizationContext.java

@SuppressWarnings("unchecked")
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
    setThreadJasperReportsContext();/*from   w w  w. j av a 2s .c  o  m*/

    GetField fields = in.readFields();
    cachedRenderers = (Map<String, Renderable>) fields.get("cachedRenderers", null);
    cachedTemplates = (Map<String, JRTemplateElement>) fields.get("cachedTemplates", null);
    readOnly = fields.get("readOnly", false);
    // use configured default if serialized by old version
    pageElementSize = fields.get("pageElementSize", JRPropertiesUtil.getInstance(jasperReportsContext)
            .getIntegerProperty(JRVirtualPrintPage.PROPERTY_VIRTUAL_PAGE_ELEMENT_SIZE, 0));

    setThreadVirtualizer();

    initLock();
}

From source file:twitter4j.internal.models4j.TwitterBaseImpl.java

private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
    // http://docs.oracle.com/javase/6/docs/platform/serialization/spec/input.html#2971
    stream.readFields();

    conf = (Configuration) stream.readObject();
    auth = (Authorization) stream.readObject();
    rateLimitStatusListeners = (List<RateLimitStatusListener>) stream.readObject();
    http = new HttpClientWrapper(conf);
    http.setHttpResponseListener(this);
    setFactory();//  ww  w.  java  2s . c  o  m
}

From source file:gate.annotation.AnnotationSetImpl.java

private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
    this.longestAnnot = 0l;
    ObjectInputStream.GetField gf = in.readFields();
    this.name = (String) gf.get("name", null);
    this.doc = (DocumentImpl) gf.get("doc", null);
    boolean isIndexedByType = false;
    boolean isIndexedByStartNode = false;
    this.annotations = (Annotation[]) gf.get("annotations", null);
    if (this.annotations == null) {
        // old style serialised version
        @SuppressWarnings("unchecked")
        Map<Integer, Annotation> annotsByIdMap = (Map<Integer, Annotation>) gf.get("annotsById", null);
        if (annotsByIdMap == null)
            throw new IOException(
                    "Invalid serialised data: neither annotations array or map by id" + " are present.");
        annotations = annotsByIdMap.values().toArray(new Annotation[] {});
    } else {/*w  w  w . j  a  v a2 s.  c om*/
        // new style serialised version
        isIndexedByType = in.readBoolean();
        isIndexedByStartNode = in.readBoolean();
    }
    // this.name = (String)in.readObject();
    // this.doc = (DocumentImpl)in.readObject();
    // Annotation[] annotations = (Annotation[])in.readObject();
    // do we need to create the indices?
    // boolean isIndexedByType = in.readBoolean();
    // boolean isIndexedByStartNode = in.readBoolean();
    this.annotsById = new HashMap<Integer, Annotation>(annotations.length);
    // rebuilds the indices if required
    if (isIndexedByType) {
        annotsByType = new HashMap<String, AnnotationSet>(Gate.HASH_STH_SIZE);
    }
    if (isIndexedByStartNode) {
        nodesByOffset = new RBTreeMap<Long, Node>();
        annotsByStartNode = new HashMap<Integer, Object>(annotations.length);
    }
    // add all the annotations one by one
    for (int i = 0; i < annotations.length; i++) {
        add(annotations[i]);
    }
    annotations = null;
}