org.japura.gui.model
Class NumberDocument<T extends java.lang.Number>
java.lang.Object
javax.swing.text.AbstractDocument
javax.swing.text.PlainDocument
org.japura.gui.model.NumberDocument<T>
- All Implemented Interfaces:
- java.io.Serializable, javax.swing.text.Document
- Direct Known Subclasses:
- DoubleDocument, IntegerDocument
public abstract class NumberDocument<T extends java.lang.Number>
- extends javax.swing.text.PlainDocument
Copyright (C) 2010 Carlos Eduardo Leite de Andrade
This library is free software: you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option) any
later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see www.gnu.org/licenses/
For more information, contact: www.japura.org
- Author:
- Carlos Eduardo Leite de Andrade
- See Also:
- Serialized Form
| Nested classes/interfaces inherited from class javax.swing.text.AbstractDocument |
javax.swing.text.AbstractDocument.AbstractElement, javax.swing.text.AbstractDocument.AttributeContext, javax.swing.text.AbstractDocument.BranchElement, javax.swing.text.AbstractDocument.Content, javax.swing.text.AbstractDocument.DefaultDocumentEvent, javax.swing.text.AbstractDocument.ElementEdit, javax.swing.text.AbstractDocument.LeafElement |
| 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(java.util.Locale locale,
boolean acceptFraction)
Constructor |
|
Method Summary |
protected java.lang.String |
format(java.lang.Object value)
|
protected java.text.NumberFormat |
getNumberFormat()
|
protected java.lang.String |
getText()
|
protected java.lang.String |
getValidateRegex()
|
void |
insertString(int offs,
java.lang.String str,
javax.swing.text.AttributeSet a)
|
protected abstract boolean |
isAcceptableValue(java.lang.Number number)
|
protected java.lang.Number |
parse(java.lang.String text)
|
| 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 |
maxValue
protected T extends java.lang.Number maxValue
minValue
protected T extends java.lang.Number minValue
NumberDocument
public NumberDocument(java.util.Locale locale,
boolean acceptFraction)
- Constructor
- Parameters:
locale - Locale to gets the character used for decimal sign.acceptFraction -
getValidateRegex
protected java.lang.String getValidateRegex()
getNumberFormat
protected java.text.NumberFormat getNumberFormat()
parse
protected java.lang.Number parse(java.lang.String text)
format
protected java.lang.String format(java.lang.Object value)
getText
protected java.lang.String getText()
throws javax.swing.text.BadLocationException
- Throws:
javax.swing.text.BadLocationException
isAcceptableValue
protected abstract boolean isAcceptableValue(java.lang.Number number)
insertString
public void insertString(int offs,
java.lang.String str,
javax.swing.text.AttributeSet a)
throws javax.swing.text.BadLocationException
- Specified by:
insertString in interface javax.swing.text.Document- Overrides:
insertString in class javax.swing.text.PlainDocument
- Throws:
javax.swing.text.BadLocationException