Java Code Examples for java.io.ObjectInputStream#readInt()

The following examples show how to use java.io.ObjectInputStream#readInt() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ObjectTable.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Restores a serialized object.
 *
 * @param stream the input stream.
 * @throws java.io.IOException    if there is an I/O problem.
 * @throws ClassNotFoundException if a class cannot be found.
 */
private void readObject( final ObjectInputStream stream )
  throws IOException, ClassNotFoundException {
  stream.defaultReadObject();
  final int rowCount = stream.readInt();
  this.data = new Object[ rowCount ][];
  for ( int r = 0; r < rowCount; r++ ) {
    final boolean isNotNull = stream.readBoolean();
    if ( isNotNull ) {
      final int columnCount = stream.readInt();
      final Object[] column = new Object[ columnCount ];
      this.data[ r ] = column;
      for ( int c = 0; c < columnCount; c++ ) {
        column[ c ] = readSerializedData( stream );
      }
    }
  }
}
 
Example 2
Source File: RecurrentLayer.java    From CupDnn with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void loadModel(ObjectInputStream in) {
	// TODO Auto-generated method stub
	try {
		seqLen = in.readInt();
		inSize = in.readInt();
		hidenSize = in.readInt();
		String type = in.readUTF();
		if(type.equals("RNN")) {
			this.type = RecurrentType.RNN;
			mCell = new RnnCell(mNetwork,RecurrentLayer.this);
			mCell.loadModel(in);
		}
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
Example 3
Source File: CustomObjTrees.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
private void readObject(ObjectInputStream in)
    throws IOException, ClassNotFoundException
{
    z = in.readBoolean();
    b = in.readByte();
    c = in.readChar();
    s = in.readShort();
    i = in.readInt();
    f = in.readFloat();
    j = in.readLong();
    d = in.readDouble();
    str = (String) in.readObject();
    parent = in.readObject();
    left = in.readObject();
    right = in.readObject();
}
 
Example 4
Source File: HopRowCoder.java    From hop with Apache License 2.0 6 votes vote down vote up
@Override public HopRow decode( InputStream inStream ) throws CoderException, IOException {

    ObjectInputStream in = new ObjectInputStream( inStream );

    Object[] row = null;
    int length = in.readInt();
    if ( length < 0 ) {
      return new HopRow( row );
    }
    row = new Object[ length ];
    for ( int i = 0; i < length; i++ ) {
      // Null?
      boolean isNull = in.readBoolean();
      if ( !isNull ) {
        int objectType = in.readInt();
        Object object = read( in, objectType );
        row[ i ] = object;
      }
    }

    return new HopRow( row );
  }
 
Example 5
Source File: AbstractAction.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private void readObject(ObjectInputStream s) throws ClassNotFoundException,
    IOException {
    s.defaultReadObject();
    for (int counter = s.readInt() - 1; counter >= 0; counter--) {
        putValue((String)s.readObject(), s.readObject());
    }
}
 
Example 6
Source File: CodeRegionCPUResultsResponse.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
void readObject(ObjectInputStream in) throws IOException {
    int len = in.readInt();
    results = new long[len];

    for (int i = 0; i < len; i++) {
        results[i] = in.readLong();
    }
}
 
Example 7
Source File: GetClassFileBytesCommand.java    From netbeans with Apache License 2.0 5 votes vote down vote up
void readObject(ObjectInputStream in) throws IOException {
    int nClasses = in.readInt();

    if (nClasses == 0) {
        return;
    }

    classes = new String[nClasses];
    classLoaderIds = new int[nClasses];

    for (int i = 0; i < nClasses; i++) {
        classes[i] = in.readUTF().replace('/', '.');    // NOI18N
        classLoaderIds[i] = in.readInt();
    }
}
 
Example 8
Source File: DefaultDrawingSupplier.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Restores a serialized object.
 *
 * @param stream  the input stream.
 *
 * @throws IOException if there is an I/O problem.
 * @throws ClassNotFoundException if there is a problem loading a class.
 */
private void readObject(ObjectInputStream stream)
    throws IOException, ClassNotFoundException {
    stream.defaultReadObject();

    int paintCount = stream.readInt();
    this.paintSequence = new Paint[paintCount];
    for (int i = 0; i < paintCount; i++) {
        this.paintSequence[i] = SerialUtilities.readPaint(stream);
    }

    int outlinePaintCount = stream.readInt();
    this.outlinePaintSequence = new Paint[outlinePaintCount];
    for (int i = 0; i < outlinePaintCount; i++) {
        this.outlinePaintSequence[i] = SerialUtilities.readPaint(stream);
    }

    int strokeCount = stream.readInt();
    this.strokeSequence = new Stroke[strokeCount];
    for (int i = 0; i < strokeCount; i++) {
        this.strokeSequence[i] = SerialUtilities.readStroke(stream);
    }

    int outlineStrokeCount = stream.readInt();
    this.outlineStrokeSequence = new Stroke[outlineStrokeCount];
    for (int i = 0; i < outlineStrokeCount; i++) {
        this.outlineStrokeSequence[i] = SerialUtilities.readStroke(stream);
    }

    int shapeCount = stream.readInt();
    this.shapeSequence = new Shape[shapeCount];
    for (int i = 0; i < shapeCount; i++) {
        this.shapeSequence[i] = SerialUtilities.readShape(stream);
    }

}
 
Example 9
Source File: UintMap.java    From openbd-core with GNU General Public License v3.0 5 votes vote down vote up
private void readObject(ObjectInputStream in)
    throws IOException, ClassNotFoundException
{
    in.defaultReadObject();

    int writtenKeyCount = keyCount;
    if (writtenKeyCount != 0) {
        keyCount = 0;
        boolean hasIntValues = in.readBoolean();
        boolean hasObjectValues = in.readBoolean();

        int N = 1 << power;
        if (hasIntValues) {
            keys = new int[2 * N];
            ivaluesShift = N;
        }else {
            keys = new int[N];
        }
        for (int i = 0; i != N; ++i) {
            keys[i] = EMPTY;
        }
        if (hasObjectValues) {
            values = new Object[N];
        }
        for (int i = 0; i != writtenKeyCount; ++i) {
            int key = in.readInt();
            int index = insertNewKey(key);
            if (hasIntValues) {
                int ivalue = in.readInt();
                keys[ivaluesShift + index] = ivalue;
            }
            if (hasObjectValues) {
                values[index] = in.readObject();
            }
        }
    }
}
 
Example 10
Source File: LinkedList.java    From jtransc with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private void readObject(ObjectInputStream stream) throws IOException,
        ClassNotFoundException {
    stream.defaultReadObject();
    size = stream.readInt();
    voidLink = new Link<E>(null, null, null);
    Link<E> link = voidLink;
    for (int i = size; --i >= 0;) {
        Link<E> nextLink = new Link<E>((E) stream.readObject(), link, null);
        link.next = nextLink;
        link = nextLink;
    }
    link.next = voidLink;
    voidLink.previous = link;
}
 
Example 11
Source File: SimpleTimeZone.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Reconstitute this object from a stream (i.e., deserialize it).
 *
 * We handle both JDK 1.1
 * binary formats and full formats with a packed byte array.
 */
private void readObject(ObjectInputStream stream)
     throws IOException, ClassNotFoundException
{
    stream.defaultReadObject();

    if (serialVersionOnStream < 1) {
        // Fix a bug in the 1.1 SimpleTimeZone code -- namely,
        // startDayOfWeek and endDayOfWeek were usually uninitialized.  We can't do
        // too much, so we assume SUNDAY, which actually works most of the time.
        if (startDayOfWeek == 0) {
            startDayOfWeek = Calendar.SUNDAY;
        }
        if (endDayOfWeek == 0) {
            endDayOfWeek = Calendar.SUNDAY;
        }

        // The variables dstSavings, startMode, and endMode are post-1.1, so they
        // won't be present if we're reading from a 1.1 stream.  Fix them up.
        startMode = endMode = DOW_IN_MONTH_MODE;
        dstSavings = millisPerHour;
    } else {
        // For 1.1.4, in addition to the 3 new instance variables, we also
        // store the actual rules (which have not be made compatible with 1.1)
        // in the optional area.  Read them in here and parse them.
        int length = stream.readInt();
        byte[] rules = new byte[length];
        stream.readFully(rules);
        unpackRules(rules);
    }

    if (serialVersionOnStream >= 2) {
        int[] times = (int[]) stream.readObject();
        unpackTimes(times);
    }

    serialVersionOnStream = currentSerialVersion;
}
 
Example 12
Source File: InstrumentMethodGroupCommand.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
void readObject(ObjectInputStream in) throws IOException {
    instrType = in.readInt();

    if (!isEmpty()) {
        b.readObject(in);
    }
}
 
Example 13
Source File: TDoubleDoubleHashMap.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
private void readObject(ObjectInputStream stream)
    throws IOException, ClassNotFoundException {
    stream.defaultReadObject();

    int size = stream.readInt();
    setUp(size);
    while (size-- > 0) {
        double key = stream.readDouble();
        double val = stream.readDouble();
        put(key, val);
    }
}
 
Example 14
Source File: PaintList.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Provides serialization support.
 *
 * @param stream  the input stream.
 *
 * @throws IOException  if there is an I/O error.
 * @throws ClassNotFoundException  if there is a classpath problem.
 */
private void readObject(final ObjectInputStream stream) throws IOException, ClassNotFoundException {

    stream.defaultReadObject();
    final int count = stream.readInt();
    for (int i = 0; i < count; i++) {
        final int index = stream.readInt();
        if (index != -1) {
            setPaint(index, SerialUtilities.readPaint(stream));
        }
    }
    
}
 
Example 15
Source File: DiskBasedCache.java    From android_tv_metro with Apache License 2.0 5 votes vote down vote up
/**
 * @return a string to string map which contains the entries read from {@code ois}
 *     previously written by {@link #writeStringStringMap}
 */
private static Map<String, String> readStringStringMap(ObjectInputStream ois)
        throws IOException {
    int size = ois.readInt();
    Map<String, String> result = (size == 0)
            ? Collections.<String, String>emptyMap()
            : new HashMap<String, String>(size);
    for (int i = 0; i < size; i++) {
        String key = ois.readUTF().intern();
        String value = ois.readUTF().intern();
        result.put(key, value);
    }
    return result;
}
 
Example 16
Source File: GetDefiningClassLoaderCommand.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
void readObject(ObjectInputStream in) throws IOException {
    className = in.readUTF();
    classLoaderId = in.readInt();
}
 
Example 17
Source File: Serialization.java    From codebuff with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * Populates a map by reading an input stream, as part of deserialization.
 * See {@link #writeMap} for the data format.
 */

static <K, V> void populateMap(Map<K, V> map, ObjectInputStream stream) throws IOException, ClassNotFoundException {
  int size = stream.readInt();
  populateMap(map, stream, size);
}
 
Example 18
Source File: MapMakerInternalMap.java    From codebuff with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@SuppressWarnings("deprecation") // serialization of deprecated feature
MapMaker readMapMaker(ObjectInputStream in) throws IOException {
  int size = in.readInt();
  return new MapMaker().initialCapacity(size).setKeyStrength(keyStrength).setValueStrength(valueStrength).keyEquivalence(keyEquivalence).concurrencyLevel(concurrencyLevel);
}
 
Example 19
Source File: StringBuilder.java    From juniversal with MIT License 3 votes vote down vote up
/**
 * Reads the state of a {@code StringBuilder} from the passed stream and
 * restores it to this instance.
 *
 * @param in
 *            the stream to read the state from.
 * @throws IOException
 *             if the stream throws it during the read.
 * @throws ClassNotFoundException
 *             if the stream throws it during the read.
 */
private void readObject(ObjectInputStream in) throws IOException,
        ClassNotFoundException {
    in.defaultReadObject();
    int count = in.readInt();
    char[] value = (char[]) in.readObject();
    set(value, count);
}
 
Example 20
Source File: BeanContextServicesSupport.java    From TencentKona-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * called from BeanContextSupport readObject before it deserializes the
 * children ...
 *
 * This class will deserialize any Serializable BeanContextServiceProviders
 * serialized earlier thus making them available to the children when they
 * deserialized.
 *
 * subclasses may envelope this method to insert their own serialization
 * processing that has to occur prior to serialization of the children
 */

protected synchronized void bcsPreDeserializationHook(ObjectInputStream ois) throws IOException, ClassNotFoundException {

    serializable = ois.readInt();

    int count = serializable;

    while (count > 0) {
        services.put(ois.readObject(), ois.readObject());
        count--;
    }
}