Apama API Reference for .NET  9.10.0.4
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
Apama.Event.Parser.DecimalFieldValue Class Reference

Represents the value of an Apama decimal field, using Decimal or Double objects. More...

Public Member Functions

 DecimalFieldValue (String value)
 Create a new DecimalFieldValue

Parameters
valuefrom a string representation.
More...
 
 DecimalFieldValue (Decimal value)
 Create a new DecimalFieldValue

Parameters
valuefrom a Decimal value
More...
 
override String ToString ()
 Stringify this instance of a DecimalFieldValue, using the Decimal value if it is not null, otherwise using the floating point representation, which could show also be NaN or Infinity.

Returns
the stringified version of this DecimalFieldValue.
More...
 

Properties

double FloatValue [get]
 The floating point representation of this value. More...
 
bool IsInfinity [get]
 Indicates if this instance of a DecimalFieldValue represents an infinity value More...
 
bool IsNaN [get]
 Indicates if this instance of a DecimalFieldValue represents a NaN (Not a Number) value More...
 
String StringValue [get]
 The string representation. This is the original string value (or the Decimal value converted), depending on how the object was originally constructed. More...
 
Nullable< Decimal > Value [get]
 The Decimal value. If the value returned is null, please use the FloatValue or or StringValue properties (see remarks). More...
 

Detailed Description

Represents the value of an Apama decimal field, using Decimal or Double objects.

This class allows for a wider range of values to be stored than the Decimal type allows. If the value is within range allowed by a Decimal, as stated in the remarks section there, using either constructor allows the value to be stored internally as a Decimal. If it is outside the range, the string constructor should be used. The value will then be internally represented as a Double, which allows infinities and NaNs too.

Field<DecimalFieldValue> decimalField = FieldTypes.Decimal.NewField("decimalField");
EventParser eventParser = new EventParser(new EventType("sample.MyEvent", decimalField));
Event e = eventParser.Parse("sample.MyEvent(1.00000001)");
DecimalFieldValue decimalValue = e.GetField(decimalField);
// DecimalFieldValue.ToString() will automatically determine which of the BigDecimal or Float values are correct
System.Console.WriteLine("Decimal ToString is: "+decimalValue.ToString());
String decimalValueString;
if (decimalValue.Value != null)
{
// If the value is representable by BigDecimals then Value will return a non-null and correct value
decimalValueString = decimalValue.Value.ToString();
}
else
{
// If the value is not representable by BigDecimals, then Value will return null and
// FloatValue will return the float representation of the number, i.e. NaN, Infinity etc...
double decimalValueAsFloat = decimalValue.FloatValue;
decimalValueString = String.Format("%f", decimalValueAsFloat);
}
// The original number is stored as a string
System.Console.WriteLine("Decimal original value was: " + decimalValue.StringValue + "; current decimal value is: " + decimalValueString);

Constructor & Destructor Documentation

Apama.Event.Parser.DecimalFieldValue.DecimalFieldValue ( String  value)

Create a new DecimalFieldValue

Parameters
valuefrom a string representation.

Using this constructor allows for a wider range of values to be stored than the .Net Decimal type allows. If the value is within range allowed by a Decimal (see remarks section there), the value is stored as a Decimal. If it is outside the range (either too big or too small), it will be stored as a Double. If it is outside the range of a Double then it will be stored as an Infinity (and isInfinity will return true, although the original string value will remain) or zero dependent on it's size. It can also be set to Not a Number through this constructor. If the value cannot be parsed, a FormatException is thrown. If the value passed is null, an ArgumentNullException is thrown.

Apama.Event.Parser.DecimalFieldValue.DecimalFieldValue ( Decimal  value)

Create a new DecimalFieldValue

Parameters
valuefrom a Decimal value

Use this constructor if the value falls within the range allowed by a Decimal (see remarks section there), the value is stored as a Decimal. This constructor cannot be used to set Infinities or NaN values.

Member Function Documentation

override String Apama.Event.Parser.DecimalFieldValue.ToString ( )

Stringify this instance of a DecimalFieldValue, using the Decimal value if it is not null, otherwise using the floating point representation, which could show also be NaN or Infinity.

Returns
the stringified version of this DecimalFieldValue.

Property Documentation

double Apama.Event.Parser.DecimalFieldValue.FloatValue
get

The floating point representation of this value.

Under normal circumstances, this is intended to be as accurate a representation of the decimal value as possible. If the decimal representation from Value returned null (i.e. was outside the range storable), then this function should be used. It can also represent NaN and Infinities. One special case is where the value is extremely close to zero. If this property is 0, and the Value property is null, please use StringValue to see the original number.

bool Apama.Event.Parser.DecimalFieldValue.IsInfinity
get

Indicates if this instance of a DecimalFieldValue represents an infinity value

bool Apama.Event.Parser.DecimalFieldValue.IsNaN
get

Indicates if this instance of a DecimalFieldValue represents a NaN (Not a Number) value

String Apama.Event.Parser.DecimalFieldValue.StringValue
get

The string representation. This is the original string value (or the Decimal value converted), depending on how the object was originally constructed.

Nullable<Decimal> Apama.Event.Parser.DecimalFieldValue.Value
get

The Decimal value. If the value returned is null, please use the FloatValue or or StringValue properties (see remarks).

When a null value is returned, the value is either outside the range allowable by the Decimal type. It could also be a NaN, or Positive/Negative Infinity value. Whilst typically the value might be too large in magnitude to be represented as a decimal, one special case is where the value is extremely close to zero. If this proeprty is null, and FloatValue is 0, please use StringValue to see the original number.

Submit a bug or feature
Copyright (c) 2013-2016 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors. Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG.