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.splicemachine.orc.predicate.SpliceORCPredicate.java

@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    baseColumnMap = ArrayUtil.readIntArray(in);
    if (in.readBoolean()) {
        qualifiers = new Qualifier[in.readInt()][];
        qualifiers[0] = new Qualifier[in.readInt()];
        for (int i = 0; i < qualifiers[0].length; i++) {
            qualifiers[0][i] = (Qualifier) in.readObject();
        }//from  w ww  .  j a  v a2 s .c  om
        for (int and_idx = 1; and_idx < qualifiers.length; and_idx++) {
            qualifiers[and_idx] = new Qualifier[in.readInt()];
            for (int or_idx = 0; or_idx < qualifiers[and_idx].length; or_idx++) {
                qualifiers[and_idx][or_idx] = (Qualifier) in.readObject();
            }
        }
    }
    structType = (StructType) StructType.fromJson((String) in.readObject());
}

From source file:com.near.chimerarevo.fragments.PostsRecyclerFragment.java

private boolean readOfflineFile() {
    try {/*from ww  w .j  a va2  s. c  o m*/
        if (new File(getActivity().getCacheDir() + "/posts.ser").exists()) {
            mLoadingBar.setVisibility(View.VISIBLE);
            mSwipeRefreshLayout.setRefreshing(true);

            InputStream file = new FileInputStream(getActivity().getCacheDir() + "/posts.ser");
            ObjectInput input = new ObjectInputStream(new BufferedInputStream(file));
            mJson = ((PostsListObject) input.readObject()).getJSONs();
            input.close();
            shouldAddToStack = false;
            shouldSmoothScroll = false;

            try {
                for (String json : mJson) {
                    setItems(JSONUtils.getJSONArray(json, Constants.KEY_POSTS));
                    shouldAddToStack = true;
                }
                mSwipeRefreshLayout.setRefreshing(false);
                mLoadingBar.setVisibility(View.GONE);
                mFab.setEnabled(true);
                return true;
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    } catch (IOException | ClassCastException | ClassNotFoundException e) {
        e.printStackTrace();
    }

    mSwipeRefreshLayout.setRefreshing(false);
    mLoadingBar.setVisibility(View.GONE);

    return false;
}

From source file:org.grails.ignite.DeferredStartIgniteSpringBean.java

/**
 * {@inheritDoc}//from w w  w  . j a v  a 2  s  . c  o  m
 */
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    g = (Ignite) in.readObject();

    cfg = g.configuration();
}

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

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

    id = (String) input.readObject();
    contextFunction = (ContextFunction) input.readObject();

    // read the map content
    int keySize = input.readInt();
    Map<Attribute, Set<Constraint>> map = new HashMap<>();

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

        Attribute attribute = attributeExt.readExternal(input);
        int constSize = input.readInt();
        Set<Constraint> constrSet = new HashSet<>();

        for (int j = 0; j < constSize; j++) {

            constrSet.add(constraintExt.readExternal(input, attribute.getType()));
        }/*from   w w  w  .  ja  v a2s.  c o  m*/

        map.put(attribute, constrSet);
    }

    constraints = map;
}

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

@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    this.setId(in.readLong());
    this.setTopicId(in.readLong());
    this.setGenerationTime(in.readLong());
    this.setFinishedTime(in.readLong());
    this.setConsolidated(in.readBoolean());
    this.setReady(in.readBoolean());
    this.setChoosenTime(String.valueOf(in.readObject()));
}

From source file:org.kepler.util.AuthNamespace.java

/**
 * Read in the Authority and Namespace from the AuthorizedNamespace file.
 *//* ww w. ja v  a 2s .c o  m*/
public void refreshAuthNamespace() {
    if (isDebugging)
        log.debug("refreshAuthNamespace()");

    try {
        InputStream is = null;
        ObjectInput oi = null;
        try {
            is = new FileInputStream(_anFileName);
            oi = new ObjectInputStream(is);
            Object newObj = oi.readObject();

            String theString = (String) newObj;
            int firstColon = theString.indexOf(':');
            setAuthority(theString.substring(0, firstColon));
            setNamespace(theString.substring(firstColon + 1));
        } finally {
            if (oi != null) {
                oi.close();
            }
            if (is != null) {
                is.close();
            }
        }
    } catch (FileNotFoundException e) {
        log.error(_saveFileName + " file was not found: " + _anFileName);
        e.printStackTrace();
    } catch (IOException e) {
        log.error("Unable to create ObjectInputStream");
        e.printStackTrace();
    } catch (ClassNotFoundException e) {
        log.error("Unable to read from ObjectInput");
        e.printStackTrace();
    } catch (Exception e) {
        log.error(e.toString());
        e.printStackTrace();
    }

    if (isDebugging) {
        log.debug("Instance Authority: " + getAuthority());
        log.debug("Instance Namespace: " + getNamespace());
        log.debug("Instance AuthNamespace: " + getAuthNamespace());
        log.debug("Instance Hash Value: " + getFileNameForm());
    }

}

