gr.zeus.ui.typesafe

## Class TypeSafeTextDocumentFilter

- java.lang.Object
- - javax.swing.text.DocumentFilter
  - - gr.zeus.ui.typesafe.TypeSafeTextDocumentFilter

-     public final class TypeSafeTextDocumentFilter
      extends javax.swing.text.DocumentFilter

  This class creates a custom filter for JTextComponents by extending the DocumentFilter. With this filter we achieve the following data validation within a field:
- max characters
- uppercase/lowercase or not
- valid characters
- invalid characters
- replaceable/replaced character pairs

Since:
  1.20
Author:
  Gregory Kotsaftis

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class javax.swing.text.DocumentFilter

      `javax.swing.text.DocumentFilter.FilterBypass`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `DEFAULT_MAXCHARS`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TypeSafeTextDocumentFilter()` Constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.String` | `getInvalidChars()` Gets invalid characters.
    `boolean` | `getLowerCase()` Gets lowercase flag.
    `int` | `getMaxChars()` Gets max characters allowed.
    `java.lang.String` | `getReplacableChars()` Gets the replacable characters.
    `java.lang.String` | `getReplacedChars()` Gets the replaced characters.
    `boolean` | `getUpperCase()` Gets uppercase flag.
    `java.lang.String` | `getValidChars()` Gets valid characters.
    `void` | `insertString(javax.swing.text.DocumentFilter.FilterBypass fb, int offset, java.lang.String text, javax.swing.text.AttributeSet attrs)` Invoked prior to insertion of text into the specified Document.
    `void` | `remove(javax.swing.text.DocumentFilter.FilterBypass fb, int offset, int length)` Invoked prior to removal of the specified region in the specified Document.
    `void` | `replace(javax.swing.text.DocumentFilter.FilterBypass fb, int offset, int length, java.lang.String text, javax.swing.text.AttributeSet attrs)` Invoked prior to replacing a region of text in the specified Document.
    `void` | `setInvalidChars(java.lang.String all)` Sets invalid characters.
    `void` | `setLowerCase(boolean f)` Sets lowercase flag.
    `void` | `setMaxChars(int num)` Sets max characters allowed.
    `void` | `setReplacableChars(java.lang.String all)` Sets replacable characters.
    `void` | `setReplacedChars(java.lang.String all)` Sets replaced characters.
    `void` | `setUpperCase(boolean f)` Sets uppercase flag.
    `void` | `setValidChars(java.lang.String all)` Sets valid characters.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### DEFAULT_MAXCHARS

          public static final int DEFAULT_MAXCHARS

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### TypeSafeTextDocumentFilter

          public TypeSafeTextDocumentFilter()

      Constructor.

  - ### Method Detail

    - #### insertString

          public void insertString(javax.swing.text.DocumentFilter.FilterBypass fb,
                                   int offset,
                                   java.lang.String text,
                                   javax.swing.text.AttributeSet attrs)
                            throws javax.swing.text.BadLocationException

      Invoked prior to insertion of text into the specified Document.

      Overrides:
        `insertString` in class `javax.swing.text.DocumentFilter`
      Parameters:
        `fb` - The FilterBypass.
        `offset` - The offset.
        `text` - The text to insert.
        `attrs` - The AttributeSet.
      Throws:
        `javax.swing.text.BadLocationException`

    - #### remove

          public void remove(javax.swing.text.DocumentFilter.FilterBypass fb,
                             int offset,
                             int length)
                      throws javax.swing.text.BadLocationException

      Invoked prior to removal of the specified region in the specified Document.

      Overrides:
        `remove` in class `javax.swing.text.DocumentFilter`
      Parameters:
        `fb` - The FilterBypass.
        `offset` - The offset.
        `length` - The length to remove.
      Throws:
        `javax.swing.text.BadLocationException`

    - #### replace

          public void replace(javax.swing.text.DocumentFilter.FilterBypass fb,
                              int offset,
                              int length,
                              java.lang.String text,
                              javax.swing.text.AttributeSet attrs)
                       throws javax.swing.text.BadLocationException

      Invoked prior to replacing a region of text in the specified Document.

      Overrides:
        `replace` in class `javax.swing.text.DocumentFilter`
      Parameters:
        `fb` - The FilterBypass.
        `offset` - The offset.
        `length` - The length of the text.
        `text` - The text to replace.
        `attrs` - The AttributeSet.
      Throws:
        `javax.swing.text.BadLocationException`

    - #### getUpperCase

          public boolean getUpperCase()

      Gets uppercase flag.

      Returns:
        true/false.

    - #### setUpperCase

          public void setUpperCase(boolean f)

      Sets uppercase flag.

      Parameters:
        `f` - true/false.

    - #### getLowerCase

          public boolean getLowerCase()

      Gets lowercase flag.

      Returns:
        true/false.

    - #### setLowerCase

          public void setLowerCase(boolean f)

      Sets lowercase flag.

      Parameters:
        `f` - true/false.

    - #### getMaxChars

          public int getMaxChars()

      Gets max characters allowed.

      Returns:
        maxChars.

    - #### setMaxChars

          public void setMaxChars(int num)

      Sets max characters allowed.

      Parameters:
        `num` - maxChars.

    - #### getValidChars

          public java.lang.String getValidChars()

      Gets valid characters.

      Returns:
        validChars.

    - #### setValidChars

          public void setValidChars(java.lang.String all)

      Sets valid characters.

      Parameters:
        `all` - validChars.

    - #### getInvalidChars

          public java.lang.String getInvalidChars()

      Gets invalid characters.

      Returns:
        invalidChars.

    - #### setInvalidChars

          public void setInvalidChars(java.lang.String all)

      Sets invalid characters.

      Parameters:
        `all` - invalidChars.

    - #### getReplacableChars

          public java.lang.String getReplacableChars()

      Gets the replacable characters. Must be used in conjuction with replaced characters.

      Returns:
        replacableChars.

    - #### setReplacableChars

          public void setReplacableChars(java.lang.String all)

      Sets replacable characters. Must be used in conjuction with replaced characters.

      Parameters:
        `all` - replacableChars.

    - #### getReplacedChars

          public java.lang.String getReplacedChars()

      Gets the replaced characters. Must be used in conjuction with replacable characters.

      Returns:
        replacedChars.

    - #### setReplacedChars

          public void setReplacedChars(java.lang.String all)

      Sets replaced characters. Must be used in conjuction with replacable characters.

      Parameters:
        `all` - replacedChars.