public class FSDMsg extends java.lang.Object implements Loggeable, java.lang.Cloneable
The message format (or schema) is defined in xml files containing a schema element, with an optional id attribute, and multiple field elements. A field element is made up of the following attributes:
set(String, String)
. It should be unique amongst the fields in an FSDMsg.Possible types are:
Supported field separators are:
Key fields allow you to specify a tree of possible message formats. The key fields are the fork points of the tree. Multiple key fields are supported. It is also possible to have more key fields specified in appended schemas.
Modifier and Type | Field and Description |
---|---|
static char |
EOF |
static char |
EOM |
static char |
FS |
static char |
GS |
static char |
PIPE |
static char |
RS |
static char |
US |
Constructor and Description |
---|
FSDMsg(java.lang.String basePath)
Creates a FSDMsg with a specific base path for the message format schema.
|
FSDMsg(java.lang.String basePath,
java.lang.String baseSchema)
Creates a FSDMsg with a specific base path for the message format schema, and a base schema name.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
clone() |
void |
copy(java.lang.String fieldName,
FSDMsg msg) |
void |
copy(java.lang.String fieldName,
FSDMsg msg,
java.lang.String def) |
void |
dump(java.io.PrintStream p,
java.lang.String indent) |
boolean |
equals(java.lang.Object o) |
java.lang.String |
get(java.lang.String fieldName) |
java.lang.String |
get(java.lang.String fieldName,
java.lang.String def) |
protected java.lang.String |
get(java.lang.String id,
java.lang.String type,
int length,
java.lang.String defValue,
java.lang.String separator) |
java.lang.String |
getBasePath() |
java.lang.String |
getBaseSchema() |
byte[] |
getHeader() |
byte[] |
getHexBytes(java.lang.String name) |
java.lang.String |
getHexHeader() |
int |
getInt(java.lang.String name) |
int |
getInt(java.lang.String name,
int def) |
java.util.Map |
getMap() |
protected org.jdom2.Element |
getSchema() |
protected org.jdom2.Element |
getSchema(java.lang.String message) |
protected org.jdom2.Element |
getSchema(java.lang.String prefix,
java.lang.String suffix,
java.lang.String defSuffix) |
boolean |
hasField(java.lang.String fieldName) |
int |
hashCode() |
boolean |
isSeparator(byte b) |
protected org.jdom2.Element |
loadSchema(java.lang.String uri,
boolean throwex) |
void |
merge(FSDMsg m) |
java.lang.String |
pack() |
protected void |
pack(org.jdom2.Element schema,
java.lang.StringBuilder sb) |
byte[] |
packToBytes() |
protected java.lang.String |
read(java.io.InputStreamReader r,
int len,
java.lang.String type,
java.lang.String separator) |
protected java.lang.String |
readField(java.io.InputStreamReader r,
java.lang.String fieldName,
int len,
java.lang.String type,
java.lang.String separator) |
protected java.io.InputStream |
schemaResouceInputStream(java.lang.String resource) |
void |
set(java.lang.String name,
java.lang.String value) |
void |
setCharset(java.nio.charset.Charset charset) |
void |
setHeader(byte[] h) |
void |
setMap(java.util.Map fields) |
void |
setSeparator(java.lang.String separatorName,
char separator) |
org.jdom2.Element |
toXML() |
void |
unpack(byte[] b)
parse message.
|
void |
unpack(java.io.InputStream is)
parse message.
|
protected void |
unpack(java.io.InputStreamReader r,
org.jdom2.Element schema) |
void |
unsetSeparator(java.lang.String separatorName) |
public static char FS
public static char US
public static char GS
public static char RS
public static char EOF
public static char PIPE
public static char EOM
public FSDMsg(java.lang.String basePath)
basePath
- schema path, for example: "file:src/data/NDC-" looks for a file src/data/NDC-base.xmlpublic FSDMsg(java.lang.String basePath, java.lang.String baseSchema)
basePath
- schema pathbaseSchema
- schema namepublic java.lang.String getBasePath()
public java.lang.String getBaseSchema()
public void setCharset(java.nio.charset.Charset charset)
public void setSeparator(java.lang.String separatorName, char separator)
public void unsetSeparator(java.lang.String separatorName)
public void unpack(java.io.InputStream is) throws java.io.IOException, org.jdom2.JDOMException
is
- input streamjava.io.IOException
org.jdom2.JDOMException
public void unpack(byte[] b) throws java.io.IOException, org.jdom2.JDOMException
b
- message imagejava.io.IOException
org.jdom2.JDOMException
public java.lang.String pack() throws org.jdom2.JDOMException, java.io.IOException, ISOException
org.jdom2.JDOMException
java.io.IOException
ISOException
public byte[] packToBytes() throws org.jdom2.JDOMException, java.io.IOException, ISOException
org.jdom2.JDOMException
java.io.IOException
ISOException
protected java.lang.String get(java.lang.String id, java.lang.String type, int length, java.lang.String defValue, java.lang.String separator) throws ISOException
ISOException
public boolean isSeparator(byte b)
protected void pack(org.jdom2.Element schema, java.lang.StringBuilder sb) throws org.jdom2.JDOMException, java.io.IOException, ISOException
org.jdom2.JDOMException
java.io.IOException
ISOException
protected void unpack(java.io.InputStreamReader r, org.jdom2.Element schema) throws java.io.IOException, org.jdom2.JDOMException
java.io.IOException
org.jdom2.JDOMException
protected java.lang.String read(java.io.InputStreamReader r, int len, java.lang.String type, java.lang.String separator) throws java.io.IOException
java.io.IOException
protected java.lang.String readField(java.io.InputStreamReader r, java.lang.String fieldName, int len, java.lang.String type, java.lang.String separator) throws java.io.IOException
java.io.IOException
public void set(java.lang.String name, java.lang.String value)
public void setHeader(byte[] h)
public byte[] getHeader()
public java.lang.String getHexHeader()
public java.lang.String get(java.lang.String fieldName)
public java.lang.String get(java.lang.String fieldName, java.lang.String def)
public void copy(java.lang.String fieldName, FSDMsg msg)
public void copy(java.lang.String fieldName, FSDMsg msg, java.lang.String def)
public byte[] getHexBytes(java.lang.String name)
public int getInt(java.lang.String name)
public int getInt(java.lang.String name, int def)
public org.jdom2.Element toXML()
protected org.jdom2.Element getSchema() throws org.jdom2.JDOMException, java.io.IOException
org.jdom2.JDOMException
java.io.IOException
protected org.jdom2.Element getSchema(java.lang.String message) throws org.jdom2.JDOMException, java.io.IOException
org.jdom2.JDOMException
java.io.IOException
protected org.jdom2.Element getSchema(java.lang.String prefix, java.lang.String suffix, java.lang.String defSuffix) throws org.jdom2.JDOMException, java.io.IOException
org.jdom2.JDOMException
java.io.IOException
protected org.jdom2.Element loadSchema(java.lang.String uri, boolean throwex) throws org.jdom2.JDOMException, java.io.IOException
org.jdom2.JDOMException
java.io.IOException
protected java.io.InputStream schemaResouceInputStream(java.lang.String resource) throws org.jdom2.JDOMException, java.io.IOException
org.jdom2.JDOMException
java.io.IOException
public java.util.Map getMap()
public void setMap(java.util.Map fields)
public void dump(java.io.PrintStream p, java.lang.String indent)
public boolean hasField(java.lang.String fieldName)
public java.lang.Object clone()
clone
in class java.lang.Object
public void merge(FSDMsg m)
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object