net.sourceforge.squirrel_sql.plugins.refactoring.gui.util
Class NumberDocument

java.lang.Object
  extended by javax.swing.text.AbstractDocument
      extended by javax.swing.text.PlainDocument
          extended by net.sourceforge.squirrel_sql.plugins.refactoring.gui.util.NumberDocument
All Implemented Interfaces:
Serializable, Document

public class NumberDocument
extends PlainDocument
implements Document

A document that only holds numeric values.

See Also:
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
 
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
NumberDocument()
          Create an instance with no maximum length.
NumberDocument(int length)
          Create an instance with a maximum length.
NumberDocument(int length, boolean fractional)
          Create an instance with a maximum length that allowes floating point numbers.
NumberDocument(int length, String specialValid)
          Create an instance with a maximum length and special characters that are allowed.
 
Method Summary
 void insertString(int i, String string, AttributeSet attributeSet)
          Inserts some content 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
 
Methods inherited from interface javax.swing.text.Document
addDocumentListener, addUndoableEditListener, createPosition, getDefaultRootElement, getEndPosition, getLength, getProperty, getRootElements, getStartPosition, getText, getText, putProperty, remove, removeDocumentListener, removeUndoableEditListener, render
 

Constructor Detail

NumberDocument

public NumberDocument()
Create an instance with no maximum length.


NumberDocument

public NumberDocument(int length)
Create an instance with a maximum length.

Parameters:
length - maximum length

NumberDocument

public NumberDocument(int length,
                      String specialValid)
Create an instance with a maximum length and special characters that are allowed.

Parameters:
length - maximum length
specialValid - special characters that are allowed

NumberDocument

public NumberDocument(int length,
                      boolean fractional)
Create an instance with a maximum length that allowes floating point numbers.

Parameters:
length - maximum length
fractional - true enables floating point numbers, false allowes only integers.
Method Detail

insertString

public void insertString(int i,
                         String string,
                         AttributeSet attributeSet)
                  throws BadLocationException
Inserts some content into the document. Inserting content causes a write lock to be held while the actual changes are taking place, followed by notification to the observers on the thread that grabbed the write lock.

This override checks if string contains only valid characters. Default: numbers 0-9

Specified by:
insertString in interface Document
Overrides:
insertString in class PlainDocument
Parameters:
i - the starting offset >= 0
string - the string to insert; does nothing with null/empty strings
attributeSet - the attributes for the inserted content
Throws:
BadLocationException - the given insert position is not a valid position within the document


Copyright © 2001-2010. All Rights Reserved.