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 Details

  • Constructor Details

    • FormattedString

      public FormattedString()
    • FormattedString

      public FormattedString(String s)
    • FormattedString

      public FormattedString(PropertySource defaultProperties)
    • FormattedString

      public FormattedString(String formatString, PropertySource defaultProperties)
  • Method Details

    • setFormat

      public void setFormat(String fs)
    • getFormat

      public String getFormat()
    • setProperty

      public void setProperty(String name, String value)
    • clearProperties

      public void clearProperties()
    • setDefaultProperties

      public void setDefaultProperties(PropertySource defaultProperties)
    • getDefaultProperties

      public PropertySource getDefaultProperties()
    • getText

      public String getText()
      Returns:
      the resulting string after substituting properties
    • getLocalizedText

      public String getLocalizedText()
    • getText

      public String 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 property
      Parameters:
      ps - property source
      Returns:
      Return the resulting string after substituting properties
      See Also:
      GamePiece.getProperty(java.lang.Object)
    • getText

      public 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. If the resulting string is empty, then the default is returned.
      Parameters:
      ps - Property source
      def - the default if the result is otherwise empty
      Returns:
      Return the resulting string after substituting properties
      See Also:
      GamePiece.getProperty(java.lang.Object)
    • getLocalizedText

      public String getLocalizedText(PropertySource ps)
    • getText

      protected String getText(PropertySource ps, boolean localized)
    • getTextAsInt

      public int getTextAsInt(PropertySource ps, String description, EditablePiece source)
      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

      public int getTextAsInt(PropertySource ps, String description, AbstractConfigurable source)
    • debugInfo

      public static String debugInfo(FormattedString fs, String value, String description)
      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 formatted contains an expression that has been expanded.
      Parameters:
      format - Formatted String
      description - Description of the String
      value - Value generated by the formatted string
      Returns:
      error message
    • debugInfo

      public String debugInfo(String value, String description)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • getComponentTypeName

      public String getComponentTypeName()
      Specified by:
      getComponentTypeName in interface RecursionLimiter.Loopable
    • getComponentName

      public String getComponentName()
      Specified by:
      getComponentName in interface RecursionLimiter.Loopable