Added a new property, characterEncoding, to MessageFactory, IsoMessage, FieldParseInfo and IsoValue. This helps in parsing messages from byte buffers containing extended characters in encodings other than the default for the JVM. Tested with UTF8 on a Mac (which has default Mac OS Roman) and worked fine.

Several methods now have an additional encoding parameter (just a String, not directly a Charset), but the default is always the JVM's default encoding (taken from the property 'file.encoding').


git-svn-id: https://j8583.svn.sourceforge.net/svnroot/j8583/j8583@70 db60a039-f72e-0410-b1d2-baa000846441
This commit is contained in:
chochos
2011-03-21 23:22:58 +00:00
parent c7d696acc7
commit 5c4259eba3
15 changed files with 153 additions and 56 deletions
@@ -40,6 +40,7 @@ public class IsoValue<T> implements Cloneable {
private T value;
private CustomField<T> encoder;
private int length;
private String encoding;
public IsoValue(IsoType t, T value) {
this(t, value, null);
@@ -156,6 +157,13 @@ public class IsoValue<T> implements Cloneable {
return value;
}
public void setCharacterEncoding(String value) {
encoding = value;
}
public String getCharacterEncoding() {
return encoding;
}
/** Returns the formatted value as a String. The formatting depends on the type of the
* receiver. */
public String toString() {
@@ -302,8 +310,7 @@ public class IsoValue<T> implements Cloneable {
}
}
} else {
//Just write the value as text
outs.write(toString().getBytes());
outs.write(encoding == null ? toString().getBytes() : toString().getBytes(encoding));
}
}