Class ISOAmount
java.lang.Object
org.jpos.iso.ISOComponent
org.jpos.iso.ISOAmount
- All Implemented Interfaces:
Externalizable, Serializable, Cloneable
ISO component representing an amount with currency and decimal scale.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.ISOAmount(int fieldNumber) Constructs an ISOAmount for the given field number.ISOAmount(int fieldNumber, int currencyCode, BigDecimal amount) Constructs an ISOAmount with all fields. -
Method Summary
Modifier and TypeMethodDescriptionvoiddump(PrintStream p, String indent) Writes a human-readable dump of this component for diagnostics.booleanReturns the monetary amount.Returns the amount formatted as a legacy ISO string.Returns the amount as a formatted string.intReturns the ISO 4217 currency code.Returns the currency code as a 3-digit string.intReturns the field number this component occupies within its container.getKey()valid on Leafs only.intgetScale()Returns the decimal scale.Returns the scale as a two-character string.getValue()valid on Leafs only.inthashCode()byte[]pack()Packs this component into its on-wire byte representation.voidvoidsetFieldNumber(int fieldNumber) changes this Component field number
Use with care, this method does not change any reference held by a Composite.voidSets the value of this component.toString()intunpack(byte[] b) Unpacks this component frombstarting at offset 0.voidunpack(InputStream in) Unpacks this component by reading fromin.voidMethods inherited from class ISOComponent
getBytes, getChildren, getComposite, getMaxField, pack, set, unsetModifier and TypeMethodDescriptionbyte[]getBytes()get Value as bytes (when possible)dummy behaviour - return empty mapIn order to interchange Composites and Leafs we use getComposite().inta Composite must override this functionvoidpack(OutputStream out) Packs this component and writes it toout.voidset(ISOComponent c) Set a field within this messagevoidunset(int fldno) Unset a field
-
Constructor Details
-
ISOAmount
public ISOAmount()Default constructor. -
ISOAmount
Constructs an ISOAmount for the given field number.- Parameters:
fieldNumber- the ISO field number
-
ISOAmount
Constructs an ISOAmount with all fields.- Parameters:
fieldNumber- the ISO field numbercurrencyCode- the ISO 4217 currency codeamount- the monetary amount- Throws:
ISOException- if the value cannot be encoded
-
-
Method Details
-
getKey
Description copied from class:ISOComponentvalid on Leafs only. The value returned is used by ISOMsg as a key to this field.- Overrides:
getKeyin classISOComponent- Returns:
- object representing the field number
-
getValue
Description copied from class:ISOComponentvalid on Leafs only.- Overrides:
getValuein classISOComponent- Returns:
- object representing the field value
- Throws:
ISOException- thrown by composites; leaves return their value
-
setValue
Description copied from class:ISOComponentSets the value of this component.- Specified by:
setValuein classISOComponent- Parameters:
obj- new value- Throws:
ISOException- if the value is rejected by the component implementation
-
setFieldNumber
Description copied from class:ISOComponentchanges this Component field number
Use with care, this method does not change any reference held by a Composite.- Specified by:
setFieldNumberin classISOComponent- Parameters:
fieldNumber- new field number
-
getFieldNumber
Description copied from class:ISOComponentReturns the field number this component occupies within its container.- Specified by:
getFieldNumberin classISOComponent- Returns:
- the field number
-
getAmount
-
getScale
-
getScaleAsString
-
getCurrencyCode
-
getCurrencyCodeAsString
Returns the currency code as a 3-digit string.- Returns:
- currency code string
- Throws:
ISOException- on error
-
getAmountAsLegacyString
Returns the amount formatted as a legacy ISO string.- Returns:
- formatted amount string
- Throws:
ISOException- on error
-
getAmountAsString
Returns the amount as a formatted string.- Returns:
- the formatted amount string
- Throws:
ISOException- on error
-
pack
Description copied from class:ISOComponentPacks this component into its on-wire byte representation.- Specified by:
packin classISOComponent- Returns:
- packed bytes
- Throws:
ISOException- if packing fails
-
unpack
Description copied from class:ISOComponentUnpacks this component frombstarting at offset 0.- Specified by:
unpackin classISOComponent- Parameters:
b- packed bytes- Returns:
- number of bytes consumed
- Throws:
ISOException- if unpacking fails
-
unpack
Description copied from class:ISOComponentUnpacks this component by reading fromin.- Specified by:
unpackin classISOComponent- Parameters:
in- source stream- Throws:
ISOException- if unpacking fails
-
dump
Description copied from class:ISOComponentWrites a human-readable dump of this component for diagnostics.- Specified by:
dumpin classISOComponent- Parameters:
p- destination streamindent- prefix to apply to every emitted line
-
writeExternal
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
equals
-
hashCode
-
toString
-