Example usage for java.io ObjectInput readInt

List of usage examples for java.io ObjectInput readInt

Introduction

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

Prototype

int readInt() throws IOException;

Source Link

Document

Reads four input bytes and returns an int value.

Usage

From source file:net.lightbody.bmp.proxy.jetty.jetty.servlet.WebApplicationContext.java

public void readExternal(java.io.ObjectInput in) throws java.io.IOException, ClassNotFoundException {
    setContextPath((String) in.readObject());
    setVirtualHosts((String[]) in.readObject());
    Object o = in.readObject();//  w  w w .j  ava 2  s  .c  om

    while (o instanceof HttpHandler) {
        addHandler((HttpHandler) o);
        o = in.readObject();
    }
    setAttributes((Map) o);
    setRedirectNullPath(in.readBoolean());
    setMaxCachedFileSize(in.readInt());
    setMaxCacheSize(in.readInt());
    setStatsOn(in.readBoolean());
    setPermissions((PermissionCollection) in.readObject());
    setClassLoaderJava2Compliant(in.readBoolean());

    _defaultsDescriptor = (String) in.readObject();
    _war = (String) in.readObject();
    _extract = in.readBoolean();
    _ignorewebjetty = in.readBoolean();
    _distributable = in.readBoolean();
    _configurationClassNames = (String[]) in.readObject();
}

From source file:es.udc.gii.common.eaf.algorithm.population.Individual.java

/**
 * This method is called whenever an instance of this class has to be
 * de-serialized.<p>/* www  .j  a  v a 2  s .  com*/
 * 
 * It sets the values of Individual#getSerializeEvalResults and
 * Individual#getSerializeGenotype accordingly to the information received
 * so that subclasses can rely on them to know what kind of information is
 * to be read.<p>
 * 
 * Subclasses should override this method if they introduce new attibutes.
 * Remember to call <code>super.readExternal()</code> in order to
 * be sure that the state of the parent class is de-serialized and the values
 * of Individual#getSerializeEvalResults and Individual#getSerializeGenotype
 * contain the right information.
 * 
 * @param in - DataInput from which the bytes are read.
 * @throws java.io.IOException
 * @throws java.lang.ClassNotFoundException
 */
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {

    /* Retrieve the type of information comming in */
    boolean evals = in.readBoolean();
    boolean genotype = in.readBoolean();

    this.serializeEvalResults = evals;
    this.serializeGenotype = genotype;

    /* Read the evaluation results, if present */
    if (evals) {
        /* Read number of violated constraints */
        this.violatedConstraints = in.readInt();

        /* Read the fitness value */
        this.fitness = in.readDouble();

        /* Read the number of objectives (-1 means no objective values) */
        int nObjs = in.readInt();

        if (nObjs == -1) {
            this.objectives = null;
        } else {
            /* Read all objective values */
            this.objectives = new ArrayList<Double>(nObjs);
            for (int i = 0; i < nObjs; i++) {
                this.objectives.add(in.readDouble());
            }
        }

        /* Read the number of constraints (-1 means no constraint values) */
        int nConstr = in.readInt();

        if (nConstr == -1) {
            this.constraints = null;
        } else {
            /* Read all constraint values */
            this.constraints = new ArrayList<Double>(nConstr);
            for (int i = 0; i < nConstr; i++) {
                this.constraints.add(in.readDouble());
            }
        }
    }

    /* Read the genotype information, if present */
    if (genotype) {
        int nChroms = in.readInt();

        if (nChroms == -1) {
            this.chromosomes = null;
        } else {
            /* Read all the chromosomes */
            this.chromosomes = new DoubleArray[nChroms];
            for (int i = 0; i < nChroms; i++) {
                int nGenes = in.readInt();
                this.chromosomes[i] = new ResizableDoubleArray(nGenes);
                for (int j = 0; j < nGenes; j++) {
                    this.chromosomes[i].addElement(in.readDouble());
                }
            }
        }
    }
}

From source file:org.openfaces.component.table.TableDataModel.java

public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    sortingRules = (List<SortingRule>) in.readObject();
    rowKeyExpression = ValueBindings.readValueExpression(in);
    rowDataByKeyExpression = ValueBindings.readValueExpression(in);
    pageSize = in.readInt();
    pageIndex = in.readInt();/*ww  w . ja  va 2  s.  c  om*/
    setWrappedData(null);

    // restoring old extracted row keys is needed for correct restoreRows/restoreRowIndexes functionality, which
    // in turn is required for correct data submission in case of concurrent data modifications
    extractedRowKeys = (List) in.readObject();
}

