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

    • getComponentTypeName

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

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

      public void setFormat​(String s)
    • getFormat

      public String getFormat()
    • setProperty

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

      public void clearProperties()
    • getText

      public String getText()
      Return the resulting string after substituting properties
      Returns:
    • 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 -
      Returns:
      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 -
      def - the default if the result is otherwise empty
      Returns:
      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 format, 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 formated 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)
    • getDefaultProperties

      public PropertySource getDefaultProperties()
    • setDefaultProperties

      public void setDefaultProperties​(PropertySource defaultProperties)
    • hashCode

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

      public boolean equals​(Object obj)
      Overrides:
      equals in class Object