@Override public Object read(ObjectInput in) throws IOException { byte[] data = new byte[in.readInt()]; if (data.length > 0) { in.readFully(data); } return new MarshObject(data); } });
public MarshObject(byte[] bytes) { _bytes = bytes; _hashCode = bytes != null ? computeHash(bytes) : NULL_HASHCODE; }
@Override public void write(Object object, ObjectOutput out) throws IOException { byte[] data = ((MarshObject) object).getBytes(); out.writeInt(data.length); if (data.length > 0) { out.write(data); // out.flush(); } }
public Object getObject(MarshObject marsh) throws IOException, ClassNotFoundException { return getObject(marsh.getBytes()); }
private MarshObject getMarshObjectInternal(Object o, boolean init) throws IOException { byte[] bc; if (init) { bc = serializeToByteArray(o); } else { // We need to reset state and pass this indication to the // deserializing stream _bao.setBuffer(_byteArrayCache.get()); _oo.reset(); bc = serializeToByteArray(o); _byteArrayCache.notifyUsedSize(bc.length); _bao.setBuffer(DUMMY_BUFFER); _oo.reset(); } MarshObject marObj = new MarshObject(bc); return marObj; }
public Object getObject(MarshObject marsh) throws IOException, ClassNotFoundException { if (!(marsh instanceof CompressedMarshObject)) throw new IOException("Can decompress only CompressedMarshObject"); _bai.setBuffer(marsh.getBytes()); _zi.getNextEntry(); if (_oi == null) { _oi = getObjectInputStream(_zi); } Object object = _oi.readObject(); // It seems ZipInputStream has some internal state and it needs // to be cleared both before and after setting the underlying // InputStream // buffer _zi.getNextEntry(); _bai.setBuffer(DUMMY_BUFFER); return object; }
if (_serUID) { try { basicName = new String(mc.getMarshObject(name).getBytes(), "ISO-8859-1"); validate = false; } catch (IOException e) {