From source file:com.inmobi.grill.server.query.QueryExecutionServiceImpl.java

@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    super.readExternal(in);
    Map<String, GrillDriver> driverMap = new HashMap<String, GrillDriver>();
    synchronized (drivers) {
        drivers.clear();//from  w  w  w  .j  a va2s .  com
        int numDrivers = in.readInt();
        for (int i = 0; i < numDrivers; i++) {
            String driverClsName = in.readUTF();
            GrillDriver driver;
            try {
                Class<? extends GrillDriver> driverCls = (Class<? extends GrillDriver>) Class
                        .forName(driverClsName);
                driver = (GrillDriver) driverCls.newInstance();
                driver.configure(conf);
            } catch (Exception e) {
                LOG.error("Could not instantiate driver:" + driverClsName);
                throw new IOException(e);
            }
            driver.readExternal(in);
            drivers.add(driver);
            driverMap.put(driverClsName, driver);
        }
    }
    synchronized (allQueries) {
        int numQueries = in.readInt();
        for (int i = 0; i < numQueries; i++) {
            QueryContext ctx = (QueryContext) in.readObject();
            allQueries.put(ctx.getQueryHandle(), ctx);
            boolean driverAvailable = in.readBoolean();
            if (driverAvailable) {
                String clsName = in.readUTF();
                ctx.setSelectedDriver(driverMap.get(clsName));
            }
            try {
                ctx.setConf(getGrillConf(null, ctx.getQconf()));
            } catch (GrillException e) {
                LOG.error("Could not set query conf");
            }
        }

        // populate the query queues
        for (QueryContext ctx : allQueries.values()) {
            switch (ctx.getStatus().getStatus()) {
            case NEW:
            case QUEUED:
                // queued queries wont recovered.
                try {
                    setFailedStatus(ctx, "Launching query failed due to server restart", "Server is restarted");
                } catch (GrillException e) {
                    LOG.error("Failing query " + ctx.getQueryHandle() + " failed", e);
                }
                break;
            case LAUNCHED:
            case RUNNING:
                launchedQueries.add(ctx);
                break;
            case SUCCESSFUL:
            case FAILED:
            case CANCELED:
                updateFinishedQuery(ctx, null);
                break;
            case CLOSED:
                allQueries.remove(ctx.getQueryHandle());
            }
        }
        LOG.info("Recovered " + allQueries.size() + " queries");
    }
}

From source file:com.joey.software.regionSelectionToolkit.controlers.ImageProfileTool.java

@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    setBlockUpdate(true);//w  w  w . j  a v a  2  s.c om
    int version = in.readInt();

    dataPoints = in.readInt();
    crossColor = new Color(in.readInt());
    pointSize = in.readDouble();

    value = new float[in.readInt()];
    for (int i = 0; i < value.length; i++) {
        value[i] = in.readFloat();
    }

    selectionData = new float[in.readInt()];
    for (int i = 0; i < selectionData.length; i++) {
        selectionData[i] = in.readFloat();
    }

    useData = new boolean[in.readInt()];
    for (int i = 0; i < useData.length; i++) {
        useData[i] = in.readBoolean();
    }

    offset.setValue(in.readDouble());
    showOffset.setSelected(in.readBoolean());

    setBlockUpdate(false);
    // dataPoints = p.dataPoints;
    // crossColor = new Color(p.crossColor.getRGB());
    // pointSize = p.pointSize;
    // value = new float[p.value.length];
    // for (int i = 0; i < value.length; i++)
    // {
    // value[i] = p.value[i];
    // }
    //
    // selectionData = new float[p.selectionData.length];
    // for (int i = 0; i < selectionData.length; i++)
    // {
    // selectionData[i] = p.selectionData[i];
    // }
    //
    // useData = new boolean[p.useData.length];
    // for (int i = 0; i < useData.length; i++)
    // {
    // useData[i] = p.useData[i];
    // }
    //
    // offset.setValue(p.offset.getValue());
    // showOffset.setSelected(p.showOffset.isSelected());
}

