work on #32
This commit is contained in:
@@ -250,7 +250,8 @@ public class IsoValue<T> implements Cloneable {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
IsoValue<?> comp = (IsoValue<?>)other;
|
IsoValue<?> comp = (IsoValue<?>)other;
|
||||||
return (comp.getType() == getType() && comp.getValue().equals(getValue()) && comp.getLength() == getLength());
|
return (comp.getType() == getType() && comp.getValue().equals(getValue())
|
||||||
|
&& comp.getLength() == getLength());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -66,7 +66,8 @@ public class MessageFactory<T extends IsoMessage> {
|
|||||||
/** Indicates if the factory should create binary messages and also parse binary messages. */
|
/** Indicates if the factory should create binary messages and also parse binary messages. */
|
||||||
private boolean useBinary;
|
private boolean useBinary;
|
||||||
private int etx = -1;
|
private int etx = -1;
|
||||||
/** Flag to specify if missing fields should be ignored as long as they're at the end of the message. */
|
/** Flag to specify if missing fields should be ignored as long as they're at
|
||||||
|
* the end of the message. */
|
||||||
private boolean ignoreLast;
|
private boolean ignoreLast;
|
||||||
private boolean forceb2;
|
private boolean forceb2;
|
||||||
private boolean binBitmap;
|
private boolean binBitmap;
|
||||||
@@ -124,13 +125,14 @@ public class MessageFactory<T extends IsoMessage> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the encoding used to parse ALPHA, LLVAR and LLLVAR fields. The default is the file.encoding
|
/** Returns the encoding used to parse ALPHA, LLVAR and LLLVAR fields. The default is the
|
||||||
* system property. */
|
* file.encoding system property. */
|
||||||
public String getCharacterEncoding() {
|
public String getCharacterEncoding() {
|
||||||
return encoding;
|
return encoding;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Sets or clears the flag to pass to new messages, to include a secondary bitmap even if it's not needed. */
|
/** Sets or clears the flag to pass to new messages, to include a secondary bitmap
|
||||||
|
* even if it's not needed. */
|
||||||
public void setForceSecondaryBitmap(boolean flag) {
|
public void setForceSecondaryBitmap(boolean flag) {
|
||||||
forceb2 = flag;
|
forceb2 = flag;
|
||||||
}
|
}
|
||||||
@@ -296,7 +298,8 @@ public class MessageFactory<T extends IsoMessage> {
|
|||||||
if (buf.length < minlength) {
|
if (buf.length < minlength) {
|
||||||
throw new ParseException("Insufficient buffer length, needs to be at least " + minlength, 0);
|
throw new ParseException("Insufficient buffer length, needs to be at least " + minlength, 0);
|
||||||
}
|
}
|
||||||
final T m = createIsoMessage(isoHeaderLength > 0 ? new String(buf, 0, isoHeaderLength, encoding) : null);
|
final T m = createIsoMessage(isoHeaderLength > 0 ?
|
||||||
|
new String(buf, 0, isoHeaderLength, encoding) : null);
|
||||||
m.setCharacterEncoding(encoding);
|
m.setCharacterEncoding(encoding);
|
||||||
final int type;
|
final int type;
|
||||||
if (useBinary) {
|
if (useBinary) {
|
||||||
@@ -440,16 +443,20 @@ public class MessageFactory<T extends IsoMessage> {
|
|||||||
m.setField(i, val);
|
m.setField(i, val);
|
||||||
if (val != null) {
|
if (val != null) {
|
||||||
if (val.getType() == IsoType.NUMERIC || val.getType() == IsoType.DATE10
|
if (val.getType() == IsoType.NUMERIC || val.getType() == IsoType.DATE10
|
||||||
|| val.getType() == IsoType.DATE4 || val.getType() == IsoType.DATE_EXP
|
|| val.getType() == IsoType.DATE4
|
||||||
|| val.getType() == IsoType.AMOUNT || val.getType() == IsoType.TIME) {
|
|| val.getType() == IsoType.DATE_EXP
|
||||||
|
|| val.getType() == IsoType.AMOUNT
|
||||||
|
|| val.getType() == IsoType.TIME) {
|
||||||
pos += (val.getLength() / 2) + (val.getLength() % 2);
|
pos += (val.getLength() / 2) + (val.getLength() % 2);
|
||||||
} else {
|
} else {
|
||||||
pos += val.getLength();
|
pos += val.getLength();
|
||||||
}
|
}
|
||||||
if (val.getType() == IsoType.LLVAR || val.getType() == IsoType.LLBIN) {
|
if (val.getType() == IsoType.LLVAR || val.getType() == IsoType.LLBIN) {
|
||||||
pos++;
|
pos++;
|
||||||
} else if (val.getType() == IsoType.LLLVAR || val.getType() == IsoType.LLLBIN
|
} else if (val.getType() == IsoType.LLLVAR
|
||||||
|| val.getType() == IsoType.LLLLVAR || val.getType() == IsoType.LLLLBIN) {
|
|| val.getType() == IsoType.LLLBIN
|
||||||
|
|| val.getType() == IsoType.LLLLVAR
|
||||||
|
|| val.getType() == IsoType.LLLLBIN) {
|
||||||
pos += 2;
|
pos += 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -557,7 +564,7 @@ public class MessageFactory<T extends IsoMessage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the template for the specified message type. This allows templates to be modified
|
/** Returns the template for the specified message type. This allows templates to be modified
|
||||||
* programatically. */
|
* programmatically. */
|
||||||
public T getMessageTemplate(int type) {
|
public T getMessageTemplate(int type) {
|
||||||
return typeTemplates.get(type);
|
return typeTemplates.get(type);
|
||||||
}
|
}
|
||||||
@@ -582,7 +589,8 @@ public class MessageFactory<T extends IsoMessage> {
|
|||||||
ArrayList<Integer> index = new ArrayList<>();
|
ArrayList<Integer> index = new ArrayList<>();
|
||||||
index.addAll(map.keySet());
|
index.addAll(map.keySet());
|
||||||
Collections.sort(index);
|
Collections.sort(index);
|
||||||
log.trace(String.format("ISO8583 MessageFactory adding parse map for type %04x with fields %s", type, index));
|
log.trace(String.format("ISO8583 MessageFactory adding parse map for type %04x with fields %s",
|
||||||
|
type, index));
|
||||||
parseOrder.put(type, index);
|
parseOrder.put(type, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import com.solab.iso8583.TraceNumberGenerator;
|
|||||||
*/
|
*/
|
||||||
public class SimpleTraceGenerator implements TraceNumberGenerator {
|
public class SimpleTraceGenerator implements TraceNumberGenerator {
|
||||||
|
|
||||||
private int value = 0;
|
private volatile int value = 0;
|
||||||
|
|
||||||
/** Creates a new instance that will use the specified initial value. This means
|
/** Creates a new instance that will use the specified initial value. This means
|
||||||
* the first nextTrace() call will return this number.
|
* the first nextTrace() call will return this number.
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ public class ConfigParser {
|
|||||||
if (elem.getChildNodes() == null || elem.getChildNodes().getLength() == 0) {
|
if (elem.getChildNodes() == null || elem.getChildNodes().getLength() == 0) {
|
||||||
if (elem.getAttribute("ref") != null && !elem.getAttribute("ref").isEmpty()) {
|
if (elem.getAttribute("ref") != null && !elem.getAttribute("ref").isEmpty()) {
|
||||||
if (refs == null) {
|
if (refs == null) {
|
||||||
refs = new ArrayList<Element>(nodes.getLength()-i);
|
refs = new ArrayList<>(nodes.getLength()-i);
|
||||||
}
|
}
|
||||||
refs.add(elem);
|
refs.add(elem);
|
||||||
}
|
}
|
||||||
@@ -142,7 +142,8 @@ public class ConfigParser {
|
|||||||
}
|
}
|
||||||
String h = mfact.getIsoHeader(t2);
|
String h = mfact.getIsoHeader(t2);
|
||||||
if (h == null) {
|
if (h == null) {
|
||||||
throw new IllegalArgumentException("Header def " + type + " refers to nonexistent header " + t2);
|
throw new IllegalArgumentException("Header def " + type +
|
||||||
|
" refers to nonexistent header " + t2);
|
||||||
}
|
}
|
||||||
if (log.isTraceEnabled()) {
|
if (log.isTraceEnabled()) {
|
||||||
log.trace("Adding ISO8583 header for type {}: {} (copied from {})",
|
log.trace("Adding ISO8583 header for type {}: {} (copied from {})",
|
||||||
@@ -165,7 +166,7 @@ public class ConfigParser {
|
|||||||
}
|
}
|
||||||
if (elem.getAttribute("extends") != null && !elem.getAttribute("extends").isEmpty()) {
|
if (elem.getAttribute("extends") != null && !elem.getAttribute("extends").isEmpty()) {
|
||||||
if (subs == null) {
|
if (subs == null) {
|
||||||
subs = new ArrayList<Element>(nodes.getLength()-i);
|
subs = new ArrayList<>(nodes.getLength()-i);
|
||||||
}
|
}
|
||||||
subs.add(elem);
|
subs.add(elem);
|
||||||
continue;
|
continue;
|
||||||
@@ -261,7 +262,7 @@ public class ConfigParser {
|
|||||||
protected static <T extends IsoMessage> void parseGuides(
|
protected static <T extends IsoMessage> void parseGuides(
|
||||||
final NodeList nodes, final MessageFactory<T> mfact) throws IOException {
|
final NodeList nodes, final MessageFactory<T> mfact) throws IOException {
|
||||||
ArrayList<Element> subs = null;
|
ArrayList<Element> subs = null;
|
||||||
HashMap<Integer,HashMap<Integer,FieldParseInfo>> guides = new HashMap<Integer, HashMap<Integer, FieldParseInfo>>();
|
HashMap<Integer,HashMap<Integer,FieldParseInfo>> guides = new HashMap<>();
|
||||||
for (int i = 0; i < nodes.getLength(); i++) {
|
for (int i = 0; i < nodes.getLength(); i++) {
|
||||||
Element elem = (Element)nodes.item(i);
|
Element elem = (Element)nodes.item(i);
|
||||||
int type = parseType(elem.getAttribute("type"));
|
int type = parseType(elem.getAttribute("type"));
|
||||||
@@ -270,12 +271,12 @@ public class ConfigParser {
|
|||||||
}
|
}
|
||||||
if (elem.getAttribute("extends") != null && !elem.getAttribute("extends").isEmpty()) {
|
if (elem.getAttribute("extends") != null && !elem.getAttribute("extends").isEmpty()) {
|
||||||
if (subs == null) {
|
if (subs == null) {
|
||||||
subs = new ArrayList<Element>(nodes.getLength()-i);
|
subs = new ArrayList<>(nodes.getLength()-i);
|
||||||
}
|
}
|
||||||
subs.add(elem);
|
subs.add(elem);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
HashMap<Integer, FieldParseInfo> parseMap = new HashMap<Integer, FieldParseInfo>();
|
HashMap<Integer, FieldParseInfo> parseMap = new HashMap<>();
|
||||||
NodeList fields = elem.getElementsByTagName("field");
|
NodeList fields = elem.getElementsByTagName("field");
|
||||||
for (int j = 0; j < fields.getLength(); j++) {
|
for (int j = 0; j < fields.getLength(); j++) {
|
||||||
Element f = (Element)fields.item(j);
|
Element f = (Element)fields.item(j);
|
||||||
@@ -302,7 +303,7 @@ public class ConfigParser {
|
|||||||
+ elem.getAttribute("type") + " extends nonexistent guide "
|
+ elem.getAttribute("type") + " extends nonexistent guide "
|
||||||
+ elem.getAttribute("extends"));
|
+ elem.getAttribute("extends"));
|
||||||
}
|
}
|
||||||
HashMap<Integer,FieldParseInfo> child = new HashMap<Integer, FieldParseInfo>();
|
HashMap<Integer,FieldParseInfo> child = new HashMap<>();
|
||||||
child.putAll(parent);
|
child.putAll(parent);
|
||||||
NodeList fields = elem.getElementsByTagName("field");
|
NodeList fields = elem.getElementsByTagName("field");
|
||||||
for (int j = 0; j < fields.getLength(); j++) {
|
for (int j = 0; j < fields.getLength(); j++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user