Package VASSAL.tools
Class FormattedString
java.lang.Object
VASSAL.tools.FormattedString
- All Implemented Interfaces:
RecursionLimiter.Loopable
- Direct Known Subclasses:
PlayerIdFormattedString
public class FormattedString extends Object implements RecursionLimiter.Loopable
FormattedString.java
A String that can include options of the form $optionName$. Option values
are maintained in a property list and getText returns the string will all
options replaced by their value
-
Field Summary
Fields Modifier and Type Field Description protected PropertySource
defaultProperties
protected Expression
format
protected String
formatString
protected Map<String,String>
props
-
Constructor Summary
Constructors Constructor Description FormattedString()
FormattedString(String s)
FormattedString(String formatString, PropertySource defaultProperties)
FormattedString(PropertySource defaultProperties)
-
Method Summary
Modifier and Type Method Description void
clearProperties()
String
debugInfo(String value, String description)
static String
debugInfo(FormattedString format, String value, String description)
Format a standard debug message for use in Decorator bad data reports.boolean
equals(Object obj)
String
getComponentName()
String
getComponentTypeName()
PropertySource
getDefaultProperties()
String
getFormat()
String
getLocalizedText()
String
getLocalizedText(PropertySource ps)
String
getText()
Return the resulting string after substituting propertiesString
getText(PropertySource ps)
Return the resulting string after substituting properties Also, if any property keys match a property in the given GamePiece, substitute the value of that propertyprotected String
getText(PropertySource ps, boolean localized)
String
getText(PropertySource ps, String def)
Return the resulting string after substituting properties Also, if any property keys match a property in the given GamePiece, substitute the value of that property.int
getTextAsInt(PropertySource ps, String description, AbstractConfigurable source)
int
getTextAsInt(PropertySource ps, String description, EditablePiece source)
Expand a FormattedString using the supplied propertySource and parse it as an integer.int
hashCode()
void
setDefaultProperties(PropertySource defaultProperties)
void
setFormat(String s)
void
setProperty(String name, String value)
-
Field Details
-
formatString
-
format
-
props
-
defaultProperties
-
-
Constructor Details
-
FormattedString
public FormattedString() -
FormattedString
-
FormattedString
-
FormattedString
-
-
Method Details
-
getComponentTypeName
- Specified by:
getComponentTypeName
in interfaceRecursionLimiter.Loopable
-
getComponentName
- Specified by:
getComponentName
in interfaceRecursionLimiter.Loopable
-
setFormat
-
getFormat
-
setProperty
-
clearProperties
public void clearProperties() -
getText
Return the resulting string after substituting properties- Returns:
-
getLocalizedText
-
getText
Return the resulting string after substituting properties Also, if any property keys match a property in the given GamePiece, substitute the value of that property- Parameters:
ps
-- Returns:
- See Also:
GamePiece.getProperty(java.lang.Object)
-
getText
Return the resulting string after substituting properties Also, if any property keys match a property in the given GamePiece, substitute the value of that property. If the resulting string is empty, then the default is returned.- Parameters:
ps
-def
- the default if the result is otherwise empty- Returns:
- See Also:
GamePiece.getProperty(java.lang.Object)
-
getLocalizedText
-
getText
-
getTextAsInt
Expand a FormattedString using the supplied propertySource and parse it as an integer. If the expanded string is not an integer, generate a Bad Data Report with debugging information and return a value of 0 -
getTextAsInt
-
debugInfo
Format a standard debug message for use in Decorator bad data reports. description=value description[format]=value Use format 1 if the generated value is the same as the format Use format 2 if the formated contains an expression that has been expanded.- Parameters:
format
- Formatted Stringdescription
- Description of the Stringvalue
- Value generated by the formatted string- Returns:
- error message
-
debugInfo
-
getDefaultProperties
-
setDefaultProperties
-
hashCode
public int hashCode() -
equals
-