SilverStream
Application Server 3.5

com.sssw.rt.form
Class AgcValueField

java.lang.Object
 |
 +--java.awt.Component
       |
       +--java.awt.TextComponent
             |
             +--java.awt.TextField
                   |
                   +--com.sssw.rt.atlas.AtTextField
                         |
                         +--com.sssw.rt.form.AgcTextField
                               |
                               +--com.sssw.rt.form.AgcValueField
All Implemented Interfaces:
AgiControl, AgiHelpInfo, ImageObserver, MenuContainer, Serializable
Direct Known Subclasses:
AgcBigDecimalField, AgcDateField, AgcDoubleField, AgcIntegerField, AgcTimeField, AgcTimestampField

public class AgcValueField
extends AgcTextField

Base class of all text fields that have a non-text value (integer, floating point, date, time, timestamp).

See Also:
Serialized Form

Fields inherited from class com.sssw.rt.form.AgcTextField
NO_LIMIT
 
Fields inherited from class com.sssw.rt.atlas.AtTextField
ENFORCE_CASE_LOWER, ENFORCE_CASE_NONE, ENFORCE_CASE_UPPER
 
Fields inherited from class java.awt.TextComponent
textListener
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
AgcValueField()
           
 
Method Summary
 String format(Object ob, String pattern, int style1, int style2)
          Formats the object according to the specified pattern or style.
 String getDisplayPattern()
          Returns a String that identifies the pattern that the control uses to display the data.
 int getDisplayStyle()
          Obtains the control's display style.
 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)
          Assigns the control's display format.
 void setDisplayStyle(int style)
          Assigns the control's display style.
 
Methods inherited from class com.sssw.rt.form.AgcTextField
getBackgroundColor, getEditable, getEmptyStringIsNull, getFontIdentifier, getMaxLength, getMinLength, getTextColor, setBackgroundColor, setEmptyStringIsNull, setFontIdentifier, setMaxLength, setMinLength, setTextColor
 
Methods inherited from class com.sssw.rt.atlas.AtTextField
deliverMouseEvent, deliverMouseMoveEvent, doAtCommand, enableAtCommands, getEnforceCase, getHelper, getToolTipText, getToolTipText, grabFocus, grabTabstopFocus, isFocusTraversable, isRequestFocusEnabled, preprocessKeyEvent, processEvent, requestFocus, setEnforceCase, setRequestFocusEnabled, setToolTipText
 
Methods inherited from class java.awt.TextField
addActionListener, addNotify, echoCharIsSet, getColumns, getEchoChar, getMinimumSize, getMinimumSize, getPreferredSize, getPreferredSize, minimumSize, minimumSize, paramString, preferredSize, preferredSize, processActionEvent, removeActionListener, setColumns, setEchoChar, setEchoCharacter, setText
 
Methods inherited from class java.awt.TextComponent
addTextListener, getCaretPosition, getSelectedText, getSelectionEnd, getSelectionStart, getText, isEditable, processTextEvent, removeNotify, removeTextListener, select, selectAll, setCaretPosition, setEditable, setSelectionEnd, setSelectionStart
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, postEvent, prepareImage, prepareImage, print, printAll, processComponentEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, update, validate
 
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.AgiControl
getBackgroundImage, getBackgroundImageMode, getComponent, getHelpInfo, setBackgroundImage, setBackgroundImageMode, setHelpInfo
 

Constructor Detail

AgcValueField

public AgcValueField()
Method Detail

getDisplayPattern

public String getDisplayPattern()
Returns a String that identifies the pattern that the control uses to display the data.
Usage:
For information on display patterns and styles, see Formatting Patterns and Styles in the online General Reference.

For Integer and Floating Point fields, see also DecimalFormat. For Time, Date and Timestamp fields, see also SimpleDateFormat.

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

Example:
  String pattern;
  pattern = ControlName1.getDisplayPattern();
 
See Also:
Display Format property, AgcValueField.setDisplayPattern(String), AgcValueField.getDisplayStyle(), AgcValueField.setDisplayStyle(int)

setDisplayPattern

public void setDisplayPattern(String pattern)
Assigns the control's display format.
Parameters:
pattern - specifies the pattern
Usage:
For information on display patterns and styles, see Formatting Patterns and Styles in the online General Reference.

For Integer and Floating Point fields, see also DecimalFormat. For Time, Date and Timestamp fields, see also SimpleDateFormat.

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

Example:
 ControlName1.setDisplayPattern("$#,##0.00;($#,##0.00)");
 
See Also:
Display Format property, AgcValueField.getDisplayPattern(), AgcValueField.getDisplayStyle(), AgcValueField.setDisplayStyle(int)

getDisplayStyle

public int getDisplayStyle()
Obtains the control's display style.
Usage:
For information on display patterns and styles, see Formatting Patterns and Styles in the online General Reference.

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

Example:
  int style;
  style = ControlName1.getDisplayStyle();
 
See Also:
Display Format property, AgcValueField.setDisplayPattern(String), AgcValueField.getDisplayPattern(), AgcValueField.setDisplayStyle(int)

setDisplayStyle

public void setDisplayStyle(int style)
Assigns the control's display style.
Parameters:
style - specifies a Style constant.
Usage:
For information on display patterns and styles, see Formatting Patterns and Styles in the online General Reference.

A note about the numeric style PERCENTSTYLE: "63%" represents a value of .63, not 63. So this style makes little sense for integer fields (it could only display 100%, 200%, etc).

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

Example:
  ControlName1.setDisplayStyle(AgFormat.CURRENCYSTYLE);
 
See Also:
Display Style property, AgcValueField.getDisplayStyle(), AgcValueField.setDisplayPattern(String)

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 style1 and style2 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:
AgFormat

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 output String.
style2 - If the Object is a Timestamp, specifies a style for parsing the date portion of the output 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

SilverStream
Application Server 3.5