public FSTObjectInput getObjectInput(InputStream inputStream) { return conf.getObjectInput(inputStream); } }
public FSTObjectInput getObjectInput(InputStream inputStream) { return conf.getObjectInput(inputStream); } }
/** * take the given array as input. the array is NOT copied. * * WARNING: the input streams takes over ownership and might overwrite content * of this array in subsequent IO operations. * * @param arr * @return */ public FSTObjectInput getObjectInput( byte arr[]) { return getObjectInput(arr, arr.length); }
public FSTObjectInput getObjectInput() { return getObjectInput((InputStream)null); }
/** * take the given array as input. the array is NOT copied. * * WARNING: the input streams takes over ownership and might overwrite content * of this array in subsequent IO operations. * * @param arr * @return */ public FSTObjectInput getObjectInput( byte arr[]) { return getObjectInput(arr, arr.length); }
public FSTObjectInput getObjectInput() { return getObjectInput((InputStream)null); }
@Override public Object decode(ByteBuf buf, State state) throws IOException { try { ByteBufInputStream in = new ByteBufInputStream(buf); FSTObjectInput inputStream = config.getObjectInput(in); return inputStream.readObject(); } catch (IOException e) { throw e; } catch (Exception e) { throw new IOException(e); } } };
/** * @see encodeToStream * * @param in * @return * @throws Exception */ public Object decodeFromStream( InputStream in ) throws Exception { int read = in.read(); if ( read < 0 ) throw new EOFException("stream is closed"); int ch1 = (read + 256) & 0xff; int ch2 = (in.read()+ 256) & 0xff; int ch3 = (in.read() + 256) & 0xff; int ch4 = (in.read() + 256) & 0xff; int len = (ch4 << 24) + (ch3 << 16) + (ch2 << 8) + (ch1 << 0); if ( len <= 0 ) throw new EOFException("stream is corrupted"); byte buffer[] = new byte[len]; // this could be reused ! while (len > 0) { len -= in.read(buffer, buffer.length - len, len); } return getObjectInput(buffer).readObject(); }
@Override public Object decode(ByteBuf buf, State state) throws IOException { try { ByteBufInputStream in = new ByteBufInputStream(buf); FSTObjectInput inputStream = config.getObjectInput(in); return inputStream.readObject(); } catch (IOException e) { throw e; } catch (Exception e) { throw new IOException(e); } } };
/** * convenience */ public Object asObject( byte b[] ) { try { return getObjectInput(b).readObject(); } catch (Exception e) { System.out.println("unable to decode:" +new String(b,0,0,Math.min(b.length,100)) ); try { String debug = new String(b, "UTF-8"); } catch (UnsupportedEncodingException e1) { // } try { getObjectInput(b).readObject(); } catch (Exception e1) { // debug hook } FSTUtil.<RuntimeException>rethrow(e); } return null; }
/** * @see encodeToStream * * @param in * @return * @throws Exception */ public Object decodeFromStream( InputStream in ) throws Exception { int read = in.read(); if ( read < 0 ) throw new EOFException("stream is closed"); int ch1 = (read + 256) & 0xff; int ch2 = (in.read()+ 256) & 0xff; int ch3 = (in.read() + 256) & 0xff; int ch4 = (in.read() + 256) & 0xff; int len = (ch4 << 24) + (ch3 << 16) + (ch2 << 8) + (ch1 << 0); if ( len <= 0 ) throw new EOFException("stream is corrupted"); byte buffer[] = new byte[len]; // this could be reused ! while (len > 0) { len -= in.read(buffer, buffer.length - len, len); } return getObjectInput(buffer).readObject(); }
/** * convenience */ public Object asObject( byte b[] ) { try { return getObjectInput(b).readObject(); } catch (Exception e) { System.out.println("unable to decode:" +new String(b,0,0,Math.min(b.length,100)) ); try { String debug = new String(b, "UTF-8"); } catch (UnsupportedEncodingException e1) { // } try { getObjectInput(b).readObject(); } catch (Exception e1) { // debug hook } FSTUtil.<RuntimeException>rethrow(e); } return null; }
if ( sharedRefs ) { out = conf.getObjectOutput(); in = conf.getObjectInput(); } else { out = new FSTObjectOutputNoShared(conf);
if (sharedRefs) { out = conf.getObjectOutput(); in = conf.getObjectInput(); } else { out = new FSTObjectOutputNoShared(conf);
if ( sharedRefs ) { out = conf.getObjectOutput(); in = conf.getObjectInput(); } else { out = new FSTObjectOutputNoShared(conf);
if (sharedRefs) { out = conf.getObjectOutput(); in = conf.getObjectInput(); } else { out = new FSTObjectOutputNoShared(conf);
public FSTObjectInput getObjectInput(InputStream inputStream) { return conf.getObjectInput(inputStream); } }
public FSTObjectInput getObjectInput(InputStream inputStream) { return conf.getObjectInput(inputStream); } }
public FSTObjectInput getObjectInput(InputStream inputStream) { return conf.getObjectInput(inputStream); } }
public static <T> T readObject(InputStream input, Class<T> clazz) throws Exception { FSTObjectInput in = getFST().getObjectInput(input); Object obj = in.readObject(clazz); input.close(); if (isNull(obj)) { return null; } return clazz.cast(obj); }