Package net.sf.saxon.trans
Class DecimalSymbols
java.lang.Object
net.sf.saxon.trans.DecimalSymbols
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.
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionDecimalSymbols(HostLanguage language, int languageLevel) Create a DecimalSymbols object with default values for all propertiesDecimalSymbols(DecimalSymbols input) Copy a set of decimal format symbols -
Method Summary
Modifier and TypeMethodDescriptionvoidCheck that no character is used in more than one rolebooleanTest if two sets of decimal format symbols are the samevoidexport(StructuredQName name, ExpressionPresenter out) Export a decimal format to a SEF fileintgetMarker(DecimalSymbols.Property marker) Get the value of a single-character propertygetProperty(DecimalSymbols.Property property) Get the value of a given propertystatic DecimalSymbols.PropertygetPropertyForName(String name) Get the property with a given namebooleanhasDefaultValue(DecimalSymbols.Property property) Ask whether a given property takes its default valueinthashCode()static booleanisValidPropertyName(String name) Ask if the supplied string is recognized as a decimal format property namestatic booleanisValidZeroDigit(int zeroDigit) Check that the character declared as a zero-digit is indeed a valid zero-digitvoidsetHostLanguage(HostLanguage language, int languageLevel) Set the host language and versionvoidsetProperty(String propertyName, UnicodeString value) Set the value of a propertyvoidsetProperty(String prop, UnicodeString value, int precedence) Set the value of a property at a given precedence level
-
Constructor Details
-
DecimalSymbols
Create a DecimalSymbols object with default values for all properties- Parameters:
language- e.g. XSLT or XQuerylanguageLevel- language version (times ten), e.g. 40 for XQuery 4.0
-
DecimalSymbols
Copy a set of decimal format symbols- Parameters:
input- the symbols to be copied
-
-
Method Details
-
isValidPropertyName
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
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
Set the host language and version- Parameters:
language- e.g. XSLT or XQuerylanguageLevel- language version (times ten), e.g. 40 for XQuery 4.0
-
getProperty
Get the value of a given property- Parameters:
property- the property required- Returns:
- the property value if set, or null if not.
-
getMarker
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
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
Set the value of a property- Parameters:
propertyName- the name of the property as a stringvalue- the value of the property- Throws:
XPathException- if the name or value is invalid
-
setProperty
Set the value of a property at a given precedence level- Parameters:
prop- the property to be setvalue- 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
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 formatout- the destination of the export
-
checkConsistency
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
Test if two sets of decimal format symbols are the same -
hashCode
public int hashCode()
-