Element Class |
Namespace: Bloomberglp.Blpapi
The Element type exposes the following members.
Name | Description | |
---|---|---|
Datatype | Gets the Datatype of this Element.
| |
ElementDefinition | Gets a reference to the read-only element definition object that
defines the properties of this elements value.
| |
Elements |
Gets an enumerable collection of all sub-elements.
| |
IsArray | Gets true if this element is an array.
| |
IsComplexType |
Indicates whether this element is a complex type.
| |
IsNull | Gets true if this element is null (has no values).
| |
IsReadOnly | Gets true if this element can not be modified.
| |
ItemInt32 |
This is the same as GetValue(index).
| |
ItemString | Obsolete.
This is the same as GetElement(name).
| |
ItemName |
This is the same as GetElement(name).
| |
ItemString, Int32 | Obsolete.
This is the same as GetElement(name).
GetValue(index).
| |
ItemName, Int32 |
This is the same as GetElement(name).
GetValue(index).
| |
Name | Gets the name of this element.
| |
NumElements | Gets the number of elements this element contains.
| |
NumValues | Gets the number of values this element contains.
| |
TypeDefinition | Gets the SchemaTypeDefinition for this element.
|
Name | Description | |
---|---|---|
AppendElement | If this Element is an array of Sequence or Choice Elements, appends
a default initialized element to this element and return the appended
element.
| |
AppendValue(Boolean) | Appends the specified value to this array element.
| |
AppendValue(Byte) | Obsolete. Appends the specified value to this array element.
Deprecated. Arrays of byte arrays are not supported.
This method will always throw an NotSupportedException.
| |
AppendValue(Char) | Appends the specified value to this array element.
| |
AppendValue(Double) | Appends the specified value to this array element.
| |
AppendValue(Int32) | Appends the specified value to this array element.
| |
AppendValue(Int64) | Appends the specified value to this array element.
| |
AppendValue(Single) | Appends the specified value to this array element.
| |
AppendValue(String) | Appends the specified value to this array element.
| |
AppendValue(Constant) | Appends the specified value to this array element.
| |
AppendValue(Datetime) | Appends the specified value to this array element.
| |
AppendValue(Name) | Appends the specified value to this array element.
| |
Clone | Clone this element.
| |
FindConstant(ConstantsList) | Finds the constant in a ConstantList that is equal to the value of
this element.
| |
FindConstant(ConstantsList, Int32) | Gets the constant in a ConstantList that is equal to the value at the specified index of
this element.
| |
GetChoice | Returns the selected choice if this is a choice type.
| |
GetElement(Int32) | Returns the sub-element at the specified zero based position.
| |
GetElement(String) | Obsolete. Returns the named sub-element, creating it if it doesn't
exist and this element is modifiable.
Deprecated, use GetElement(Name) instead.
| |
GetElement(Name) | Returns the named sub-element, creating it if it doesn't exist and this
element is modifiable.
| |
GetElementAsBool(String) | Obsolete. Returns the value of the named sub-element as a boolean.
Deprecated, use GetElementAsBool(Name) instead.
| |
GetElementAsBool(Name) | Returns the value of the named sub-element as a boolean.
| |
GetElementAsBytes(String) | Obsolete. Returns the value of the named sub-element as a byte array.
Deprecated, use GetElementAsBytes(Name) instead.
| |
GetElementAsBytes(Name) | Returns the value of the named sub-element as a byte array.
| |
GetElementAsChar(String) | Obsolete. Returns the value of the named sub-element as a char.
Deprecated, use GetElementAsChar(Name) instead.
| |
GetElementAsChar(Name) | Returns the value of the named sub-element as a char.
| |
GetElementAsDate(String) | Obsolete. Returns the value of the named sub-element as a Date.
Deprecated, use GetElementAsDate(Name) instead.
| |
GetElementAsDate(Name) | Returns the value of the named sub-element as a Date.
| |
GetElementAsDatetime(String) | Obsolete. Returns the value of the named sub-element as a Datetime.
Deprecated, use GetElementAsDatetime(Name) instead.
| |
GetElementAsDatetime(Name) | Returns the value of the named sub-element as a Datetime.
| |
GetElementAsFloat32(String) | Obsolete. Returns the value of the named sub-element as a float.
Deprecated, use GetElementAsFloat32(Name) instead.
| |
GetElementAsFloat32(Name) | Returns the value of the named sub-element as a float.
| |
GetElementAsFloat64(String) | Obsolete. Returns the value of the named sub-element as a double.
Deprecated, use GetElementAsFloat64(Name) instead.
| |
GetElementAsFloat64(Name) | Returns the value of the named sub-element as a double.
| |
GetElementAsInt32(String) | Obsolete. Returns the value of the named sub-element as an int.
Deprecated, use GetElementAsInt32(Name) instead.
| |
GetElementAsInt32(Name) | Returns the value of the named sub-element as an int.
| |
GetElementAsInt64(String) | Obsolete. Returns the value of the named sub-element as a long.
Deprecated, use GetElementAsInt64(Name) instead.
| |
GetElementAsInt64(Name) | Returns the value of the named sub-element as a long.
| |
GetElementAsName(String) | Obsolete. Returns the value of the named sub-element as a Name.
Deprecated, use GetElementAsName(Name) instead.
| |
GetElementAsName(Name) | Returns the value of the named sub-element as a Name.
| |
GetElementAsString(String) | Obsolete. Returns the value of the named sub-element as a string.
Deprecated, use GetElementAsString(Name) instead.
| |
GetElementAsString(Name) | Returns the value of the named sub-element as a string.
| |
GetElementAsTime(String) | Obsolete. Returns the value of the named sub-element as a Time.
Deprecated, use GetElementAsTime(Name) instead.
| |
GetElementAsTime(Name) | Returns the value of the named sub-element as a Time.
| |
GetValue | Returns the value of this element as an object.
| |
GetValue(Int32) | Returns the value of the element
at the specified index as an object.
| |
GetValueAsBool | Returns the value of this element as a boolean.
| |
GetValueAsBool(Int32) | Returns the value of the element
at the specified index as a boolean.
| |
GetValueAsBytes | Returns the value of this element as a byte array.
| |
GetValueAsBytes(Int32) | Returns the value of this element at the specified index as a byte array.
| |
GetValueAsChar | Returns the value of this element as a char.
| |
GetValueAsChar(Int32) | Returns the value of this element at the specified index as a char.
| |
GetValueAsDate | Returns the value of this element as a Date.
| |
GetValueAsDate(Int32) | Returns the value of this element at the specified index as a Date.
| |
GetValueAsDatetime | Returns the value of this element as a Datetime.
| |
GetValueAsDatetime(Int32) | Returns the value of this element at the specified index as a Datetime.
| |
GetValueAsElement |
Returns the value of this element as an Element.
| |
GetValueAsElement(Int32) | Returns the value at the specified index
in this element as an Element.
| |
GetValueAsEnumeration | Returns the value of this element as a Enumeration constant.
| |
GetValueAsEnumeration(Int32) | Returns the value of this element at the specified index as an Enumeration
constant.
| |
GetValueAsFloat32 | Returns the value of this element as a float.
| |
GetValueAsFloat32(Int32) | Returns the value of this element at the specified index as a float.
| |
GetValueAsFloat64 | Returns the value of this element as a double.
| |
GetValueAsFloat64(Int32) | Returns the value of this element at the specified index as a double.
| |
GetValueAsInt32 | Returns the value of this element as an int.
| |
GetValueAsInt32(Int32) | Returns the value of this element at the specified index as an int.
| |
GetValueAsInt64 | Returns the value of this element as a long.
| |
GetValueAsInt64(Int32) | Returns the value of this element at the specified index as a long.
| |
GetValueAsName | Returns the value of this element as a Enumeration constant.
| |
GetValueAsName(Int32) | Returns the value of this element at the specified index as an Enumeration
constant.
| |
GetValueAsString | Returns the value of this element as a string.
| |
GetValueAsString(Int32) | Returns the value of this element at the specified index as a string.
| |
GetValueAsTime | Returns the value of this element as a Time.
| |
GetValueAsTime(Int32) | Returns the value of this element at the specified index as a Time.
| |
HasElement(String) | Obsolete. Returns true if this element contains an element with the specified name.
Deprecated, use HasElement(Name) instead.
| |
HasElement(Name) | Returns true if this element contains an element with the specified name.
| |
HasElement(String, Boolean) | Obsolete. Returns true if this element contains an element with the specified name.
Deprecated, use HasElement(Name, Boolean) instead.
| |
HasElement(Name, Boolean) | Returns true if this element contains an element with the specified name.
| |
IsEqualTo(Constant) | Gets true if the value this element is equal to the specified constant.
| |
IsEqualTo(Constant, Int32) | Gets true if the value at the specified index of this element is equal
to the specified constant.
| |
IsNullValue | Gets true if the sub-element at the specified position in a sequence or
choice element is null.
| |
Print(Stream) |
Prints the contents of this element to the specified Stream.
| |
Print(TextWriter) |
Prints the contents of this element to the specified TextWriter.
| |
SetChoice(String) | Obsolete. Sets the named sub-element as the choice's selection.
Deprecated, use SetChoice(Name) instead.
| |
SetChoice(Name) | Sets the named sub-element as the choice's selection.
| |
SetElement(String, Constant) | Obsolete. Sets the named sub-element to the specified value.
Deprecated, use SetElement(Name, Constant) instead.
| |
SetElement(String, Datetime) | Obsolete. Sets the named sub-element to the specified value.
Deprecated, use SetElement(Name, Datetime) instead.
| |
SetElement(String, Name) | Obsolete. Sets the named sub-element to the specified value.
Deprecated, use SetElement(Name, Name) instead.
| |
SetElement(String, Boolean) | Obsolete. Sets the named sub-element to the specified value.
Deprecated, use SetElement(Name, Boolean) instead.
| |
SetElement(String, Byte) | Obsolete. Sets the named sub-element to the specified value.
Deprecated, use SetElement(Name, Byte) instead.
| |
SetElement(String, Char) | Obsolete. Sets the named sub-element to the specified value.
Deprecated, use SetElement(Name, Char) instead.
| |
SetElement(String, Double) | Obsolete. Sets the named sub-element to the specified value.
Deprecated, use SetElement(Name, Double) instead.
| |
SetElement(String, Int32) | Obsolete. Sets the named sub-element to the specified value.
Deprecated, use SetElement(Name, Int32) instead.
| |
SetElement(String, Int64) | Obsolete. Sets the named sub-element to the specified value.
Deprecated, use SetElement(Name, Int64) instead.
| |
SetElement(String, Single) | Obsolete. Sets the named sub-element to the specified value.
Deprecated, use SetElement(Name, Single) instead.
| |
SetElement(String, String) | Obsolete. Sets the named sub-element to the specified value.
Deprecated, use SetElement(Name, String) instead.
| |
SetElement(Name, Constant) | Sets the named sub-element to the specified value.
| |
SetElement(Name, Datetime) | Sets the named sub-element to the specified value.
| |
SetElement(Name, Name) | Sets the named sub-element to the specified value.
| |
SetElement(Name, Boolean) | Sets the named sub-element to the specified value.
| |
SetElement(Name, Byte) | ||
SetElement(Name, Char) | Sets the named sub-element to the specified value.
| |
SetElement(Name, Double) | Sets the named sub-element to the specified value.
| |
SetElement(Name, Int32) | Sets the named sub-element to the specified value.
| |
SetElement(Name, Int64) | Sets the named sub-element to the specified value.
| |
SetElement(Name, Single) | Sets the named sub-element to the specified value.
| |
SetElement(Name, String) | Sets the named sub-element to the specified value.
| |
SetValue(Boolean) | Sets the value of this element to the specified value.
| |
SetValue(Byte) | Sets the value of this element to the specified value.
| |
SetValue(Char) | Sets the value of this element to the specified value.
| |
SetValue(Double) | Sets the value of this element to the specified value.
| |
SetValue(Int32) | Sets the value of this element to the specified value.
| |
SetValue(Int64) | Sets the value of this element to the specified value.
| |
SetValue(Single) | Sets the value of this element to the specified value.
| |
SetValue(String) | Sets the value of this element to the specified value.
| |
SetValue(Constant) | Sets the value of this element to the specified value.
| |
SetValue(Datetime) | Sets the value of this element to the specified value.
| |
SetValue(Name) | Sets the value of this element to the specified value.
| |
SetValue(Boolean, Int32) | Sets the value of this element to the specified value.
| |
SetValue(Byte, Int32) | Sets the value of this element to the specified value.
| |
SetValue(Char, Int32) | Sets the value of this element to the specified value.
| |
SetValue(Double, Int32) | Sets the value of this element to the specified value.
| |
SetValue(Int32, Int32) | Sets the value of this element to the specified value.
| |
SetValue(Int64, Int32) | Sets the value of this element to the specified value.
| |
SetValue(Single, Int32) | Sets the value of this element to the specified value.
| |
SetValue(String, Int32) | Sets the value of this element to the specified value.
| |
SetValue(Constant, Int32) | Sets the value of this element to the specified value.
| |
SetValue(Datetime, Int32) | Sets the value of this element to the specified value.
| |
SetValue(Name, Int32) | Sets the value of this element to the specified value.
| |
ToString | Return the string representation of this object.
(Overrides ObjectToString.) | |
ValueIsNull | Obsolete. Gets true if the element at the specified position in a sequence or
choice element is null.
|
Using "Element" objects
An element is a variant type. That is they can represent any of the data types supported by the blpapi. Elements can represent simple scalar values like (float, string), arrays of simple types, complex values (sequences/choices), and arrays of complex values.
Accessing Elements
Elements are used when accessing messages received from the API, and when preparing requests for API services. There are two classes of accessor/manipulators that are used to access/manipulate elements. When accessing simple values and arrays, the "GetValueAsX" family of functions are used where 'X' is the target data type(e.g., "GetValueAsInt32"). For simplicity, all "GetValueAsX" functions can optionally be supplied with an index parameter to access elements of an array. For scalar elements, index should not be supplied, or zero should be supplied. The following are examples of accessing simple and array elements.
This example shows how to access the value of a scalar element as an integer number. Then goes on to show how to access the same element as a String
Element e; ... int x = e.GetValueAsIn32(); System.Console.WriteLine(e.GetValueAsString()); (or) System.Console.WriteLine(e.GetValueAsString(0));
The following example shows how to access array elements
int count = e.NumValues; for (int i = 0; i < count; ++i) { System.Console.WriteLine(e.GetValueAsString(i)); }
Use NumValues to determine the number of values available. For scalar values, it will return either 0 or 1. For arrays it will return the actual number of values in the array.
Complex elements contain named sub-elements. Sub-elements are accessed using the "GetElement", and "GetElementAsX" accessor functions. To demonstrate, the following example shows how to access the "city" sub-element of an "address" element:
private static readonly Name City = Name.GetName("city"); Element address; ... address.GetElement(City);
The following example retrieves the value of the "city" sub-element as a string value.
address.GetElementAsString(City);
To determine the number of available sub elements in a given element, the "NumElements" accessor can be used. To retrieve the Nth available sub-element of a complex element, the "GetElement(int)" accessor can be used. For example:
int numElements = address.NumElements; for (int i = 0; i < numElements; ++i) { Element e = address.GetElement(i); System.Console.WriteLine($"{e.Name}={e.GetValueAsString()}"); }
Manipulating Elements
Elements are also used to submit input for API services (e.g., preparing a reference data request). Just as when accessing element values, there are two types of manipulators used to set elements. To set the value of simple elements, and arrays of simple elements, the "SetValue", and "AppendValue" manipulator are used. For example
private static readonly Name Security = Name.GetName("security"); private static readonly Name Fields = Name.GetName("fields"); Request request; ... Element security = request.GetElement(Security); security.SetValue("IBM UN Equity"); Element fields = request.GetElement(Fields); fields.AppendValue("DS003"); fields.AppendValue("PX_LAST");
request.SetElement(Security, "IBM UN Equity");
Type Conversions
The API will convert data types as long as there is no loss of precision
involved. So
- A BOOL can be returned as bool, char, Int32, Int64, Float32, Float64,
String (the string will be "true" or "false")
- A BOOL can be set from bool, String (if it has a value of "y", "n", "yes",
"no", "true" or "false")
- A CHAR can be returned as char, Int32, Int64, Float32, Float64, String
- A CHAR can be set from char
- An INT32 can be returned as Int32, Int64, Float64, String
- An INT32 can be set from char, Int32
- An INT64 can be returned as Int64, String
- An INT64 can be set from char, Int32, Int64
- A FLOAT32 can be returned as Float32, Float64, String
- A FLOAT32 can be set from char, Float32
- A FLOAT64 can be returned as Float64, String
- A FLOAT64 can be set from char, Float32, Float64
- A BYTEARRAY can be set from byte[] and returned as byte[] ONLY