Example usage for java.io DataInput readLong

List of usage examples for java.io DataInput readLong

Introduction

In this page you can find the example usage for java.io DataInput readLong.

Prototype

long readLong() throws IOException;

Source Link

Document

Reads eight input bytes and returns a long value.

Usage

From source file:com.fiorano.openesb.application.aps.Route.java

/**
 *  This method reads this object <code>Routes</code> from the specified
 *  input stream object.//from  w  w  w  .j ava  2s  .c  o m
 *
 * @param is DataInput object
 * @param versionNo
 * @exception IOException if an error occurs while reading bytes or while
 *      converting them into specified Java primitive type.
 * @see #toStream(DataOutput, int)
 * @since Tifosi2.0
 */
public void fromStream(DataInput is, int versionNo) throws IOException {
    super.fromStream(is, versionNo);

    m_isP2PRoute = is.readBoolean();

    m_isPersitant = is.readBoolean();

    m_isDurable = is.readBoolean();

    m_applyTransformationAtSrc = is.readBoolean();

    String temp = UTFReaderWriter.readUTF(is);

    if (temp.equals("")) {
        m_routeName = null;
    } else {
        m_routeName = temp;
    }

    temp = UTFReaderWriter.readUTF(is);
    if (temp.equals("")) {
        m_routeGUID = null;
    } else {
        m_routeGUID = temp;
    }

    m_iTimeToLive = is.readLong();

    temp = UTFReaderWriter.readUTF(is);
    if (temp.equals("")) {
        m_srcServInst = null;
    } else {
        m_srcServInst = temp;
    }

    temp = UTFReaderWriter.readUTF(is);
    if (temp.equals("")) {
        m_trgtServInst = null;
    } else {
        m_trgtServInst = temp;
    }

    temp = UTFReaderWriter.readUTF(is);
    if (temp.equals("")) {
        m_srcPortName = null;
    } else {
        m_srcPortName = temp;
    }

    temp = UTFReaderWriter.readUTF(is);
    if (temp.equals("")) {
        m_trgtPortName = null;
    } else {
        m_trgtPortName = temp;
    }

    temp = UTFReaderWriter.readUTF(is);
    if (temp.equals("")) {
        m_transformationXSL = null;
    } else {
        m_transformationXSL = temp;
    }

    int size = is.readInt();

    if (size > 0) {
        _readSelectorFromOldDmi(is, versionNo, size);
    } else if (size < 0) {
        _readSelector(is, versionNo);
    }

    int tempInt = 0;

    if ((tempInt = is.readInt()) != 0) {
        for (int i = 0; i < tempInt; i++) {
            Param param = new Param();

            param.fromStream(is, versionNo);
            m_params.add(param);
        }
    }

    temp = UTFReaderWriter.readUTF(is);
    if (temp.equals("")) {
        m_shortDescription = null;
    } else {
        m_shortDescription = temp;
    }

    temp = UTFReaderWriter.readUTF(is);
    if (temp.equals("")) {
        m_longDescription = null;
    } else {
        m_longDescription = temp;
    }

    if (is.readInt() == 1) {
        m_altDestination = new AlternateDestination();
        m_altDestination.fromStream(is, versionNo);
    }
}

From source file:hybridewah.HybridBitmap.java

/**
 * Deserialize./*from w  ww .j  a va 2  s .c  o  m*/
 * 
 * @param in
 *          the DataInput stream
 * @throws IOException
 *           Signals that an I/O exception has occurred.
 */
public void deserialize(DataInput in) throws IOException {
    this.sizeinbits = in.readInt();
    this.actualsizeinwords = in.readInt();
    if (this.buffer.length < this.actualsizeinwords) {
        this.buffer = new long[this.actualsizeinwords];
    }
    for (int k = 0; k < this.actualsizeinwords; ++k)
        this.buffer[k] = in.readLong();
    this.rlw = new RunningLengthWord(this.buffer, in.readInt());
}

From source file:com.fiorano.openesb.application.aps.ServiceInstance.java

/**
 *  This method reads this object <code>ServiceInstance</code> from the
 *  specified object of input stream.//from   ww  w.java2  s . co m
 *
 * @param is DataInput object
 * @param versionNo
 * @exception IOException if an error occurs while reading bytes or while
 *      converting them into specified Java primitive type.
 * @since Tifosi2.0
 */
