private static byte[] unwrapEncoded(GTSWrapper wrapper){
  if (!wrapper.isCompressed()) {
    return wrapper.getEncoded();
  }
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
  byte[] bytes=wrapper.getEncoded();
  int pass=wrapper.getCompressionPasses();
  while (pass > 0) {
    ByteArrayInputStream in=new ByteArrayInputStream(bytes);
    baos.reset();
    try {
      GZIPInputStream gzis=new GZIPInputStream(in);
      byte[] buf=new byte[1024];
      while (true) {
        int len=gzis.read(buf);
        if (len < 0) {
          break;
        }
        baos.write(buf,0,len);
      }
      gzis.close();
    }
 catch (    IOException ioe) {
      throw new RuntimeException("Invalid compressed content.");
    }
    bytes=baos.toByteArray();
    pass--;
  }
  return bytes;
}

private static byte [ ] unwrapEncoded ( GTSWrapper wrapper ) { if ( ! wrapper . isCompressed ( ) ) { return wrapper . getEncoded ( ) ; } ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; byte [ ] bytes = wrapper . getEncoded ( ) ; int pass = wrapper . getCompressionPasses ( ) ; while ( pass > 0 ) { ByteArrayInputStream in = new ByteArrayInputStream ( bytes ) ; baos . reset ( ) ; try { GZIPInputStream gzis = new GZIPInputStream ( in ) ; byte [ ] buf = new byte [ 1024 ] ; while ( true ) { int len = gzis . read ( buf ) ; if ( len < 0 ) { break ; } baos . write ( buf , 0 , len ) ; } gzis . close ( ) ; } catch ( IOException ioe ) { throw new RuntimeException ( "Invalid compressed content." ) ; } bytes = baos . toByteArray ( ) ; pass -- ; } return bytes ; }
extract the encoded data , removing compression if needed
