net.rim.device.api.ui.text
Class PhoneTextFilter

java.lang.Object
  extended by net.rim.device.api.ui.text.TextFilter
      extended by net.rim.device.api.ui.text.PhoneTextFilter

public class PhoneTextFilter
extends TextFilter

Filters out characters not usable in phone number text strings.

This filter recognizes as valid characters all digits, plus left and right parentheses, minus sign, plus sign, x (for extension), the space character, the number sign, the asterisk, question mark and period, uppercase letters (for the following map).

1
2
ABC
3
DEF
4
GHI
5
JKL
6
MNO
7
PQRS
8
TUV
9
WXYZ
*
0
#


Field Summary
static int ACCEPT_ALPHA
          Flag to enable input of alphabetic characters.
static int ACCEPT_CONTROL
          Flag to enable input of control characters.
static int ACCEPT_EVERYTHING_EXCEPT_WILD_CARD
          Flag to enable input of all characters except the ?
static int ACCEPT_EXTENSION
          Flag to enable input of characters used to indicate a phone extension.
static int ACCEPT_FORMATTING
          Flag to enable input of ?
static int ACCEPT_INTERNATIONAL
          Flag to enable input of characters used when dialing international phone numbers.
static int ACCEPT_PAUSE
          Flag to enable input of the pause character.
static int ACCEPT_WAIT
          Flag to enable input of the wait character.
static int ACCEPT_WILD_CARD
          Flag to enable input of the wild card character.
static int INTERNATIONAL_MUST_BE_FIRST
          Flag to specify that the field should only accept characters used in international dialing only if they are the first character in the field.
 
Fields inherited from class net.rim.device.api.ui.text.TextFilter
ADN_SIM_PHONE, DEFAULT, DEFAULT_SMART_PHONE, EMAIL, FDN_SIM_PHONE, FILENAME, HEXADECIMAL, INTEGER, IP, LOWERCASE, NUMERIC, PHONE, PIN_ADDRESS, REAL_NUMERIC, SIM_PHONE, SMS_PHONE, STYLE_SHIFT, UPPERCASE, URL, VOICEMAIL_PHONE
 
Constructor Summary
PhoneTextFilter()
          Constructs a new PhoneTextFilter instance.
PhoneTextFilter(int style)
          Constructs a new PhoneTextFilter instance, with flags to accept validation of specific characters
 
Method Summary
 char convert(char character, int status)
          Passes character through phone text filter.
 boolean validate(char character)
          Determines if character is a valid phone string character.
 boolean validate(AbstractString text)
          Determines if provided string contains valid characters.
 
Methods inherited from class net.rim.device.api.ui.text.TextFilter
convert, get, validate
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 



Field Detail

ACCEPT_PAUSE

public static final int ACCEPT_PAUSE
Flag to enable input of the pause character. This character is a comma (,).

See Also:
Constant Field Values
Since:
BlackBerry API 4.0.2

ACCEPT_WAIT

public static final int ACCEPT_WAIT
Flag to enable input of the wait character. This character is an exclamation mark (!).

See Also:
Constant Field Values
Since:
BlackBerry API 4.0.2

ACCEPT_CONTROL

public static final int ACCEPT_CONTROL
Flag to enable input of control characters. These characters are an asterisk (*) and a number sign (#).

See Also:
Constant Field Values
Since:
BlackBerry API 4.0.2

ACCEPT_WILD_CARD

public static final int ACCEPT_WILD_CARD
Flag to enable input of the wild card character. This character is a question mark (?).

See Also:
Constant Field Values
Since:
BlackBerry API 4.0.2

ACCEPT_ALPHA

public static final int ACCEPT_ALPHA
Flag to enable input of alphabetic characters. These characters are any uppercase and lowercase letters.

See Also:
Constant Field Values
Since:
BlackBerry API 4.0.2

ACCEPT_FORMATTING

public static final int ACCEPT_FORMATTING
Flag to enable input of ?formatting? characters. These characters are hyphen (-), period (.), space ( ), and opening and closing parentheses.

See Also:
Constant Field Values
Since:
BlackBerry API 4.0.2

ACCEPT_EXTENSION

public static final int ACCEPT_EXTENSION
Flag to enable input of characters used to indicate a phone extension. These characters are the letters ?e?, ?x?, and ?t?.

See Also:
Constant Field Values
Since:
BlackBerry API 4.0.2

ACCEPT_INTERNATIONAL

public static final int ACCEPT_INTERNATIONAL
Flag to enable input of characters used when dialing international phone numbers. These characters consist of only the plus sign (+).

See Also:
Constant Field Values
Since:
BlackBerry API 4.0.2

INTERNATIONAL_MUST_BE_FIRST

public static final int INTERNATIONAL_MUST_BE_FIRST
Flag to specify that the field should only accept characters used in international dialing only if they are the first character in the field.

See Also:
Constant Field Values
Since:
BlackBerry API 4.0.2

ACCEPT_EVERYTHING_EXCEPT_WILD_CARD

public static final int ACCEPT_EVERYTHING_EXCEPT_WILD_CARD
Flag to enable input of all characters except the ?wild card? character. See ACCEPT_WILD_CARD.

See Also:
Constant Field Values
Since:
BlackBerry API 4.0.2


Constructor Detail

PhoneTextFilter

public PhoneTextFilter()
Constructs a new PhoneTextFilter instance. All valid characters are accepted except '?' This duplicates the default behaviour of this filter before the flags were added.


PhoneTextFilter

public PhoneTextFilter(int style)
Constructs a new PhoneTextFilter instance, with flags to accept validation of specific characters

Parameters:
style - The Style for this filter. Flags to accept validation of specific characters (for example: ACCEPT_PAUSE, ACCEPT_WAIT).
Since:
BlackBerry API 4.0.2


Method Detail

convert

public char convert(char character,
                    int status)
Passes character through phone text filter.

The current behaviour of this filter is to automatically ALT the characters so that numbers, the period, and the dash are entered by default. When SHIFT is pressed, uppercase letters are returned. Holding ALT allows for 'x' to be entered (in case there is an allowable symbol on this key).

Specified by:
convert in class TextFilter
Parameters:
character - Character to translate.
status - a value that indicates how the character was generated.
Returns:
Filtered version of provided character.

Special Cases:
- ALT 'space' on a SureType keypad returns 'space'.


validate

public boolean validate(char character)
Determines if character is a valid phone string character.

Specified by:
validate in class TextFilter
Parameters:
character - Character to test.
Returns:
True if the character is a valid phone string character (see this class's description); otherwise, false.

validate

public boolean validate(AbstractString text)
Determines if provided string contains valid characters.

This method checks each character in your provided string with PhoneTextFilter.validate(char) for validity. It does no checking that your string is a well formed phone number.

Overrides:
validate in class TextFilter
Parameters:
text - String to test.
Returns:
True if each character in the string passes a validity check, or if string is null; otherwise, false.





Copyright 1999-2010 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.