question: private void process ( ) { while ( reader . getPointer ( ) < reader . getTotalBitLen ( ) ) { int flag = reader . getPositive ( bitsPerFlag ) ; Point2D p = getPointCoords ( ) ; float [ ] cc = { 1f , 1f , 1f , 1f } ; for ( int z = 0 ; z < colCompCount ; z ++ ) { cc [ z ] = reader . getFloat ( bitsPerComponent ) ; } Color c = new Color ( cc [ 0 ] , cc [ 1 ] , cc [ 2 ] , cc [ 3 ] ) ; switch ( flag ) { case 0 : break ; case 1 : Point2D temp [ ] = new Point2D [ 2 ] ; temp [ 0 ] = triangles . get ( triangles . size ( ) - 2 ) ; temp [ 1 ] = triangles . get ( triangles . size ( ) - 1 ) ; triangles . addAll ( Arrays . asList ( temp ) ) ; Color tc [ ] = new Color [ 2 ] ; tc [ 0 ] = triColors . get ( triColors . size ( ) - 2 ) ; tc [ 1 ] = triColors . get ( triColors . size ( ) - 1 ) ; triColors . addAll ( Arrays . asList ( tc ) ) ; break ; case 2 : Point2D ff [ ] = new Point2D [ 2 ] ; ff [ 0 ] = triangles . get ( triangles . size ( ) - 3 ) ; ff [ 1 ] = triangles . get ( triangles . size ( ) - 1 ) ; triangles . addAll ( Arrays . asList ( ff ) ) ; Color fc [ ] = new Color [ 2 ] ; fc [ 0 ] = triColors . get ( triColors . size ( ) - 3 ) ; fc [ 1 ] = triColors . get ( triColors . size ( ) - 1 ) ; triColors . addAll ( Arrays . asList ( fc ) ) ; break ; } triangles . add ( p ) ; triColors . add ( c ) ; } }
target:  process the datastream and update the variables