Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Attributes
txKeyHash Class Reference

#include <txKey.h>

Collaboration diagram for txKeyHash:
Collaboration graph

List of all members.

Public Member Functions

 txKeyHash (const txExpandedNameMap &aKeys)
nsresult init ()
nsresult getKeyNodes (const txExpandedName &aKeyName, const txXPathNode &aDocument, const nsAString &aKeyValue, PRBool aIndexIfNotFound, txExecutionState &aEs, txNodeSet **aResult)

Private Attributes

txKeyValueHash mKeyValues
txIndexedKeyHash mIndexedKeys
const txExpandedNameMapmKeys
nsRefPtr< txNodeSetmEmptyNodeSet

Detailed Description

Definition at line 195 of file txKey.h.

Constructor & Destructor Documentation

Definition at line 198 of file txKey.h.

        : mKeys(aKeys)

Member Function Documentation

nsresult txKeyHash::getKeyNodes ( const txExpandedName aKeyName,
const txXPathNode aDocument,
const nsAString &  aKeyValue,
PRBool  aIndexIfNotFound,
txExecutionState aEs,
txNodeSet **  aResult 

Definition at line 207 of file txKeyFunctionCall.cpp.

    NS_ENSURE_TRUE(mKeyValues.mHashTable.ops && mIndexedKeys.mHashTable.ops,

    *aResult = nsnull;

    PRInt32 identifier = txXPathNodeUtils::getUniqueIdentifier(aDocument);

    txKeyValueHashKey valueKey(aKeyName, identifier, aKeyValue);
    txKeyValueHashEntry* valueEntry = mKeyValues.GetEntry(valueKey);
    if (valueEntry) {
        *aResult = valueEntry->mNodeSet;

        return NS_OK;

    // We didn't find a value. This could either mean that that key has no
    // nodes with that value or that the key hasn't been indexed using this
    // document.

    if (!aIndexIfNotFound) {
        // If aIndexIfNotFound is set then the caller knows this key is
        // indexed, so don't bother investigating.
        *aResult = mEmptyNodeSet;

        return NS_OK;

    txIndexedKeyHashKey indexKey(aKeyName, identifier);
    txIndexedKeyHashEntry* indexEntry = mIndexedKeys.AddEntry(indexKey);

    if (indexEntry->mIndexed) {
        // The key was indexed and apparently didn't contain this value so
        // return the empty nodeset.
        *aResult = mEmptyNodeSet;

        return NS_OK;

    // The key needs to be indexed.
    txXSLKey* xslKey = (txXSLKey*)mKeys.get(aKeyName);
    if (!xslKey) {
        // The key didn't exist, so bail.
        return NS_ERROR_INVALID_ARG;

    nsresult rv = xslKey->indexDocument(aDocument, mKeyValues, aEs);
    NS_ENSURE_SUCCESS(rv, rv);
    indexEntry->mIndexed = PR_TRUE;

    // Now that the key is indexed we can get its value.
    valueEntry = mKeyValues.GetEntry(valueKey);
    if (valueEntry) {
        *aResult = valueEntry->mNodeSet;
    else {
        *aResult = mEmptyNodeSet;

    return NS_OK;

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 283 of file txKeyFunctionCall.cpp.

Here is the caller graph for this function:

Member Data Documentation

Definition at line 223 of file txKey.h.

txIndexedKeyHash txKeyHash::mIndexedKeys [private]

Definition at line 217 of file txKey.h.

Definition at line 220 of file txKey.h.

txKeyValueHash txKeyHash::mKeyValues [private]

Definition at line 214 of file txKey.h.

The documentation for this class was generated from the following files: