SilverStream
Application Server 3.5

com.sssw.rt.jform
Class AgcJValueField

java.lang.Object
 |
 +--java.awt.Component
       |
       +--java.awt.Container
             |
             +--javax.swing.JComponent
                   |
                   +--javax.swing.text.JTextComponent
                         |
                         +--javax.swing.JTextField
                               |
                               +--com.sssw.rt.jform.AgcJTextField
                                     |
                                     +--com.sssw.rt.jform.AgcJValueField
All Implemented Interfaces:
Accessible, AgiHelpInfo, ImageObserver, MenuContainer, Scrollable, Serializable, SwingConstants
Direct Known Subclasses:
AgcJBigDecimalField, AgcJDateField, AgcJDoubleField, AgcJIntegerField, AgcJTimeField, AgcJTimestampField

public class AgcJValueField
extends AgcJTextField

Base class of several input fields that have non-text data types.

The subclasses for specific data types include:

See Also:
Serialized Form

Inner classes inherited from class javax.swing.JTextField
JTextField.AccessibleJTextField
 
Inner classes inherited from class javax.swing.text.JTextComponent
JTextComponent.AccessibleJTextComponent, JTextComponent.KeyBinding
 
Inner classes inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Fields inherited from class com.sssw.rt.jform.AgcJTextField
NO_LIMIT
 
Fields inherited from class javax.swing.JTextField
notifyAction
 
Fields inherited from class javax.swing.text.JTextComponent
DEFAULT_KEYMAP, FOCUS_ACCELERATOR_KEY
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
AgcJValueField(char datatype)
          Creates an AgcJValueField control.
 
Method Summary
 String format(Object ob, String pattern, int style1, int style2)
          Formats the object according to the specified pattern or style.
 String getDisplayPattern()
          Gets the pattern that the control uses to parse the user's input and display the data.
 int getDisplayStyle()
          Gets the number of the display style assigned to the control.
 Object parse(int datatype, String parseStr, String pattern, int style1, int style2)
          Parses the string according to the specified pattern or style.
 void setDisplayPattern(String pattern)
          Sets the pattern that the control uses to parse the user's input and display the data.
 void setDisplayStyle(int style)
          Sets the style used to parse the user's input and format the displayed data.
 
Methods inherited from class com.sssw.rt.jform.AgcJTextField
getEmptyStringIsNull, getMaxLength, getMinLength, setEmptyStringIsNull, setMaxLength, setMinLength
 
Methods inherited from class javax.swing.JTextField
addActionListener, createDefaultModel, fireActionPerformed, getAccessibleContext, getActions, getColumns, getColumnWidth, getHorizontalAlignment, getHorizontalVisibility, getPreferredSize, getScrollOffset, getUIClassID, isValidateRoot, paramString, postActionEvent, removeActionListener, scrollRectToVisible, setActionCommand, setColumns, setFont, setHorizontalAlignment, setScrollOffset
 
Methods inherited from class javax.swing.text.JTextComponent
addCaretListener, addInputMethodListener, addKeymap, copy, cut, fireCaretUpdate, getCaret, getCaretColor, getCaretPosition, getDisabledTextColor, getDocument, getFocusAccelerator, getHighlighter, getInputMethodRequests, getKeymap, getKeymap, getMargin, getPreferredScrollableViewportSize, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedText, getSelectedTextColor, getSelectionColor, getSelectionEnd, getSelectionStart, getText, getText, getUI, isEditable, isFocusTraversable, isOpaque, loadKeymap, modelToView, moveCaretPosition, paste, processComponentKeyEvent, processInputMethodEvent, read, removeCaretListener, removeKeymap, removeNotify, replaceSelection, select, selectAll, setCaret, setCaretColor, setCaretPosition, setDisabledTextColor, setDocument, setEditable, setEnabled, setFocusAccelerator, setHighlighter, setKeymap, setMargin, setOpaque, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setText, setUI, updateUI, viewToModel, write
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInsets, getInsets, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, isDoubleBuffered, isFocusCycleRoot, isLightweightComponent, isManagingFocus, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, processFocusEvent, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setForeground, setMaximumSize, setMinimumSize, setNextFocusableComponent, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setCursor, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getInputContext, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hide, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods implemented from interface com.sssw.rt.form.AgiHelpInfo
getHelpInfo, setHelpInfo
 

Constructor Detail

AgcJValueField

public AgcJValueField(char datatype)
Creates an AgcJValueField control.
Parameters:
datatype - a constant defined in DatatypeCodes specifying the data type of the value in the input field
Method Detail

getDisplayPattern

public String getDisplayPattern()
Gets the pattern that the control uses to parse the user's input and display the data.
Returns:
a String that is the current display pattern
Usage:
For information on display patterns and styles, see Formatting Patterns and Styles in the online General Reference.

A display pattern overrides a display style. If the display pattern is null, then the display style is used.

You can also set the Display Format property in the Property Inspector.

Example:
  String pattern;
  pattern = ControlName1.getDisplayPattern();
 
See Also:
AgcJValueField.setDisplayPattern(String), AgcJValueField.getDisplayStyle(), AgcJValueField.setDisplayStyle(int)

setDisplayPattern

public void setDisplayPattern(String pattern)
Sets the pattern that the control uses to parse the user's input and display the data.
Parameters:
pattern - a String specifying a format for the numeric data
Usage:
The pattern characters you use depend on the data type of the input field. For information on display patterns and styles, see Formatting Patterns and Styles in the online General Reference. For numeric fields, see also DecimalFormat. For Time, Date and Timestamp field, see also SimpleDateFormat.

