CXdmDocument Class Reference

class CXdmDocument : public CActive

Inherits from

Public Member Functions
~CXdmDocument()
IMPORT_C voidAppendL(CXdmDocumentNode *)
IMPORT_C voidAppendToModelL(CXdmDocumentNode *, CXdmDocumentNode *)
CXdmDocumentNode *CreateRootL()
CXdmDocumentNode *CurrentExtent()
IMPORT_C voidDeleteDataL(CXdmDocumentNode *)
CXdmDocumentNode *DocumentRoot()
IMPORT_C CXdmDocumentNode *DocumentSubsetL(const TDesC &)
TXdmDocType DocumentType()
CXdmDocumentNode *ErrorRoot()
IMPORT_C voidFetchDataL(CXdmDocumentNode *)
IMPORT_C TIntFind(const CXdmDocumentNode &, RPointerArray< CXdmDocumentNode > &)
IMPORT_C TIntFind(const TDesC &, RPointerArray< CXdmDocumentNode > &)
IMPORT_C TIntFind(const TDesC &, RPointerArray< CXdmNodeAttribute > &)
IMPORT_C TIntFind(const TDesC &, RPointerArray< CXdmDocumentNode > &, const RPointerArray< SXdmAttribute16 > &)
IMPORT_C voidInsertL(CXdmDocumentNode *)
IMPORT_C TPtrCName()
IMPORT_C voidRemoveFromModelL(CXdmDocumentNode *)
IMPORT_C voidReplaceInModelL(CXdmDocumentNode *, CXdmDocumentNode *)
IMPORT_C voidReplaceL()
IMPORT_C voidReplaceL(CXdmDocumentNode *, CXdmDocumentNode *)
voidResetContents()
IMPORT_C voidResetSubset()
TTime TimeStamp()
IMPORT_C TBooloperator==(CXdmDocument &)
Protected Member Functions
CXdmDocument(CXdmEngine &)
voidAppendPathPartL(const TDesC &)
IMPORT_C voidBaseConstructL(TInt, const TDesC &)
IMPORT_C voidBaseConstructL(TInt, const TDesC8 &)
Private Member Functions
voidCancelUpdate()
TInt DoFindAttributes(CXdmDocumentNode *, const TDesC &, RPointerArray< CXdmNodeAttribute > &)
voidEmptyOperationQueue()
voidSaveClientStatus(TRequestStatus &)
voidStartUpdateL()
Inherited Functions
CActive::CActive(TInt)
CActive::Cancel()
CActive::Deque()
CActive::DoCancel()
CActive::Extension_(TUint,TAny *&,TAny *)
CActive::IsActive()const
CActive::IsAdded()const
CActive::Priority()const
CActive::RunError(TInt)
CActive::RunL()
CActive::SetActive()
CActive::SetPriority(TInt)
CActive::~CActive()
CBase::CBase()
CBase::Delete(CBase *)
CBase::operator new(TUint)
CBase::operator new(TUint,TAny *)
CBase::operator new(TUint,TLeave)
CBase::operator new(TUint,TLeave,TUint)
CBase::operator new(TUint,TUint)
CBase::~CBase()
Inherited Enumerations
CActive:TPriority
Protected Attributes
RPointerArray< MXdmOperation >iChangeRequests
TRequestStatus *iClientStatus
TBool iDocSubset
HBufC *iDocumentName
CXdmOperationFactory *iOperationFactory
TTime iTimeStamp
CXdmEngine &iXdmEngine
Inherited Attributes
CActive::iStatus

Constructor & Destructor Documentation

CXdmDocument(CXdmEngine &)

IMPORT_CCXdmDocument(CXdmEngine &aXdmEngine)[protected]

C++ constructor is private.

Parameters

CXdmEngine & aXdmEngine

~CXdmDocument()

IMPORT_C~CXdmDocument()

Destructor.

Member Functions Documentation

AppendL(CXdmDocumentNode *)

IMPORT_C voidAppendL(CXdmDocumentNode *aDocNode = NULL)

Append data to the document this object models beginning from the element the parameter points to. If the parameter is not specified, the operation applies to the whole of the document.

