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 Summary
Fields Modifier and Type Field Description private int
argumentCount
private java.lang.String
format
private java.util.Set<FormatPart>
formatParts
private java.util.Set<StringFormatPart>
formats
static java.util.regex.Pattern
PATTERN
The Regex pattern.private boolean
valid
-
Constructor Summary
Constructors Modifier Constructor Description private
StringFormatValidator(java.lang.String format)
Private constructor for the singleton pattern.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
argumentCount()
The number of arguments needed for the format.java.lang.String
asFormat()
Recreates the format using the internal formatting descriptors.private static void
checkText(java.lang.String text)
Checks text to make sure we don't have extra garbage.java.lang.String
format()
Returns the format string used for validation.private static <K,V extends java.lang.Comparable<? super V>>
java.util.Set<V>getOrAdd(java.util.Map<K,java.util.Set<V>> map, K key)
private void
init()
Initialize the string format.boolean
isValid()
Returnstrue
of the format is valid, otherwisefalse
.static StringFormatValidator
of(java.lang.String format)
Creates a string format.static StringFormatValidator
of(java.lang.String format, java.lang.Object... parameters)
Creates a string format.(package private) static java.util.List<StringFormatPart>
sortParts(java.util.Collection<StringFormatPart> parts)
java.lang.String
toString()
private void
validate()
Validatesprivate void
validate(java.lang.Object... parameters)
static StringFormatValidator
withTranslation(java.lang.String format, java.lang.String translationFormat)
Creates a string format.-
Methods inherited from class org.jboss.logging.processor.validation.AbstractFormatValidator
detailMessage, setDetailMessage, setDetailMessage, setSummaryMessage, setSummaryMessage, summaryMessage
-
-
-
-
Field Detail
-
PATTERN
public static final java.util.regex.Pattern PATTERN
The Regex pattern.
-
formatParts
private final java.util.Set<FormatPart> formatParts
-
formats
private final java.util.Set<StringFormatPart> formats
-
argumentCount
private int argumentCount
-
valid
private boolean valid
-
format
private final java.lang.String format
-
-
Method Detail
-
of
public static StringFormatValidator of(java.lang.String format)
Creates a string format.- Parameters:
format
- the format.- Returns:
- the string format.
-
withTranslation
public static StringFormatValidator withTranslation(java.lang.String format, java.lang.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(java.lang.String format, java.lang.Object... parameters)
Creates a string format.- Parameters:
format
- the format.parameters
- the parameters to validate against.- Returns:
- the string format.
-
sortParts
static java.util.List<StringFormatPart> sortParts(java.util.Collection<StringFormatPart> parts)
-
validate
private void validate()
Validates
-
validate
private void validate(java.lang.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 java.lang.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
Returnstrue
of the format is valid, otherwisefalse
.- Returns:
true
of the format is valid, otherwisefalse
.
-
asFormat
public java.lang.String asFormat()
Recreates the format using the internal formatting descriptors.- Returns:
- the format.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
init
private void init()
Initialize the string format.
-
checkText
private static void checkText(java.lang.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 java.lang.Comparable<? super V>> java.util.Set<V> getOrAdd(java.util.Map<K,java.util.Set<V>> map, K key)
-
-