If the control has both a display pattern and a display style, the display pattern is used. When you change the display pattern, it doesn't take effect until the value in the control changes.

Example:
  String pattern = "dd-MMM-yyyy";
  ControlName1.setDisplayPattern(pattern);
 
See Also:
AgcJValueField.getDisplayPattern(), AgcJValueField.getDisplayStyle(), AgcJValueField.setDisplayStyle(int)

getDisplayStyle

public int getDisplayStyle()
Gets the number of the display style assigned to the control.
Returns:
an int value corresponding to a predefined display style
Usage:
For information on display patterns and named constants for display styles, see Formatting Patterns and Styles in the online General Reference.
See Also:
AgcJValueField.getDisplayPattern(), AgcJValueField.setDisplayPattern(String), AgcJValueField.setDisplayStyle(int)

setDisplayStyle

public void setDisplayStyle(int style)
Sets the style used to parse the user's input and format the displayed data.
Parameters:
style - an int specifying a named display style. Set it to null to use the default pattern.
Usage:
Typical display styles include numeric styles such as percent, number, currency, and date and time styles such as short, long, and full. For information on display patterns and named constants for display styles, see Formatting Patterns and Styles in the online General Reference.

If the control has both a display pattern and a display style, the display style is ignored and the display pattern is used.

See Also:
AgcJValueField.getDisplayPattern(), AgcJValueField.setDisplayPattern(String), AgcJValueField.getDisplayStyle()

format

public String format(Object ob,
                     String pattern,
                     int style1,
                     int style2)
Formats the object according to the specified pattern or style. To be overridden by classes that extend AgcValueField. The parameters described here are as AgFormat.format() expects them.
Specified by:
format in interface com.sssw.rt.util.AgiValueHelperCallback
Parameters:
ob - an Object whose value you want to represent as a String with appropriate formatting
pattern - specifies the pattern for the output String. If pattern is null, format() uses the style parameters to determine the format of the output String.
style1 - specifies a style for the output String. If the Object's type is Timestamp, specifies a style for the time portion of the output String.
style2 - If the Object's type is Timestamp, specifies a style for the date portion of the output String. For other object types, specify null.
Returns:
a String representing the Object's value with formatting characters added
Usage:
This method is not useful for developers using standard SilverStream classes. It is provided for developers who want to extend AgcValueField to support additional data types. They can override format() and parse() to implement additional formatting and parsing rules. SilverStream calls the format() method to convert the value associated with the input field to a String so it can be displayed.

The default implementation calls AgFormat.format(ob, pattern, style1, style2) and can format numeric, date, and time data. When you extend AgcValueField to implement another data type, you can override format() and parse() to handle the data.

When you are using SilverStream formatting, you can find information on characters for formatting patterns and named constants for styles in Formatting Patterns and Styles in the online General Reference.

See Also:
8 @see #parse(int, String, String, int, int)

parse

public Object parse(int datatype,
                    String parseStr,
                    String pattern,
                    int style1,
                    int style2)
             throws IllegalArgumentException
Parses the string according to the specified pattern or style. To be overridden by classes that extend AgcValueField. The parameters described here are as AgParse.parse() expects them.
Specified by:
parse in interface com.sssw.rt.util.AgiValueHelperCallback
Parameters:
datatype - a constant defined in the com.sssw.rt.form.DatatypeCodes class, which identifies the data type of the resulting object. The value of parseStr must be compatible with the specified data type. Otherwise, an IllegalArgumentException is thrown.
parseStr - a String whose text can be converted to the specified data type
pattern - specifies the first pattern to use when trying to parse the string. The pattern is often null. If it is null, then a list of common patterns and styles is used to try to parse the string. If it is not null, then the specified pattern is tried first. If that pattern fails, then the list of common patterns and styles is used.
style1 - specifies the first style to use when trying to parse the string. If style is not null, it is used before the pattern. If the Object's type is Timestamp, specifies a style for parsing the time portion of the input String.
style2 - If the Object is a Timestamp, specifies a style for parsing the date portion of the input String. For other object types, specify null.
Returns:
an Object whose type is specified in datatype and whose value is the result of applying the specified pattern or style to the value in parseStr
Usage:
This method is not useful for developers using standard SilverStream classes. It is provided for developers who want to extend AgcValueField or its subclasses to support additional data types. They can override format() and parse() to implement additional formatting and parsing rules. SilverStream calls the parse() method when the user enters text in the input field and SilverStream needs to convert it to an object of the appropriate data type.

If you are extending one of the classes derived from AgcValueField, the data type is one of the constants defined in com.sssw.rt.util.DatatypeCodes. For example, for AgcIntegerField, the data type is DatatypeCodes.TYPE_LONG.

If you extend AgcValueField directly and define your own formatting and parsing, then the data type you specify doesn't matter with this caveat: do not use the data type TYPE_STRING. This type gets special handling that bypasses extra formatting and parsing, which you do not want in your extended control.

The default implementation calls AgParse.parse(datatype, parseStr, pattern, style1, style2) and can parse string that represent numbers, dates, or times. When you extend AgcValueField to implement another data type, you can override format() and parse() to handle the data.

When you are using SilverStream formatting, you can find information on characters for formatting patterns and named constants for styles in Formatting Patterns and Styles in the online General Reference.

See Also:
AgParse, AgcJValueField.format(Object, String, int, int)

SilverStream
Application Server 3.5