com.prowidesoftware.swift.model.field
Class Field

java.lang.Object
  extended by com.prowidesoftware.swift.model.field.Field
All Implemented Interfaces:
PatternContainer
Direct Known Subclasses:
Field103, Field11A, Field11R, Field11S, Field12, Field12A, Field12B, Field12C, Field12E, Field12F, Field13A, Field13B, Field13C, Field13D, Field13E, Field13J, Field13K, Field14A, Field14C, Field14D, Field14F, Field14G, Field14J, Field14S, Field14T, Field15A, Field15B, Field15C, Field15D, Field15E, Field15F, Field15G, Field15H, Field15I, Field15J, Field15K, Field15L, Field15M, Field15N, Field16A, Field16R, Field16S, Field177, Field17A, Field17B, Field17F, Field17G, Field17N, Field17O, Field17R, Field17T, Field17U, Field17V, Field18A, Field19, Field19A, Field19B, Field20, Field20C, Field20D, Field20E, Field21, Field21A, Field21B, Field21C, Field21D, Field21E, Field21F, Field21G, Field21N, Field21P, Field21R, Field22, Field22A, Field22B, Field22C, Field22D, Field22E, Field22F, Field22G, Field22H, Field22J, Field22K, Field22L, Field22X, Field23, Field23A, Field23B, Field23C, Field23D, Field23E, Field23F, Field23G, Field23X, Field243, Field24B, Field24D, Field24E, Field25, Field25A, Field25D, Field26A, Field26B, Field26C, Field26D, Field26E, Field26F, Field26G, Field26H, Field26J, Field26K, Field26L, Field26N, Field26P, Field26T, Field27, Field27A, Field28, Field28C, Field28D, Field28E, Field29A, Field29B, Field29C, Field29D, Field29E, Field29F, Field29G, Field29H, Field29J, Field29K, Field29S, Field30, Field30F, Field30G, Field30H, Field30J, Field30P, Field30Q, Field30T, Field30U, Field30V, Field30X, Field31B, Field31C, Field31D, Field31E, Field31F, Field31G, Field31H, Field31J, Field31L, Field31P, Field31R, Field31S, Field31T, Field31X, Field32A, Field32B, Field32C, Field32D, Field32E, Field32F, Field32G, Field32H, Field32J, Field32K, Field32M, Field32N, Field32P, Field32Q, Field32R, Field32U, Field33A, Field33B, Field33C, Field33D, Field33E, Field33F, Field33G, Field33J, Field33K, Field33N, Field33P, Field33R, Field33S, Field33T, Field33V, Field34A, Field34B, Field34C, Field34D, Field34E, Field34F, Field34G, Field34H, Field34J, Field34N, Field34P, Field34R, Field35A, Field35B, Field35C, Field35D, Field35E, Field35F, Field35H, Field35L, Field35N, Field35P, Field35S, Field35T, Field35U, Field36, Field36A, Field36B, Field36C, Field36E, Field37A, Field37B, Field37C, Field37D, Field37E, Field37F, Field37G, Field37H, Field37J, Field37K, Field37L, Field37M, Field37N, Field37P, Field37R, Field37S, Field37U, Field38A, Field38B, Field38D, Field38E, Field38G, Field38H, Field38J, Field39A, Field39B, Field39C, Field39D, Field39P, Field40A, Field40B, Field40C, Field40E, Field40F, Field41A, Field41D, Field42A, Field42C, Field42D, Field42M, Field42P, Field43P, Field43T, Field44A, Field44B, Field44C, Field44D, Field44E, Field44F, Field45A, Field45B, Field46A, Field46B, Field47A, Field47B, Field48, Field49, Field49H, Field49J, Field50, Field50A, Field50B, Field50C, Field50D, Field50F, Field50G, Field50H, Field50K, Field50L, Field50M, Field51A, Field51C, Field51D, Field52A, Field52B, Field52C, Field52D, Field52G, Field53A, Field53B, Field53C, Field53D, Field53J, Field54A, Field54B, Field54D, Field55A, Field55B, Field55D, Field56A, Field56B, Field56C, Field56D, Field56J, Field57A, Field57B, Field57C, Field57D, Field57J, Field58A, Field58B, Field58C, Field58D, Field58J, Field59, Field59A, Field60A, Field60B, Field60F, Field60M, Field61, Field62A, Field62B, Field62F, Field62M, Field64, Field65, Field67A, Field68A, Field68B, Field68C, Field69A, Field69B, Field69C, Field69D, Field69E, Field69F, Field69J, Field70, Field70C, Field70D, Field70E, Field70F, Field70G, Field71A, Field71B, Field71C, Field71D, Field71E, Field71F, Field71G, Field71H, Field71J, Field71K, Field71L, Field72, Field72C, Field73, Field74, Field75, Field76, Field77A, Field77B, Field77C, Field77D, Field77E, Field77F, Field77G, Field77H, Field77J, Field77K, Field77R, Field77S, Field77T, Field78, Field78B, Field79, Field80A, Field80B, Field80C, Field82A, Field82B, Field82C, Field82D, Field82J, Field82S, Field83A, Field83C, Field83D, Field83J, Field83R, Field84A, Field84B, Field84D, Field84J, Field85A, Field85B, Field85C, Field85D, Field85J, Field86, Field86A, Field86B, Field86D, Field86J, Field87A, Field87B, Field87C, Field87D, Field87E, Field87F, Field87J, Field88A, Field88B, Field88C, Field88D, Field88J, Field90A, Field90B, Field90C, Field90D, Field90E, Field90F, Field90J, Field90K, Field91A, Field91B, Field91C, Field91D, Field91E, Field91F, Field91G, Field91H, Field92A, Field92B, Field92C, Field92D, Field92E, Field92F, Field92J, Field92K, Field92L, Field92M, Field92N, Field93A, Field93B, Field93C, Field93D, Field94A, Field94B, Field94C, Field94D, Field94F, Field94G, Field94H, Field95C, Field95P, Field95Q, Field95R, Field95S, Field95T, Field95U, Field95V, Field97A, Field97B, Field97C, Field97E, Field98A, Field98B, Field98C, Field98D, Field98E, Field98F, Field99A, Field99B

public abstract class Field
extends java.lang.Object
implements PatternContainer

Base class implemented by classes that provide a general access to field components.

Since:
6.0
Author:
www.prowidesoftware.com

Field Summary
protected  java.util.List<java.lang.String> components
          Zero based list of field components in String format.
For example: for field content ":FOO//EUR1234 will be components[0]=FOO, components[1]=EUR and components[1]=1234
 
Constructor Summary
protected Field()
          Deprecated. usar Field(int)
protected Field(int components)
           
 
Method Summary
protected  void appendInLines(java.lang.StringBuilder sb, int componentStart, int componentEnd)
          Append each component between componentStart and componentEnd in a new lines, empty components are ignored
protected  void appendInLines(java.lang.StringBuilder sb, java.lang.String... lines)
          Append each lines in a new lines, empty lines are ignored
 boolean equals(java.lang.Object obj)
          Implementation of equals using EqualsBuilder from commons-lang
 java.lang.String findComponentStartingWith(java.lang.String prefix)
          Returns the first component starting with the given prefix value or null if not found.
protected static java.lang.String format(java.util.Calendar d)
           
protected static java.lang.String formatAccount(java.lang.String a)
          A formatted amount with a fixed format nnnn-nnnnn-nnn-n
protected static java.lang.String formatNumber(java.lang.Object aValue)
          Format the given object as a money number without currency information in format
static java.math.BigDecimal getAsBigDecimal(java.lang.Number number)
          Gets a BigDecimal from a generic Number argument
 java.lang.String getComponent(int number)
          Gets a specific component from the components list.
protected  java.lang.Object getComponentAs(int component, java.lang.Class c)
           
 java.util.List<java.lang.String> getComponents()
           
 java.lang.String getConditionalQualifier()
          Deprecated. 
 java.lang.String getDSS()
          Deprecated. 
static Field getField(Tag t)
          Creates a Field instance for the given Tag object, using reflection.
 java.lang.String getLabel()
          Returns the field business description using the default locale for the resource bundle.
 java.lang.String getLabel(java.util.Locale locale)
          Returns the field business description name, using resource bundle from pw_swift_labels property files.
static java.lang.String getLabel(java.lang.String fieldName, java.util.Locale locale)
           
