Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

RSE
Release 3.0

org.eclipse.rse.ui.validators
Class ValidatorUniqueString


java.lang.Object
  extended by 
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.


Field Summary
static boolean CASE_INSENSITIVE
           
static boolean CASE_SENSITIVE
           
protected  boolean caseSensitive
           
protected   SystemMessage currentMessage
           
protected   String[] existingList
           
protected   SystemMessage msg_Empty
           
protected   SystemMessage msg_NonUnique
           
static char QUOTE
           
protected   ISystemValidator syntaxValidator
           
protected  boolean useUpperCase
           
 
Constructor Summary
ValidatorUniqueString ( Collection existingList, boolean caseSensitive)
           
ValidatorUniqueString ( Collection existingList, boolean caseSensitive, ISystemValidator syntaxValidator)
          Constructor accepting a collection and another validator to use for the syntax checking.
ValidatorUniqueString ( String[] existingList, boolean caseSensitive)
          Constructor accepting an Array.
ValidatorUniqueString ( String[] existingList, boolean caseSensitive, ISystemValidator syntaxValidator)
          Constructor accepting an Array and another validator to use for the syntax checking.
 
Method Summary
protected   String doMessageSubstitution ( SystemMessage msg, String substitution)
          Helper method to substitute data into a message
  String[] getExistingNamesList ()
          Return the existing names list.
 int getMaximumNameLength ()
          Return the max length for this name, or -1 if no max
  SystemMessage getSystemMessage ()
          When isValid returns non-null, call this to get the SystemMessage object for the error versus the simple string message.
protected   String getSystemMessageText ( SystemMessage msg)
          Helper method to set the current system message and return its level one text
  SystemMessage isSyntaxOk ( String newText)
          Override in child to do your own syntax checking.
  String isValid ( Object newValue)
          As required by ICellEditor
  String isValid ( String newText)
          Deprecated. You should be using validate(String) and SystemMessage objects
static  String quotedToLowerCase ( String input)
          Special-case way to fold non-quoted parts of a string to lowercase
 void setCaseSensitive (boolean caseSensitive)
          Reset whether this is a case-sensitive list or not
 void setErrorMessages ( SystemMessage msg_Empty, SystemMessage msg_NonUnique)
          Supply your own error message text.
 void setExistingNamesList ( Collection newList)
          Reset the collection of existing names.
 void setExistingNamesList ( String[] existingList)
          Reset the existing names list.
 void setUseUpperCase ()
          For case-insensitive, we typically fold to lowercase, affecting what this user sees in the substitution value of error messages.
  String toString ()
           
  SystemMessage validate ( String text)
          For convenience, this is a shortcut to calling: if (isValid(text) !
 
Methods inherited from class java.lang. Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

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
Constructor Detail

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.
Method Detail

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

RSE
Release 3.0

Copyright (c) IBM Corporation and others 2000, 2008. All Rights Reserved.

 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire