EDU.ksu.cis.calculator
Class NumericDocument

java.lang.Object
  |
  +--javax.swing.text.AbstractDocument
        |
        +--javax.swing.text.PlainDocument
              |
              +--EDU.ksu.cis.calculator.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.

Author:
Rod Howell (howell@cis.ksu.edu)
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

NumericDocument

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

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

insertString

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
Overrides:
insertString in class PlainDocument
Parameters:
offs - The offset at which the String is inserted.
str - The String to be inserted.
a - The attributes for the inserted content.
Throws:
BadLocationException - If offs does not represent a valid insertion location.

isModified

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


remove

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
Overrides:
remove in class AbstractDocument
Throws:
BadLocationException - If the given remove position is not a valid position within the document.