Example usage for java.io ObjectInputStream readInt

List of usage examples for java.io ObjectInputStream readInt

Introduction

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

Prototype

public int readInt() throws IOException 

Source Link

Document

Reads a 32 bit int.

Usage

From source file:edu.stanford.muse.datacache.BlobStore.java

private synchronized void unpack_from_stream(ObjectInputStream ois) throws IOException, ClassNotFoundException {
    uniqueBlobs = (Set<Blob>) ois.readObject();
    id_map = (Map<Blob, Integer>) ois.readObject();
    views = (Map<Blob, Map<String, Object>>) ois.readObject();
    next_data_id = ois.readInt();
}

From source file:IntObjectHashMap.java

/**
 * Reconstitute the <tt>IntObjectHashMap</tt> instance from a stream (i.e.,
 * deserialize it).//  w  w  w  .  java 2s. c  o  m
 */
private void readObject(java.io.ObjectInputStream s) throws IOException, ClassNotFoundException {
    // Read in the threshold, loadfactor, and any hidden stuff
    s.defaultReadObject();

    // Read in number of buckets and allocate the bucket array;
    int numBuckets = s.readInt();
    table = new Entry[numBuckets];

    // Read in size (number of Mappings)
    int size = s.readInt();

    // Read the keys and values, and put the mappings in the IntObjectHashMap
    for (int i = 0; i < size; i++) {
        int key = s.readInt();
        Object value = s.readObject();
        putForCreate(key, value);
    }
}

From source file:org.objectweb.proactive.core.remoteobject.RemoteObjectSet.java

/**
 * Update the protocol order from the new ProActive Runtime
 * when the remote remote object is reified
 */// w  ww. jav a 2  s. com
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
    in.defaultReadObject();
    int size = in.readInt();
    ReentrantReadWriteLock.WriteLock wl = rwlock.writeLock();
    wl.lock();
    this.rros = new LinkedHashMap<URI, RemoteRemoteObject>(size);
    this.sortedrros = new ArrayList<URI>();
    this.lastBenchmarkResults = new ConcurrentHashMap<URI, Integer>();

    // read protocols
    for (int i = 0; i < size; i++) {
        Map.Entry<URI, RemoteRemoteObject> entry = readProtocol(in);
        if (entry != null) {
            URI uri = entry.getKey();
            RemoteRemoteObject rro = entry.getValue();
            if (i == 0) {
                // default protocol is the first one
                this.defaultURI = uri;
                this.defaultRO = rro;
            }
            this.rros.put(uri, rro);
            sortedrros.add(uri);
            lastBenchmarkResults.put(uri, size - i);
        }
    }
    wl.unlock();
    sortProtocolsInternal();

    if (LOGGER_RO.isDebugEnabled()) {
        LOGGER_RO.debug("[ROAdapter] read RemoteObjectSet " + sortedrros);
    }

    VMID testLocal = ProActiveRuntimeImpl.getProActiveRuntime().getVMInformation().getVMID();
    if (!vmid.equals(testLocal)) {
        this.vmid = testLocal;
        this.startBenchmark();
    }
}

From source file:mitm.application.djigzo.james.Certificates.java

private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    try {/* w w w  . j  a va  2s. c  om*/
        CertificateFactory certificateFactory = SecurityFactoryFactory.getSecurityFactory()
                .createCertificateFactory("X.509");

        certificates = new HashSet<X509Certificate>();

        long version = in.readLong();

        if (version != serialVersionUID) {
            throw new SerializationException("Version expected '" + serialVersionUID + "' but got '" + version);
        }

        /*
         * Read how many certificates we have to read.
         */
        int nrOfCertificates = in.readInt();

        for (int i = 0; i < nrOfCertificates; i++) {
            int encodedSize = in.readInt();

            byte[] encoded = new byte[encodedSize];

            in.readFully(encoded);

            X509Certificate certificate = (X509Certificate) certificateFactory
                    .generateCertificate(new ByteArrayInputStream(encoded));

            certificates.add(certificate);
        }
    } catch (NoSuchProviderException e) {
        throw new NoSuchProviderRuntimeException(e);
    } catch (CertificateException e) {
        throw new IOException(e);
    } catch (SecurityFactoryFactoryException e) {
        throw new IOException(e);
    }
}

From source file:it.scoppelletti.programmerpower.wui.DefaultActivity.java

/**
 * Deserializza l&rsquo;oggetto.//from  w  w w.  j a v a 2  s.  c o m
 * 
 * @param in Flusso di lettura.
 */
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    int i, n;
    String catg;

    in.defaultReadObject();

    try {
        if (Strings.isNullOrEmpty(myTitle)) {
            throw new PropertyNotSetException(getClass().getName(), "title");
        }
        if (Strings.isNullOrEmpty(myActivityUrl)) {
            throw new PropertyNotSetException(getClass().getName(), "activityURL");
        }
        if (Strings.isNullOrEmpty(myIconUrl)) {
            throw new PropertyNotSetException(getClass().getName(), "iconURL");
        }

        n = in.readInt();
        myCategories = new HashSet<String>(1);
        for (i = 0; i < n; i++) {
            catg = (String) in.readObject();
            myCategories.add(catg);
        }
    } catch (Exception ex) {
        throw new DeserializeException(ex);
    }
}

