com.instantbank.common.utilcomponents
Class UtilOnJdk

java.lang.Object
  |
  +--com.instantbank.common.utilcomponents.UtilOnJdk

public class UtilOnJdk
extends java.lang.Object

Various general algorithms implemented as static methods.

Author:
InstantBank (Rodrigo Lopez)

Field Summary
static int BAD_SYNTAX_NAME
          An ill formed name has been detected.
static int OK
          A verification is OK.
static char ROW_SEPARATOR
          Row separator
static char VALUE_SEPARATOR
          Value separator
static int VOID_NAME
          A void name has been detected.
 
Constructor Summary
UtilOnJdk()
           
 
Method Summary
static java.lang.Object isValidName(java.lang.String s)
          Validates if a String is a valid name in the system.
static boolean isValidNamePart(java.lang.String s)
          Decides if a nonblank String can be part of a name in the system.
static java.lang.String serializeRowSet(java.util.ArrayList rowset)
          Serialize an ArrayList to a String.
static java.lang.String squeeze(java.lang.String s)
          Starting from a String, produces a new String where all internal white space sequences have length = 1 and all letters are in lowercase.
static java.lang.String squeeze(java.lang.String s, char whiteReplacement)
          Starting from a String, produces a new String where each internal white space sequence is replaced by one occurrence of the "whiteReplacement" parameter and all letters are in lowercase.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

OK

public static final int OK
A verification is OK.

VOID_NAME

public static final int VOID_NAME
A void name has been detected.

BAD_SYNTAX_NAME

public static final int BAD_SYNTAX_NAME
An ill formed name has been detected.

ROW_SEPARATOR

public static final char ROW_SEPARATOR
Row separator

VALUE_SEPARATOR

public static final char VALUE_SEPARATOR
Value separator
Constructor Detail

UtilOnJdk

public UtilOnJdk()
Method Detail

isValidName

public static java.lang.Object isValidName(java.lang.String s)
Validates if a String is a valid name in the system. The name can contain white spaces and they are converted to exactly one occurrence between non void name parts. Letters are also converted to low case. A name part can contain any character excepting: white spaces, control characters, doublequotes, singlequotes, backquotes and backslash.
Parameters:
s - The string to be validated.
Returns:
  • An Integer object if the name is invalid
  • The converted string if the name is valid.

isValidNamePart

public static boolean isValidNamePart(java.lang.String s)
Decides if a nonblank String can be part of a name in the system. invalid characters are: doublequote, singlequote, backquote, backslash.
Parameters:
s - The string to be validated.
Returns:
True if valid, false if non valid.

squeeze

public static java.lang.String squeeze(java.lang.String s)
Starting from a String, produces a new String where all internal white space sequences have length = 1 and all letters are in lowercase.
Parameters:
s - The starting String.
Returns:
The new String with all inner white spaces sequences' length = 1.

squeeze

public static java.lang.String squeeze(java.lang.String s,
                                       char whiteReplacement)
Starting from a String, produces a new String where each internal white space sequence is replaced by one occurrence of the "whiteReplacement" parameter and all letters are in lowercase.
Parameters:
s - The starting String.
whiteReplacement - The character that replaces white spaces sequences.
Returns:
The new String with all inner white spaces sequences replaced by the whiteReplacement character.

serializeRowSet

public static java.lang.String serializeRowSet(java.util.ArrayList rowset)
Serialize an ArrayList to a String. The ArrayList contains arrays of String.
Parameters:
rowset - The set of rows to be serialized
Returns:
A String where rows are separated by the ROW_SEPARATOR non printable character and values in a row are separated by the VALUE_SEPARATOR non printable character.