|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.dellroad.stuff.string.NamedArgumentFormatter
public class NamedArgumentFormatter
Interpreter for printf-style formatting strings that identifies arguments using names rather than indicies.
Works just like Formatter but arguments are specified using names instead of numbers.
A mapping from argument name to argument value must be provided during the format operation.
| Field Summary | |
|---|---|
protected ArrayList<String> |
fieldList
The list of argument names in the order they are used. |
protected HashMap<String,Integer> |
fieldMap
Mapping from argument name to argument list index. |
protected String |
indexedFormat
The modified format string containing indexes instead of argument names. |
protected String |
originalFormat
The original format string provided to the constructor. |
| Constructor Summary | |
|---|---|
NamedArgumentFormatter(String format)
Constructor. |
|
| Method Summary | |
|---|---|
String |
format(Map<String,Object> argMap)
Format the string using the given arguments. |
Set<String> |
getArgumentNames()
Get the argument names found in the configured format string. |
String |
getFormat()
Get the original format string provided to the constructor. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final ArrayList<String> fieldList
fieldMap.
protected final HashMap<String,Integer> fieldMap
fieldList.
protected final String originalFormat
protected final String indexedFormat
| Constructor Detail |
|---|
public NamedArgumentFormatter(String format)
format - format string containing argument names instead of indicies| Method Detail |
|---|
public String format(Map<String,Object> argMap)
argMap - mapping from argument name to argument value
IllegalFormatException - if the format provided to the constructor contained illegal syntax
IllegalFormatException - if an argument value is incompatible or missing (and null would be invalid)public String getFormat()
public Set<String> getArgumentNames()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||