static java.lang.String getLabel(java.lang.String fieldName, java.lang.String mt, java.lang.String sequence, java.util.Locale locale)
          Returns the field business description name, using resource bundle from pw_swift_labels property files.
 java.lang.String getName()
          Returns the field's name composed by the field number and the letter option (if any)
 java.lang.String getValue()
          Serializes the fields' components into the single string value (SWIFT format).
 java.lang.String getValueByCodeword(java.lang.String codeword)
          Finds the first component starting with the given codeword between slashes, and returns the component subvalue.
 java.lang.String getValueDisplay()
          Get a localized, suitable for showing to humans string of the field values
 int hashCode()
          Implementation of hashCode using HashCodeBuilder from commons-lang
 boolean isDSSPresent()
          Deprecated. 
 boolean isEmpty()
          Returns true if all field's components are blank or null
abstract  boolean isGeneric()
           
abstract  boolean isOptional(int component)
           
 java.lang.String joinComponents()
          Returns a string with all field's components joined.
 java.lang.String joinComponents(boolean skipLast)
          Returns a string with all field's components joined.
 java.lang.String joinComponents(int start)
          Returns a string with all field's components joined
 java.lang.String joinComponents(int start, boolean skipLast)
          Returns a string with joined components values.
 void setComponent(int number, java.lang.String value)
          Inserts a component String value into the list of components, using the component number to position the value into the List.
 void setComponents(java.util.List<java.lang.String> components)
           
 java.lang.String toString()
          Implementation of toString using ToStringBuilder from commons-lang
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.prowidesoftware.swift.model.field.PatternContainer
componentsPattern, parserPattern
 

Field Detail

components

protected java.util.List<java.lang.String> components
Zero based list of field components in String format.
For example: for field content ":FOO//EUR1234 will be components[0]=FOO, components[1]=EUR and components[1]=1234

Constructor Detail

Field

protected Field()
Deprecated. usar Field(int)


Field

protected Field(int components)
Parameters:
components -
Method Detail

toString

public java.lang.String toString()
Implementation of toString using ToStringBuilder from commons-lang

Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Implementation of equals using EqualsBuilder from commons-lang

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Implementation of hashCode using HashCodeBuilder from commons-lang

Overrides:
hashCode in class java.lang.Object

formatNumber

protected static java.lang.String formatNumber(java.lang.Object aValue)
Format the given object as a money number without currency information in format

Parameters:
aValue -
Returns:
the formatted amount as String

format

protected static java.lang.String format(java.util.Calendar d)
Parameters:
d - Date object to format
Returns:
the formatted date as dd/MM/yyyy

formatAccount

protected static java.lang.String formatAccount(java.lang.String a)
A formatted amount with a fixed format nnnn-nnnnn-nnn-n

Parameters:
a - string with an account number or null
Returns:
the formatted account or an empty String if param is null

appendInLines

protected void appendInLines(java.lang.StringBuilder sb,
                             java.lang.String... lines)
Append each lines in a new lines, empty lines are ignored

Parameters:
sb - must not be null, target buffer
lines - may be null or empty, nothing is done in this case

appendInLines

protected void appendInLines(java.lang.StringBuilder sb,
                             int componentStart,
                             int componentEnd)
Append each component between componentStart and componentEnd in a new lines, empty components are ignored

Parameters:
sb - must not be null, target buffer
componentStart - starting component number to add
componentEnd - ending component number to add

getComponents

public java.util.List<java.lang.String> getComponents()
Returns:
comopnents list

setComponents

public void setComponents(java.util.List<java.lang.String> components)
Parameters:
components - list to set

setComponent

public void setComponent(int number,
                         java.lang.String value)
Inserts a component String value into the list of components, using the component number to position the value into the List.

Parameters:
number - component number, first component of a field should be number one
value - String value of the parsed component (without component separators ':', '/', '//')

getComponent

public java.lang.String getComponent(int number)
Gets a specific component from the components list.

Parameters:
number - number component number, first component of a field should be number one
Returns:
found component or null

getValueDisplay

public java.lang.String getValueDisplay()
Get a localized, suitable for showing to humans string of the field values

Returns:
s

getComponentAs

protected java.lang.Object getComponentAs(int component,
                                          java.lang.Class c)
Parameters:
component -
c -
Returns:
o

joinComponents

public java.lang.String joinComponents(int start,
                                       boolean skipLast)
