public ByteArrayBuffer(String value,String encoding) throws UnsupportedEncodingException { super(READWRITE,NON_VOLATILE); _bytes = value.getBytes(encoding); setGetIndex(0); setPutIndex(_bytes.length); _access=IMMUTABLE; _string = value; }
public ByteArrayBuffer(byte[] bytes, int index, int length, int access, boolean isVolatile) { super(READWRITE, isVolatile); _bytes = bytes; setPutIndex(index + length); setGetIndex(index); _access = access; }
public ByteArrayBuffer(byte[] bytes, int index, int length, int access) { super(READWRITE, NON_VOLATILE); _bytes = bytes; setPutIndex(index + length); setGetIndex(index); _access = access; }
public ByteArrayBuffer(String value) { super(READWRITE,NON_VOLATILE); _bytes = Portable.getBytes(value); setGetIndex(0); setPutIndex(_bytes.length); _access=IMMUTABLE; _string = value; }
/** Wrap a byte array * @param b */ public void wrap(byte[] b) { if (isReadOnly()) throw new IllegalStateException(__READONLY); if (isImmutable()) throw new IllegalStateException(__IMMUTABLE); _bytes=b; setGetIndex(0); setPutIndex(b.length); }
/** Wrap a byte array. * @param b * @param off * @param len */ public void wrap(byte[] b, int off, int len) { if (isReadOnly()) throw new IllegalStateException(__READONLY); if (isImmutable()) throw new IllegalStateException(__IMMUTABLE); _bytes=b; clear(); setGetIndex(off); setPutIndex(off+len); }
public int flush(Buffer buffer) throws IOException { if (_closed) throw new IOException("CLOSED"); if (_growOutput && buffer.length()>_out.space()) { _out.compact(); if (buffer.length()>_out.space()) { ByteArrayBuffer n = new ByteArrayBuffer(_out.putIndex()+buffer.length()); n.put(_out.peek(0,_out.putIndex())); if (_out.getIndex()>0) { n.mark(); n.setGetIndex(_out.getIndex()); } _out=n; } } int len = _out.put(buffer); buffer.skip(len); return len; }