Rational Developer for Power Systems Software
V7.6

com.ibm.etools.iseries.ui
Class NumericCharacterDocument

java.lang.Object
  extended by javax.swing.text.AbstractDocument
      extended by javax.swing.text.PlainDocument
          extended by com.ibm.etools.iseries.ui.NumericCharacterDocument
All Implemented Interfaces:
KeystrokeVerifier, PropertyChangeListener, VetoableChangeListener, Serializable, EventListener, Document

public class NumericCharacterDocument
extends PlainDocument
implements KeystrokeVerifier, PropertyChangeListener, VetoableChangeListener, Serializable

NumericCharacterDocument extends javax.swing.text.PlainDocument and implements KeystrokeVerifier. It serves as the data model for both numeric and character data types in an MVC relationship for JFormattedTextField.

With this data model, if the data type of a field is set as numeric, then only the digits, minus sign '-', plus sign '+', and decimal point '.' can be entered and the value entered must not exceed the data length and decimal places specified in DataAttributes. For example if dataLength is 10 and decimalPlaces is 2, then valid numeric values include: 0, .01, 1.23-, -12345678.99, 12345+, +123.4 etc.

If the data type of a field is set as character string, then any character can be entered. The only restriction is that the length of the string must not exceed the dataLength specified in DataAttributes.

See Also:
KeystrokeVerifier, UpperCaseDocument, DataAttributes, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.text.AbstractDocument
AbstractDocument.AbstractElement, AbstractDocument.AttributeContext, AbstractDocument.BranchElement, AbstractDocument.Content, AbstractDocument.DefaultDocumentEvent, AbstractDocument.ElementEdit, AbstractDocument.LeafElement
 
Field Summary
static String Copyright
           
protected  PropertyChangeSupport propertyChange
           
protected  VetoableChangeSupport vetoPropertyChange
           
 
Fields inherited from class javax.swing.text.PlainDocument
lineLimitAttribute, tabSizeAttribute
 
Fields inherited from class javax.swing.text.AbstractDocument
BAD_LOCATION, BidiElementName, ContentElementName, ElementNameAttribute, listenerList, ParagraphElementName, SectionElementName
 
Fields inherited from interface com.ibm.etools.iseries.ui.KeystrokeVerifier
copyright
 
Fields inherited from interface javax.swing.text.Document
StreamDescriptionProperty, TitleProperty
 
Constructor Summary
  NumericCharacterDocument()
          Constructs a new NumericCharacterDocument.
protected NumericCharacterDocument(AbstractDocument.Content c)
          Constructs a new NumericCharacterDocument with specified Content
  NumericCharacterDocument(Attributes dataAttributes)
          Constructs a new NumericCharacterDocument with the specified DataAttributes.
  NumericCharacterDocument(Attributes dataAttributes, Attributes editmaskAttributes)
          Constructs a new NumericCharacterDocument with the specified DataAttributes and EditmaskAttributes.
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener l)
          Add a propertyChangeListener.
 void addVetoableChangeListener(VetoableChangeListener l)
          Add a vetoableChangeListener.
static String Copyright()
          This method returns the copyright notice for this class.
 void enableErrorChecking(boolean enable)
          To enable/disable error checking.
 void firePropertyChange(String propertyName, Object oldValue, Object newValue)
          The firePropertyChange method was generated to support the propertyChange field.
 void fireVetoableChange(String propertyName, Object oldValue, Object newValue)
          The fireVetoableChange method was generated to support the vetoPropertyChange field.
 Attributes getDataAttributes()
           
 Attributes getEditmaskAttributes()
           
protected  PropertyChangeSupport getPropertyChange()
          Accessor for the propertyChange field.
 String getUneditedText()
           
