Class DecimalSymbols

java.lang.Object
net.sf.saxon.trans.DecimalSymbols

public class DecimalSymbols extends Object
This class is modelled on Java's DecimalFormatSymbols, but it allows the use of any Unicode character to represent symbols such as the decimal point and the grouping separator, whereas DecimalFormatSymbols restricts these to a char (1-65535).

Upgraded July 2024 to handle new QT4 features, in particular the ability to supply both a marker character and a rendition string for properties like PERCENT: the marker character is used in the picture string, while the rendition form is used in the output.

  • Constructor Details

    • DecimalSymbols

      public DecimalSymbols(HostLanguage language, int languageLevel)
      Create a DecimalSymbols object with default values for all properties
      Parameters:
      language - e.g. XSLT or XQuery
      languageLevel - language version (times ten), e.g. 40 for XQuery 4.0
    • DecimalSymbols

      public DecimalSymbols(DecimalSymbols input)
      Copy a set of decimal format symbols
      Parameters:
      input - the symbols to be copied
  • Method Details

    • isValidPropertyName

      public static boolean isValidPropertyName(String name)
      Ask if the supplied string is recognized as a decimal format property name
      Parameters:
      name - the name in question
      Returns:
      true if this is an acceptable property name
    • getPropertyForName

      public static DecimalSymbols.Property getPropertyForName(String name)
      Get the property with a given name
      Parameters:
      name - the property name
      Returns:
      the corresponding property. In the case of "dual" properties such as PERCENT, the marker property is returned.
    • setHostLanguage

      public void setHostLanguage(HostLanguage language, int languageLevel)
      Set the host language and version
      Parameters:
      language - e.g. XSLT or XQuery
      languageLevel - language version (times ten), e.g. 40 for XQuery 4.0
    • getProperty

      public UnicodeString getProperty(DecimalSymbols.Property property)
      Get the value of a given property
      Parameters:
      property - the property required
      Returns:
      the property value if set, or null if not.
    • getMarker

      public int getMarker(DecimalSymbols.Property marker)
      Get the value of a single-character property
      Parameters:
      marker - the property required
      Returns:
      the value of the property as a single codepoint
      Throws:
      IllegalStateException - if the value of the property is not a single character
    • hasDefaultValue

      public boolean hasDefaultValue(DecimalSymbols.Property property)
      Ask whether a given property takes its default value
      Parameters:
      property - the property in question
      Returns:
      true if the value is explicitly or implicitly set to its default value
    • setProperty

      public void setProperty(String propertyName, UnicodeString value) throws XPathException
      Set the value of a property
      Parameters:
      propertyName - the name of the property as a string
      value - the value of the property
      Throws:
      XPathException - if the name or value is invalid
    • setProperty

      public void setProperty(String prop, UnicodeString value, int precedence) throws XPathException
      Set the value of a property at a given precedence level
      Parameters:
      prop - the property to be set
      value - the value of the property as a string (in many cases, this must be a single character)
      precedence - the precedence of the property value
      Throws:
      XPathException - if the property is invalid. This method does not check the consistency of different properties. If two different values are supplied for the same property at the same precedence, the method does not complain, but notes the fact, and if the inconsistency is not subsequently cleared by supplying another value at a higher precedence, the error is reported when the checkConsistency() method is subsequently called.
    • export

      public void export(StructuredQName name, ExpressionPresenter out)
      Export a decimal format to a SEF file
      Parameters:
      name - the name of the decimal format to be exported, or null for the unnamed decimal format
      out - the destination of the export
    • checkConsistency

      public void checkConsistency(StructuredQName name) throws XPathException
      Check that no character is used in more than one role
      Parameters:
      name - the name of the decimal format (null for the unnamed decimal format)
      Throws:
      XPathException - if the same character is used in conflicting rules, for example as decimal separator and also as grouping separator
    • isValidZeroDigit

      public static boolean isValidZeroDigit(int zeroDigit)
      Check that the character declared as a zero-digit is indeed a valid zero-digit
      Parameters:
      zeroDigit - the value to be checked
      Returns:
      false if it is not a valid zero-digit
    • equals

      public boolean equals(Object obj)
      Test if two sets of decimal format symbols are the same
      Overrides:
      equals in class Object
      Parameters:
      obj - the other set of symbols
      Returns:
      true if the same characters/strings are assigned to each role in both sets of symbols. The precedences are not compared.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object