Class CallsignDocumentFilter

java.lang.Object
javax.swing.text.DocumentFilter
org.ka2ddo.yaac.gui.CallsignDocumentFilter

public class CallsignDocumentFilter extends DocumentFilter
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.
  • 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 entered
      allowComma - boolean true if comma ',' characters to delimit between multiple callsigns may be entered
      allowWildcard - boolean true if asterisk '*' characters may be entered to indicate wildcards
  • Method Details

    • getCallsignOnlyInstance

      public static CallsignDocumentFilter getCallsignOnlyInstance()
      Get a filter that only allows legal characters for a government-issued callsign.
      Returns:
      CallsignDocumentFilter instance
    • getCallsignSsidInstance

      public static CallsignDocumentFilter getCallsignSsidInstance()
      Get a filter that only allows legal characters for a government-issued callsign, plus appended SSID values.
      Returns:
      CallsignDocumentFilter instance
    • getCallsignSsidCommaInstance

      public static CallsignDocumentFilter 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 class DocumentFilter
      Parameters:
      fb - FilterBypass that can be used to mutate Document
      offset - 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 insert
      attr - 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 class DocumentFilter
      Parameters:
      fb - FilterBypass that can be used to mutate Document
      offset - Location in Document
      length - Length of text to delete
      text - Text to insert, null indicates no text to insert
      attrs - AttributeSet indicating attributes of inserted text, null is legal.
      Throws:
      BadLocationException - the given insert position is not a valid position within the document