|
xmlBlaster 2.2.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.xmlBlaster.util.xbformat.XbfParser
public class XbfParser
XbfParser class for raw socket/email messages.
This class creates and parses raw byte[] messages which can be used
to transfer over a socket connection.
XbfParser instances may be reused, but are NOT reentrant (there are many 'global' variables)
Please read the requirement specification
protocol.socket
msgLen[10] flag[6] requestId methodName sessionId lenUnzipped userData checkSum[10] +---------+-------+------ -*----------*-----------*-----------*-----------+----------+ The 'userData' consists of 0-n of these: qos key len content +-----*---------*-----*----------+ Examples, '*' marks a null byte and '|' is just to show the boundary (is not part of the message): Testing qos/key/content | 83**I**17711*publish*oxf6hZs*** *11*Hello world| Testing qos/key | 70**I**17711*get*oxf6hZs** * *0*| Testing publish return with qos | 48**R**17711*publish*oxf6hZs** **0*| Testing nothing | 38**I**17711*get*oxf6hZs****0*| Testing ping: | 29**I**11*ping*****0*| Testing XmlBlasterException | 76**E**17711*get*oxf6hZs**XbfParser*An XmlBlasterException test only*0*| Testing qos/key/content return value | 85**R**17711*publish*** * *20*Hello world response| Testing a QoS return value | 58**R**17711*get*** **0*| Testing two qos/key/content | 100**I**17711*publish*oxf6hZs** * *6*Hello1 * *6*Hello2|
Nested Class Summary | |
---|---|
private class |
XbfParser.Buf
|
Field Summary | |
---|---|
private XbfParser.Buf |
buf
|
static byte |
CHECKSUM_ADLER_BYTE
|
private long |
checkSumResult
|
static byte |
COMPRESSED_GZIP_BYTE
|
static java.lang.String |
EMPTY_STRING
|
private static byte[] |
EMPTY10
|
private byte[] |
first10
|
static int |
FLAG_FIELD_LEN
|
private Global |
glob
|
private long |
lenUnzipped
|
private static java.util.logging.Logger |
log
|
static int |
MAX_STRING_LEN
|
private int |
maxMsgLength
|
private static java.lang.String |
ME
|
private static byte |
NULL_BYTE
|
static int |
NUM_FIELD_LEN
|
private I_ProgressListener |
progressListener
If not null somebody wants to be notified about the current bytes send over socket |
static byte |
VERSION_1_BYTE
|
static java.lang.String |
XBFORMAT_EXTENSION
|
static java.lang.String |
XBFORMAT_MIMETYPE
|
static java.lang.String |
XBFORMAT_ZLIB_EXTENSION
|
static java.lang.String |
XBFORMAT_ZLIB_MIMETYPE
|
Constructor Summary | |
---|---|
XbfParser()
|
Method Summary | |
---|---|
static java.lang.String |
createLiteral(byte[] arr)
Get the raw messages as a string, for tests and for dumping only |
byte[] |
createRawMsg(MsgInfo msgInfo)
Returns a raw data string. |
java.lang.String |
getExtension(boolean isCompressed)
Get a specific extension for this format. |
java.lang.String |
getMimetype(boolean isCompressed)
Get a specific extension for this format. |
void |
init(Global glob,
I_ProgressListener progressListener,
I_PluginConfig pluginConfig)
Is guaranteed to be called by the MsgInfoParserFactory after construction. |
private void |
initialize()
|
private java.lang.String |
niceAndShort(java.lang.String tmp)
|
MsgInfo[] |
parse(java.io.InputStream in)
This parses the raw message from an InputStream (typically from a socket). |
private XbfParser.Buf |
readOneMsg(MsgInfo msgInfo,
java.io.InputStream in)
Blocks on socket until a complete message is read. |
byte[] |
toByte(XbfParser.Buf buf)
Reads the binary content of a message. |
private int |
toInt0(XbfParser.Buf buf,
int defaultVal)
Converts bytes from byte[] until \0 to an int |
java.lang.String |
toLiteral(byte[] arr)
Get the raw messages as a string, for tests and for dumping only. |
java.lang.String |
toLiteral(MsgInfo msgInfo)
Get the raw messages as a string, for tests and for dumping only |
long |
toLong0(XbfParser.Buf buf,
long defaultVal)
Converts bytes from byte[] until \0 to a long |
private java.lang.String |
toString(XbfParser.Buf buf)
Extracts string until next null byte '\0' |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final java.lang.String ME
private Global glob
private static java.util.logging.Logger log
public static final int NUM_FIELD_LEN
public static final int FLAG_FIELD_LEN
public static final int MAX_STRING_LEN
public static final java.lang.String EMPTY_STRING
public static final byte CHECKSUM_ADLER_BYTE
public static final byte COMPRESSED_GZIP_BYTE
public static final byte VERSION_1_BYTE
private static final byte[] EMPTY10
private static final byte NULL_BYTE
public static final java.lang.String XBFORMAT_EXTENSION
public static final java.lang.String XBFORMAT_ZLIB_EXTENSION
public static final java.lang.String XBFORMAT_MIMETYPE
public static final java.lang.String XBFORMAT_ZLIB_MIMETYPE
private XbfParser.Buf buf
private byte[] first10
private long lenUnzipped
private long checkSumResult
private int maxMsgLength
private I_ProgressListener progressListener
Constructor Detail |
---|
public XbfParser()
Method Detail |
---|
public void init(Global glob, I_ProgressListener progressListener, I_PluginConfig pluginConfig)
I_MsgInfoParser
init
in interface I_MsgInfoParser
pluginConfig
- Can be nullprivate void initialize()
public final java.lang.String getMimetype(boolean isCompressed)
I_MsgInfoParser
getMimetype
in interface I_MsgInfoParser
isCompressed
- true/false
public final java.lang.String getExtension(boolean isCompressed)
I_MsgInfoParser
getExtension
in interface I_MsgInfoParser
isCompressed
- true/false
private final XbfParser.Buf readOneMsg(MsgInfo msgInfo, java.io.InputStream in) throws java.io.IOException
java.io.IOException
public final MsgInfo[] parse(java.io.InputStream in) throws java.io.IOException, java.lang.IllegalArgumentException
parse
in interface I_MsgInfoParser
in
- The raw, serialized data
java.io.IOException
java.lang.IllegalArgumentException
public final byte[] createRawMsg(MsgInfo msgInfo) throws XmlBlasterException
msgLen[10] flag[6] requestId methodName sessionId lenUnzipped userData checkSum[10] +---------+-------+------ -*----------*-----------*-----------*-----------+----------+ The 'userData' consists of 0-n of these: qos key len content +-----*---------*-----*----------+ An example is ('*' marks a null byte): " 83**I**17711*publish*oxf6hZs*** *11*Hello world"
createRawMsg
in interface I_MsgInfoParser
XmlBlasterException
public final byte[] toByte(XbfParser.Buf buf) throws java.io.IOException
java.io.IOException
public final long toLong0(XbfParser.Buf buf, long defaultVal) throws java.io.IOException
java.io.IOException
private final int toInt0(XbfParser.Buf buf, int defaultVal) throws java.io.IOException
java.io.IOException
private java.lang.String niceAndShort(java.lang.String tmp)
private final java.lang.String toString(XbfParser.Buf buf) throws java.io.IOException
java.io.IOException
public final java.lang.String toLiteral(MsgInfo msgInfo) throws XmlBlasterException
toLiteral
in interface I_MsgInfoParser
XmlBlasterException
public final java.lang.String toLiteral(byte[] arr)
I_MsgInfoParser
toLiteral
in interface I_MsgInfoParser
arr
- The raw blob
public static final java.lang.String createLiteral(byte[] arr)
|
xmlBlaster 2.2.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |