Back to index

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

Implementation for XForms Event Context Info. More...

#include <nsXFormsContextInfo.h>

Inheritance diagram for nsXFormsContextInfo:
Inheritance graph
[legend]
Collaboration diagram for nsXFormsContextInfo:
Collaboration graph
[legend]

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS
NS_DECL_NSIXFORMSCONTEXTINFO 
nsXFormsContextInfo (nsIDOMElement *aElement)
 Implementation for XForms event context info.
virtual ~nsXFormsContextInfo ()
nsresult SetName (nsAString &aName)
 Set the name of the context info property; eg.
nsresult SetStringValue (const char *aName, const nsAString &aString)
 Set a string value for a context info property.
nsresult SetNumberValue (const char *aName, PRInt32 aNumber)
 Set a number value for a context info property.
nsresult SetNodeValue (const char *aName, nsIDOMNode *aNode)
 Set a node value for a context info property.
nsresult SetNodesetValue (const char *aName, nsIDOMXPathResult *aNodeset)
 Set a nodeset value for a context info property.

Public Attributes

readonly attribute DOMString name
const unsigned short STRING_TYPE = 1
const unsigned short NUMBER_TYPE = 2
const unsigned short NODE_TYPE = 3
const unsigned short NODESET_TYPE = 4
readonly attribute long type
readonly attribute DOMString stringValue
 Get the value of a STRING_TYPE context info property.
readonly attribute long numberValue
 Get the value of a NUMBER_TYPE context info property.
readonly attribute nsIDOMNode nodeValue
 Get the value of a NODE_TYPE context info property.
readonly attribute
nsIDOMXPathResult 
nodesetValue
 Get the value of a NODESET_TYPE context info property.

Private Member Functions

nsresult SetNodeValueInternal (const char *aName, const nsAString &aValue)
 Create a text node to encapsulate string and number context property types.

Private Attributes

nsIDOMElementmElement
nsString mName
PRInt32 mType
union {
nsIDOMNodemNode
nsIDOMXPathResultmNodeset
}; 

Detailed Description

Implementation for XForms Event Context Info.

Definition at line 55 of file nsXFormsContextInfo.h.


Constructor & Destructor Documentation

Implementation for XForms event context info.

Definition at line 52 of file nsXFormsContextInfo.cpp.

 : mElement(aElement), mType(0)
{
  mNode = nsnull;
}

Definition at line 58 of file nsXFormsContextInfo.cpp.

{
  if (mType == nsIXFormsContextInfo::NODESET_TYPE) {
    NS_IF_RELEASE(mNodeset);
  } else {
    // String, Number, and Node are all nodes.
    NS_IF_RELEASE(mNode);
  }
}

Member Function Documentation

nsresult nsXFormsContextInfo::SetName ( nsAString &  aName)

Set the name of the context info property; eg.

'resource-uri'

Parameters:
aName- property name

Definition at line 69 of file nsXFormsContextInfo.cpp.

{
  mName = aName;
  return NS_OK;
}

Here is the caller graph for this function:

Set a nodeset value for a context info property.

Parameters:
aName- name of the nodeset property.
aNodeset- nodeset value.

Definition at line 176 of file nsXFormsContextInfo.cpp.

{
  // Set the name of the context property.
  nsAutoString name;
  name.AppendASCII(aName);
  SetName(name);

  // Set the nodeset value of the context property.
  NS_IF_ADDREF(mNodeset = aNodeset);
  mType = nsIXFormsContextInfo::NODESET_TYPE;
  return NS_OK;
}

Here is the call graph for this function:

Set a node value for a context info property.

Parameters:
aName- name of the node property.
aNode- node value.

Definition at line 144 of file nsXFormsContextInfo.cpp.

{
  // Set the name of the context property.
  nsAutoString name;
  name.AppendASCII(aName);
  SetName(name);

  // Set the node value of the context property.
  NS_IF_ADDREF(mNode = aNode);
  mType = nsIXFormsContextInfo::NODE_TYPE;
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsXFormsContextInfo::SetNodeValueInternal ( const char *  aName,
const nsAString &  aValue 
) [private]

Create a text node to encapsulate string and number context property types.

The XPath Event function returns a txINodeset and only nodes can be added to the nodeset.

Parameters:
aName- name of the node property.
aValue- value of the text node.

Definition at line 204 of file nsXFormsContextInfo.cpp.

{
  if (!mElement)
    return NS_ERROR_FAILURE;

  nsresult rv;

  nsCOMPtr<nsIDOMDocument> doc;
  rv = mElement->GetOwnerDocument(getter_AddRefs(doc));
  NS_ENSURE_SUCCESS(rv, rv);

  nsCOMPtr<nsIDOMDOMImplementation> domImpl;
  rv = doc->GetImplementation(getter_AddRefs(domImpl));
  NS_ENSURE_SUCCESS(rv, rv);

  nsCOMPtr<nsIDOMText> textNode;
  rv = doc->CreateTextNode(aValue, getter_AddRefs(textNode));
  NS_ENSURE_SUCCESS(rv, rv);

  SetNodeValue(aName, textNode);

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsXFormsContextInfo::SetNumberValue ( const char *  aName,
PRInt32  aNumber 
)

Set a number value for a context info property.

Number values are encapsulated in a text node because the XPath Event function can only work with nodes.

Parameters:
aName- name of the number property.
aNumber- number value.

Definition at line 112 of file nsXFormsContextInfo.cpp.

{
  // Convert the number to a string and store the (string)number
  // value of the context property as a node.
  nsAutoString numberStr;
  numberStr.AppendInt(aNumber);

  SetNodeValueInternal(aName, numberStr);
  mType = nsIXFormsContextInfo::NUMBER_TYPE;
  return NS_OK;
}

Here is the call graph for this function:

nsresult nsXFormsContextInfo::SetStringValue ( const char *  aName,
const nsAString &  aString 
)

Set a string value for a context info property.

String values are encapsulated in a text node because the XPath Event function can only work with nodes.

Parameters:
aName- name of the string property.
aString- string value.

Definition at line 90 of file nsXFormsContextInfo.cpp.

{
  // Store the string value of the context property as a node.
  SetNodeValueInternal(aName, aString);
  mType = nsIXFormsContextInfo::STRING_TYPE;
  return NS_OK;
}

Here is the call graph for this function:


Member Data Documentation

union { ... } [private]

Definition at line 115 of file nsXFormsContextInfo.h.

Definition at line 117 of file nsXFormsContextInfo.h.

Definition at line 119 of file nsXFormsContextInfo.h.

readonly attribute DOMString nsIXFormsContextInfo::name [inherited]

Definition at line 55 of file nsIXFormsContextInfo.idl.

const unsigned short nsIXFormsContextInfo::NODE_TYPE = 3 [inherited]

Definition at line 60 of file nsIXFormsContextInfo.idl.

const unsigned short nsIXFormsContextInfo::NODESET_TYPE = 4 [inherited]

Definition at line 61 of file nsIXFormsContextInfo.idl.

Get the value of a NODESET_TYPE context info property.

Definition at line 75 of file nsIXFormsContextInfo.idl.

Get the value of a NODE_TYPE context info property.

Definition at line 72 of file nsIXFormsContextInfo.idl.

const unsigned short nsIXFormsContextInfo::NUMBER_TYPE = 2 [inherited]

Definition at line 59 of file nsIXFormsContextInfo.idl.

Get the value of a NUMBER_TYPE context info property.

Definition at line 69 of file nsIXFormsContextInfo.idl.

const unsigned short nsIXFormsContextInfo::STRING_TYPE = 1 [inherited]

Definition at line 58 of file nsIXFormsContextInfo.idl.

readonly attribute DOMString nsIXFormsContextInfo::stringValue [inherited]

Get the value of a STRING_TYPE context info property.

Definition at line 66 of file nsIXFormsContextInfo.idl.

Definition at line 62 of file nsIXFormsContextInfo.idl.


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