class StringFormatPart extends AbstractFormatPart
Formatter.
Represents the following format %[argument_index$][flags][width][.precision]conversion.
Date: 13.06.2011| Modifier and Type | Class and Description |
|---|---|
static class |
StringFormatPart.Conversion
The conversions for the string format.
|
static class |
StringFormatPart.Flag
The flags for the string message format.
|
| Modifier and Type | Field and Description |
|---|---|
private StringFormatPart.Conversion |
conversion |
private java.lang.Character |
dateTimeConversion |
private java.util.Set<StringFormatPart.Flag> |
flags |
private int |
index |
private int |
position |
private int |
precision |
private int |
width |
STRING| Modifier | Constructor and Description |
|---|---|
private |
StringFormatPart(int position)
Creates a parameter format part.
|
| Modifier and Type | Method and Description |
|---|---|
StringFormatPart.Conversion |
conversion()
The conversion for the string format.
|
char |
dateTimeChar()
The date/time conversion character.
|
java.util.Set<StringFormatPart.Flag> |
flags()
A collection of the flags.
|
int |
index()
Returns the format parameter index.
|
private void |
initFlags(java.lang.String s)
Initializes the flags based on the string.
|
private void |
initIndex(java.lang.String s)
Initializes the index field based on the string.
|
private void |
initPrecision(java.lang.String s)
Initializes the precision based on the string.
|
private void |
initWidth(java.lang.String s)
Initializes the width based on the string.
|
static StringFormatPart |
of(int position,
java.lang.String[] group)
Creates a parameter part of a format string.
|
java.lang.String |
part() |
int |
position() |
int |
precision()
The precision for the format.
|
java.lang.String |
toString() |
int |
width()
The width for the format.
|
compareToprivate int index
private final java.util.Set<StringFormatPart.Flag> flags
private int width
private int precision
private StringFormatPart.Conversion conversion
private java.lang.Character dateTimeConversion
private final int position
private StringFormatPart(int position)
position - the position in the string format.public static StringFormatPart of(int position, java.lang.String[] group) throws java.lang.IllegalArgumentException
position - the position of the part.group - the group array of the formats (must be a length of 6).java.lang.IllegalArgumentException - if the length of the group array is not equal to 6 or a format was invalid.public int index()
-1 is returned.public java.util.Set<StringFormatPart.Flag> flags()
public int width()
-1 is returned.public int precision()
-1 is returned.public StringFormatPart.Conversion conversion()
public char dateTimeChar()
null if there is not date time conversion character.null.private void initIndex(java.lang.String s)
throws java.lang.IllegalArgumentException
s - the index in string form.java.lang.IllegalArgumentException - if the string is not a number.private void initFlags(java.lang.String s)
throws java.util.DuplicateFormatFlagsException
index to -1 if the StringFormatPart.Flag.PREVIOUS flag is found.s - the flags in string form.java.util.DuplicateFormatFlagsException - if the flag is specified more than once.private void initWidth(java.lang.String s)
throws java.lang.IllegalArgumentException
s - the width in string form.java.lang.IllegalArgumentException - the string is an invalid number.private void initPrecision(java.lang.String s)
throws java.lang.IllegalArgumentException
s - the precision in string form.java.lang.IllegalArgumentException - if the precision is less than 0 or an invalid number.public int position()
public java.lang.String part()
public java.lang.String toString()
toString in class AbstractFormatPart