|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.abdera.i18n.text.io.PipeChannel
public class PipeChannel
Implements a buffer that provides a slightly more efficient way of writing, and then reading a stream of bytes. To use: PipeChannel pipe = new PipeChannel(); byte[] bytes = {'a','b','c','d'}; pipe.write(bytes); pipe.close(); InputStream in = pipe.getInputStream(); int i = -1; while ((i = in.read()) != -1) {...} By default, closing will automatically cause it to flip over to Read mode, locking the buffer from further writes and setting the read position to 0. Once the Buffer has been fully read, it must be reset, which sets it back into write mode
Field Summary | |
---|---|
protected String |
charset
|
protected boolean |
flipped
|
protected Pipe |
pipe
|
Constructor Summary | |
---|---|
PipeChannel()
|
|
PipeChannel(String charset)
|
Method Summary | |
---|---|
Appendable |
append(char c)
|
Appendable |
append(CharSequence csq)
|
Appendable |
append(CharSequence csq,
int start,
int end)
|
Appendable |
append(CharSequence csq,
int start,
int end,
String charset)
|
Appendable |
append(CharSequence csq,
String charset)
|
Appendable |
append(char c,
String charset)
|
void |
close()
If the pipe is writable, this will close the input and switch to readable mode If the pipe is readable, this will close the output and reset the pipe |
InputStream |
getInputStream()
Get an inputstream that can read from this pipe. |
CodepointIterator |
getIterator()
Get a CodepointIterator that can iterate over unicode codepoints in this pipe. |
CodepointIterator |
getIterator(String charset)
Get a CodepointIterator that can iterate over unicode codepoints in this pipe. |
OutputStream |
getOutputStream()
Get an outputstream that can write to this pipe. |
Reader |
getReader()
Get a reader that can reader from this pipe. |
Reader |
getReader(String charset)
Get a reader that can reader from this pipe. |
Writer |
getWriter()
Get a writer that can write to this pipe. |
Writer |
getWriter(String charset)
Get a writer that can write to this pipe. |
boolean |
isOpen()
True if the pipe is open |
boolean |
isReadable()
True if this pipe is readable |
boolean |
isWritable()
True if this pipe is writable |
int |
read(byte[] dst)
Read from the pipe. |
int |
read(byte[] dst,
int offset,
int length)
Read from the pipe. |
int |
read(ByteBuffer dst)
Read from the pipe. |
int |
read(CharBuffer cb)
|
int |
read(CharBuffer cb,
String charset)
|
void |
reset()
Reset the pipe. |
int |
write(byte[] src)
Write to the pipe |
int |
write(byte[] src,
int offset,
int len)
Write to the pipe |
int |
write(ByteBuffer src)
Write to the pipe |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected String charset
protected Pipe pipe
protected boolean flipped
Constructor Detail |
---|
public PipeChannel()
public PipeChannel(String charset)
Method Detail |
---|
public InputStream getInputStream()
public OutputStream getOutputStream()
public Writer getWriter()
public Writer getWriter(String charset)
public Reader getReader(String charset)
public Reader getReader()
public CodepointIterator getIterator()
public CodepointIterator getIterator(String charset)
public int read(ByteBuffer dst) throws IOException
read
in interface ReadableByteChannel
IOException
public int read(byte[] dst) throws IOException
IOException
public int read(byte[] dst, int offset, int length) throws IOException
IOException
public boolean isOpen()
isOpen
in interface Channel
public int write(ByteBuffer src) throws IOException
write
in interface WritableByteChannel
IOException
public int write(byte[] src) throws IOException
IOException
public int write(byte[] src, int offset, int len) throws IOException
IOException
public boolean isReadable()
public boolean isWritable()
public void close() throws IOException
close
in interface Closeable
close
in interface Channel
IOException
public void reset()
public Appendable append(CharSequence csq) throws IOException
append
in interface Appendable
IOException
public Appendable append(char c) throws IOException
append
in interface Appendable
IOException
public Appendable append(CharSequence csq, int start, int end) throws IOException
append
in interface Appendable
IOException
public Appendable append(CharSequence csq, String charset) throws IOException
IOException
public Appendable append(char c, String charset) throws IOException
IOException
public Appendable append(CharSequence csq, int start, int end, String charset) throws IOException
IOException
public int read(CharBuffer cb) throws IOException
read
in interface Readable
IOException
public int read(CharBuffer cb, String charset) throws IOException
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |