|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.solab.iso8583.MessageFactory
public class MessageFactory
This class is used to create messages, either from scratch or from an existing String or byte buffer. It can be configured to put default values on newly created messages, and also to know what to expect when reading messages from an InputStream.
The factory can be configured to know what values to set for newly created messages, both from a template (useful for fields that must be set with the same value for EVERY message created) and individually (for trace [field 11] and message date [field 7]).
It can also be configured to know what fields to expect in incoming messages (all possible values must be stated, indicating the date type for each). This way the messages can be parsed from a byte buffer.
| Field Summary | |
|---|---|
protected Logger |
log
|
| Constructor Summary | |
|---|---|
MessageFactory()
|
|
| Method Summary | |
|---|---|
void |
addMessageTemplate(IsoMessage templ)
Adds a message template to the factory. |
IsoMessage |
createResponse(IsoMessage request)
Creates a message to respond to a request. |
void |
freeze()
Invoke this method in case you want to freeze the configuration, making message and parsing templates, as well as iso headers and custom fields, immutable. |
boolean |
getAssignDate()
Returns true if the factory is assigning the current date to newly created messages (field 7). |
String |
getCharacterEncoding()
Returns the encoding used to parse ALPHA, LLVAR and LLLVAR fields. |
CustomField<?> |
getCustomField(int index)
Returns a custom field encoder/decoder for the specified field number, if one is available. |
CustomField<?> |
getCustomField(Integer index)
Returns a custom field encoder/decoder for the specified field number, if one is available. |
int |
getEtx()
|
boolean |
getForceSecondaryBitmap()
|
boolean |
getIgnoreLastMissingField()
This flag indicates if the MessageFactory throws an exception if the last field of a message is not really present even though it's specified in the bitmap. |
String |
getIsoHeader(int type)
Returns the ISO header used for the specified type. |
IsoMessage |
getMessageTemplate(int type)
Returns the template for the specified message type. |
TraceNumberGenerator |
getTraceNumberGenerator()
Returns the generator used to assign trace numbers to new messages. |
boolean |
getUseBinaryMessages()
Returns true is the factory is set to create and parse binary messages, false if it uses ASCII messages. |
IsoMessage |
newMessage(int type)
Creates a new message of the specified type, with optional trace and date values as well as any other values specified in a message template. |
IsoMessage |
parseMessage(byte[] buf,
int isoHeaderLength)
Creates a new message instance from the buffer, which must contain a valid ISO8583 message. |
void |
removeMessageTemplate(int type)
Removes the message template for the specified type. |
void |
setAssignDate(boolean flag)
Sets whether the factory should set the current date on newly created messages, in field 7. |
void |
setCharacterEncoding(String value)
Sets the character encoding used for parsing ALPHA, LLVAR and LLLVAR fields. |
void |
setConfigPath(String path)
Tells the receiver to read the configuration at the specified path. |
void |
setCustomField(int index,
CustomField<?> value)
Sets the CustomField encoder for the specified field number. |
void |
setCustomFields(Map<Integer,CustomField<?>> value)
Specifies a map for custom field encoder/decoders. |
void |
setEtx(int value)
Sets the ETX character to be sent at the end of the message. |
void |
setForceSecondaryBitmap(boolean flag)
Sets or clears the flag to pass to new messages, to include a secondary bitmap even if it's not needed. |
void |
setIgnoreLastMissingField(boolean flag)
Setting this property to true avoids getting a ParseException when parsing messages that don't have the last field specified in the bitmap. |
void |
setIsoHeader(int type,
String value)
Sets the ISO header for a specific message type. |
void |
setIsoHeaders(Map<Integer,String> value)
Sets the ISO header to be used in each message type. |
void |
setParseMap(int type,
Map<Integer,FieldParseInfo> map)
Sets a map with the fields that are to be expected when parsing a certain type of message. |
void |
setTraceNumberGenerator(TraceNumberGenerator value)
Sets the generator that this factory will get new trace numbers from. |
void |
setUseBinaryMessages(boolean flag)
Tells the receiver to create and parse binary messages if the flag is true. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final Logger log
| Constructor Detail |
|---|
public MessageFactory()
| Method Detail |
|---|
public void setCharacterEncoding(String value)
public String getCharacterEncoding()
public void setForceSecondaryBitmap(boolean flag)
public boolean getForceSecondaryBitmap()
public void setIgnoreLastMissingField(boolean flag)
public boolean getIgnoreLastMissingField()
public void setCustomFields(Map<Integer,CustomField<?>> value)
public void setCustomField(int index,
CustomField<?> value)
public CustomField<?> getCustomField(int index)
public CustomField<?> getCustomField(Integer index)
public void setConfigPath(String path)
throws IOException
IOExceptionpublic void setUseBinaryMessages(boolean flag)
public boolean getUseBinaryMessages()
public void setEtx(int value)
value - The ASCII value of the ETX character or -1 to indicate no terminator should be used.public int getEtx()
public IsoMessage newMessage(int type)
type - The message type, for example 0x200, 0x400, etc.public IsoMessage createResponse(IsoMessage request)
request - An ISO8583 message with a request type (ending in 00).
public IsoMessage parseMessage(byte[] buf,
int isoHeaderLength)
throws ParseException,
UnsupportedEncodingException
buf - The byte buffer containing the message. Must not include the length header.isoHeaderLength - The expected length of the ISO header, after which the message type
and the rest of the message must come.
ParseException
UnsupportedEncodingExceptionpublic void setAssignDate(boolean flag)
public boolean getAssignDate()
public void setTraceNumberGenerator(TraceNumberGenerator value)
public TraceNumberGenerator getTraceNumberGenerator()
public void setIsoHeaders(Map<Integer,String> value)
value - A map where the keys are the message types and the values are the ISO headers.
public void setIsoHeader(int type,
String value)
type - The message type, for example 0x200.value - The ISO header, or NULL to remove any headers for this message type.public String getIsoHeader(int type)
public void addMessageTemplate(IsoMessage templ)
public void removeMessageTemplate(int type)
public IsoMessage getMessageTemplate(int type)
public void freeze()
public void setParseMap(int type,
Map<Integer,FieldParseInfo> map)
type - The message type.map - A map of FieldParseInfo instances, each of which define what type and length
of field to expect. The keys will be the field numbers.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||