com.instantbank.common.utilcomponents
Class CodeDescription

java.lang.Object
  |
  +--com.instantbank.common.utilcomponents.CodeDescription
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class CodeDescription
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

Utility class allowing manipulation of pairs "code,description".

Author:
InstantBank (Rodrigo Lopez).
See Also:
Serialized Form

Field Summary
private  long code
          A numeric code with a related description.
private  java.lang.String description
          A readable description of the code.
 
Constructor Summary
CodeDescription()
          Default constructor.
CodeDescription(long cod, java.lang.String d)
          Constructor .
 
Method Summary
static CodeDescription assocCode(long cod, CodeDescription[] cdArray)
          Locates a CodigoDescription by its code in an array of CodigoDescriptions.
static CodeDescription assocDescription(java.lang.String descr, CodeDescription[] cdArray)
          Locates a CodigoDescription by its description in an array of CodigoDescriptions.
 java.lang.Object clone()
          Creates a clone of this.
 boolean equals(CodeDescription cd)
          Standard equal comparison.
 long getCode()
          Getter method for code.
 java.lang.String getDescription()
          Getter method for description.
static int getIndexCode(long code, CodeDescription[] cd)
          Gets the index of the first entry in a CodeDescription array having a specific "code" value.
static int getIndexDescription(java.lang.String desc, CodeDescription[] cd)
          Gets the index of the first entry in a CodeDescription array having a specific "description" value.
 void setCode(long code)
          Setter method for code.
 void setDescription(java.lang.String description)
          Setter method for description.
static long[] toCodes(CodeDescription[] cd)
          Delivers an array with "codes" starting from an array of CodeDescriptions .
static java.lang.String[] toDescriptions(CodeDescription[] cd)
          Delivers an array with "descriptions" starting from an array of CodeDescriptions .
static java.lang.String[] toDescriptionsWithUndef(CodeDescription[] cd, java.lang.String undef)
          Delivers an array with "descriptions" starting from an array of CodeDescriptions .
 
Methods inherited from class java.lang.Object
, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

code

private long code
A numeric code with a related description.

description

private java.lang.String description
A readable description of the code.
Constructor Detail

CodeDescription

public CodeDescription()
Default constructor.

CodeDescription

public CodeDescription(long cod,
                       java.lang.String d)
Constructor .

Parameters:
cod - The code value.
d - The code description.
Method Detail

assocCode

public static CodeDescription assocCode(long cod,
                                        CodeDescription[] cdArray)
Locates a CodigoDescription by its code in an array of CodigoDescriptions.
Parameters:
cod - code used as search criteria.
cdArray - Array where the CodigoDescription object is looked for.
Returns:
  • The first CodigoDescription inside arreglo whose code matches cod, if it is found.
  • null Otherwise.

assocDescription

public static CodeDescription assocDescription(java.lang.String descr,
                                               CodeDescription[] cdArray)
Locates a CodigoDescription by its description in an array of CodigoDescriptions.
Parameters:
descr - description used as search criteria.
cdArray - Array where the CodigoDescription object is looked for.
Returns:
  • The first CodigoDescription inside arreglo whose description matches desrc, if it is found.
  • null Otherwise.

clone

public java.lang.Object clone()
Creates a clone of this.
Overrides:
clone in class java.lang.Object
Returns:
El clon creado.

equals

public boolean equals(CodeDescription cd)
Standard equal comparison.
Parameters:
cd - The comparison object.

Comparison restricted to code. Descriptions are not compared!!.
Returns:
  • true If codes are equal.
  • false Otherwise.

  • toDescriptions

    public static java.lang.String[] toDescriptions(CodeDescription[] cd)
    Delivers an array with "descriptions" starting from an array of CodeDescriptions .
    Parameters:
    cd - An array of CodeDescriptions.
    Returns:
    An array of descriptions or null if the parameter is null.

    toDescriptionsWithUndef

    public static java.lang.String[] toDescriptionsWithUndef(CodeDescription[] cd,
                                                             java.lang.String undef)
    Delivers an array with "descriptions" starting from an array of CodeDescriptions . This array starts with a String corresponding to the "undefined" code.
    Parameters:
    cd - An array of CodeDescriptions.
    undef - A description for the "undefined" code.
    Returns:
    An array of descriptions, starting with a description for the "undefined" code, or null if the cd parameter is null.

    toCodes

    public static long[] toCodes(CodeDescription[] cd)
    Delivers an array with "codes" starting from an array of CodeDescriptions .
    Parameters:
    cd - An array of CodeDescriptions.
    Returns:
    An array of codes, or null if the cd parameter is null.

    setCode

    public void setCode(long code)
    Setter method for code.
    Parameters:
    code - The new code value

    setDescription

    public void setDescription(java.lang.String description)
    Setter method for description.
    Parameters:
    description - The new description value

    getCode

    public long getCode()
    Getter method for code.
    Returns:
    The code value

    getDescription

    public java.lang.String getDescription()
    Getter method for description.
    Returns:
    The description value

    getIndexCode

    public static int getIndexCode(long code,
                                   CodeDescription[] cd)
    Gets the index of the first entry in a CodeDescription array having a specific "code" value.
    Parameters:
    code - The code searched for.
    cd - The array where the code is searched.
    Returns:
    • The index of the first entry having the searched code.
    • -1 If there is no entry with the searched code.

    getIndexDescription

    public static int getIndexDescription(java.lang.String desc,
                                          CodeDescription[] cd)
    Gets the index of the first entry in a CodeDescription array having a specific "description" value.
    Parameters:
    desc - The description searched for.
    cd - The array where the description is searched.
    Returns:
    • The index of the first entry having the searched description.
    • -1 If there is no entry with the searched description.