org.eclipse.rse.ui.validators
Class ValidatorUniqueString
java.lang.Object
org.eclipse.rse.ui.validators.ValidatorUniqueString
-
All Implemented Interfaces:
-
IInputValidator,
ICellEditorValidator,
ISystemValidator,
ISystemValidatorUniqueString
-
Direct Known Subclasses:
-
ValidatorConnectionName,
ValidatorFileFilterString,
ValidatorFileName,
ValidatorFileUniqueName,
ValidatorFilterName,
ValidatorFilterPoolName,
ValidatorFilterString,
ValidatorFolderName,
ValidatorPathName,
ValidatorSourceType,
ValidatorSystemName
-
public class ValidatorUniqueString
- extends
Object
- implements
ISystemValidator,
ISystemValidatorUniqueString
This class is used in dialogs that prompt for a string
that has to be unique. Unless you use the constructor that takes another
IInputValidator as input, no syntax checking is done other than checking
the input is non-empty and unique.
The IInputValidator interface is implemented by our parent and it
is used by jface's InputDialog class and property sheet window.
CASE_SENSITIVE
public static final boolean CASE_SENSITIVE
-
See Also:
-
Constant Field Values
CASE_INSENSITIVE
public static final boolean CASE_INSENSITIVE
-
See Also:
-
Constant Field Values
QUOTE
public static final char QUOTE
-
See Also:
-
Constant Field Values
syntaxValidator
protected
ISystemValidator syntaxValidator
caseSensitive
protected boolean caseSensitive
useUpperCase
protected boolean useUpperCase
existingList
protected
String[] existingList
msg_Empty
protected
SystemMessage msg_Empty
msg_NonUnique
protected
SystemMessage msg_NonUnique
currentMessage
protected
SystemMessage currentMessage
ValidatorUniqueString
public ValidatorUniqueString(
Collection existingList,
boolean caseSensitive)
-
Parameters:
-
existingList
- a collection of existing strings to compare against.
Note that toString() is used to get the string from each item. -
caseSensitive
- true if comparisons are to be case sensitive, false if case insensitive.
ValidatorUniqueString
public ValidatorUniqueString(
String[] existingList,
boolean caseSensitive)
- Constructor accepting an Array.
-
Parameters:
-
existingList
- An array containing list of existing strings to compare against. -
caseSensitive
- true if comparisons are to be case sensitive, false if case insensitive.
ValidatorUniqueString
public ValidatorUniqueString(
Collection existingList,
boolean caseSensitive,
ISystemValidator syntaxValidator)
- Constructor accepting a collection and another validator to use for the syntax checking.
-
Parameters:
-
existingList
- A collection of existing strings to compare against.
Note that toString() is used to get the string from each item. -
caseSensitive
- true if comparisons are to be case sensitive, false if case insensitive. -
syntaxValidator
- Another IInputValidator who does the job of checking the syntax. After
checking for non-nullness and uniqueness, this validator is used to
check for syntax.
ValidatorUniqueString
public ValidatorUniqueString(
String[] existingList,
boolean caseSensitive,
ISystemValidator syntaxValidator)
- Constructor accepting an Array and another validator to use for the syntax checking.
-
Parameters:
-
existingList
- An array containing list of existing strings to compare against. -
caseSensitive
- true if comparisons are to be case sensitive, false if case insensitive. -
syntaxValidator
- Another IInputValidator who does the job of checking the syntax. After
checking for non-nullness and uniqueness, this validator is used to
check for syntax.
setCaseSensitive
public void setCaseSensitive(boolean caseSensitive)
- Reset whether this is a case-sensitive list or not
-
-
Specified by:
-
setCaseSensitive
in interface
ISystemValidatorUniqueString
-
setUseUpperCase
public void setUseUpperCase()
- For case-insensitive, we typically fold to lowercase, affecting what
this user sees in the substitution value of error messages.
Call this so the value substituted is uppercase vs lowercase.
-
-
setExistingNamesList
public void setExistingNamesList(
Collection newList)
- Reset the collection of existing names.
The collection will not be modified by the validator.
-
-
Specified by:
-
setExistingNamesList
in interface
ISystemValidatorUniqueString
-
setExistingNamesList
public void setExistingNamesList(
String[] existingList)
- Reset the existing names list.
-
-
Specified by:
-
setExistingNamesList
in interface
ISystemValidatorUniqueString
-
getExistingNamesList
public
String[] getExistingNamesList()
- Return the existing names list. This will be a case-normalized and sorted list.
-
-
Specified by:
-
getExistingNamesList
in interface
ISystemValidatorUniqueString
-
quotedToLowerCase
public static
String quotedToLowerCase(
String input)
- Special-case way to fold non-quoted parts of a string to lowercase
-
-
setErrorMessages
public void setErrorMessages(
SystemMessage msg_Empty,
SystemMessage msg_NonUnique)
- Supply your own error message text. By default, messages from RSEUIPlugin resource bundle are used.
-
-
-
Parameters:
-
msg_Empty
- error message when entry field is empty or null if to keep the default -
msg_NonUnique
- error message when value entered is not unique or null if to keep the default
isSyntaxOk
public
SystemMessage isSyntaxOk(
String newText)
- Override in child to do your own syntax checking.
-
-
toString
public
String toString()
-
-
Overrides:
-
toString
in class
Object
-
doMessageSubstitution
protected
String doMessageSubstitution(
SystemMessage msg,
String substitution)
- Helper method to substitute data into a message
-
-
getSystemMessageText
protected
String getSystemMessageText(
SystemMessage msg)
- Helper method to set the current system message and return its level one text
-
-
isValid
public
String isValid(
String newText)
-
Deprecated. You should be using
validate(String)
and SystemMessage objects
- Validates the given string. Returns the error message
used if the given string isn't valid. A return value
null
or a string of length zero indicates
that the value is valid.
Note this is called per keystroke, by the platform.
-
-
Specified by:
-
isValid
in interface
IInputValidator
-
isValid
public
String isValid(
Object newValue)
- As required by ICellEditor
-
-
Specified by:
-
isValid
in interface
ICellEditorValidator
-
getMaximumNameLength
public int getMaximumNameLength()
- Return the max length for this name, or -1 if no max
-
-
Specified by:
-
getMaximumNameLength
in interface
ISystemValidator
-
getSystemMessage
public
SystemMessage getSystemMessage()
- When isValid returns non-null, call this to get the SystemMessage object for the error
versus the simple string message.
-
-
Specified by:
-
getSystemMessage
in interface
ISystemValidator
-
validate
public
SystemMessage validate(
String text)
- For convenience, this is a shortcut to calling:
if (isValid(text) != null)
msg = getSystemMessage();
-
-
Specified by:
-
validate
in interface
ISystemValidator
-
Copyright (c) IBM Corporation and others 2000, 2008. All Rights Reserved.