NOTE: This is a "blind insert"; no guarantees can be given as to the success or failure of the operation, since it includes no checking for existence of the resource that is to be appended/inserted. It is also worth noticing that this method may effectively turn into a replace operation in case the method is invoked on a document that already exists in the storage endpoint.

Parameters

CXdmDocumentNode * aDocNode = NULL

AppendPathPartL(const TDesC &)

voidAppendPathPartL(const TDesC &aString)[protected, pure virtual]

Append an element to the path identifying the the current document subset

Parameters

const TDesC & aString

AppendToModelL(CXdmDocumentNode *, CXdmDocumentNode *)

IMPORT_C voidAppendToModelL(CXdmDocumentNode *aNewNode,
CXdmDocumentNode *aParentNode
)

Append an element to the document model

NOTE: This method cannot be used with document models that only target a fragment of the document; in practise this means that if the client has constructed a node using DocumentSubsetL(), this method leaves with KErrGeneral. A document subset cannot be treated as an actual document since only a fraction of the elements and their dependencies in the document is known. The client must have the whole document at its disposal in order to be properly able to make use of this method.

Parameters

CXdmDocumentNode * aNewNode
CXdmDocumentNode * aParentNode

BaseConstructL(TInt, const TDesC &)

IMPORT_C voidBaseConstructL(TIntaOperationFactoryUid,
const TDesC &aDocumentName
)[protected]

By default Symbian OS constructor is private.

Parameters

TInt aOperationFactoryUid
const TDesC & aDocumentName

BaseConstructL(TInt, const TDesC8 &)

IMPORT_C voidBaseConstructL(TIntaOperationFactoryUid,
const TDesC8 &aDocumentName
)[protected]

By default Symbian OS constructor is private.

Parameters

TInt aOperationFactoryUid
const TDesC8 & aDocumentName

CancelUpdate()

voidCancelUpdate()[private, pure virtual]

Cancel a document update

CreateRootL()

CXdmDocumentNode *CreateRootL()[pure virtual]

Construct an "anonymous" entry point for this document. This node effectively becomes the root of this document.

CurrentExtent()

CXdmDocumentNode *CurrentExtent()const [pure virtual]

Return the currently last node in the path. NOTE: Only works with document subsets!

DeleteDataL(CXdmDocumentNode *)

IMPORT_C voidDeleteDataL(CXdmDocumentNode *aDocNode = NULL)

Delete data from the document this object models beginning from the element the parameter points to. If the parameter is not specified, the operation applies to the whole of the document.

Parameters

CXdmDocumentNode * aDocNode = NULL

DoFindAttributes(CXdmDocumentNode *, const TDesC &, RPointerArray< CXdmNodeAttribute > &)

TInt DoFindAttributes(CXdmDocumentNode *aNode,
const TDesC &aAttributeName,
RPointerArray< CXdmNodeAttribute > &aResultArray
)const [private]

Find attributes by name

Parameters

CXdmDocumentNode * aNode
const TDesC & aAttributeName
RPointerArray< CXdmNodeAttribute > & aResultArray

DocumentRoot()

CXdmDocumentNode *DocumentRoot()const [pure virtual]

Return the root element of this document

NOTE: The returning node may or may not contain any data, since, in the case that this document model does not have content yet, the element is a simple "entry point" to the whole document. Thus, for instance, if the client application requests the XDM Engine to fetch a particular document, the root element points to nothing until the request has been completed.

Also note that in case the client has created a document subset using the DocumentSubsetL() method, this method will return NULL, since the document is not traversable from the root; it, by definition, represents only a subset of this document. In case of a document subset, the path from the root node to the target node should be considered a simple linked list that does not necessarily contain all children for any of the nodes in between.

DocumentSubsetL(const TDesC &)

IMPORT_C CXdmDocumentNode *DocumentSubsetL(const TDesC &aNodePath)

Return a subset of the document this object models. For instance, if the whole (physical) document is the following:

<root> <element1> <child1> <leaf1>Foo</leaf1> </child1> </element1> </root>

calling this method with the parameter "root/element1/child1" would make this document model model the subset

<child1> <leaf1>Foo</leaf1> </child1>

