com.billpringle.utils
Class WrpPattern

java.lang.Object
  extended by com.billpringle.utils.WrpPattern

public class WrpPattern
extends java.lang.Object

This class translates content strings into pattern strings, reflecting the type of characters in the original strings.

This class allows the user to determine the general pattern of a data string, such as all numeric, alphabetic, etc. Pattern indicators include the following:

This class can also be used to remove any characters that doesn't match a given pattern. The following types of patterns are supported. The following codes are case-insensitive.

Creative Commons License Creative Commons License Symbols Unless noted otherwise, all materials available for download from my site are copyrighted by Bill Pringle, and are licensed under a Creative Commons License.

Author:
Bill Pringle

Field Summary
private  boolean caseFlg
          case sensitive flag
private  java.lang.String inString
          input string - output pattern based on this string
private  java.lang.String pattern
          pattern key - what kind of pattern
 
Constructor Summary
WrpPattern()
          Default constructor
WrpPattern(java.lang.String str)
          Constructor using default pattern and specified string
 
Method Summary
 java.lang.String applyPattern(java.lang.String fld)
          Apply the previously specified pattern against the specified field string.
 java.lang.String applyPattern(java.lang.String str, java.lang.String patt)
          Apply the specified pattern to the specified string.
 java.lang.String getPattern()
           
 java.lang.String getString()
           
private  void init()
          Initialization routine.
 boolean isCaseFlg()
           
static void main(java.lang.String[] args)
           
 void setCaseFlg(boolean caseFlg)
           
 void setPattern(java.lang.String pattern)
          Define a pattern This method stores the specified pattern for later use.
 void setString(java.lang.String str)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

inString

private java.lang.String inString
input string - output pattern based on this string


pattern

private java.lang.String pattern
pattern key - what kind of pattern


caseFlg

private boolean caseFlg
case sensitive flag

Constructor Detail

WrpPattern

public WrpPattern()
Default constructor


WrpPattern

public WrpPattern(java.lang.String str)
Constructor using default pattern and specified string

Parameters:
str -
Method Detail

init

private void init()
Initialization routine. This method clears the input string and the output pattern string.


setPattern

public void setPattern(java.lang.String pattern)
Define a pattern This method stores the specified pattern for later use.


applyPattern

public java.lang.String applyPattern(java.lang.String str,
                                     java.lang.String patt)
Apply the specified pattern to the specified string. The pattern is saved and will be used for future calls unless it is overwritten by a subsequent call. If additional patterns are to be built using the same pattern, the applyPattern(fld) method can be used.

Parameters:
str - the string for which a pattern is to be built
patt - the pattern code to be used in builing the resulting pattern
Returns:
a string containing the pattern of the input string using the specified pattern code

applyPattern

public java.lang.String applyPattern(java.lang.String fld)
Apply the previously specified pattern against the specified field string.

Parameters:
fld - the input string
Returns:
the resulting pattern for the input string using the current pattern

setString

public void setString(java.lang.String str)

getString

public java.lang.String getString()

getPattern

public java.lang.String getPattern()

main

public static void main(java.lang.String[] args)
Parameters:
args -

isCaseFlg

public boolean isCaseFlg()
Returns:
the caseFlg

setCaseFlg

public void setCaseFlg(boolean caseFlg)
Parameters:
caseFlg - the caseFlg to set