com.cafesoft.core.field
Class IntegerFieldValuePattern

java.lang.Object
  |
  +--com.cafesoft.core.field.IntegerFieldValuePattern
All Implemented Interfaces:
FieldValuePattern

public class IntegerFieldValuePattern
extends Object
implements FieldValuePattern

Integer implementation of the FieldValuePattern interface. This object provides a mechanism to specify Integer specific patterns. This object contains the necessary logic to match Integer and String values to the specified pattern.


Constructor Summary
IntegerFieldValuePattern(String pattern)
          Create a new IntegerFieldValuePattern.
 
Method Summary
 boolean equals(Object obj)
          Indicates whether some other object is "equal to" this one.
 String getPattern()
          Get a String representation of the pattern.
 int hashCode()
          Get the hashCode of the IntegerFieldValuePattern object.
 boolean matches(Object fieldValue)
          Check for a pattern match.
 BigDecimal score()
          Get the score of the FieldValuePattern.
 String toString()
          Returns a string representation of the object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IntegerFieldValuePattern

public IntegerFieldValuePattern(String pattern)
                         throws InvalidPatternException
Create a new IntegerFieldValuePattern.

This pattern value must be either "*" or a parsable integer value. Failure to follow these two constraints will result in a InvalidPatternException being thrown.

Parameters:
pattern - the String representation of the pattern.
Throws:
InvalidPatternException - if the pattern is null, or if the pattern does not equal * and is not a valid integer value.
Method Detail

matches

public boolean matches(Object fieldValue)
Check for a pattern match.

Matching is done using the following algorithm.

  1. If the fieldValue object is null the pattern DOES NOT MATCH.
  2. If the fieldValue object is an instance of a String object that is not a valid parsable integer value the pattern DOES NOT MATCH.
  3. If the fieldValue object is not an instance of either a String object or an Integer object the pattern DOES NOT MATCH.
  4. If the pattern is the wildcard character "*" the pattern MATCHES.
  5. If the pattern does not equal the integer value described by the pattern then the pattern DOES NOT MATCH.
  6. If the algorithm has successfully navigated through these rules then the pattern MATCHES.

    Specified by:
    matches in interface FieldValuePattern
    Returns:
    true if this FieldValuePattern matches the specified Field value else return false.

getPattern

public String getPattern()
Get a String representation of the pattern.

Specified by:
getPattern in interface FieldValuePattern
Returns:
a String representation of the pattern.

score

public BigDecimal score()
Get the score of the FieldValuePattern.

The FieldValuePattern's score is a value that determines how specific a particular a pattern is. It is a mechanism that allows the implementor to decided how specific a pattern is. For example, a concrete string value of "abcde" is much more specific than a string that contains a wildcard such as "abcd*". Therefore, this method allows for the calculation of that value.

The score of the IntegerFieldValuePattern is calculated using the following algorithm:

Specified by:
score in interface FieldValuePattern
Returns:
a BigDecimal object that contains this FieldValuePattern objects score.

hashCode

public int hashCode()
Get the hashCode of the IntegerFieldValuePattern object.

Overrides:
hashCode in class Object
Returns:
the hashCode of the IntegerFieldValuePattern object.

equals

public boolean equals(Object obj)
Indicates whether some other object is "equal to" this one.

Overrides:
equals in class Object
Parameters:
obj - the reference object with which to compare.
Returns:
true if this object is the same as the obj argument; false otherwise.

toString

public String toString()
Returns a string representation of the object.

Overrides:
toString in class Object
Returns:
a string representation of the object.


Generated on 8:41:50 AM June 06, 2005, © 1996-2005 Cafésoft LLC. All rights reserved.