JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.field.validate
Interface JCValidator

All Superinterfaces:
Serializable
All Known Implementing Classes:
AbstractValidator

public interface JCValidator
extends Serializable

Interface for writing validators.


Field Summary
static int DOWN
          Enum for mask returned by calculateSpinability().
static int UP
          Enum for mask returned by calculateSpinability().
 
Method Summary
 int calculateSpinability(Object current_value)
          Finds out whether or not further spinning is possible.
 void changeText(com.klg.jclass.field.validate.TextEvent e)
          Called by a TextChangedListener; gives the validator an opportunity to control the change of text.
 boolean compareValues(Object v1, Object v2)
          Since we cannot always rely on an object's equals() method we must define out own compare method.
 Object copyValue(Object value)
          Since the clone() method is protected in the Object class, we cannot actually clone a generic object without knowing what it is; therefore the validator must provide this routine to do the copying for Field.
 com.klg.jclass.field.validate.PopupFieldEditor createPopupComponent()
          Returns the PopupFieldEditor.
 String format(Object obj)
          Generates a String representation of the given object.
 String formatForEdit(Object obj)
          Generates a String representation of the given object for use in edit mode.
 Object getDefaultValue()
          Returns the default value for the validator.
 int getFirstValidCursorPosition()
          Gets the first valid cursor position.
 ListModel getPickList()
          Returns the list of values that the end user can pick from.
 int getPickListIndex(Object obj)
          Returns the offset into the PickList of the object.
 boolean hasEditFormat()
          Reports whether the validator has a different edit format or not.
 void inferSubField(int selection_start, int selection_end)
          Infers the sub-field we need to work on from the current selected region.
 boolean isClassSupported(Class c)
          Returns true if the object passed in is the native type that the validator is designed to support.
 Object parse(Class c, String text)
          Validates the specified text, and returns a new Object if successful.
 void setCursor(com.klg.jclass.field.validate.TextCursorEvent e)
          Sets the cursor to the specified position.
 void setPickList(ListModel picklist)
          Sets the pick list.
 Object spinDown(Object current)
          If the validator has the ability to "spin," this gives us the prvious value.
 Object spinUp(Object current)
          If the validator has the ability to "spin," this gives us the next value.
 boolean validate(Object obj)
          Validates the given object.
 

Field Detail

UP

public static final int UP
Enum for mask returned by calculateSpinability().

See Also:
Constant Field Values

DOWN

public static final int DOWN
Enum for mask returned by calculateSpinability().

See Also:
Constant Field Values
Method Detail

getPickList

public ListModel getPickList()
Returns the list of values that the end user can pick from.

Returns:
list of values the end user can pick from

setPickList

public void setPickList(ListModel picklist)
Sets the pick list.

Parameters:
picklist -

changeText

public void changeText(com.klg.jclass.field.validate.TextEvent e)
Called by a TextChangedListener; gives the validator an opportunity to control the change of text.

Parameters:
e -

copyValue

public Object copyValue(Object value)
Since the clone() method is protected in the Object class, we cannot actually clone a generic object without knowing what it is; therefore the validator must provide this routine to do the copying for Field.
Note: Objects that are inherently immutable don't need to be copied and hence just return the passed-in value as the implementation.

Parameters:
value -
Returns:

compareValues

public boolean compareValues(Object v1,
                             Object v2)
Since we cannot always rely on an object's equals() method we must define out own compare method. The default implementation of this in the AbstractValidator class is to call equals() If this is not sufficient, then the subclass can override this method without having to subclass the data object.

Parameters:
v1 -
v2 -
Returns:

setCursor

public void setCursor(com.klg.jclass.field.validate.TextCursorEvent e)
Sets the cursor to the specified position. See TextCursorEvent for the methods setCursor() would use to reposition the cursor, or to reset its position if validation fails.

Parameters:
e - the event triggering the repositioning of the cursor

parse

public Object parse(Class c,
                    String text)
             throws FieldParseException
Validates the specified text, and returns a new Object if successful.

Parameters:
c - sets which class object the text should be converted to
text - text to be converted to an object
Returns:
Throws:
FieldParseException

validate

public boolean validate(Object obj)
Validates the given object.

Parameters:
obj -
Returns:

format

public String format(Object obj)
Generates a String representation of the given object.

Parameters:
obj -
Returns:

formatForEdit

public String formatForEdit(Object obj)
Generates a String representation of the given object for use in edit mode.

Parameters:
obj -
Returns:

hasEditFormat

public boolean hasEditFormat()
Reports whether the validator has a different edit format or not.

Returns:

inferSubField

public void inferSubField(int selection_start,
                          int selection_end)
Infers the sub-field we need to work on from the current selected region. If there is no selected region then the selected region is equal to the cursor position and we don't ever need to look at the cursor position.

Parameters:
selection_start -
selection_end -

spinUp

public Object spinUp(Object current)
If the validator has the ability to "spin," this gives us the next value.

Parameters:
current -
Returns:

spinDown

public Object spinDown(Object current)
If the validator has the ability to "spin," this gives us the prvious value.

Parameters:
current -
Returns:

calculateSpinability

public int calculateSpinability(Object current_value)
Finds out whether or not further spinning is possible. Returns a mask of AbstractValidator.UP and/or AbstractValidator.DOWN.

Parameters:
current_value -
Returns:

getFirstValidCursorPosition

public int getFirstValidCursorPosition()
Gets the first valid cursor position.

Returns:

getPickListIndex

public int getPickListIndex(Object obj)
Returns the offset into the PickList of the object.

Parameters:
obj -
Returns:
offset into the PickList of the object

isClassSupported

public boolean isClassSupported(Class c)
Returns true if the object passed in is the native type that the validator is designed to support.

Parameters:
c -
Returns:
true if the object passed in is the native type

getDefaultValue

public Object getDefaultValue()
Returns the default value for the validator.

Returns:

createPopupComponent

public com.klg.jclass.field.validate.PopupFieldEditor createPopupComponent()
Returns the PopupFieldEditor.

Returns:
the PopupFieldEditor

Copyright © 2004 Quest Software Inc..
All rights reserved.