It is important to understand that, after calling this method, the document model only models the document starting from the node the method returns. The client may traverse the document all the way to the root node and back, but the way from the root node to the node this method returns should be regarded merely as a "path" of elements that has no real content.

A prime use case for this method is one in which the structure of the document the client application wants to operate on is well-known; a typical example would be an XDM directory document. The schema for this application usage is very simple: the root element is <xcap-directory> that has a collection of <folder> elements as its children. Each <folder> element has a mandatory "auid" parameter that identifies the type of documents that particular folder contains. Therefore, a client application has all the necessary information it needs to have in order to be able to carry out a fetch for a document subset (one folder):

_LIT( KNodePath, "xcap-directory/folder" ); CXdmDocumentNode* node = iDirectoryDoc->DocumentSubsetL( KNodePath ); CleanupStack::PushL( node ); CXdmNodeAttribute* auid = node->CreateAttributeL( _L( "auid" ) ); CleanupStack::PushL( auid ); auid->SetAttributeValueL( _L( "My document type" ) ); iDirectoryDoc->FetchDataL( node ); CleanupStack::Pop( 2 ); //auid, node

In this particular case, even after the fetch operation is complete, the <xcap-directory> element in this document model would not be a real element, a genuine part of the document, but, rather, a "virtual" node on the way to the element that is of real interest to the client application.

Also note that the instance of CXdmDocument on which this subset has been created, cannot be used as a container for a whole document until ResetSubset() has been called.

The incoming parameter MUST separate each step to the target element with a slash character ('/').

Parameters

const TDesC & aNodePath

DocumentType()

TXdmDocType DocumentType()const [pure virtual]

Return the type of this document

EmptyOperationQueue()

voidEmptyOperationQueue()[private]

Empty the operation queue

ErrorRoot()

CXdmDocumentNode *ErrorRoot()[pure virtual]

Return an error document for a failed update

NOTE: The returning object will be zero in case the used protocol does not support this feature.

FetchDataL(CXdmDocumentNode *)

IMPORT_C voidFetchDataL(CXdmDocumentNode *aDocNode = NULL)

Fetch data from the document this object models beginning from the element the parameter points to. If the parameter is not specified, the operation applies to the whole of the document.

Parameters

CXdmDocumentNode * aDocNode = NULL

Find(const CXdmDocumentNode &, RPointerArray< CXdmDocumentNode > &)

IMPORT_C TIntFind(const CXdmDocumentNode &aTargetNode,
RPointerArray< CXdmDocumentNode > &aResultArray
)const

Search for nodes which match the specified name & attributes

Parameters

const CXdmDocumentNode & aTargetNode
RPointerArray< CXdmDocumentNode > & aResultArray

Find(const TDesC &, RPointerArray< CXdmDocumentNode > &)

IMPORT_C TIntFind(const TDesC &aNodeName,
RPointerArray< CXdmDocumentNode > &aResultArray
)const

Search for nodes which match the specified name & attributes

Parameters

const TDesC & aNodeName
RPointerArray< CXdmDocumentNode > & aResultArray

Find(const TDesC &, RPointerArray< CXdmNodeAttribute > &)

IMPORT_C TIntFind(const TDesC &aAttributeName,
RPointerArray< CXdmNodeAttribute > &aResultArray
)const

Search for attributes which match the specified name

Parameters

const TDesC & aAttributeName
RPointerArray< CXdmNodeAttribute > & aResultArray

Find(const TDesC &, RPointerArray< CXdmDocumentNode > &, const RPointerArray< SXdmAttribute16 > &)

IMPORT_C TIntFind(const TDesC &aNodeName,
RPointerArray< CXdmDocumentNode > &aResultArray,
const RPointerArray< SXdmAttribute16 > &aAttributeArray
)const

Search for nodes which match the specified name & attributes

Parameters

const TDesC & aNodeName
RPointerArray< CXdmDocumentNode > & aResultArray
const RPointerArray< SXdmAttribute16 > & aAttributeArray

InsertL(CXdmDocumentNode *)

IMPORT_C voidInsertL(CXdmDocumentNode *aDocNode)

