public static Compression guessCompressionMethod(byte [] bits){ AutoBuffer ab = new AutoBuffer(bits); // Look for ZIP magic if( bits.length > ZipFile.LOCHDR && ab.get4(0) == ZipFile.LOCSIG ) return Compression.ZIP; if( bits.length > 2 && ab.get2(0) == GZIPInputStream.GZIP_MAGIC ) return Compression.GZIP; return Compression.NONE; }
@Override public IcedHashMap<K,V> read(AutoBuffer bb) { int n = bb.get4(); for(int i = 0; i < n; ++i) put(bb.<K>get(),bb.<V>get()); return this; }
@Override public AutoBuffer write(AutoBuffer bb) { bb.put4(size()); for(Map.Entry<K, V> e:entrySet())bb.put(e.getKey()).put(e.getValue()); return bb; }
@Override public IcedArrayList<T> read(AutoBuffer bb) { int n = bb.get4(); for(int i = 0; i < n; ++i) add(bb.<T>get()); return this; }
@Override public AutoBuffer write(AutoBuffer bb) { bb.put4(size()); for(T t:this) bb.put(t); return bb; }