Class StringFormatValidator

java.lang.Object
org.jboss.logging.processor.validation.AbstractFormatValidator
org.jboss.logging.processor.validation.StringFormatValidator
All Implemented Interfaces:
FormatValidator

public final class StringFormatValidator extends AbstractFormatValidator
A string format representation.

Date: 13.06.2011

  • Field Details

    • PATTERN

      public static final Pattern PATTERN
      The Regex pattern.
    • formatParts

      private final Set<FormatPart> formatParts
    • formats

      private final Set<StringFormatPart> formats
    • argumentCount

      private int argumentCount
    • valid

      private boolean valid
    • format

      private final String format
  • Constructor Details

    • StringFormatValidator

      private StringFormatValidator(String format)
      Private constructor for the singleton pattern.
      Parameters:
      format - the format.
  • Method Details

    • of

      public static StringFormatValidator of(String format)
      Creates a string format.
      Parameters:
      format - the format.
      Returns:
      the string format.
    • withTranslation

      public static StringFormatValidator withTranslation(String format, String translationFormat)
      Creates a string format.

      Note: The validator returned is the validator for the translation format.

      Parameters:
      format - the format.
      translationFormat - the format of the translation
      Returns:
      the string format.
    • of

      public static StringFormatValidator of(String format, Object... parameters)
      Creates a string format.
      Parameters:
      format - the format.
      parameters - the parameters to validate against.
      Returns:
      the string format.
    • sortParts

      static List<StringFormatPart> sortParts(Collection<StringFormatPart> parts)
    • validate

      private void validate()
      Validates
    • validate

      private void validate(Object... parameters)
    • argumentCount

      public int argumentCount()
      Description copied from interface: FormatValidator
      The number of arguments needed for the format.
      Returns:
      the number of arguments needed.
    • format

      public String format()
      Description copied from interface: FormatValidator
      Returns the format string used for validation.
      Returns:
      the format string.
    • isValid

      public boolean isValid()
      Description copied from interface: FormatValidator
      Returns true of the format is valid, otherwise false.
      Returns:
      true of the format is valid, otherwise false.
    • asFormat

      public String asFormat()
      Recreates the format using the internal formatting descriptors.
      Returns:
      the format.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • init

      private void init()
      Initialize the string format.
    • checkText

      private static void checkText(String text)
      Checks text to make sure we don't have extra garbage.
      Parameters:
      text - the text to check.
    • getOrAdd

      private static <K, V extends Comparable<? super V>> Set<V> getOrAdd(Map<K,Set<V>> map, K key)