org.pojomatic.formatter
Class AccountNumberFormatter

java.lang.Object
  extended by org.pojomatic.formatter.DefaultPropertyFormatter
      extended by org.pojomatic.formatter.AccountNumberFormatter
All Implemented Interfaces:
PropertyFormatter

public class AccountNumberFormatter
extends DefaultPropertyFormatter

A property formatter which shows only the last 4 characters of the string representation of the Property, with all others replaced by an asterisk ('*'). Useful for credit card numbers, social security numbers, etc.

For example, a 16 character String representing a credit card number would be formatted as "************1234".


Constructor Summary
AccountNumberFormatter()
           
 
Method Summary
 java.lang.String format(java.lang.Object value)
          Format a given value.
protected  char getFillChar()
           
protected  int getPlaintextChars()
           
 void initialize(java.lang.reflect.AnnotatedElement element)
          Initialize the formatter for use; this method will be called exactly once on an instance, prior to any calls to PropertyFormatter.format(Object).
protected  void setFillChar(char fillChar)
           
protected  void setPlaintextChars(int plaintextChars)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AccountNumberFormatter

public AccountNumberFormatter()
Method Detail

initialize

public void initialize(java.lang.reflect.AnnotatedElement element)
Description copied from interface: PropertyFormatter
Initialize the formatter for use; this method will be called exactly once on an instance, prior to any calls to PropertyFormatter.format(Object). This method does not need to be thread-safe.

Specified by:
initialize in interface PropertyFormatter
Overrides:
initialize in class DefaultPropertyFormatter

format

public java.lang.String format(java.lang.Object value)
Description copied from interface: PropertyFormatter
Format a given value. This method must be thread safe.

Specified by:
format in interface PropertyFormatter
Overrides:
format in class DefaultPropertyFormatter
Parameters:
value - the value to format
Returns:
the value, formatted (must not be null)

getPlaintextChars

protected int getPlaintextChars()

setPlaintextChars

protected void setPlaintextChars(int plaintextChars)

getFillChar

protected char getFillChar()

setFillChar

protected void setFillChar(char fillChar)


Copyright © 2008-2009. All Rights Reserved.