de.janrufmonitor.util.formatter
Class Formatter

java.lang.Object
  extended by de.janrufmonitor.util.formatter.Formatter

public class Formatter
extends Object

This class provides formatting functions for phonenumbers and names.

Author:
Thilo Brandt

Method Summary
static Formatter getInstance(IRuntime runtime)
          Gets the singleton instance of the Formatter for the specified IRuntime instance.
 String getParsedCall(String text, ICall call)
          Deprecated.  
 String getParsedCaller(String text, ICaller caller)
          Deprecated.  
 String getParsedCalltime(String text, Date date)
          Deprecated.  
 String getParsedName(String text, IName name)
          Deprecated.  
 String getParsedPhonenumber(String text, IPhonenumber pn)
          Deprecated.  
 IPhonenumber getPhonenumber(String phone, String format)
          Parses a phone string and tries to build a valid IPhonenumber object.
 String normalizePhonenumber(String phone)
           
 String parse(String text, Object o)
          Parses the String object and replaces the standard placeholders with the value of the passed Object.
 String toCallablePhonenumber(String phone)
          Formats a string with number information in a callable format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static Formatter getInstance(IRuntime runtime)
Gets the singleton instance of the Formatter for the specified IRuntime instance.

Parameters:
runtime -
Returns:

parse

public String parse(String text,
                    Object o)
Parses the String object and replaces the standard placeholders with the value of the passed Object. The Object is checked for instances of ICall, ICaller, IPhonenumber, IName and Date. An individual parsing method is called for each instance type. If an unknown Object instance is passed, the original String is returned back. If null is passed the original String is returned back, too.

Parameters:
text - String containing the standard placeholders.
o - object to get the data for replacement from
Returns:
the parsed String object

getPhonenumber

public IPhonenumber getPhonenumber(String phone,
                                   String format)
Parses a phone string and tries to build a valid IPhonenumber object.

Parameters:
phone -
Returns:

getParsedCall

public String getParsedCall(String text,
                            ICall call)
Deprecated. 

Parses call object in the specified text representation. The wildcard definitions are taken for parsing.

Parameters:
text - text to parse
call - object to get the information from
Returns:
parsed text

getParsedCalltime

public String getParsedCalltime(String text,
                                Date date)
Deprecated. 

Parses date object in the specified text representation. The wildcard definitions are taken for parsing.

Parameters:
text - text to parse
date - object to get the information from
Returns:
parsed text

getParsedCaller

public String getParsedCaller(String text,
                              ICaller caller)
Deprecated. 

Parses caller object in the specified text representation. The wildcard definitions are taken for parsing.

Parameters:
text - text to parse
caller - object to get the information from
Returns:
parsed text

getParsedPhonenumber

public String getParsedPhonenumber(String text,
                                   IPhonenumber pn)
Deprecated. 

Parses phonenumber object in the specified text representation. The wildcard definitions are taken for parsing.

Parameters:
text - text to parse
phonenumber - object to get the information from
Returns:
parsed text

getParsedName

public String getParsedName(String text,
                            IName name)
Deprecated. 

Parses Name object in the specified text representation. The wildcard definitions are taken for parsing.

Parameters:
text - text to parse
Name - object to get the information from
Returns:
parsed text

normalizePhonenumber

public String normalizePhonenumber(String phone)

toCallablePhonenumber

public String toCallablePhonenumber(String phone)
Formats a string with number information in a callable format. Example: +4972657110 --> 004972657110 +49 (7165) 7110 --> 004972657110

Parameters:
phone -
Returns:


Copyright © 2010 by Thilo Brandt. All Rights Reserved.