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:com.ning.metrics.serialization.event.SmileEnvelopeEvent.java

/**
 * The object implements the readExternal method to restore its
 * contents by calling the methods of DataInput for primitive
 * types and readObject for objects, strings and arrays.  The
 * readExternal method must read the values in the same sequence
 * and with the same types as were written by writeExternal.
 *
 * @param in the stream to read data from in order to restore the object
 * @throws java.io.IOException if I/O errors occur
 *//*from  w w  w .j  a  v  a2  s. c o  m*/
@Override
public void readExternal(final ObjectInput in) throws IOException {
    // Name of the event first
    final int smileEventNameBytesSize = in.readInt();
    final byte[] eventNameBytes = new byte[smileEventNameBytesSize];
    in.readFully(eventNameBytes);
    eventName = new String(eventNameBytes, NAME_CHARSET);

    // Then payload
    final int smilePayloadSize = in.readInt();
    final byte[] smilePayload = new byte[smilePayloadSize];
    in.readFully(smilePayload);

    root = parseAsTree(smilePayload);

    setEventPropertiesFromNode(root);
}

From source file:com.redhat.red.build.koji.model.xmlrpc.KojiBuildInfo.java

@SuppressWarnings("unchecked")
@Override/*from w  ww  .j  a v  a 2  s. c  o m*/
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    int version = in.readInt();

    if (version != 1) {
        throw new IOException("Invalid version: " + version);
    }

    this.id = in.readInt();
    this.packageId = in.readInt();
    this.name = ExternalizableUtils.readUTF(in);
    this.version = ExternalizableUtils.readUTF(in);
    this.release = ExternalizableUtils.readUTF(in);
    this.completionTime = (Date) in.readObject();
    this.creationTime = (Date) in.readObject();
    this.nvr = ExternalizableUtils.readUTF(in);
    this.taskId = (Integer) in.readObject();
    this.ownerId = (Integer) in.readObject();
    this.ownerName = ExternalizableUtils.readUTF(in);
    this.buildState = (KojiBuildState) in.readObject();
    this.creationEventId = (Integer) in.readObject();
    this.mavenGroupId = ExternalizableUtils.readUTF(in);
    this.mavenArtifactId = ExternalizableUtils.readUTF(in);
    this.mavenVersion = ExternalizableUtils.readUTF(in);
    this.platform = ExternalizableUtils.readUTF(in);
    this.extra = (Map<String, Object>) in.readObject();
    this.source = ExternalizableUtils.readUTF(in);
    // XXX: This has @JsonIgnore
    this.typeNames = (List<String>) in.readObject();
    this.volumeName = ExternalizableUtils.readUTF(in);
}

From source file:org.apache.axis2.context.externalize.SafeObjectInputStream.java

/**
 * Get the byte stream for an object that is written using the 
 * byte format.  /*from   www  .  j a  va 2  s  .  com*/
 * EXPECTED format
 *     int (number of bytes)
 *     bytes 
 *     
 * @param in
 * @return
 * @throws IOException
 * @throws ClassNotFoundException
 */
private ByteArrayInputStream getByteStream(ObjectInput in) throws IOException, ClassNotFoundException {

    // Read the length
    int size = in.readInt();

    // Fill our temporary buffer
    if (buffer == null || buffer.length < size) {
        int allocSize = (size > BUFFER_MIN_SIZE) ? size : BUFFER_MIN_SIZE;
        buffer = new byte[allocSize];
    }
    in.readFully(buffer, 0, size);

    // Return a stream backed by the buffer
    return new ByteArrayInputStream(buffer, 0, size);
}

From source file:BinaryHeapQueue.java

public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    comparator = (Comparator) in.readObject();
    elements = (Queueable[]) in.readObject();
    size = in.readInt();
}

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:com.delphix.session.impl.frame.SerialNumber.java

@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    serialBits = in.readByte() & 0xff; // Unsigned byte

    if (serialBits < Byte.SIZE) {
        serialNumber = in.readByte();//  w  ww. j  a v a2 s.co  m
    } else if (serialBits < Short.SIZE) {
        serialNumber = in.readShort();
    } else if (serialBits < Integer.SIZE) {
        serialNumber = in.readInt();
    } else {
        serialNumber = in.readLong();
    }
}

From source file:LinkedList.java

public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    firstNode = (LinkedListNode) in.readObject();
    lastNode = (LinkedListNode) in.readObject();
    size = in.readInt();
    iterator = (LinkedListIterator) in.readObject();
}

From source file:xbird.xquery.expr.path.PathExpr.java

public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    final int numSteps = in.readInt();
    final ArrayList<XQExpression> steps = new ArrayList<XQExpression>(numSteps);
    for (int i = 0; i < numSteps; i++) {
        XQExpression step = (XQExpression) in.readObject();
        steps.add(step);/*from  w w w  . j  a v a 2s. c om*/
    }
    this._steps = steps;
    final boolean hasAnalyzedExpr = in.readBoolean();
    if (hasAnalyzedExpr) {
        this._analyzedExpr = (XQExpression) in.readObject();
    }
}

From source file:org.apache.rahas.Token.java

/**
 * Implementing de-serialization logic in accordance with the serialization logic.
 * @param in Stream which used to read data.
 * @throws IOException If unable to de-serialize particular data member.
 * @throws ClassNotFoundException //from   ww  w .  j  a v  a2  s  .  c  o m
 */
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {

    this.id = (String) in.readObject();

    this.state = in.readInt();

    String stringElement = (String) in.readObject();
    this.token = convertStringToOMElement(stringElement);

    stringElement = (String) in.readObject();
    this.previousToken = convertStringToOMElement(stringElement);

    stringElement = (String) in.readObject();
    this.attachedReference = convertStringToOMElement(stringElement);

    stringElement = (String) in.readObject();
    this.unattachedReference = convertStringToOMElement(stringElement);

    this.properties = (Properties) in.readObject();

    this.changed = in.readBoolean();

    // Read the length of the secret
    int secretLength = in.readInt();

    if (0 != secretLength) {
        byte[] buffer = new byte[secretLength];
        if (secretLength != in.read(buffer)) {
            throw new IllegalStateException("Bytes read from the secret key is not equal to serialized length");
        }
        this.secret = buffer;
    } else {
        this.secret = null;
    }

    this.created = (Date) in.readObject();

    this.expires = (Date) in.readObject();

    this.issuerAddress = (String) in.readObject();

    this.encrKeySha1Value = (String) in.readObject();
}

From source file:org.apache.lens.server.session.HiveSessionService.java

@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    int numSessions = in.readInt();
    restorableSessions = new ArrayList<LensSessionImpl.LensSessionPersistInfo>();

    for (int i = 0; i < numSessions; i++) {
        LensSessionImpl.LensSessionPersistInfo persistInfo = new LensSessionImpl.LensSessionPersistInfo();
        persistInfo.readExternal(in);/* www .j a v a  2  s . co  m*/
        restorableSessions.add(persistInfo);
        SESSION_MAP.put(persistInfo.getSessionHandle().getPublicId().toString(),
                persistInfo.getSessionHandle());
    }
    log.info("Session service recovered " + SESSION_MAP.size() + " sessions");
}