public class RuleInputField extends JComponent implements KeyListener, FocusListener, CaretListener, ProcessingClient
N:X:Y
- numeric field, accepts digits only
H:X:Y
- hex field, accepts only hexadecimal digits
A:X:Y
- alpha field, accepts only letters, no digits
AN:X:Y
- alpha-numeric field, accepts digits and letters
"N:4:4 - H:6:6 - AN:3:3 x A:5:5"
Modifier and Type | Class and Description |
---|---|
private static class |
RuleInputField.FieldSpec |
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
private RuleTextField |
activeField |
private boolean |
backstep |
private static int |
DEFAULT
Used internally to identify the default setting for the return format.
|
static int |
DISPLAY_FORMAT
Used to specify the retsult format.
|
static int |
ENCRYPTED
Used to specify the retsult format.
|
private Processor |
encryptionService
Holds an instance of the
Processor if one was specified and available |
private boolean |
hasParams |
private InstallData |
idata |
private Vector |
inputFields
This
Vector holds a reference to each input field, in the order in which they
appear on the screen. |
private Vector |
items |
static int |
PLAIN_STRING
Used to specify the retsult format.
|
private int |
resultFormat |
private String |
separator |
private static long |
serialVersionUID |
static int |
SPECIAL_SEPARATOR
Used to specify the retsult format.
|
private Toolkit |
toolkit |
private Validator |
validationService
Holds an instance of the
Validator if one was specified and available |
private Map |
validatorParams |
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
RuleInputField(String format,
String preset,
String separator,
String validator,
Map validatorParams,
String processor,
int resultFormat,
Toolkit toolkit,
InstallData idata)
Constructs a rule input field.
|
RuleInputField(String format,
String preset,
String separator,
String validator,
String processor,
int resultFormat,
Toolkit toolkit,
InstallData idata)
Constructs a rule input field.
|
Modifier and Type | Method and Description |
---|---|
void |
caretUpdate(CaretEvent event)
Called when the caret position is updated.
|
private void |
createItems(String format)
Creates the items that make up this field.
|
void |
focusGained(FocusEvent event)
Invoked when a component gains the keyboard focus.
|
void |
focusLost(FocusEvent event)
Invoked when a component loses the keyboard focus.
|
String |
getFieldContents(int index)
Returns the contents of the field indicated by
index . |
int |
getNumFields()
Returns the number of sub-fields composing this
RuleInputField . |
String |
getText()
Returns the field contents, assembled acording to the encryption and separator rules.
|
Map |
getValidatorParams()
Returns the validator parameters, if any.
|
boolean |
hasParams() |
void |
keyPressed(KeyEvent event)
This method is invoked when a key has been pressed.
|
void |
keyReleased(KeyEvent event)
This method is invoked when a key has been released.
|
void |
keyTyped(KeyEvent event)
This method is invoked when a key has been typed.
|
private void |
setFields(String data)
Sets each field to a pre-defined value.
|
boolean |
validateContents()
This method validates the field content.
|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
private static final long serialVersionUID
public static final int PLAIN_STRING
public static final int DISPLAY_FORMAT
public static final int SPECIAL_SEPARATOR
public static final int ENCRYPTED
private static int DEFAULT
private Vector inputFields
Vector
holds a reference to each input field, in the order in which they
appear on the screen.private boolean hasParams
private Map validatorParams
private RuleTextField activeField
private boolean backstep
private int resultFormat
private InstallData idata
private Validator validationService
Validator
if one was specified and availableprivate Processor encryptionService
Processor
if one was specified and availablepublic RuleInputField(String format, String preset, String separator, String validator, Map validatorParams, String processor, int resultFormat, Toolkit toolkit, InstallData idata)
format
- a string that specifies the formatting and to a limited degree the behavior of
this field.preset
- a string that specifies preset values for specific sub-fields.separator
- a string to be used for separating the contents of individual fields in the
string returned by getText()
validator
- A string that specifies a class to perform validation services. The string
must completely identify the class, so that it can be instantiated. The class must implement
the RuleValidator
interface. If an attempt to instantiate this class fails, no
validation will be performed.validatorParams
- A java.util.Map
containing name/ value pairs, which
will be forwarded to the validator.processor
- A string that specifies a class to perform processing services. The string
must completely identify the class, so that it can be instantiated. The class must implement
the Processor
interface. If an attempt to instantiate this class fails, no
processing will be performed. Instead, the text is returned in the default formatting.resultFormat
- specifies in which format the resulting text should be returned, wehn
getText()
is called. The following values are legal:toolkit
- needed to gain access to beep()
public RuleInputField(String format, String preset, String separator, String validator, String processor, int resultFormat, Toolkit toolkit, InstallData idata)
format
- a string that specifies the formatting and to a limited degree the behavior of
this field.preset
- a string that specifies preset values for specific sub-fields.separator
- a string to be used for separating the contents of individual fields in the
string returned by getText()
validator
- A string that specifies a class to perform validation services. The string
must completely identify the class, so that it can be instantiated. The class must implement
the RuleValidator
interface. If an attempt to instantiate this class fails, no
validation will be performed.processor
- A string that specifies a class to perform processing services. The string
must completely identify the class, so that it can be instantiated. The class must implement
the Processor
interface. If an attempt to instantiate this class fails, no
processing will be performed. Instead, the text is returned in the default formatting.resultFormat
- specifies in which format the resulting text should be returned, wehn
getText()
is called. The following values are legal:toolkit
- needed to gain access to beep()
public boolean hasParams()
public int getNumFields()
RuleInputField
.getNumFields
in interface ProcessingClient
public String getFieldContents(int index) throws IndexOutOfBoundsException
index
.getFieldContents
in interface ProcessingClient
index
- the index of the sub-field from which the contents is requested.IndexOutOfBoundsException
- if the index is out of bounds.public Map getValidatorParams()
hasParams()
method prior to invoking this method.public String getText()
private void createItems(String format)
items
. In addition, all fields are
stored in inputFields
.format
- a string that specifies the layout of the input fields and separators.private void setFields(String data)
data
- a String
containing the preset values for each field. The format
of the string is as follows: The content for the individuals fields must be separated by
whitespace. Each data block is preceeded by the index of the field to set (counting starts at
0) followed by a colon ':'and after that the actual data for the field.public boolean validateContents()
true
if the validation passes or no implementation of a validation
rule exists. Otherwise false
is returned.public void keyTyped(KeyEvent event)
keyTyped
in interface KeyListener
event
- the key event forwarded by the system.public void keyPressed(KeyEvent event)
keyPressed
in interface KeyListener
event
- the key event forwarded by the system.public void keyReleased(KeyEvent event)
keyReleased
in interface KeyListener
event
- the key event forwarded by the system.public void focusGained(FocusEvent event)
focusGained
in interface FocusListener
event
- the focus event forwardes by the sytem.public void focusLost(FocusEvent event)
focusLost
in interface FocusListener
event
- the focus event forwardes by the sytem.public void caretUpdate(CaretEvent event)
caretUpdate
in interface CaretListener
event
- the caret event received from the text fieldWebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses