org.gjt.btools.ext
Class IntegerDocument

java.lang.Object
  |
  +--javax.swing.text.AbstractDocument
        |
        +--javax.swing.text.PlainDocument
              |
              +--org.gjt.btools.ext.IntegerDocument
All Implemented Interfaces:
javax.swing.text.Document, java.io.Serializable

public class IntegerDocument
extends javax.swing.text.PlainDocument

A document class used to enter an integer into a text component. The integer may be positive, zero or negative. This class ensures that the input contains only digits and an optional leading minus sign.

See Also:
Serialized Form

Field Summary
 
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 javax.swing.text.Document
StreamDescriptionProperty, TitleProperty
 
Constructor Summary
IntegerDocument()
           
 
Method Summary
 int getIntValue()
          Returns the integer value stored in the document as an int.
 long getLongValue()
          Returns the integer value stored in the document as a long.
 void insertString(int offs, java.lang.String str, javax.swing.text.AttributeSet a)
          Attempts to insert a string into the document.
 
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, remove, 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
 

Constructor Detail

IntegerDocument

public IntegerDocument()
Method Detail

insertString

public void insertString(int offs,
                         java.lang.String str,
                         javax.swing.text.AttributeSet a)
                  throws javax.swing.text.BadLocationException
Attempts to insert a string into the document.

Specified by:
insertString in interface javax.swing.text.Document
Overrides:
insertString in class javax.swing.text.PlainDocument
javax.swing.text.BadLocationException

getIntValue

public int getIntValue()
                throws EmptyDocumentException
Returns the integer value stored in the document as an int.

Returns:
the integer stored.
Throws:
EmptyDocumentException - thrown if the document is empty (which is possible) or if the integer could not be parsed (which should never be the case).

getLongValue

public long getLongValue()
                  throws EmptyDocumentException
Returns the integer value stored in the document as a long.

Returns:
the integer stored.
Throws:
EmptyDocumentException - thrown if the document is empty (which is possible) or if the integer could not be parsed (which should never be the case).


Copyright © 1998-2001, Ben Burton
This software is released under the GNU Public License.
For further information, or to submit a bug or other problem, please contact Ben Burton (bab@debian.org).