protected  VetoableChangeSupport getVetoPropertyChange()
          Accessor for the vetoPropertyChange field.
 void insertString(int offs, String str, AttributeSet a)
          Inserts some content into the document.
 void propertyChange(PropertyChangeEvent e)
          Examine the PropertyChangeEvent and decides what to do on a particular event.
 void remove(int offs, int len)
          Removes some content from the document.
 void removePropertyChangeListener(PropertyChangeListener l)
          Removes a propertyChangeListener.
 void removeVetoableChangeListener(VetoableChangeListener l)
          Removes a vetoableChangeListener.
 void setCurrentFocusField(JComponent comp)
          Set the focus on the component that passed in as argument.
 void setDataAttributes(Attributes a)
          Sets the dataAttributes property (com.ibm.etools.iseries.ui.Attributes) value.
 void setEditmaskAttributes(Attributes ea)
          Sets the editmaskAttributes property (com.ibm.etools.iseries.ui.Attributes) value.
 void vetoableChange(PropertyChangeEvent e)
          This method gets called when a constrained property is changed.
 
Methods inherited from class javax.swing.text.PlainDocument
createDefaultRoot, getDefaultRootElement, getParagraphElement, insertUpdate, removeUpdate
 
Methods inherited from class javax.swing.text.AbstractDocument
addDocumentListener, addUndoableEditListener, createBranchElement, createLeafElement, createPosition, dump, fireChangedUpdate, fireInsertUpdate, fireRemoveUpdate, fireUndoableEditUpdate, getAsynchronousLoadPriority, getAttributeContext, getBidiRootElement, getContent, getCurrentWriter, getDocumentFilter, getDocumentListeners, getDocumentProperties, getEndPosition, getLength, getListeners, getProperty, getRootElements, getStartPosition, getText, getText, getUndoableEditListeners, postRemoveUpdate, putProperty, readLock, readUnlock, removeDocumentListener, removeUndoableEditListener, render, replace, setAsynchronousLoadPriority, setDocumentFilter, setDocumentProperties, writeLock, writeUnlock
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.text.Document
addDocumentListener, addUndoableEditListener, createPosition, getDefaultRootElement, getEndPosition, getLength, getProperty, getRootElements, getStartPosition, getText, getText, putProperty, removeDocumentListener, removeUndoableEditListener, render
 

Field Detail

Copyright

public static final String Copyright
See Also:
Constant Field Values

propertyChange

protected transient PropertyChangeSupport propertyChange

vetoPropertyChange

protected transient VetoableChangeSupport vetoPropertyChange
Constructor Detail

NumericCharacterDocument

public NumericCharacterDocument()
Constructs a new NumericCharacterDocument.


NumericCharacterDocument

public NumericCharacterDocument(Attributes dataAttributes)
Constructs a new NumericCharacterDocument with the specified DataAttributes. Please note that the parameter must be an instance of com.ibm.etools.iseries.ui.DataAttributes; otherwise java.beans.PropertyVetoException will be thrown at run time.

Parameters:
dataAttributes - com.ibm.etools.iseries.ui.Attributes

NumericCharacterDocument

public NumericCharacterDocument(Attributes dataAttributes,
                                Attributes editmaskAttributes)
Constructs a new NumericCharacterDocument with the specified DataAttributes and EditmaskAttributes. Please note that the first parameter must be an instance of com.ibm.etools.iseries.ui.DataAttributes and the second parameter must be an instance of com.ibm.etools.iseries.ui.EditmaskAttributes; otherwise java.beans.PropertyVetoException will be thrown at run time.

Parameters:
dataAttributes - com.ibm.etools.iseries.ui.Attributes
editmaskAttributes - com.ibm.etools.iseries.ui.Attributes

NumericCharacterDocument

protected NumericCharacterDocument(AbstractDocument.Content c)
Constructs a new NumericCharacterDocument with specified Content

Parameters:
c - javax.swing.text.AbstractDocument.Content
Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener l)
Add a propertyChangeListener.

Parameters:
l - PropertyChangeListener

addVetoableChangeListener

public void addVetoableChangeListener(VetoableChangeListener l)
Add a vetoableChangeListener.

Parameters:
l - java.beans.VetoableChangeListener

Copyright

public static String Copyright()
This method returns the copyright notice for this class.

Returns:
java.lang.String

enableErrorChecking

public void enableErrorChecking(boolean enable)
To enable/disable error checking. If error checking is on, the data model is in effect; otherwise any data can be set in the data string. Error checking has to be on in order to restrict user input and error checking has to be off in order to change the user input to a formatted text.

