Class StringFormatPart
- java.lang.Object
-
- org.jboss.logging.processor.validation.AbstractFormatPart
-
- org.jboss.logging.processor.validation.StringFormatPart
-
- All Implemented Interfaces:
java.lang.Comparable<FormatPart>,FormatPart
class StringFormatPart extends AbstractFormatPart
The parameter part of a format forFormatter. Represents the following format {@linkplain %[argument_index$][flags][width][.precision]conversion}. Date: 13.06.2011
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classStringFormatPart.ConversionThe conversions for the string format.static classStringFormatPart.FlagThe flags for the string message format.
-
Field Summary
Fields Modifier and Type Field Description private StringFormatPart.Conversionconversionprivate java.lang.CharacterdateTimeConversionprivate java.util.Set<StringFormatPart.Flag>flagsprivate intindexprivate intpositionprivate intprecisionprivate intwidth-
Fields inherited from interface org.jboss.logging.processor.validation.FormatPart
STRING
-
-
Constructor Summary
Constructors Modifier Constructor Description privateStringFormatPart(int position)Creates a parameter format part.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringFormatPart.Conversionconversion()The conversion for the string format.chardateTimeChar()The date/time conversion character.java.util.Set<StringFormatPart.Flag>flags()A collection of the flags.intindex()Returns the format parameter index.private voidinitFlags(java.lang.String s)Initializes the flags based on the string.private voidinitIndex(java.lang.String s)Initializes the index field based on the string.private voidinitPrecision(java.lang.String s)Initializes the precision based on the string.private voidinitWidth(java.lang.String s)Initializes the width based on the string.static StringFormatPartof(int position, java.lang.String[] group)Creates a parameter part of a format string.java.lang.Stringpart()The part of the format.intposition()The position for the part.intprecision()The precision for the format.java.lang.StringtoString()intwidth()The width for the format.-
Methods inherited from class org.jboss.logging.processor.validation.AbstractFormatPart
compareTo
-
-
-
-
Field Detail
-
index
private int index
-
flags
private final java.util.Set<StringFormatPart.Flag> flags
-
width
private int width
-
precision
private int precision
-
conversion
private StringFormatPart.Conversion conversion
-
dateTimeConversion
private java.lang.Character dateTimeConversion
-
position
private final int position
-
-
Method Detail
-
of
public static StringFormatPart of(int position, java.lang.String[] group) throws java.lang.IllegalArgumentException
Creates a parameter part of a format string.- Parameters:
position- the position of the part.group- the group array of the formats (must be a length of 6).- Returns:
- the the parameter part.
- Throws:
java.lang.IllegalArgumentException- if the length of the group array is not equal to 6 or a format was invalid.
-
index
public int index()
Returns the format parameter index. If the index is inherited,-1is returned.- Returns:
- the format parameter index.
-
flags
public java.util.Set<StringFormatPart.Flag> flags()
A collection of the flags.- Returns:
- the flags.
-
width
public int width()
The width for the format. If the width was not specified,-1is returned.- Returns:
- the width.
-
precision
public int precision()
The precision for the format. If the precision was not specified,-1is returned.- Returns:
- the precision.
-
conversion
public StringFormatPart.Conversion conversion()
The conversion for the string format.- Returns:
- the conversion.
-
dateTimeChar
public char dateTimeChar()
The date/time conversion character.nullif there is not date time conversion character.- Returns:
- the date/time conversion character or
null.
-
initIndex
private void initIndex(java.lang.String s) throws java.lang.IllegalArgumentExceptionInitializes the index field based on the string.- Parameters:
s- the index in string form.- Throws:
java.lang.IllegalArgumentException- if the string is not a number.
-
initFlags
private void initFlags(java.lang.String s) throws java.util.DuplicateFormatFlagsExceptionInitializes the flags based on the string. Will set theindexto-1if theStringFormatPart.Flag.PREVIOUSflag is found.- Parameters:
s- the flags in string form.- Throws:
java.util.DuplicateFormatFlagsException- if the flag is specified more than once.
-
initWidth
private void initWidth(java.lang.String s) throws java.lang.IllegalArgumentExceptionInitializes the width based on the string.- Parameters:
s- the width in string form.- Throws:
java.lang.IllegalArgumentException- the string is an invalid number.
-
initPrecision
private void initPrecision(java.lang.String s) throws java.lang.IllegalArgumentExceptionInitializes the precision based on the string.- Parameters:
s- the precision in string form.- Throws:
java.lang.IllegalArgumentException- if the precision is less than 0 or an invalid number.
-
position
public int position()
Description copied from interface:FormatPartThe position for the part.- Returns:
- the position.
-
part
public java.lang.String part()
Description copied from interface:FormatPartThe part of the format.- Returns:
- the part of the format.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classAbstractFormatPart
-
-