Package org.ka2ddo.yaac.gui
Class CallsignDocumentFilter
java.lang.Object
javax.swing.text.DocumentFilter
org.ka2ddo.yaac.gui.CallsignDocumentFilter
These document filters automatically upshifts lowercase text. It also restricts the character set
to only those allowed in an AX.25 callsign (optionally with SSID suffix and comma delimiters between
multiple callsigns). These Filter objects have no state and therefore can be shared between multiple
Documents.
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.text.DocumentFilter
DocumentFilter.FilterBypass
-
Constructor Summary
ConstructorDescriptionCallsignDocumentFilter
(boolean allowHyphen, boolean allowComma, boolean allowWildcard) Create a CallsignDocumentFilter, that will permit ASCII letters and digits, and optionally a few other characters to be entered into a document. -
Method Summary
Modifier and TypeMethodDescriptionstatic CallsignDocumentFilter
Get a filter that only allows legal characters for a government-issued callsign.static CallsignDocumentFilter
Get a filter that only allows legal characters for a government-issued callsign, plus SSIDs and commas.static CallsignDocumentFilter
Get a filter that only allows legal characters for a government-issued callsign, plus appended SSID values.void
insertString
(DocumentFilter.FilterBypass fb, int offset, String string, AttributeSet attr) Invoked prior to insertion of text into the specified Document.void
replace
(DocumentFilter.FilterBypass fb, int offset, int length, String text, AttributeSet attrs) Invoked prior to replacing a region of text in the specified Document.Methods inherited from class javax.swing.text.DocumentFilter
remove
-
Constructor Details
-
CallsignDocumentFilter
public CallsignDocumentFilter(boolean allowHyphen, boolean allowComma, boolean allowWildcard) Create a CallsignDocumentFilter, that will permit ASCII letters and digits, and optionally a few other characters to be entered into a document.- Parameters:
allowHyphen
- boolean true if hyphen '-' characters (such as in a SSID suffix) to be enteredallowComma
- boolean true if comma ',' characters to delimit between multiple callsigns may be enteredallowWildcard
- boolean true if asterisk '*' characters may be entered to indicate wildcards
-
-
Method Details
-
getCallsignOnlyInstance
Get a filter that only allows legal characters for a government-issued callsign.- Returns:
- CallsignDocumentFilter instance
-
getCallsignSsidInstance
Get a filter that only allows legal characters for a government-issued callsign, plus appended SSID values.- Returns:
- CallsignDocumentFilter instance
-
getCallsignSsidCommaInstance
Get a filter that only allows legal characters for a government-issued callsign, plus SSIDs and commas.- Returns:
- CallsignDocumentFilter instance
-
insertString
public void insertString(DocumentFilter.FilterBypass fb, int offset, String string, AttributeSet attr) throws BadLocationException Invoked prior to insertion of text into the specified Document.- Overrides:
insertString
in classDocumentFilter
- Parameters:
fb
- FilterBypass that can be used to mutate Documentoffset
- the offset into the document to insert the content >= 0. All positions that track change at or after the given location will move.string
- the string to insertattr
- the attributes to associate with the inserted content. This may be null if there are no attributes.- Throws:
BadLocationException
- the given insert position is not a valid position within the document
-
replace
public void replace(DocumentFilter.FilterBypass fb, int offset, int length, String text, AttributeSet attrs) throws BadLocationException Invoked prior to replacing a region of text in the specified Document.- Overrides:
replace
in classDocumentFilter
- Parameters:
fb
- FilterBypass that can be used to mutate Documentoffset
- Location in Documentlength
- Length of text to deletetext
- Text to insert, null indicates no text to insertattrs
- AttributeSet indicating attributes of inserted text, null is legal.- Throws:
BadLocationException
- the given insert position is not a valid position within the document
-