Specified by:
enableErrorChecking in interface KeystrokeVerifier
Parameters:
enable - boolean

firePropertyChange

public void firePropertyChange(String propertyName,
                               Object oldValue,
                               Object newValue)
The firePropertyChange method was generated to support the propertyChange field.


fireVetoableChange

public void fireVetoableChange(String propertyName,
                               Object oldValue,
                               Object newValue)
                        throws PropertyVetoException
The fireVetoableChange method was generated to support the vetoPropertyChange field.

Throws:
PropertyVetoException

getDataAttributes

public Attributes getDataAttributes()
Specified by:
getDataAttributes in interface KeystrokeVerifier

getEditmaskAttributes

public Attributes getEditmaskAttributes()
Specified by:
getEditmaskAttributes in interface KeystrokeVerifier

getPropertyChange

protected PropertyChangeSupport getPropertyChange()
Accessor for the propertyChange field.


getUneditedText

public String getUneditedText()
Specified by:
getUneditedText in interface KeystrokeVerifier

getVetoPropertyChange

protected VetoableChangeSupport getVetoPropertyChange()
Accessor for the vetoPropertyChange field.


insertString

public void insertString(int offs,
                         String str,
                         AttributeSet a)
                  throws BadLocationException
Inserts some content into the document.

Specified by:
insertString in interface Document
Overrides:
insertString in class PlainDocument
Parameters:
offs - int
str - java.lang.String
a - AttributeSet
Throws:
BadLocationException - The exception description.

propertyChange

public void propertyChange(PropertyChangeEvent e)
Examine the PropertyChangeEvent and decides what to do on a particular event.

Specified by:
propertyChange in interface PropertyChangeListener
Parameters:
e - java.beans.PropertyChangeEvent

remove

public void remove(int offs,
                   int len)
            throws BadLocationException
Removes some content from the document.

Specified by:
remove in interface Document
Overrides:
remove in class AbstractDocument
Parameters:
offs - int
len - int
Throws:
BadLocationException

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener l)
Removes a propertyChangeListener.

Parameters:
l - PropertyChangeListener

removeVetoableChangeListener

public void removeVetoableChangeListener(VetoableChangeListener l)
Removes a vetoableChangeListener.

Parameters:
l - java.beans.VetoableChangeListener

setCurrentFocusField

public void setCurrentFocusField(JComponent comp)
Set the focus on the component that passed in as argument.

Specified by:
setCurrentFocusField in interface KeystrokeVerifier
Parameters:
comp - javax.swing.JComponent

setDataAttributes

public void setDataAttributes(Attributes a)
                       throws PropertyVetoException
Sets the dataAttributes property (com.ibm.etools.iseries.ui.Attributes) value. Please note that the parameter must be an instance of com.ibm.etools.iseries.ui.DataAttributes; otherwise java.beans.PropertyVetoException will be thrown at run time.

Specified by:
setDataAttributes in interface KeystrokeVerifier
Parameters:
dataAttributes - The new value for the property.
Throws:
PropertyVetoException
See Also:
getDataAttributes()

setEditmaskAttributes

public void setEditmaskAttributes(Attributes ea)
                           throws PropertyVetoException
Sets the editmaskAttributes property (com.ibm.etools.iseries.ui.Attributes) value. Please note that the parameter must be an instance of com.ibm.etools.iseries.ui.EditmaskAttributes; otherwise java.beans.PropertyVetoException will be thrown at run time.

Specified by:
setEditmaskAttributes in interface KeystrokeVerifier
Parameters:
editmaskAttributes - The new value for the property.
Throws:
PropertyVetoException
See Also:
getEditmaskAttributes()

vetoableChange

public void vetoableChange(PropertyChangeEvent e)
                    throws PropertyVetoException
This method gets called when a constrained property is changed.

Specified by:
vetoableChange in interface VetoableChangeListener
Parameters:
e - java.beans.PropertyChangeEvent a PropertyChangeEvent object describing the event source and the property that has changed.
Throws:
PropertyVetoException - if the recipient wishes the property change to be rolled back.

Rational Developer for Power Systems Software
V7.6

Copyright © 2011 IBM Corp. All Rights Reserved.

Note: This documentation is for part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.