Insert the node identified by the parameter. Note that this method cannot be applied to complete documents. Thus the method will fail in case the parameter is NULL. If the client needs to a) add b) replace a document, it needs to do this through the AppendL() or the ReplaceL() method.

NOTE: The operation will fail in case the element identified by the aDocNode parameter already exists in the document. XDM Engine does not make assumptions in this regard; it does not, for instance, change some aspects of the request in order to turn it into a valid insert operation. Instead, it will re-read the whole document and retry the insert operation. If the operation still fails, the engine reports the failure that occurred while performing the operation. In the latter case, the client can get a hold of the error report document, provided that the used protocol supports the feature and that the server included the document in the response, by fetching the root node of the error document through ErrorRoot() method.

Parameters

CXdmDocumentNode * aDocNode

Name()

IMPORT_C TPtrCName()const

Returns the name of this document

RemoveFromModelL(CXdmDocumentNode *)

IMPORT_C voidRemoveFromModelL(CXdmDocumentNode *aChileNode)

Remove an element from the document model

NOTE: This method cannot be used with document models that only target a fragment of the document; in practise this means that if the client has constructed a node using DocumentSubsetL(), this method leaves with KErrGeneral. A document subset cannot be treated as an actual document since only a fraction of the elements and their dependencies in the document is known. The client must have the whole document at its disposal in order to be properly able to make use of this method.

Parameters

CXdmDocumentNode * aChileNode

ReplaceInModelL(CXdmDocumentNode *, CXdmDocumentNode *)

IMPORT_C voidReplaceInModelL(CXdmDocumentNode *aNewNode,
CXdmDocumentNode *aTargetNode
)

Replace an element in the document model

NOTE: This method cannot be used with document models that only target a fragment of the document; in practise this means that if the client has constructed a node using DocumentSubsetL(), this method leaves with KErrGeneral. A document subset cannot be treated as an actual document since only a fraction of the elements and their dependencies in the document is known. The client must have the whole document at its disposal in order to be properly able to make use of this method.

Parameters

CXdmDocumentNode * aNewNode
CXdmDocumentNode * aTargetNode

ReplaceL()

IMPORT_C voidReplaceL()

Replace the document this object models

NOTE: The name of the document MUST remain the same. This is because the operation first needs to delete the old document and then store the new one. The risk of creating conflicting document names is far too great in case this rule is not imposed.

ReplaceL(CXdmDocumentNode *, CXdmDocumentNode *)

IMPORT_C voidReplaceL(CXdmDocumentNode *aOldNode,
CXdmDocumentNode *aNewNode
)

Replace a named element in the document this object models

NOTE: Both elements MUST have a common parent element, which, in effect, must be the element this document model points to. Also note that the operation will fail in case the "aOldNode" does not exist in the document.

Parameters

CXdmDocumentNode * aOldNode
CXdmDocumentNode * aNewNode

ResetContents()

voidResetContents()[pure virtual]

ResetSubset()

IMPORT_C voidResetSubset()[virtual]

SaveClientStatus(TRequestStatus &)

voidSaveClientStatus(TRequestStatus &aClientStatus)[private, pure virtual]

Save the client's request status

Parameters

TRequestStatus & aClientStatus

StartUpdateL()

voidStartUpdateL()[private, pure virtual]

Start updating the document

TimeStamp()

TTime TimeStamp()const [pure virtual]

Return the time stamp for this document

operator==(CXdmDocument &)

IMPORT_C TBooloperator==(CXdmDocument &aDocument)const

Comparison operator

Parameters

CXdmDocument & aDocument

Member Data Documentation

RPointerArray< MXdmOperation > iChangeRequests

RPointerArray< MXdmOperation >iChangeRequests[protected]

TRequestStatus * iClientStatus

TRequestStatus *iClientStatus[protected]

TBool iDocSubset

TBool iDocSubset[protected]

HBufC * iDocumentName

HBufC *iDocumentName[protected]

CXdmOperationFactory * iOperationFactory

CXdmOperationFactory *iOperationFactory[protected]

TTime iTimeStamp

TTime iTimeStamp[protected]

CXdmEngine & iXdmEngine

CXdmEngine &iXdmEngine[protected]