public void restoreFromStream(final ByteArrayInputStream bis) throws IOException, ClassNotFoundException {
  final ObjectInput os=new ObjectInputStream(bis);
  final int size=(Integer)os.readObject();
  max_size=size;
  items=new Object[size];
  Object nextObject;
  Integer type;
  for (int i=0; i < size; i++) {
    type=(Integer)os.readObject();
    if (type.compareTo(BASICSTROKE) == 0) {
      final float w=os.readFloat();
      final int current_line_cap_style=os.readInt();
      final int current_line_join_style=os.readInt();
      final float mitre_limit=os.readFloat();
      final float[] current_line_dash_array=(float[])os.readObject();
      final float current_line_dash_phase=os.readFloat();
      nextObject=new BasicStroke(w,current_line_cap_style,current_line_join_style,mitre_limit,current_line_dash_array,current_line_dash_phase);
    }
 else     if (type.compareTo(RECT) == 0) {
      final float x=os.readFloat();
      final float y=os.readFloat();
      final float w=os.readFloat();
      final float h=os.readFloat();
      nextObject=new Rectangle2D.Float(x,y,w,h);
    }
 else     if (type.compareTo(BUFFERED_IMAGE) == 0) {
      final byte[] bytes=(byte[])os.readObject();
      nextObject=DefaultImageHelper.read(bytes);
    }
 else     if (type.compareTo(GENERAL_PATH) == 0) {
      nextObject=PathSerializer.deserializePath(os);
    }
 else     if (type.compareTo(T1GLYPH) == 0) {
      final T1Glyph glyph=(T1Glyph)os.readObject();
      final int count=(Integer)os.readObject();
      final GeneralPath[] paths=new GeneralPath[count];
      for (int j=0; j < count; j++) {
        paths[j]=PathSerializer.deserializePath(os);
      }
      final Vector_Path vp=new Vector_Path();
      vp.set(paths);
      vp.setCurrent_item(paths.length);
      glyph.setPaths(vp);
      nextObject=glyph;
    }
 else     if (type.compareTo(TTGLYPH) == 0) {
      final TTGlyph glyph=(TTGlyph)os.readObject();
      final int count=(Integer)os.readObject();
      final GeneralPath[] paths=new GeneralPath[count];
      for (int j=0; j < count; j++) {
        paths[j]=PathSerializer.deserializePath(os);
      }
      final Vector_Path vp=new Vector_Path();
      vp.set(paths);
      vp.setCurrent_item(paths.length);
      glyph.setPaths(vp);
      nextObject=glyph;
    }
 else     if (type.compareTo(T3GLYPH) == 0) {
      nextObject=new T3Glyph(os);
    }
 else     if (type.compareTo(TEXTUREDPAINT) == 0) {
      final byte[] bytes=(byte[])os.readObject();
      final BufferedImage img=DefaultImageHelper.read(bytes);
      final float x=os.readFloat();
      final float y=os.readFloat();
      final float w=os.readFloat();
      final float h=os.readFloat();
      final Rectangle2D anchor=new Rectangle2D.Float(x,y,w,h);
      nextObject=new PdfTexturePaint(img,anchor);
    }
 else     if (type.compareTo(AREA) == 0) {
      final GeneralPath path=PathSerializer.deserializePath(os);
      nextObject=new Area(path);
    }
 else {
      nextObject=os.readObject();
    }
    items[i]=nextObject;
  }
}

public void restoreFromStream ( final ByteArrayInputStream bis ) throws IOException , ClassNotFoundException { final ObjectInput os = new ObjectInputStream ( bis ) ; final int size = ( Integer ) os . readObject ( ) ; max_size = size ; items = new Object [ size ] ; Object nextObject ; Integer type ; for ( int i = 0 ; i < size ; i ++ ) { type = ( Integer ) os . readObject ( ) ; if ( type . compareTo ( BASICSTROKE ) == 0 ) { final float w = os . readFloat ( ) ; final int current_line_cap_style = os . readInt ( ) ; final int current_line_join_style = os . readInt ( ) ; final float mitre_limit = os . readFloat ( ) ; final float [ ] current_line_dash_array = ( float [ ] ) os . readObject ( ) ; final float current_line_dash_phase = os . readFloat ( ) ; nextObject = new BasicStroke ( w , current_line_cap_style , current_line_join_style , mitre_limit , current_line_dash_array , current_line_dash_phase ) ; } else if ( type . compareTo ( RECT ) == 0 ) { final float x = os . readFloat ( ) ; final float y = os . readFloat ( ) ; final float w = os . readFloat ( ) ; final float h = os . readFloat ( ) ; nextObject = new Rectangle2D . Float ( x , y , w , h ) ; } else if ( type . compareTo ( BUFFERED_IMAGE ) == 0 ) { final byte [ ] bytes = ( byte [ ] ) os . readObject ( ) ; nextObject = DefaultImageHelper . read ( bytes ) ; } else if ( type . compareTo ( GENERAL_PATH ) == 0 ) { nextObject = PathSerializer . deserializePath ( os ) ; } else if ( type . compareTo ( T1GLYPH ) == 0 ) { final T1Glyph glyph = ( T1Glyph ) os . readObject ( ) ; final int count = ( Integer ) os . readObject ( ) ; final GeneralPath [ ] paths = new GeneralPath [ count ] ; for ( int j = 0 ; j < count ; j ++ ) { paths [ j ] = PathSerializer . deserializePath ( os ) ; } final Vector_Path vp = new Vector_Path ( ) ; vp . set ( paths ) ; vp . setCurrent_item ( paths . length ) ; glyph . setPaths ( vp ) ; nextObject = glyph ; } else if ( type . compareTo ( TTGLYPH ) == 0 ) { final TTGlyph glyph = ( TTGlyph ) os . readObject ( ) ; final int count = ( Integer ) os . readObject ( ) ; final GeneralPath [ ] paths = new GeneralPath [ count ] ; for ( int j = 0 ; j < count ; j ++ ) { paths [ j ] = PathSerializer . deserializePath ( os ) ; } final Vector_Path vp = new Vector_Path ( ) ; vp . set ( paths ) ; vp . setCurrent_item ( paths . length ) ; glyph . setPaths ( vp ) ; nextObject = glyph ; } else if ( type . compareTo ( T3GLYPH ) == 0 ) { nextObject = new T3Glyph ( os ) ; } else if ( type . compareTo ( TEXTUREDPAINT ) == 0 ) { final byte [ ] bytes = ( byte [ ] ) os . readObject ( ) ; final BufferedImage img = DefaultImageHelper . read ( bytes ) ; final float x = os . readFloat ( ) ; final float y = os . readFloat ( ) ; final float w = os . readFloat ( ) ; final float h = os . readFloat ( ) ; final Rectangle2D anchor = new Rectangle2D . Float ( x , y , w , h ) ; nextObject = new PdfTexturePaint ( img , anchor ) ; } else if ( type . compareTo ( AREA ) == 0 ) { final GeneralPath path = PathSerializer . deserializePath ( os ) ; nextObject = new Area ( path ) ; } else { nextObject = os . readObject ( ) ; } items [ i ] = nextObject ; } }
method to deserialize each object in the input stream not part of api and subject to change ( do not use )
