|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.rim.device.api.ui.text.TextFilter
net.rim.device.api.ui.text.IPTextFilter
public class IPTextFilter
Filters out characters not used in IP/Port text strings
Field Summary | ||
---|---|---|
static int |
NO_PORTS
A constant indicating that no ports are allowed in the string. |
|
static int |
NUMERIC_IP_ONLY
A constant indicating that if set, IP addresses can only consist of numeric characters. |
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 | ||
---|---|---|
IPTextFilter()
Constructs new IPTextFilter object with no parameters. |
||
IPTextFilter(int flag)
Constructs new IPTextFilter object. |
Method Summary | ||
---|---|---|
char |
convert(char character,
int status)
Converts a valid character to its lower case form and an invalid character to its alternate version. |
|
void |
convert(StringBuffer characters,
int status,
StringBuffer result)
Convert a user input character to its appropriate alternate version if it is invalid for the current text field. |
|
boolean |
validate(char character)
Validates a character for use with this filter. |
|
boolean |
validate(AbstractString text)
Determines if the 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 |
---|
public static final int NO_PORTS
public static final int NUMERIC_IP_ONLY
Constructor Detail |
---|
public IPTextFilter()
public IPTextFilter(int flag)
Takes an argument that specifies if UDP ports are allowed.
flag
- Flag to specify if UDP ports are allowed.Method Detail |
---|
public char convert(char character, int status)
convert
in class TextFilter
character
- The character to convert.status
- Indicates how the character was generated: some filters use this to affect the conversion performed.
public void convert(StringBuffer characters, int status, StringBuffer result)
Convert a user input character to its appropriate alternate version if it is invalid for the current text field. Also used to filter key labels to help create desired (reduced) keyboard layout for the current text field.
This function works in three different scenarios indicated by the current input field type (see private field _flags) and whether virtual keyboard is supported.
In case 3, only a single character is converted by using the following rules:
if the char is not valid if the field is IP address return the alternative char else if the _toLower bit is set return the lowercase char
Note that the alternative char may still be an invalid char for the current field. After calling this function, users still need to call this class' validate function to check each char.
For a device with a virtual keyboard, if a text field is IP address or hostname, this method is used both to filter keyboard input and filter keys' labels to create keyboard layout desired for the current text field. For example, on a reduced keyboard for IP address editing the number sign key (#) can be mapped to the period key (.) and the asterisk key (*) can be mapped to the colon key (:).
In case 2, for both keyboard input and key labels, the conversion is carried out in the same way as in case 3 except that there might be multiple chars to convert. The multiple chars occur when a device with a virtual keyboard is in a portrait view and the device has a SureType™ keyboard, such as the keyboard on the BlackBerry® Pearl™ Flip 8220 smartphone, where each key has a multiple char label.
In case 1, the function works on a single char and it filters both keyboard labels and keyboard input. When a device with a virtual keyboard is in a portrait view, if the current field is IP address, different from case 2, and the keyboard is a reduced multi-tap style keyboard where only the number (0-9), period (.), colon (:), Del, and Enter keys are displayed (the Alt and Sym keys are also shown but are disabled), a lot of key mapping work must occur.
KeypadListener.STATUS_ALT
is set in status, it is a primary label and returns null.
convert
in class TextFilter
characters
- The character to convert.status
- Indicates how the character was generated, the type of the text field and
how the conversion should be performed.result
- The converted result.
For case 2 and 3, return the lowercase form of the given alphabet character(s) for
invalid character(s) - returns the result of Keypad.getAltedChar(char)
.
For case 1, the result is dependent on the running contextpublic boolean validate(AbstractString text)
validate
in class TextFilter
text
- The string with characters to validate.
public boolean validate(char character)
validate
in class TextFilter
character
- The character to validate.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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.