HiRISE

HiRISE.HiPlan.Utilities
Class Observation_ID_Document

java.lang.Object
  extended by javax.swing.text.AbstractDocument
      extended by javax.swing.text.PlainDocument
          extended by HiRISE.HiPlan.Utilities.Observation_ID_Document
All Implemented Interfaces:
Serializable, Document

public class Observation_ID_Document
extends PlainDocument

A PlainDocument that allows only those characters suitable for the text form of a HiRISE observation ID. These include letters, numbers, and the underscore ('_') character only. Furthermore, letters are forced into uppercase and spaces are converted to underscores. All other characters are ignored and never become part of the Observation_ID_Document's content.

Version:
1.7
Author:
Christian Schaller - UA/PIRL
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
static String ID
          Class identification name with source code version and date.
 
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
Observation_ID_Document()
          Creates a new Observation_ID_Document using the PlainDocument's default content container.
Observation_ID_Document(AbstractDocument.Content container)
          Creates a new Observation_ID_Document using the specified container for the document's content.
 
Method Summary
 void insertString(int offset, String str, AttributeSet a)
          Inserts content into the document.
static String transformText(String str)
          Transforms input text according to the observation ID document rules.
 
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
 

Field Detail

ID

public static final String ID
Class identification name with source code version and date.

See Also:
Constant Field Values
Constructor Detail

Observation_ID_Document

public Observation_ID_Document()
Creates a new Observation_ID_Document using the PlainDocument's default content container.

See Also:
PlainDocument.PlainDocument()

Observation_ID_Document

public Observation_ID_Document(AbstractDocument.Content container)
Creates a new Observation_ID_Document using the specified container for the document's content.

Parameters:
container - the document's content container.
See Also:
PlainDocument.PlainDocument(AbstractDocument.Content)
Method Detail

insertString

public void insertString(int offset,
                         String str,
                         AttributeSet a)
                  throws BadLocationException
Inserts content into the document. The document's rules are applied on the insert.

Specified by:
insertString in interface Document
Overrides:
insertString in class PlainDocument
Parameters:
offset - the starting offset, at least 0.
str - the string to insert; null/empty strings are not inserted.
a - the attributes for the inserted content; this document does not use attributes.
Throws:
BadLocationException
See Also:
PlainDocument.insertString(int, java.lang.String, javax.swing.text.AttributeSet)

transformText

public static String transformText(String str)
Transforms input text according to the observation ID document rules.

Parameters:
str - the input text; may be null.
Returns:
the transformed string or an empty string if str is null.

HiRISE

Copyright (C) Arizona Board of Regents on behalf of the Planetary Image Research Laboratory, Lunar and Planetary Laboratory at the University of Arizona