work on #32
This commit is contained in:
@@ -250,7 +250,8 @@ public class IsoValue<T> implements Cloneable {
|
||||
return false;
|
||||
}
|
||||
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
|
||||
|
||||
@@ -66,7 +66,8 @@ public class MessageFactory<T extends IsoMessage> {
|
||||
/** Indicates if the factory should create binary messages and also parse binary messages. */
|
||||
private boolean useBinary;
|
||||
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 forceb2;
|
||||
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
|
||||
* system property. */
|
||||
/** Returns the encoding used to parse ALPHA, LLVAR and LLLVAR fields. The default is the
|
||||
* file.encoding system property. */
|
||||
public String getCharacterEncoding() {
|
||||
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) {
|
||||
forceb2 = flag;
|
||||
}
|
||||
@@ -296,7 +298,8 @@ public class MessageFactory<T extends IsoMessage> {
|
||||
if (buf.length < minlength) {
|
||||
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);
|
||||
final int type;
|
||||
if (useBinary) {
|
||||
@@ -440,16 +443,20 @@ public class MessageFactory<T extends IsoMessage> {
|
||||
m.setField(i, val);
|
||||
if (val != null) {
|
||||
if (val.getType() == IsoType.NUMERIC || val.getType() == IsoType.DATE10
|
||||
|| val.getType() == IsoType.DATE4 || val.getType() == IsoType.DATE_EXP
|
||||
|| val.getType() == IsoType.AMOUNT || val.getType() == IsoType.TIME) {
|
||||
|| val.getType() == IsoType.DATE4
|
||||
|| val.getType() == IsoType.DATE_EXP
|
||||
|| val.getType() == IsoType.AMOUNT
|
||||
|| val.getType() == IsoType.TIME) {
|
||||
pos += (val.getLength() / 2) + (val.getLength() % 2);
|
||||
} else {
|
||||
pos += val.getLength();
|
||||
}
|
||||
if (val.getType() == IsoType.LLVAR || val.getType() == IsoType.LLBIN) {
|
||||
pos++;
|
||||
} else if (val.getType() == IsoType.LLLVAR || val.getType() == IsoType.LLLBIN
|
||||
|| val.getType() == IsoType.LLLLVAR || val.getType() == IsoType.LLLLBIN) {
|
||||
} else if (val.getType() == IsoType.LLLVAR
|
||||
|| val.getType() == IsoType.LLLBIN
|
||||
|| val.getType() == IsoType.LLLLVAR
|
||||
|| val.getType() == IsoType.LLLLBIN) {
|
||||
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
|
||||
* programatically. */
|
||||
* programmatically. */
|
||||
public T getMessageTemplate(int type) {
|
||||
return typeTemplates.get(type);
|
||||
}
|
||||
@@ -582,7 +589,8 @@ public class MessageFactory<T extends IsoMessage> {
|
||||
ArrayList<Integer> index = new ArrayList<>();
|
||||
index.addAll(map.keySet());
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ import com.solab.iso8583.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
|
||||
* 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.getAttribute("ref") != null && !elem.getAttribute("ref").isEmpty()) {
|
||||
if (refs == null) {
|
||||
refs = new ArrayList<Element>(nodes.getLength()-i);
|
||||
refs = new ArrayList<>(nodes.getLength()-i);
|
||||
}
|
||||
refs.add(elem);
|
||||
}
|
||||
@@ -142,7 +142,8 @@ public class ConfigParser {
|
||||
}
|
||||
String h = mfact.getIsoHeader(t2);
|
||||
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()) {
|
||||
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 (subs == null) {
|
||||
subs = new ArrayList<Element>(nodes.getLength()-i);
|
||||
subs = new ArrayList<>(nodes.getLength()-i);
|
||||
}
|
||||
subs.add(elem);
|
||||
continue;
|
||||
@@ -261,7 +262,7 @@ public class ConfigParser {
|
||||
protected static <T extends IsoMessage> void parseGuides(
|
||||
final NodeList nodes, final MessageFactory<T> mfact) throws IOException {
|
||||
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++) {
|
||||
Element elem = (Element)nodes.item(i);
|
||||
int type = parseType(elem.getAttribute("type"));
|
||||
@@ -270,12 +271,12 @@ public class ConfigParser {
|
||||
}
|
||||
if (elem.getAttribute("extends") != null && !elem.getAttribute("extends").isEmpty()) {
|
||||
if (subs == null) {
|
||||
subs = new ArrayList<Element>(nodes.getLength()-i);
|
||||
subs = new ArrayList<>(nodes.getLength()-i);
|
||||
}
|
||||
subs.add(elem);
|
||||
continue;
|
||||
}
|
||||
HashMap<Integer, FieldParseInfo> parseMap = new HashMap<Integer, FieldParseInfo>();
|
||||
HashMap<Integer, FieldParseInfo> parseMap = new HashMap<>();
|
||||
NodeList fields = elem.getElementsByTagName("field");
|
||||
for (int j = 0; j < fields.getLength(); j++) {
|
||||
Element f = (Element)fields.item(j);
|
||||
@@ -302,7 +303,7 @@ public class ConfigParser {
|
||||
+ elem.getAttribute("type") + " extends nonexistent guide "
|
||||
+ elem.getAttribute("extends"));
|
||||
}
|
||||
HashMap<Integer,FieldParseInfo> child = new HashMap<Integer, FieldParseInfo>();
|
||||
HashMap<Integer,FieldParseInfo> child = new HashMap<>();
|
||||
child.putAll(parent);
|
||||
NodeList fields = elem.getElementsByTagName("field");
|
||||
for (int j = 0; j < fields.getLength(); j++) {
|
||||
|
||||
Reference in New Issue
Block a user