From source file:StringMap.java

public void readExternal(java.io.ObjectInput in) throws java.io.IOException, ClassNotFoundException {
    HashMap map = (HashMap) in.readObject();
    this.putAll(map);
}

From source file:com.microsoft.applicationinsights.internal.channel.common.TransmissionFileSystemOutput.java

private Optional<Transmission> loadTransmission(File file) {
    Transmission transmission = null;/*from ww  w  .  j a  v  a  2  s .  c o  m*/

    InputStream fileInput = null;
    ObjectInput input = null;
    try {
        if (file == null) {
            return Optional.absent();
        }

        fileInput = new FileInputStream(file);
        InputStream buffer = new BufferedInputStream(fileInput);
        input = new ObjectInputStream(buffer);
        transmission = (Transmission) input.readObject();
    } catch (FileNotFoundException e) {
        InternalLogger.INSTANCE.error("Failed to load transmission, file not found, exception: %s",
                e.getMessage());
    } catch (ClassNotFoundException e) {
        InternalLogger.INSTANCE.error("Failed to load transmission, non transmission, exception: %s",
                e.getMessage());
    } catch (IOException e) {
        InternalLogger.INSTANCE.error("Failed to load transmission, io exception: %s", e.getMessage());
    } finally {
        if (input != null) {
            try {
                input.close();
            } catch (IOException e) {
            }
        }
    }

    return Optional.fromNullable(transmission);
}

From source file:qauth.djd.qauthclient.main.ContentFragment.java

@Override
public void onMessageReceived(MessageEvent messageEvent) {
    Log.i("qAuthWear", "on message received23123123!!!!!");

    if (messageEvent.getPath().equals("REGISTER")) {
        //Log.i("test", "device id:" + messageEvent.getData().toString());

        watch = null;/*from   ww w . j a va2 s .c o  m*/
        ByteArrayInputStream bis = new ByteArrayInputStream(messageEvent.getData());
        ObjectInput in = null;
        try {
            in = new ObjectInputStream(bis);
        } catch (Exception e) {
            Log.i("exception1", "e: " + e);
        }
        try {
            watch = (Watch) in.readObject();
        } catch (Exception e) {
            Log.i("exception2", "e: " + e);
        }

        if (watch != null) {
            Log.i("WATCH SERIALIZABLE", "deviceId:" + watch.deviceId + " model:" + watch.model);
            getActivity().runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    if (!wDataset.contains(watch)) {
                        wDataset.add(watch);
                        wAdapter.notifyDataSetChanged();
                    }
                }
            });

            RSAPrivateKey rsaPrivKey = null;
            RSAPublicKey rsaPubKey = null;

            try {
                rsaPrivKey = (RSAPrivateKey) Authenticate.getPrivKeyFromString(watch.privKey);
                rsaPubKey = (RSAPublicKey) Authenticate.getPubKeyFromString(watch.pubKey);
            } catch (Exception e) {
            }

            String N = rsaPubKey.getModulus().toString(10); //N
            int E = rsaPubKey.getPublicExponent().intValue(); //E

            for (String nodeId : getNodes()) {

                SharedPreferences prefs = getActivity().getSharedPreferences("qauth.djd.qauthclient",
                        Context.MODE_PRIVATE);
                String email = prefs.getString("email", "email");
                String password = prefs.getString("password", "password");
                new RegisterBluetooth(email, password, watch.deviceId, N, E, nodeId).execute();

            }

        } else {
            Log.i("WATCH SERIALIZABLE", "watch = null");
        }

    }

}

From source file:org.springframework.webflow.engine.impl.FlowExecutionImpl.java

@SuppressWarnings("unchecked")
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    status = (FlowExecutionStatus) in.readObject();
    flowSessions = (LinkedList<FlowSessionImpl>) in.readObject();
}