Class NumberToken
A Token which represents a numeric value.
Implements
Inherited Members
Namespace: Sdl.LanguagePlatform.Core.Tokenization
Assembly: Sdl.LanguagePlatform.Core.dll
Syntax
public class NumberToken : Token, ILocalizableToken
Constructors
NumberToken(NumberToken)
Initializes a new instance with the values of another instance, creating a deep copy.
Declaration
public NumberToken(NumberToken other)
Parameters
| Type | Name | Description |
|---|---|---|
| NumberToken | other | The instance to copy |
NumberToken(String, NumericSeparator, NumericSeparator, Char, Char, Sign, String, String, String)
Initializes a new instance with the specified values.
Declaration
public NumberToken(string text, NumericSeparator groupSeparator, NumericSeparator decimalSeparator, char alternateGroupSeparator, char alternateDecimalSeparator, Sign sign, string rawSign, string rawDecimalDigits, string rawFractionalDigits)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | text | The text of the token, as it appeared in the input |
| NumericSeparator | groupSeparator | The type of group separator used |
| NumericSeparator | decimalSeparator | The type of decimal separator used |
| System.Char | alternateGroupSeparator | The character of an alternative group separator, if used |
| System.Char | alternateDecimalSeparator | The character of an alternative decimal separator, if used |
| Sign | sign | The type of sign used |
| System.String | rawSign | The "raw text" of the sign |
| System.String | rawDecimalDigits | The "raw decimal digits", without separators, between 0-9 |
| System.String | rawFractionalDigits | The "raw fractional digits", without separators, between 0-9 |
NumberToken(String, String, String, String, NumberFormatInfo)
Initializes a new instance with the specified values.
Declaration
public NumberToken(string text, string sign, string decimalPart, string fractionalPart, NumberFormatInfo format)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | text | The token text |
| System.String | sign | The sign of the numeric value |
| System.String | decimalPart | The decimal part of the numeric value |
| System.String | fractionalPart | The fractional part of the numeric value |
| System.Globalization.NumberFormatInfo | format | The number format of the token's culture, used to determine whether default or alternate separators were used |
Properties
AlternateDecimalSeparator
Gets or sets an alternate decimal separator, which is a single char if an alternate separator is used, or the null character if no alternate separator is used.
Declaration
public char AlternateDecimalSeparator { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Char |
AlternateGroupSeparator
Gets or sets an alternate group separator, which is a single char if an alternate separator is used, or the null character if no alternate separator is used.
Declaration
public char AlternateGroupSeparator { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Char |
DecimalSeparator
Gets or sets the decimal separator
Declaration
public NumericSeparator DecimalSeparator { get; set; }
Property Value
| Type | Description |
|---|---|
| NumericSeparator |
GroupSeparator
Gets or sets the group separator
Declaration
public NumericSeparator GroupSeparator { get; set; }
Property Value
| Type | Description |
|---|---|
| NumericSeparator |
IsPlaceable
IsPlaceable. Always true for this class.
Declaration
public override bool IsPlaceable { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Overrides
IsSubstitutable
IsSubstitutable. Always true for this class.
Declaration
public override bool IsSubstitutable { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Overrides
RawDecimalDigits
Gets or sets the raw decimal digits, which are a sequence of digits without separators or signs.
Declaration
public string RawDecimalDigits { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
RawFractionalDigits
Gets or sets the raw fractional digits, which are a sequence of digits without separators or signs.
Declaration
public string RawFractionalDigits { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
RawSign
Gets or sets the "raw" sign, i.e. the textual representation of the sign
Declaration
public string RawSign { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Sign
Gets or sets the sign.
Declaration
public Sign Sign { get; set; }
Property Value
| Type | Description |
|---|---|
| Sign |
Value
Gets or sets the numeric value. Do not use the setter, it is for internal purposes only.
Declaration
public double Value { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
ValueValid
Gets or sets the flag whether the numeric value is valid or not. Do not use the setter, it is for internal purposes only.
Declaration
public bool ValueValid { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Methods
AcceptSegmentElementVisitor(ISegmentElementVisitor)
Visitor pattern implementation. Calls VisitNumberToken(NumberToken).
Declaration
public override void AcceptSegmentElementVisitor(ISegmentElementVisitor visitor)
Parameters
| Type | Name | Description |
|---|---|---|
| ISegmentElementVisitor | visitor | The visitor instance |
Overrides
Duplicate()
See Duplicate()
Declaration
public override SegmentElement Duplicate()
Returns
| Type | Description |
|---|---|
| SegmentElement | A new instance that is a deep copy of this instance. |
Overrides
Equals(Object)
Declaration
public override bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | obj | The object to compare with the current object. |
Returns
| Type | Description |
|---|---|
| System.Boolean | true if the specified object is equal to the current object; otherwise, false. |
Overrides
FormatNumber(CultureInfo)
Format the number according to the provided culture, applying overrides for separators as appropriate. This method uses a proprietary implementation for the formatting and does not use the default .Net formatting methods.
Declaration
public string FormatNumber(CultureInfo culture)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Globalization.CultureInfo | culture |
Returns
| Type | Description |
|---|---|
| System.String |
FormatNumber(NumberFormatInfo)
Format the number according to the provided number format information, applying overrides for separators as appropriate. This method uses a proprietary implementation for the formatting and does not use the default .Net formatting methods.
Declaration
public string FormatNumber(NumberFormatInfo nfi)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Globalization.NumberFormatInfo | nfi |
Returns
| Type | Description |
|---|---|
| System.String |
GetHashCode()
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| System.Int32 |
Overrides
GetSimilarity(SegmentElement)
Declaration
public override SegmentElement.Similarity GetSimilarity(SegmentElement other)
Parameters
| Type | Name | Description |
|---|---|---|
| SegmentElement | other | The other instance. |
Returns
| Type | Description |
|---|---|
| SegmentElement.Similarity | A value indicating the degree of similarity to the provided segment element. |
Overrides
GetTokenType()
Declaration
protected override TokenType GetTokenType()
Returns
| Type | Description |
|---|---|
| TokenType |
Overrides
Localize(CultureInfo, AutoLocalizationSettings)
Auto-localizes the token according to the settings of the specified target culture and the provided auto-localization settings. The text of the token will be changed, but not the values.
For some token types, special AutoLocalizationSettings will be used, if provided.
Declaration
public virtual bool Localize(CultureInfo culture, AutoLocalizationSettings autoLocalizationSettings)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Globalization.CultureInfo | culture | The target culture |
| AutoLocalizationSettings | autoLocalizationSettings | Contains the AutoLocalizationSettings to use for some token types. May be null, in which case default settings will be used. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Localize(CultureInfo, AutoLocalizationSettings, ILocalizableToken, Boolean)
Auto-localizes the token according to the settings of the specified target culture and the provided auto-localization settings. The text of the token will be changed, but not the values.
For some token types, special AutoLocalizationSettings will be used, if provided.
Declaration
public virtual bool Localize(CultureInfo culture, AutoLocalizationSettings autoLocalizationSettings, ILocalizableToken originalMemoryToken, bool adjustCasing)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Globalization.CultureInfo | culture | The target culture |
| AutoLocalizationSettings | autoLocalizationSettings | Contains the AutoLocalizationSettings to use for some token types. May be null, in which case default settings will be used. |
| ILocalizableToken | originalMemoryToken | The original memory token. Some auto-localization settings will be derived from the token, if provided. |
| System.Boolean | adjustCasing | If true, it is assumed that the token is in segment-initial position. Then, casing will be adjusted if the original memory token is supplied as well. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
SetValue(Token, Boolean)
Overwrites the current token's value with the value from blueprint, which
also must be a DateTimeToken. Note that only the value and the type are
overwritten, not the textual representation.
Declaration
public virtual bool SetValue(Token blueprint, bool keepNumericSeparators)
Parameters
| Type | Name | Description |
|---|---|---|
| Token | blueprint | The token to take the value from |
| System.Boolean | keepNumericSeparators | Applicable to numeric (number and measurement) tokens only: if true, do not override the original group and decimal separators. |
Returns
| Type | Description |
|---|---|
| System.Boolean | A flag indicating whether the token's value or type were changed. |
SetValue(String, String, String, NumberFormatInfo)
Overwrites the current token values with the specified values.
Declaration
public virtual void SetValue(string sign, string decimalPart, string fractionalPart, NumberFormatInfo format)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | sign | The sign of the numeric value |
| System.String | decimalPart | The decimal part of the numeric value |
| System.String | fractionalPart | The fractional part of the numeric value |
| System.Globalization.NumberFormatInfo | format | The number format of the token's culture, used to determine whether default or alternate separators were used |