Class NumericDocument

All Implemented Interfaces:
Document, Serializable

public class NumericDocument
extends PlainDocument

A Document for storing an arbitrarily large number in an arbitrary base, 2-36.

Rod Howell (
See Also:
Serialized Form

Nested Class Summary
Nested classes inherited from class javax.swing.text.AbstractDocument
AbstractDocument.AbstractElement, AbstractDocument.AttributeContext, AbstractDocument.BranchElement, AbstractDocument.Content, AbstractDocument.DefaultDocumentEvent, AbstractDocument.ElementEdit, AbstractDocument.LeafElement
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
NumericDocument(int b, String s)
          Constructs a new NumericDocument.
Method Summary
 void insertString(int offs, String str, AttributeSet a)
          Inserts the given String into the document, removing any illegal characters.
 boolean isModified()
          Returns true iff this NumericDocument has been modified since its creation.
 void remove(int offs, int len)
          Removes the specified substring from this NumericDocument.
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

Constructor Detail


public NumericDocument(int b,
                       String s)
Constructs a new NumericDocument.

b - The radix in which the numeric content is represented.
s - The initial content of the document.
Method Detail


public void insertString(int offs,
                         String str,
                         AttributeSet a)
                  throws BadLocationException
Inserts the given String into the document, removing any illegal characters.

Specified by:
insertString in interface Document
insertString in class PlainDocument
offs - The offset at which the String is inserted.
str - The String to be inserted.
a - The attributes for the inserted content.
BadLocationException - If offs does not represent a valid insertion location.


public boolean isModified()
Returns true iff this NumericDocument has been modified since its creation.


public void remove(int offs,
                   int len)
            throws BadLocationException
Removes the specified substring from this NumericDocument. If the content has not been modified since its creation, the removal is suppressed. This forces the first modification to be an insertion, which in fact replaces any content entirely.

Specified by:
remove in interface Document
remove in class AbstractDocument
BadLocationException - If the given remove position is not a valid position within the document.