From source file:gnu.trove.map.custom_hash.TObjectByteCustomHashMap.java

public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {

    // VERSION//from   ww  w  .  jav  a  2s.c om
    in.readByte();

    // SUPER
    super.readExternal(in);

    // STRATEGY
    strategy = (HashingStrategy<K>) in.readObject();

    // NO_ENTRY_VALUE
    no_entry_value = in.readByte();

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

    // ENTRIES
    while (size-- > 0) {
        //noinspection unchecked
        K key = (K) in.readObject();
        byte val = in.readByte();
        put(key, val);
    }
}

From source file:gnu.trove.map.custom_hash.TObjectCharCustomHashMap.java

public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {

    // VERSION//from   ww w .j a  v a  2s  .c o  m
    in.readByte();

    // SUPER
    super.readExternal(in);

    // STRATEGY
    strategy = (HashingStrategy<K>) in.readObject();

    // NO_ENTRY_VALUE
    no_entry_value = in.readChar();

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

    // ENTRIES
    while (size-- > 0) {
        //noinspection unchecked
        K key = (K) in.readObject();
        char val = in.readChar();
        put(key, val);
    }
}

From source file:gnu.trove.map.custom_hash.TObjectFloatCustomHashMap.java

public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {

    // VERSION/*ww  w  . j  a va2 s  . c om*/
    in.readByte();

    // SUPER
    super.readExternal(in);

    // STRATEGY
    strategy = (HashingStrategy<K>) in.readObject();

    // NO_ENTRY_VALUE
    no_entry_value = in.readFloat();

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

    // ENTRIES
    while (size-- > 0) {
        //noinspection unchecked
        K key = (K) in.readObject();
        float val = in.readFloat();
        put(key, val);
    }
}

From source file:gnu.trove.map.custom_hash.TObjectDoubleCustomHashMap.java

public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {

    // VERSION//from  ww w  .j a  va 2 s  .  c om
    in.readByte();

    // SUPER
    super.readExternal(in);

    // STRATEGY
    strategy = (HashingStrategy<K>) in.readObject();

    // NO_ENTRY_VALUE
    no_entry_value = in.readDouble();

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

    // ENTRIES
    while (size-- > 0) {
        //noinspection unchecked
        K key = (K) in.readObject();
        double val = in.readDouble();
        put(key, val);
    }
}

From source file:org.apache.lens.driver.hive.HiveDriver.java

@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    synchronized (hiveHandles) {
        int numHiveHnadles = in.readInt();
        for (int i = 0; i < numHiveHnadles; i++) {
            QueryHandle qhandle = (QueryHandle) in.readObject();
            OperationHandle opHandle = new OperationHandle((TOperationHandle) in.readObject());
            hiveHandles.put(qhandle, opHandle);
            log.debug("Hive driver {} recovered {}:{}", getFullyQualifiedName(), qhandle, opHandle);
        }/*w ww  . j a va2  s . co  m*/
        log.info("Hive driver {} recovered {} queries", getFullyQualifiedName(), hiveHandles.size());
        int numSessions = in.readInt();
        for (int i = 0; i < numSessions; i++) {
            String lensId = in.readUTF();
            SessionHandle sHandle = new SessionHandle((TSessionHandle) in.readObject(),
                    TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V6);
            lensToHiveSession.put(lensId, sHandle);
        }
        log.info("Hive driver {} recovered {} sessions", getFullyQualifiedName(), lensToHiveSession.size());
    }
    int numOpHandles = in.readInt();
    for (int i = 0; i < numOpHandles; i++) {
        OperationHandle opHandle = new OperationHandle((TOperationHandle) in.readObject());
        SessionHandle sHandle = new SessionHandle((TSessionHandle) in.readObject(),
                TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V6);
        opHandleToSession.put(opHandle, sHandle);
    }
    log.info("Hive driver {} recovered {} operation handles", getFullyQualifiedName(),
            opHandleToSession.size());
    int numOrphanedSessions = in.readInt();
    for (int i = 0; i < numOrphanedSessions; i++) {
        SessionHandle sHandle = new SessionHandle((TSessionHandle) in.readObject(),
                TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V6);
        orphanedHiveSessions.add(sHandle);
    }
    log.info("Hive driver {} recovered {} orphaned sessions", getFullyQualifiedName(),
            orphanedHiveSessions.size());
}