public void fromStream(DataInput is, int versionNo) throws IOException {
    super.fromStream(is, versionNo);

    m_isManualLaunch = is.readBoolean();

    m_isStateful = is.readBoolean();

    m_isDelayedLaunch = is.readBoolean();

    String temp = UTFReaderWriter.readUTF(is);

    if (temp == null)
        m_delayedPortName = "";
    else
        m_delayedPortName = temp;

    m_isTransacted = is.readBoolean();

    m_isErrorHandlingEnabled = is.readBoolean();

    m_isVersionLocked = is.readBoolean();

    m_isEndOfWorkflow = is.readBoolean();

    m_isInMemoryLaunch = is.readBoolean();

    m_isTransportLPC = is.readBoolean();

    m_bPreferLaunchOnHigherLevelNode = is.readBoolean();

    m_bIsDurableSubscription = is.readBoolean();

    m_bIsDurableConnection = is.readBoolean();

    m_bKillPrimaryOnSecondaryLaunch = is.readBoolean();

    m_bIsDebugMode = is.readBoolean();

    m_iDebugPort = is.readInt();

    m_maxRetries = is.readInt();

    temp = UTFReaderWriter.readUTF(is);
    if (temp.equals(""))
        m_version = null;
    else
        m_version = temp;

    m_dBufferSizePerPort = is.readLong();

    temp = UTFReaderWriter.readUTF(is);
    if (temp.equals(""))
        m_servInstName = null;
    else
        m_servInstName = temp;

    temp = UTFReaderWriter.readUTF(is);
    if (temp.equals(""))
        m_servGUID = null;
    else
        m_servGUID = temp;

    temp = UTFReaderWriter.readUTF(is);
    if (temp.equals(""))
        m_longDescription = null;
    else
        m_longDescription = temp;

    temp = UTFReaderWriter.readUTF(is);
    if (temp.equals(""))
        m_shortDescription = null;
    else
        m_shortDescription = temp;

    // Service Dependency
    int tempInt = is.readInt();

    for (int i = 0; i < tempInt; ++i) {
        RuntimeDependency serv = new RuntimeDependency();

        serv.fromStream(is, versionNo);
        m_runtimeDependencies.addElement(serv);
    }

    tempInt = is.readInt();

    if (tempInt != 0) {
        m_runtimeArgs = new RuntimeArgs();
        m_runtimeArgs.fromStream(is, versionNo);
    }

    tempInt = is.readInt();
    if (tempInt != 0) {
        m_portInstDescriptor = new PortInstDescriptor();
        m_portInstDescriptor.fromStream(is, versionNo);
    }

    if ((tempInt = is.readInt()) != 0)
        for (int i = 0; i < tempInt; i++) {
            Param param = new Param();

            param.fromStream(is, versionNo);
            m_params.add(param);
        }

    tempInt = is.readInt();
    if (tempInt != 0) {
        m_statusTracking = new StatusTracking();
        m_statusTracking.fromStream(is, versionNo);
    }

    tempInt = is.readInt();

    if (tempInt != 0) {
        m_vecEndStates = new Vector();
        for (int i = 0; i < tempInt; i++) {
            EndState endState = new EndState();

            endState.fromStream(is, versionNo);
            m_vecEndStates.add(endState);

        }
    }

    tempInt = is.readInt();
    if (tempInt != 0)
        for (int i = 0; i < tempInt; i++)
            m_nodes.put(UTFReaderWriter.readUTF(is), UTFReaderWriter.readUTF(is));

    tempInt = is.readInt();
    if (tempInt != 0) {
        m_monitor = new Monitor();
        m_monitor.fromStream(is, versionNo);
    }

    tempInt = is.readInt();
    if (tempInt != 0) {
        m_logModules = new LogModules();
        m_logModules.fromStream(is, versionNo);
    }

    // Log Manager and log params
    m_logManager = readUTF(is);
    m_profile = readUTF(is);

    if ((tempInt = is.readInt()) != 0)
        for (int i = 0; i < tempInt; i++) {
            Param param = new Param();

            param.fromStream(is, versionNo);
            m_logParams.add(param);
        }

    //  Event Parameters.
    m_eventDeliveryMode = readUTF(is);
    m_eventExpiryTime = is.readLong();
    m_eventHandler = is.readInt();
}

From source file:bobs.is.compress.sevenzip.SevenZFile.java