From source file:net.sf.jasperreports.engine.base.JRVirtualPrintPage.java

private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
    Object object = in.readObject();
    if (object instanceof VirtualizableElementList) {
        elements = (VirtualizableElementList) object;
    } else {/*from   w ww  .  j  a v  a  2s .c  o m*/
        // page serialized by old version
        String oldUid = (String) object;
        if (log.isDebugEnabled()) {
            log.debug("Original page uid " + oldUid);
        }

        JRVirtualizationContext virtualizationContext = (JRVirtualizationContext) in.readObject();

        int length = in.readInt();
        byte[] buffer = new byte[length];
        in.readFully(buffer);
        ByteArrayInputStream inputStream = new ByteArrayInputStream(buffer, 0, buffer.length);
        VirtualizationObjectInputStream elementsStream = new VirtualizationObjectInputStream(inputStream,
                virtualizationContext);
        try {
            @SuppressWarnings("unchecked")
            List<JRPrintElement> elementsList = (List<JRPrintElement>) elementsStream.readObject();

            // create a new list for the elements
            elements = new VirtualizableElementList(virtualizationContext, this);
            elements.addAll(elementsList);
        } finally {
            elementsStream.close();
        }
    }
}

From source file:it.unimi.di.big.mg4j.document.TRECDocumentCollection.java

private void readObject(final ObjectInputStream s) throws IOException, ClassNotFoundException {
    s.defaultReadObject();//from w w w  . ja v  a  2  s.c  om

    final long size = s.readLong();
    final ObjectBigArrayBigList<TRECDocumentDescriptor> descriptors = new ObjectBigArrayBigList<TRECDocumentDescriptor>();
    descriptors.ensureCapacity(size);
    for (int i = 0; i < size; i++)
        descriptors.add(new TRECDocumentDescriptor(s.readInt(), s.readLong(), s.readInt(), s.readInt()));
    this.descriptors = descriptors;
}

From source file:tvbrowser.core.Settings.java

private static void loadWindowSettings() {
    File windowSettingsFile = new File(Settings.getUserSettingsDirName(), WINDOW_SETTINGS_FILE);

    if (windowSettingsFile.isFile() && windowSettingsFile.canRead()) {
        try {/*from  w  w w  . ja  v  a 2  s .  c  om*/
            StreamUtilities.objectInputStream(windowSettingsFile, new ObjectInputStreamProcessor() {
                public void process(ObjectInputStream in) throws IOException {
                    if (in.available() > 0) {
                        in.readInt(); // read version

                        int n = in.readInt(); // read number of window settings

                        mWindowSettings = new HashMap<String, WindowSetting>(n);

                        for (int i = 0; i < n; i++) {
                            mWindowSettings.put(in.readUTF(), new WindowSetting(in));
                        }
                    }

                    in.close();
                }
            });
        } catch (Exception e) {
            // propably defect settings, create new settings
            mWindowSettings = null;
        }
    }

    if (mWindowSettings == null) {
        mWindowSettings = new HashMap<String, WindowSetting>(1);
    }
}

From source file:fr.pasteque.pos.ticket.TicketInfo.java

/** Deserialize as shared ticket */
public TicketInfo(byte[] data) throws IOException {
    ByteArrayInputStream bis = new ByteArrayInputStream(data);
    ObjectInputStream in = new ObjectInputStream(bis);
    try {/*from  w w w.  j a v  a  2 s.  c  o m*/
        m_sId = (String) in.readObject();
        tickettype = in.readInt();
        m_iTicketId = in.readInt();
        m_Customer = (CustomerInfoExt) in.readObject();
        m_dDate = (Date) in.readObject();
        attributes = (Properties) in.readObject();
        m_aLines = (List<TicketLineInfo>) in.readObject();
        this.customersCount = (Integer) in.readObject();
        this.tariffAreaId = (Integer) in.readObject();
        this.discountProfileId = (Integer) in.readObject();
        this.discountRate = in.readDouble();
    } catch (ClassNotFoundException cnfe) {
        // Should never happen
        cnfe.printStackTrace();
    }
    in.close();
    m_User = null;
    m_sActiveCash = null;

    payments = new ArrayList<PaymentInfo>();
    taxes = null;
}

From source file:org.largecollections.MapFactory.java

private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
    this.folder = (String) in.readObject();
    this.name = (String) in.readObject();
    this.cacheSize = in.readInt();

    this.bloomFilterSize = in.readInt();
    this.bloomFilter = (BloomFilter<K>) in.readObject();
    this.myMaps = (Map<String, Map<K, V>>) in.readObject();
    Map m = DBUtils.createDB(this.folder, this.name, this.cacheSize);
    this.db = (DB) m.get(Constants.DB_KEY);
    this.options = (Options) m.get(Constants.DB_OPTIONS_KEY);
    this.dbFile = (File) m.get(Constants.DB_FILE_KEY);
    for (Map.Entry<String, Map<K, V>> e : this.myMaps.entrySet()) {
        ((InnerMap) e.getValue()).setDb(this.db);
        ((InnerMap) e.getValue()).setBloomFilter(this.bloomFilter);
    }/*  w w  w. ja  v  a  2 s . c o m*/
}