com.billpringle.utils.wrputils
Class WrpPattern

java.lang.Object
  extended by com.billpringle.utils.wrputils.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  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 str)
          Apply the default pattern to the specified string.
static java.lang.String applyPattern(java.lang.String fld, java.lang.String patt)
          Apply the previously specified pattern against the specified field string.
 java.lang.String getPattern()
          Get the default pattern.
 java.lang.String getString()
          Get the default input string.
private  void init()
          Initialization routine.
static void main(java.lang.String[] args)
          Test driver.
 java.lang.String patternString(java.lang.String patt)
          Apply the default pattern to the specified string.
 void setPattern(java.lang.String pattern)
          Define the default pattern.
 void setString(java.lang.String str)
          Set the default string.
 
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

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 the default pattern. This method stores the specified pattern for later use.


applyPattern

public java.lang.String applyPattern(java.lang.String str)
Apply the default pattern to the specified string.

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

patternString

public java.lang.String patternString(java.lang.String patt)
Apply the default pattern to the specified string.

Parameters:
patt - the pattern to be applied
Returns:
the result of the pattern applied to the default input string

applyPattern

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

Parameters:
fld - the input string
patt - the pattern code to be used in builing the resulting pattern
Returns:
the resulting pattern for the input string using the current pattern

setString

public void setString(java.lang.String str)
Set the default string.

Parameters:
str - the default input string

getString

public java.lang.String getString()
Get the default input string.

Returns:
the default input string

getPattern

public java.lang.String getPattern()
Get the default pattern.

Returns:
the default pattern

main

public static void main(java.lang.String[] args)
Test driver.

Parameters:
args - not used