diff --git a/src/main/java/com/solab/iso8583/IsoValue.java b/src/main/java/com/solab/iso8583/IsoValue.java index 60a5126..3fed509 100644 --- a/src/main/java/com/solab/iso8583/IsoValue.java +++ b/src/main/java/com/solab/iso8583/IsoValue.java @@ -250,7 +250,8 @@ public class IsoValue 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 diff --git a/src/main/java/com/solab/iso8583/MessageFactory.java b/src/main/java/com/solab/iso8583/MessageFactory.java index 0f0404c..a2a0746 100644 --- a/src/main/java/com/solab/iso8583/MessageFactory.java +++ b/src/main/java/com/solab/iso8583/MessageFactory.java @@ -66,7 +66,8 @@ public class MessageFactory { /** 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 { } } - /** 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 { 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 { 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 { } /** 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 { ArrayList 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); } diff --git a/src/main/java/com/solab/iso8583/impl/SimpleTraceGenerator.java b/src/main/java/com/solab/iso8583/impl/SimpleTraceGenerator.java index baf4821..2a9ca5e 100644 --- a/src/main/java/com/solab/iso8583/impl/SimpleTraceGenerator.java +++ b/src/main/java/com/solab/iso8583/impl/SimpleTraceGenerator.java @@ -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. diff --git a/src/main/java/com/solab/iso8583/parse/ConfigParser.java b/src/main/java/com/solab/iso8583/parse/ConfigParser.java index 93271a3..13221d5 100644 --- a/src/main/java/com/solab/iso8583/parse/ConfigParser.java +++ b/src/main/java/com/solab/iso8583/parse/ConfigParser.java @@ -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(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(nodes.getLength()-i); + subs = new ArrayList<>(nodes.getLength()-i); } subs.add(elem); continue; @@ -261,7 +262,7 @@ public class ConfigParser { protected static void parseGuides( final NodeList nodes, final MessageFactory mfact) throws IOException { ArrayList subs = null; - HashMap> guides = new HashMap>(); + HashMap> 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(nodes.getLength()-i); + subs = new ArrayList<>(nodes.getLength()-i); } subs.add(elem); continue; } - HashMap parseMap = new HashMap(); + HashMap 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 child = new HashMap(); + HashMap child = new HashMap<>(); child.putAll(parent); NodeList fields = elem.getElementsByTagName("field"); for (int j = 0; j < fields.getLength(); j++) {