public class XTalkTransporter extends Object implements FrameTransporter
Modifier and Type | Field and Description |
---|---|
static byte |
DOCUMENT_MARKER |
static byte |
ELEMENT_MARKER |
static byte[] |
HEADER |
static byte |
PI_MARKER |
static byte |
STRING_MARKER |
static byte |
VERSION_CODE |
Constructor and Description |
---|
XTalkTransporter() |
Modifier and Type | Method and Description |
---|---|
void |
attributesToBin(OutputStream os,
Attributes attributes,
byte[] workbuf) |
static int |
consumeCharacters(InputStream is,
byte[] byteBuf,
char[] charBuf,
int bytesToRead)
Consume the string of bytesToRead utf-8 bytes.
|
void |
consumeChildren(InputStream is,
Frame f,
int field_count,
int marker,
byte[] buffer,
char[] cbuffer) |
KeyValuePair |
consumeRootChildren(InputStream is,
Frame f,
byte[] buffer,
char[] cbuffer) |
KeyValuePair |
consumeRootElement(InputStream is,
Frame f,
byte[] buffer,
char[] cbuffer) |
static String |
consumeString(InputStream is)
Consume a string from the input stream.
|
static String |
consumeString(InputStream is,
byte[] buffer,
char[] cbuffer) |
void |
elementToBin(OutputStream os,
Frame f,
byte[] workbuf) |
KeyValuePair |
fromStream(InputStream is,
Frame f)
Parse the data-stream according to the XTalk protocol.
|
KeyValuePair |
fromStreamWork(InputStream is,
Frame f)
Once we know that this is an XTalk document, perform XTalk parsing.
|
KeyValuePair |
fromStreamWork(InputStream is,
Frame f,
byte[] buffer,
char[] cbuffer) |
protected void |
ignorePI(InputStream is) |
static void |
readFully(byte[] b,
InputStream in) |
static void |
readFully(byte[] b,
int length,
InputStream in) |
static int |
readInt(InputStream in) |
static void |
stringToBin(char[] str,
int begin,
int len,
OutputStream os) |
static void |
stringToBin(char[] str,
int begin,
int len,
OutputStream os,
byte[] buffer) |
static void |
stringToBin(String str,
OutputStream os)
Sends a string over, without the type byte.
|
static void |
stringToBin(String str,
OutputStream os,
byte[] buffer)
Sends a string as utf8, using the temporary buffer if it is big enough to avoid allocating new
memory.
|
void |
toStream(OutputStream os,
Frame f)
Populate the (empty) frame from the stream contents.
|
static void |
writeInt(int write_me,
OutputStream out) |
public static final byte DOCUMENT_MARKER
public static final byte ELEMENT_MARKER
public static final byte PI_MARKER
public static final byte STRING_MARKER
public static final byte VERSION_CODE
public static final byte[] HEADER
public KeyValuePair fromStream(InputStream is, Frame f) throws IOException, EOFException
fromStream
in interface FrameTransporter
is
- input streamf
- frameIOException
EOFException
public KeyValuePair fromStreamWork(InputStream is, Frame f) throws IOException
is
- input streamf
- frameIOException
- if the versions don't match, or have unexpected element markerpublic KeyValuePair fromStreamWork(InputStream is, Frame f, byte[] buffer, char[] cbuffer) throws IOException
IOException
protected void ignorePI(InputStream is) throws IOException
is
- the input streamIOException
- passthrupublic KeyValuePair consumeRootChildren(InputStream is, Frame f, byte[] buffer, char[] cbuffer) throws IOException
is
- the input streamf
- frameIOException
- passthrupublic KeyValuePair consumeRootElement(InputStream is, Frame f, byte[] buffer, char[] cbuffer) throws IOException
is
- the input streamf
- the FrameIOException
- passthrupublic void consumeChildren(InputStream is, Frame f, int field_count, int marker, byte[] buffer, char[] cbuffer) throws IOException
is
- input streamf
- framefield_count
- field countmarker
- markerIOException
- passthrupublic static String consumeString(InputStream is) throws IOException
is
- input streamIOException
- if key is longer than limitpublic static String consumeString(InputStream is, byte[] buffer, char[] cbuffer) throws IOException
IOException
public static int consumeCharacters(InputStream is, byte[] byteBuf, char[] charBuf, int bytesToRead) throws IOException
is
- input streambyteBuf
- a byte buffercharBuf
- a character bufferbytesToRead
- the number of bytes to readIOException
- passthrupublic void toStream(OutputStream os, Frame f) throws IOException
FrameTransporter
toStream
in interface FrameTransporter
os
- output streamf
- frameIOException
- passthrupublic void elementToBin(OutputStream os, Frame f, byte[] workbuf) throws IOException
os
- output streamf
- frameIOException
- passthrupublic static void stringToBin(String str, OutputStream os) throws IOException
str
- the string to sendos
- the output streamIOException
- passthrupublic static void stringToBin(String str, OutputStream os, byte[] buffer) throws IOException
str
- the string to sendos
- the output streambuffer
- a bufferIOException
- passthrupublic static void stringToBin(char[] str, int begin, int len, OutputStream os) throws IOException
IOException
public static void stringToBin(char[] str, int begin, int len, OutputStream os, byte[] buffer) throws IOException
IOException
public static void writeInt(int write_me, OutputStream out) throws IOException
write_me
- the integer to writeout
- the output streamIOException
- passthrupublic static int readInt(InputStream in) throws IOException
in
- the input streamIOException
- if any of the pieces read are negativepublic static void readFully(byte[] b, InputStream in) throws IOException
b
- the byte array to read intoin
- the input streamIOException
- passthrupublic static void readFully(byte[] b, int length, InputStream in) throws IOException
IOException
public void attributesToBin(OutputStream os, Attributes attributes, byte[] workbuf) throws IOException
os
- the output streamattributes
- attributesworkbuf
- a working bufferIOException
- passthruCopyright © 2006–2018 The Apache Software Foundation. All rights reserved.