private void readFilesInfo(final DataInput header, final Archive archive) throws IOException {
    final long numFiles = readUint64(header);
    final SevenZArchiveEntry[] files = new SevenZArchiveEntry[(int) numFiles];
    for (int i = 0; i < files.length; i++) {
        files[i] = new SevenZArchiveEntry();
    }/*  ww  w  .j a  v  a2  s .  co  m*/
    BitSet isEmptyStream = null;
    BitSet isEmptyFile = null;
    BitSet isAnti = null;
    while (true) {
        final int propertyType = header.readUnsignedByte();
        if (propertyType == 0) {
            break;
        }
        final long size = readUint64(header);
        switch (propertyType) {
        case NID.kEmptyStream: {
            isEmptyStream = readBits(header, files.length);
            break;
        }
        case NID.kEmptyFile: {
            if (isEmptyStream == null) { // protect against NPE
                throw new IOException("Header format error: kEmptyStream must appear before kEmptyFile");
            }
            isEmptyFile = readBits(header, isEmptyStream.cardinality());
            break;
        }
        case NID.kAnti: {
            if (isEmptyStream == null) { // protect against NPE
                throw new IOException("Header format error: kEmptyStream must appear before kAnti");
            }
            isAnti = readBits(header, isEmptyStream.cardinality());
            break;
        }
        case NID.kName: {
            final int external = header.readUnsignedByte();
            if (external != 0) {
                throw new IOException("Not implemented");
            }
            if (((size - 1) & 1) != 0) {
                throw new IOException("File names length invalid");
            }
            final byte[] names = new byte[(int) (size - 1)];
            header.readFully(names);
            int nextFile = 0;
            int nextName = 0;
            for (int i = 0; i < names.length; i += 2) {
                if (names[i] == 0 && names[i + 1] == 0) {
                    files[nextFile].setName(new String(names, nextName, i - nextName, CharsetNames.UTF_16LE));
                    nextName = i + 2;
                    this.mapFilename.put(files[nextFile].getName(), nextFile);
                    nextFile++;
                }
            }
            if (nextName != names.length || nextFile != files.length) {
                throw new IOException("Error parsing file names");
            }
            break;
        }
        case NID.kCTime: {
            final BitSet timesDefined = readAllOrBits(header, files.length);
            final int external = header.readUnsignedByte();
            if (external != 0) {
                throw new IOException("Unimplemented");
            }
            for (int i = 0; i < files.length; i++) {
                files[i].setHasCreationDate(timesDefined.get(i));
                if (files[i].getHasCreationDate()) {
                    files[i].setCreationDate(Long.reverseBytes(header.readLong()));
                }
            }
            break;
        }
        case NID.kATime: {
            final BitSet timesDefined = readAllOrBits(header, files.length);
            final int external = header.readUnsignedByte();
            if (external != 0) {
                throw new IOException("Unimplemented");
            }
            for (int i = 0; i < files.length; i++) {
                files[i].setHasAccessDate(timesDefined.get(i));
                if (files[i].getHasAccessDate()) {
                    files[i].setAccessDate(Long.reverseBytes(header.readLong()));
                }
            }
            break;
        }
        case NID.kMTime: {
            final BitSet timesDefined = readAllOrBits(header, files.length);
            final int external = header.readUnsignedByte();
            if (external != 0) {
                throw new IOException("Unimplemented");
            }
            for (int i = 0; i < files.length; i++) {
                files[i].setHasLastModifiedDate(timesDefined.get(i));
                if (files[i].getHasLastModifiedDate()) {
                    files[i].setLastModifiedDate(Long.reverseBytes(header.readLong()));
                }
            }
            break;
        }
        case NID.kWinAttributes: {
            final BitSet attributesDefined = readAllOrBits(header, files.length);
            final int external = header.readUnsignedByte();
            if (external != 0) {
                throw new IOException("Unimplemented");
            }
            for (int i = 0; i < files.length; i++) {
                files[i].setHasWindowsAttributes(attributesDefined.get(i));
                if (files[i].getHasWindowsAttributes()) {
                    files[i].setWindowsAttributes(Integer.reverseBytes(header.readInt()));
                }
            }
            break;
        }
        case NID.kStartPos: {
            throw new IOException("kStartPos is unsupported, please report");
        }
        case NID.kDummy: {
            // 7z 9.20 asserts the content is all zeros and ignores the property
            // Compress up to 1.8.1 would throw an exception, now we ignore it (see COMPRESS-287

            if (skipBytesFully(header, size) < size) {
                throw new IOException("Incomplete kDummy property");
            }
            break;
        }

        default: {
            // Compress up to 1.8.1 would throw an exception, now we ignore it (see COMPRESS-287
            if (skipBytesFully(header, size) < size) {
                throw new IOException("Incomplete property of type " + propertyType);
            }
            break;
        }
        }
    }
    int nonEmptyFileCounter = 0;
    int emptyFileCounter = 0;
    for (int i = 0; i < files.length; i++) {
        files[i].setHasStream(isEmptyStream == null ? true : !isEmptyStream.get(i));
        if (files[i].hasStream()) {
            files[i].setDirectory(false);
            files[i].setAntiItem(false);
            files[i].setHasCrc(archive.subStreamsInfo.hasCrc.get(nonEmptyFileCounter));
            files[i].setCrcValue(archive.subStreamsInfo.crcs[nonEmptyFileCounter]);
            files[i].setSize(archive.subStreamsInfo.unpackSizes[nonEmptyFileCounter]);
            ++nonEmptyFileCounter;
        } else {
            files[i].setDirectory(isEmptyFile == null ? true : !isEmptyFile.get(emptyFileCounter));
            files[i].setAntiItem(isAnti == null ? false : isAnti.get(emptyFileCounter));
            files[i].setHasCrc(false);
            files[i].setSize(0);

            ++emptyFileCounter;
        }
    }
    archive.files = files;
    calculateStreamMap(archive);
}

From source file:com.ibm.bi.dml.runtime.matrix.data.MatrixBlock.java

/**
 * //www .  j  av a 2s  .  c  o m
 * @param in
 * @throws IOException
 */
private long readNnzInfo(DataInput in, boolean ultrasparse) throws IOException {
    //note: if ultrasparse, int always sufficient because nnz<rlen
    // where rlen is limited to integer

    long lrlen = (long) rlen;
    long lclen = (long) clen;

    //read long if required, otherwise int (see writeNnzInfo, consistency required)
    if (lrlen * lclen > Integer.MAX_VALUE && !ultrasparse) {
        nonZeros = in.readLong();
    } else {
        nonZeros = in.readInt();
    }

    return nonZeros;
}

From source file:org.apache.bigtop.bigpetstore.generator.PetStoreTransactionInputSplit.java

public void readFields(DataInput dataInputStream) throws IOException {
    records = dataInputStream.readInt();
    state = State.valueOf(dataInputStream.readUTF());
    customerIdRange = Range.between(dataInputStream.readLong(), dataInputStream.readLong());
}

From source file:org.apache.carbondata.core.metadata.blocklet.BlockletInfo.java

@Override
public void readFields(DataInput input) throws IOException {
    dimensionOffset = input.readLong();
    measureOffsets = input.readLong();/*from   ww w.  ja v  a2s.  c om*/
    int dimensionChunkOffsetsSize = input.readShort();
    dimensionChunkOffsets = new ArrayList<>(dimensionChunkOffsetsSize);
    for (int i = 0; i < dimensionChunkOffsetsSize; i++) {
        dimensionChunkOffsets.add(input.readLong());
    }
    dimensionChunksLength = new ArrayList<>(dimensionChunkOffsetsSize);
    for (int i = 0; i < dimensionChunkOffsetsSize; i++) {
        dimensionChunksLength.add(input.readInt());
    }

    short measureChunkOffsetsSize = input.readShort();
    measureChunkOffsets = new ArrayList<>(measureChunkOffsetsSize);
    for (int i = 0; i < measureChunkOffsetsSize; i++) {
        measureChunkOffsets.add(input.readLong());
    }
    measureChunksLength = new ArrayList<>(measureChunkOffsetsSize);
    for (int i = 0; i < measureChunkOffsetsSize; i++) {
        measureChunksLength.add(input.readInt());
    }
    readChunkInfoForOlderVersions(input);
    final boolean isSortedPresent = input.readBoolean();
    if (isSortedPresent) {
        this.isSorted = input.readBoolean();
    }
    numberOfRowsPerPage = new int[input.readShort()];
    for (int i = 0; i < numberOfRowsPerPage.length; i++) {
        numberOfRowsPerPage[i] = input.readInt();
    }
}

From source file:org.apache.cassandra.db.TimestampClock.java

public IClock deserialize(DataInput in) throws IOException {
    return new TimestampClock(in.readLong());
}

From source file:org.apache.geode.internal.cache.Oplog.java

/**
 * @throws DiskAccessException if this file does not belong to our parent
 *//* w w w .j  a v a 2 s  .  co  m*/
private void readDiskStoreRecord(DataInput dis, File f) throws IOException {
    long leastSigBits = dis.readLong();
    long mostSigBits = dis.readLong();
    DiskStoreID readDSID = new DiskStoreID(mostSigBits, leastSigBits);
    if (logger.isTraceEnabled(LogMarker.PERSIST_RECOVERY)) {
        logger.trace(LogMarker.PERSIST_RECOVERY, "diskStoreId={}", readDSID);
    }
    readEndOfRecord(dis);
    DiskStoreID dsid = getParent().getDiskStoreID();
    if (!readDSID.equals(dsid)) {
        throw new DiskAccessException("The oplog file \"" + f + "\" does not belong to the init file \""
                + getParent().getInitFile() + "\".", getParent());
    }
}

From source file:org.apache.geode.internal.InternalDataSerializer.java

/** read a set of Long objects */
public static Set<Long> readSetOfLongs(DataInput in) throws IOException {
    int size = in.readInt();
    if (size < 0) {
        return null;
    } else {// ww w . ja  v a 2  s.  c o  m
        Set result = new HashSet(size);
        boolean longIDs = in.readBoolean();
        for (int i = 0; i < size; i++) {
            long l = longIDs ? in.readLong() : in.readInt();
            result.add(l);
        }
        return result;
    }
}