Returns a string with joined components values.

Parameters:
start - starting index of components to join (zero based)
skipLast - if true the last component will not be included in the join, and where the "last" component is understood as the last not empty component (this is not necessary the last component of the field's component list.
Returns:
s

joinComponents

public java.lang.String joinComponents(boolean skipLast)
Returns a string with all field's components joined.

Parameters:
skipLast -
Returns:
s
See Also:
joinComponents(int, boolean)

joinComponents

public java.lang.String joinComponents(int start)
Returns a string with all field's components joined

Parameters:
start -
Returns:
s
See Also:
joinComponents(int, boolean)

joinComponents

public java.lang.String joinComponents()
Returns a string with all field's components joined.

Returns:
s
See Also:
joinComponents(int, boolean)

getAsBigDecimal

public static java.math.BigDecimal getAsBigDecimal(java.lang.Number number)
Gets a BigDecimal from a generic Number argument

Parameters:
number -
Returns:
BigDecimal value of number parameter

findComponentStartingWith

public java.lang.String findComponentStartingWith(java.lang.String prefix)
Returns the first component starting with the given prefix value or null if not found.

Parameters:
prefix -
Returns:
s

getValueByCodeword

public java.lang.String getValueByCodeword(java.lang.String codeword)
Finds the first component starting with the given codeword between slashes, and returns the component subvalue. For example, for the following field value
/ACC/BLABLABLA CrLf
//BLABLABLA CrLf
/INS/CITIUS33MIA CrLf
//BLABLABLA CrLf
A call to this method with parameter "INS" will return "CITIUS33MIA"

Parameters:
codeword -
Returns:
the found value or null if not found
See Also:
findComponentStartingWith(String)

getValue

public java.lang.String getValue()
Serializes the fields' components into the single string value (SWIFT format). Must be overwritten by by subclasses.

Returns:
SWIFT formatted value

isEmpty

public boolean isEmpty()
Returns true if all field's components are blank or null

Returns:
true if all field's components are blank or null

getField

public static Field getField(Tag t)
Creates a Field instance for the given Tag object, using reflection. The created object is populated with parsed components data from the Tag.

Parameters:
t - a tag with proper name and value content
Returns:
a specific field object, ex: Field32A. Or null if exceptions occur during object creation.

getLabel

public java.lang.String getLabel()
Returns the field business description using the default locale for the resource bundle.

See Also:
getLabel(Locale)

getLabel

public java.lang.String getLabel(java.util.Locale locale)
Returns the field business description name, using resource bundle from pw_swift_labels property files.

Parameters:
locale - the locale for which a resource bundle is desired
Returns:
a resource bundle based label for the given locale or the tag name, or the resource key if not found

getLabel

public static java.lang.String getLabel(java.lang.String fieldName,
                                        java.util.Locale locale)
See Also:
getLabel(String, String, String, Locale)

getLabel

public static java.lang.String getLabel(java.lang.String fieldName,
                                        java.lang.String mt,
                                        java.lang.String sequence,
                                        java.util.Locale locale)
Returns the field business description name, using resource bundle from pw_swift_labels property files. Field names may be generic for all usages, or may differ for particular letter option, message type or even sequence of a message type. The property supports all this kind of definitions with generic labels and specific ones. The following example illustrate the precedence of bundle keys that are checked for field 50:

Parameters:
fieldName - field name of the field to retrieve its label, if the combination of number and letter option is provided then a specific label is returned; is the letter option is omitted then a more generic label is returned.
mt - optional indication of message type or null.
sequence - optional indication of sequence or null.
locale - the locale for which a resource bundle is desired
Returns:
a resource bundle based label for the given locale or the tag name, or the resource key if not found

getName

public java.lang.String getName()
Returns the field's name composed by the field number and the letter option (if any)


isOptional

public abstract boolean isOptional(int component)

isGeneric

public abstract boolean isGeneric()

getDSS

@Deprecated
public java.lang.String getDSS()
Deprecated. 

Moved to GenericField Interface


isDSSPresent

@Deprecated
public boolean isDSSPresent()
Deprecated. 

Moved to GenericField Interface


getConditionalQualifier

@Deprecated
public java.lang.String getConditionalQualifier()
Deprecated. 

Moved to GenericField Interface