@Test public void testGetThrowsNullPointerException1() throws Throwable { FSDMsg fSDMsg = new FSDMsg("testFSDMsgBasePath", "testFSDMsgBaseSchema"); try { fSDMsg.get("testFSDMsgId", null, 100, "testFSDMsgDefValue", null); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot invoke \"String.toUpperCase()\" because \"type\" is null", ex.getMessage(), "ex.getMessage()"); } assertEquals(0, fSDMsg.fields.size(), "fSDMsg.fields.size()"); } }
protected String get (String id, String type, int length, String defValue, String separator) throws ISOException { String value = fields.get (id); if (value == null) value = defValue == null ? "" : defValue; type = type.toUpperCase (); int lengthLength = 0; while (type.charAt(0) == 'L') { lengthLength++; type = type.substring(1); } switch (type.charAt (0)) { case 'N': if (!isSeparated(separator)) { value = ISOUtil.zeropad (value, length); } break; case 'A': if (!isSeparated(separator) && lengthLength == 0) { value = ISOUtil.strpad (value, length); } if (value.length() > length) value = value.substring(0,length); break; case 'K': if (defValue != null) value = defValue; break; case 'B': if (length << 1 < value.length()) throw new IllegalArgumentException("field content=" + value + " is too long to fit in field " + id + " whose length is " + length); if (isSeparated(separator)) { value = new String(ISOUtil.hex2byte(value), charset); } else { value = new String(ISOUtil.hex2byte(ISOUtil.zeropad( value, length << 1).substring(0, length << 1)), charset); } break; } if (lengthLength == 0 && (!isSeparated(separator) || isBinary(type) || EOM_SEPARATOR.equals(separator))) return value; else { if (lengthLength > 0) { String format = String.format("%%0%dd%%s", lengthLength); value = String.format(format, value.length(), value); } else { value = ISOUtil.blankUnPad(value); } } return value; }
FSDMsg implements Loggeable, Cloneable { protected String get (String id, String type, int length, String defValue, String separator) throws ISOException { String value = fields.get (id); if (value == null) value = defValue == null ? "" : defValue; type = type.toUpperCase (); int lengthLength = 0; while (type.charAt(0) == 'L') { lengthLength++; type = type.substring(1); } switch (type.charAt (0)) { case 'N': if (!isSeparated(separator)) { value = ISOUtil.zeropad (value, length); } break; case 'A': if (!isSeparated(separator) && lengthLength == 0) { value = ISOUtil.strpad (value, length); } if (value.length() > length) value = value.substring(0,length); break; case 'K': if (defValue != null) value = defValue; break; case 'B': if (length << 1 < value.length()) throw new IllegalArgumentException("field content=" + value + " is too long to fit in field " + id + " whose length is " + length); if (isSeparated(separator)) { value = new String(ISOUtil.hex2byte(value), charset); } else { value = new String(ISOUtil.hex2byte(ISOUtil.zeropad( value, length << 1).substring(0, length << 1)), charset); } break; } if (lengthLength == 0 && (!isSeparated(separator) || isBinary(type) || EOM_SEPARATOR.equals(separator))) return value; else { if (lengthLength > 0) { String format = String.format("%%0%dd%%s", lengthLength); value = String.format(format, value.length(), value); } else { value = ISOUtil.blankUnPad(value); } } return value; } }
FSDMsg implements Loggeable, Cloneable { protected String get (String id, String type, int length, String defValue, String separator) throws ISOException { String value = fields.get (id); if (value == null) value = defValue == null ? "" : defValue; type = type.toUpperCase (); int lengthLength = 0; while (type.charAt(0) == 'L') { lengthLength++; type = type.substring(1); } switch (type.charAt (0)) { case 'N': if (!isSeparated(separator)) { value = ISOUtil.zeropad (value, length); } break; case 'A': if (!isSeparated(separator) && lengthLength == 0) { value = ISOUtil.strpad (value, length); } if (value.length() > length) value = value.substring(0,length); break; case 'K': if (defValue != null) value = defValue; break; case 'B': if (length << 1 < value.length()) throw new IllegalArgumentException("field content=" + value + " is too long to fit in field " + id + " whose length is " + length); if (isSeparated(separator)) { value = new String(ISOUtil.hex2byte(value), charset); } else { value = new String(ISOUtil.hex2byte(ISOUtil.zeropad( value, length << 1).substring(0, length << 1)), charset); } break; } if (lengthLength == 0 && (!isSeparated(separator) || isBinary(type) || EOM_SEPARATOR.equals(separator))) return value; else { if (lengthLength > 0) { String format = String.format("%%0%dd%%s", lengthLength); value = String.format(format, value.length(), value); } else { value = ISOUtil.blankUnPad(value); } } return value; } FSDMsg(String basePath);  FSDMsg(String basePath, String baseSchema); }
FSDMsg implements Loggeable, Cloneable { protected String get (String id, String type, int length, String defValue, String separator) throws ISOException { String value = fields.get (id); if (value == null) value = defValue == null ? "" : defValue; type = type.toUpperCase (); int lengthLength = 0; while (type.charAt(0) == 'L') { lengthLength++; type = type.substring(1); } switch (type.charAt (0)) { case 'N': if (!isSeparated(separator)) { value = ISOUtil.zeropad (value, length); } break; case 'A': if (!isSeparated(separator) && lengthLength == 0) { value = ISOUtil.strpad (value, length); } if (value.length() > length) value = value.substring(0,length); break; case 'K': if (defValue != null) value = defValue; break; case 'B': if (length << 1 < value.length()) throw new IllegalArgumentException("field content=" + value + " is too long to fit in field " + id + " whose length is " + length); if (isSeparated(separator)) { value = new String(ISOUtil.hex2byte(value), charset); } else { value = new String(ISOUtil.hex2byte(ISOUtil.zeropad( value, length << 1).substring(0, length << 1)), charset); } break; } if (lengthLength == 0 && (!isSeparated(separator) || isBinary(type) || EOM_SEPARATOR.equals(separator))) return value; else { if (lengthLength > 0) { String format = String.format("%%0%dd%%s", lengthLength); value = String.format(format, value.length(), value); } else { value = ISOUtil.blankUnPad(value); } } return value; } FSDMsg(String basePath);  FSDMsg(String basePath, String baseSchema); String getBasePath(); String getBaseSchema(); void setCharset(Charset charset); void setSeparator(String separatorName, char separator); void unsetSeparator(String separatorName); void unpack(InputStream is); void unpack(byte[] b); String pack(); byte[] packToBytes(); boolean isSeparator(byte b); void set(String name, String value); void setHeader(byte[] h); byte[] getHeader(); String getHexHeader(); String get(String fieldName); String get(String fieldName, String def); void copy(String fieldName, FSDMsg msg); void copy(String fieldName, FSDMsg msg, String def); byte[] getHexBytes(String name); @SuppressWarnings("PMD.EmptyCatchBlock") int getInt(String name); @SuppressWarnings("PMD.EmptyCatchBlock") int getInt(String name, int def); Element toXML(); Map getMap(); void setMap(Map fields); @Override void dump(PrintStream p, String indent); boolean hasField(String fieldName); @Override Object clone(); void merge(FSDMsg m); @Override boolean equals(Object o); @Override int hashCode(); }
FSDMsg implements Loggeable, Cloneable { protected String get (String id, String type, int length, String defValue, String separator) throws ISOException { String value = fields.get (id); if (value == null) value = defValue == null ? "" : defValue; type = type.toUpperCase (); int lengthLength = 0; while (type.charAt(0) == 'L') { lengthLength++; type = type.substring(1); } switch (type.charAt (0)) { case 'N': if (!isSeparated(separator)) { value = ISOUtil.zeropad (value, length); } break; case 'A': if (!isSeparated(separator) && lengthLength == 0) { value = ISOUtil.strpad (value, length); } if (value.length() > length) value = value.substring(0,length); break; case 'K': if (defValue != null) value = defValue; break; case 'B': if (length << 1 < value.length()) throw new IllegalArgumentException("field content=" + value + " is too long to fit in field " + id + " whose length is " + length); if (isSeparated(separator)) { value = new String(ISOUtil.hex2byte(value), charset); } else { value = new String(ISOUtil.hex2byte(ISOUtil.zeropad( value, length << 1).substring(0, length << 1)), charset); } break; } if (lengthLength == 0 && (!isSeparated(separator) || isBinary(type) || EOM_SEPARATOR.equals(separator))) return value; else { if (lengthLength > 0) { String format = String.format("%%0%dd%%s", lengthLength); value = String.format(format, value.length(), value); } else { value = ISOUtil.blankUnPad(value); } } return value; } FSDMsg(String basePath);  FSDMsg(String basePath, String baseSchema); String getBasePath(); String getBaseSchema(); void setCharset(Charset charset); void setSeparator(String separatorName, char separator); void unsetSeparator(String separatorName); void unpack(InputStream is); void unpack(byte[] b); String pack(); byte[] packToBytes(); boolean isSeparator(byte b); void set(String name, String value); void setHeader(byte[] h); byte[] getHeader(); String getHexHeader(); String get(String fieldName); String get(String fieldName, String def); void copy(String fieldName, FSDMsg msg); void copy(String fieldName, FSDMsg msg, String def); byte[] getHexBytes(String name); @SuppressWarnings("PMD.EmptyCatchBlock") int getInt(String name); @SuppressWarnings("PMD.EmptyCatchBlock") int getInt(String name, int def); Element toXML(); Map getMap(); void setMap(Map fields); @Override void dump(PrintStream p, String indent); boolean hasField(String fieldName); @Override Object clone(); void merge(FSDMsg m); @Override boolean equals(Object o); @Override int hashCode(); static char FS; static char US; static char GS; static char RS; static char EOF; static char PIPE; static char EOM; }