Xmla.Rowset Class
This class implements an XML/A Rowset object.
You do not need to instantiate objects of this class yourself.
Rather, the Xmla class will instantiate this class to convey the result of any of the various discoverXXX() methods
(see discover()).
In addition, this class is also used to instantiate a Resultset for the
execute() method in case the
Format property is set to Tabular
(see OPTION_FORMAT and OPTION_FORMAT_TABULAR).
The request() method itself will also return an instance of this class in case the method is used to do a
Discover request, or in case it is used to do a Execute request and the Format property is set to Tabular.
An instance of the Xmla.Rowset class is returned immediately as return value from the disoverXXX() or execute() method when doing a synchronous request.
In addition, the rowset is available in the eventdata passed to any registered listeners
(see addListener()).
Note that for asynchronous requests, the only way to obtain the returned Rowset instance is through the listeners.
Constructor
Xmla.Rowset
-
node -
requestTtype -
xmla
Parameters:
-
nodeDOMDocumentThe responseXML result returned by server in response to a
Discoverrequest. -
requestTtypeStringThe requestType identifying the particular schema rowset to construct. This facilitates implementing field getters for a few complex types.
-
xmlaXmlaThe Xmla instance that created this Rowset. This is mainly used to allow the Rowset to access the options passed to the Xmla constructor.
Item Index
Methods
Properties
- MD_DIMTYPE_ACCOUNTS static
- MD_DIMTYPE_BILL_OF_MATERIALS static
- MD_DIMTYPE_CHANNEL static
- MD_DIMTYPE_CURRENCY static
- MD_DIMTYPE_CUSTOMERS static
- MD_DIMTYPE_GEOGRAPHY static
- MD_DIMTYPE_MEASURE static
- MD_DIMTYPE_ORGANIZATION static
- MD_DIMTYPE_OTHER static
- MD_DIMTYPE_PRODUCTS static
- MD_DIMTYPE_PROMOTION static
- MD_DIMTYPE_QUANTITATIVE static
- MD_DIMTYPE_RATES static
- MD_DIMTYPE_SCENARIO static
- MD_DIMTYPE_TIME static
- MD_DIMTYPE_UNKNOWN static
- MD_DIMTYPE_UTILIY static
- MD_STRUCTURE_FULLYBALANCED static
- MD_STRUCTURE_NETWORK static
- MD_STRUCTURE_RAGGEDBALANCED static
- MD_STRUCTURE_UNBALANCED static
- MD_SYSTEM_ENABLED static
- MD_SYSTEM_INTERNAL static
- MD_USER_DEFINED static
- MDMEMBER_TYPE_ALL static
- MDMEMBER_TYPE_FORMULA static
- MDMEMBER_TYPE_MEASURE static
- MDMEMBER_TYPE_REGULAR static
- MDMEMBER_TYPE_UNKNOWN static
Methods
close
()
Releases references to the DomDocument passed to the Rowset constructor. This should facilitate automatic garbage collection by the browser.
curr
()
Gets the value of the internal row index.
Note that no check is performed to ensure this points to a valid row:
you should call this function only when it is safe to do so.
This can be determined by calling hasMoreRows().
Returns:
int
eachRow
-
callback -
scope -
args
Walks through all rows, and calls the callback function for each row.
The callback function gets passed an object that represents the row. The keys of the row object are the column names, and the values are the respective column values.
The scope for calling the callback can be passed as the second argument to this method.
If the scope is not defined (or if it is null), the Rowset's this pointer is used instead.
You can pass additional data to the callback by passing in a third argument. This is then passed as is as second argument to the callback.
The eachRow method will iterate untill the callback returns false, or until all rows have been traversed.
If the callback returns false, iteration is aborted and eachRow as a whole returns false too.
If iteration is not aborted, then eachRow returns true.
Parameters:
-
callbackFunction()Function to be called for each row.
-
scopeObjectOptional. Scope in which the callback is called. Defaults to this, that is, the Rowset.
-
argsObjectOptional. Object that is passed as extra argument to the callback.
Returns:
true if all rows were itereated. If the callback returns false, iteration stops and false is returned.
fetchAllAsArray
-
rows
Fetch all values from all fields from all rows, and return it as an array of arrays.
See fetchAsArray().
Parameters:
-
rowsArrayOPTIONAL. An array to append the rows to. If not specified, a new array is created
Returns:
fetchAllAsObject
-
rows
Fetch all values from all fields from all rows, and return it as an array of objects.
See fetchAsObject().
Parameters:
-
rowsArrayOPTIONAL. An array to append the rows to. If not specified, a new array is created
Returns:
fetchAllCustom
-
rows -
func -
args
Fetch all rows using a custom function, and return the return values as an array.
See fetchCustom().
Parameters:
-
rowsArrayOPTIONAL. An array to append the rows to. If not specified, a new array is created
-
funcFunctiona callback function to extract the fields.
-
argsObjectan object to pass data to the callback.
Returns:
fetchAsArray
()
Array
Fetch all values from all fields from the current row, and return it in an array. The position of the values in the array corresponds to the column order of the rowset. The internal row pointer is also increased so the next call will read the next row. The method returns false when there are no more rows to traverse. You can use this method to drive a loop to travere all rows in the Rowset:
while (rowArray = rowset.fetchAsArray()){
...process array...
}
Returns:
fetchAsObject
()
Object | Boolean
Fetch all values from all fields from the current row, and return it in an Object literal. The property names of the returned object correspond to the fieldName (actually the fieldLabel), and the field value is assigned to its respective property. The internal row pointer is also increased so the next call will read the next row. The method returns false when there are no more rows to traverse. You can use this method to drive a loop to travere all rows in the Rowset:
while (rowObject = rowset.fetchAsObject()){
...process object...
}
Returns:
fetchCustom
-
func -
args
Fetch the values using a custom callback function.
If there are rows to fetch, the custom function is called in scope of the rowset, so you can use this inside the custom function to refer to the rowset object.
Then, the internal row pointer is increased so the next call will read the next row.
The method returns whatever object or value is returned by the custom function, or false when there are no more rows to traverse.
Parameters:
-
funcFunctiona custom function to extract and return the data from the current row of the xml result.
-
argsObjectan object that will be passed to the function. Useful to hold any data required in addition to the rowset itself (which can be referred to as this inside the function).
Returns:
fieldCount
()
Int
Returns the number of fields in this rowset.
Returns:
The number of fields in this rowset.
fieldDef
-
name
Retrieves a fieldDef object by name.
A fieldDef describes a field (column). It has the following properties:
- label
- string. This is the human readable name for this field. You should use this name for display purposes and for building restrictions. This is also the name used for matching againstt the
nameargument passed to thefieldDef()method. - name
- string. This is the (possibly escaped) name of the field as it appears in the XML document
- index
- int. The ordinal position of this field. Fields are numbered starting from 0.
- type
- string. The name of the XML data type for the values that appear in this column
- minOccurs
- string. The minimal number of occurrences of a value. "0" means the field is optional.
- maxOccurs
- string. If this is parseable as an integer, that integer specifies the number of times a value can appear in this column. "unbounded" means there is no declared limit.
- getter
- function. This function is used to extract a value from the XML document for this field.
Parameters:
-
nameStringThe name of the field to retrieve.
Returns:
The fieldDef object that matches the argument.
fieldIndex
-
name
Retrieves the index of a field by name. Field indexes start at 0.
Parameters:
-
nameStringThe name of the field for which you want to retrieve the index.
Returns:
The ordinal position (starting at 0) of the field that matches the argument.
fieldName
-
name
Retrieves the name of a field by field Index. Field indexes start at 0.
Parameters:
-
nameStringThe name of the field for which you want to retrieve the index.
Returns:
The ordinal position (starting at 0) of the field that matches the argument.
fieldVal
-
name
Retrieves a value from the current row for the field having the name specified by the argument.
Parameters:
-
nameString | intThe name or the index of the field for which you want to retrieve the value.
Returns:
From the current row, the value of the field that matches the argument.
getFieldNames
()
string
Retrieve an array of field names. The position of the names in the array corresponds to the column order of the rowset.
Returns:
An (ordered) array of field names.
getFields
()
fieldDef
Retrieve an array of fieldDef objects that describes the fields of the rows in this rowset.
The position of the fieldDef objects in the array corresponds to the column order of the rowset.
For a description of the fieldDef object, see the
fieldDef() method.
Returns:
An (ordered) array of field definition objects.
getType
()
Indicates the type of rowset. In most cases, this will be identical to the requestType value that was used in the
Discover request
Returns:
int One of the DISCOVER_XXX, DBSCHEMA_XXX or MDSCHEMA_XXX constants
hasMoreRows
()
Bool
Indicates wheter the rowset can still be traversed.
You can use this method together with the
nextRow() method
to drive a while loop to traverse all rows in the rowset, like so:
while(rowset.hasMoreRows()){
...process row...
rowsete.nextRow();
}
Returns:
true in case there are more rows to traverse. false if all rows have been traversed.
mapAllAsObject
-
key -
map
Fetch all rows as an object, store them as proprties in an object (which acts as map).
Parameters:
-
keyString | ArrayOPTIONAL. A column name or an array of column names that will be used to generate property names for the map. If not specified, the default key is used. If there is no default key, all column names will be used.
-
mapObjectOPTIONAL. The object that is used as map. Rows are added as properties to this map. If not specified, a new object is created
Returns:
mapAsObject
-
map -
key -
row
Fetch all row as an object, store it in nested objects according to values in the column identified by the key argument.
This method should typically not be called directly, rather it is a helper method for mapAllAsObject().
Parameters:
-
mapObject -
keyObject -
rowObject
Returns:
a tree using column values as branch names, and storing a row or an array of rows at the leaves.
nextRow
()
Moves the internal row index to the next row.
You can use this method together with the
hasMoreRows() method
to drive a while loop to traverse all rows in the rowset.
readAsArray
()
Array
Reads the current row and returns the result as a new array.
This method does not advance the internal row pointer, and does not check if there is a valid row.
This method exists mainly as a convience in case you want to use a custom way to extract data from the resultset using the
fetchCustom() method.
If you just want to obtain the results as arrays, see
fetchAsArray()
and
fetchAllAsArray().
Returns:
readAsObject
()
Object
Reads the current row and returns the result as a new object.
This method does not advance the internal row pointer, and does not check if there is a valid row.
This method exists mainly as a convience in case you want to use a custom way to extract data from the resultset using the
fetchCustom() method.
If you just want to obtain the results as objects, see
fetchAsObject()
and
fetchAllAsObject().
Returns:
reset
()
Resets the internal row pointer so the resultset can be traversed again.
rowCount
()
Returns the number of rows in the set.
Returns:
int
Properties
MD_DIMTYPE_ACCOUNTS
Int
final
static
A possible value for the DIMENSION_TYPE column that appears in the
MDSCHEMA_DIMENSIONS (See: discoverMDDimensions()) and
MDSCHEMA_HIERARCHIES (See: discoverMDHierarchies())rowsets.
Default: 6
MD_DIMTYPE_BILL_OF_MATERIALS
Int
final
static
A possible value for the DIMENSION_TYPE column that appears in the
MDSCHEMA_DIMENSIONS (See: discoverMDDimensions()) and
MDSCHEMA_HIERARCHIES (See: discoverMDHierarchies())rowsets.
Default: 16
MD_DIMTYPE_CHANNEL
Int
final
static
A possible value for the DIMENSION_TYPE column that appears in the
MDSCHEMA_DIMENSIONS (See: discoverMDDimensions()) and
MDSCHEMA_HIERARCHIES (See: discoverMDHierarchies())rowsets.
Default: 13
MD_DIMTYPE_CURRENCY
Int
final
static
A possible value for the DIMENSION_TYPE column that appears in the
MDSCHEMA_DIMENSIONS (See: discoverMDDimensions()) and
MDSCHEMA_HIERARCHIES (See: discoverMDHierarchies())rowsets.
Default: 11
MD_DIMTYPE_CUSTOMERS
Int
final
static
A possible value for the DIMENSION_TYPE column that appears in the
MDSCHEMA_DIMENSIONS (See: discoverMDDimensions()) and
MDSCHEMA_HIERARCHIES (See: discoverMDHierarchies())rowsets.
Default: 7
MD_DIMTYPE_GEOGRAPHY
Int
final
static
A possible value for the DIMENSION_TYPE column that appears in the
MDSCHEMA_DIMENSIONS (See: discoverMDDimensions()) and
MDSCHEMA_HIERARCHIES (See: discoverMDHierarchies())rowsets.
Default: 17
MD_DIMTYPE_MEASURE
Int
final
static
A possible value for the DIMENSION_TYPE column that appears in the
MDSCHEMA_DIMENSIONS (See: discoverMDDimensions()) and
MDSCHEMA_HIERARCHIES (See: discoverMDHierarchies())rowsets.
Default: 2
MD_DIMTYPE_ORGANIZATION
Int
final
static
A possible value for the DIMENSION_TYPE column that appears in the
MDSCHEMA_DIMENSIONS (See: discoverMDDimensions()) and
MDSCHEMA_HIERARCHIES (See: discoverMDHierarchies())rowsets.
Default: 15
MD_DIMTYPE_OTHER
Int
final
static
A possible value for the DIMENSION_TYPE column that appears in the
MDSCHEMA_DIMENSIONS (See: discoverMDDimensions()) and
MDSCHEMA_HIERARCHIES (See: discoverMDHierarchies())rowsets.
Default: 3
MD_DIMTYPE_PRODUCTS
Int
final
static
A possible value for the DIMENSION_TYPE column that appears in the
MDSCHEMA_DIMENSIONS (See: discoverMDDimensions()) and
MDSCHEMA_HIERARCHIES (See: discoverMDHierarchies())rowsets.
Default: 8
MD_DIMTYPE_PROMOTION
Int
final
static
A possible value for the DIMENSION_TYPE column that appears in the
MDSCHEMA_DIMENSIONS (See: discoverMDDimensions()) and
MDSCHEMA_HIERARCHIES (See: discoverMDHierarchies())rowsets.
Default: 14
MD_DIMTYPE_QUANTITATIVE
Int
final
static
A possible value for the DIMENSION_TYPE column that appears in the
MDSCHEMA_DIMENSIONS (See: discoverMDDimensions()) and
MDSCHEMA_HIERARCHIES (See: discoverMDHierarchies())rowsets.
Default: 5
MD_DIMTYPE_RATES
Int
final
static
A possible value for the DIMENSION_TYPE column that appears in the
MDSCHEMA_DIMENSIONS (See: discoverMDDimensions()) and
MDSCHEMA_HIERARCHIES (See: discoverMDHierarchies())rowsets.
Default: 12
MD_DIMTYPE_SCENARIO
Int
final
static
A possible value for the DIMENSION_TYPE column that appears in the
MDSCHEMA_DIMENSIONS (See: discoverMDDimensions()) and
MDSCHEMA_HIERARCHIES (See: discoverMDHierarchies())rowsets.
Default: 9
MD_DIMTYPE_TIME
Int
final
static
A possible value for the DIMENSION_TYPE column that appears in the
MDSCHEMA_DIMENSIONS (See: discoverMDDimensions()) and
MDSCHEMA_HIERARCHIES (See: discoverMDHierarchies())rowsets.
Default: 1
MD_DIMTYPE_UNKNOWN
Int
final
static
A possible value for the DIMENSION_TYPE column that appears in the
MDSCHEMA_DIMENSIONS (See: discoverMDDimensions()) and
MDSCHEMA_HIERARCHIES (See: discoverMDHierarchies())rowsets.
Default: 0
MD_DIMTYPE_UTILIY
Int
final
static
A possible value for the DIMENSION_TYPE column that appears in the
MDSCHEMA_DIMENSIONS (See: discoverMDDimensions()) and
MDSCHEMA_HIERARCHIES (See: discoverMDHierarchies())rowsets.
Default: 10
MD_STRUCTURE_FULLYBALANCED
Int
final
static
A possible value for the STRUCTURE column of the
MDSCHEMA_HIERARCHIES (See: discoverMDHierarchies())rowset.
Default: 0
MD_STRUCTURE_NETWORK
Int
final
static
A possible value for the STRUCTURE column of the
MDSCHEMA_HIERARCHIES (See: discoverMDHierarchies())rowset.
Default: 3
MD_STRUCTURE_RAGGEDBALANCED
Int
final
static
A possible value for the STRUCTURE column of the
MDSCHEMA_HIERARCHIES (See: discoverMDHierarchies())rowset.
Default: 1
MD_STRUCTURE_UNBALANCED
Int
final
static
A possible value for the STRUCTURE column of the
MDSCHEMA_HIERARCHIES (See: discoverMDHierarchies())rowset.
Default: 2
MD_SYSTEM_ENABLED
Int
final
static
A bitmap value for the HIERARCHY_ORIGIN column of the
MDSCHEMA_HIERARCHIES (See: discoverMDHierarchies())rowset.
identifies attribute hierarchies.
Default: 2
MD_SYSTEM_INTERNAL
Int
final
static
A bitmap value for the HIERARCHY_ORIGIN column of the
MDSCHEMA_HIERARCHIES (See: discoverMDHierarchies())rowset.
identifies attributes with no attribute hierarchies.
Default: 4
MD_USER_DEFINED
Int
final
static
A bitmap value for the HIERARCHY_ORIGIN column of the
MDSCHEMA_HIERARCHIES (See: discoverMDHierarchies())rowset.
Identifies user defined hierarchies.
Default: 1
MDMEMBER_TYPE_ALL
Int
final
static
A possible value for the MEMBER_TYPE column of the
MDSCHEMA_MEMBERS rowset (see: discoverMDMembers()),
indicating an all member.
Default: 2
MDMEMBER_TYPE_FORMULA
Int
final
static
A possible value for the MEMBER_TYPE column of the
MDSCHEMA_MEMBERS rowset (see: discoverMDMembers()),
indicating a formula member.
Default: 3
MDMEMBER_TYPE_MEASURE
Int
final
static
A possible value for the MEMBER_TYPE column of the
MDSCHEMA_MEMBERS rowset (see: discoverMDMembers()),
indicating a measure member.
Default: 4
MDMEMBER_TYPE_REGULAR
Int
final
static
A possible value for the MEMBER_TYPE column of the
MDSCHEMA_MEMBERS rowset (see: discoverMDMembers()),
indicating a regular member.
Default: 1
MDMEMBER_TYPE_UNKNOWN
Int
final
static
A possible value for the MEMBER_TYPE column of the
MDSCHEMA_MEMBERS rowset (see: discoverMDMembers()),
indicating a member of unknown type
Default: 0
