1 /* |
|
2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: XMLHandler class to parse the resultant reverse geocoded |
|
15 * information. |
|
16 */ |
|
17 |
|
18 #ifndef __XMLHANDLER_H__ |
|
19 #define __XMLHANDLER_H__ |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <e32base.h> |
|
23 #include <xml/contenthandler.h> // for mcontenthandler |
|
24 #include <xml/parser.h> // for cparser |
|
25 using namespace Xml; |
|
26 |
|
27 //Forward declarations |
|
28 class CAddressInfo; |
|
29 class CInternalAddressInfo; |
|
30 |
|
31 /* |
|
32 * Category of the address information. This is used for |
|
33 * internal parsing procedure. |
|
34 */ |
|
35 namespace xmlhandler |
|
36 { |
|
37 enum TLocationInfoType |
|
38 { |
|
39 ENone = 0, |
|
40 ECountryName, |
|
41 EState, |
|
42 ECity, |
|
43 EDistrict, |
|
44 EPostalCode, |
|
45 EThoroughfareName, |
|
46 EThoroughfareNumber |
|
47 }; |
|
48 } |
|
49 |
|
50 /** |
|
51 * MXmlHandlerObserver, an observer to CXmlHandler class. |
|
52 */ |
|
53 class MXmlHandlerObserver |
|
54 { |
|
55 public: |
|
56 /* |
|
57 * Signifies the completion of parsing of the output data. |
|
58 * |
|
59 * @param aError error status of parsing part. |
|
60 * @param aLocationInfo reference to the resultant address information structure. |
|
61 */ |
|
62 virtual void OnParseCompletedL( TInt aError, MAddressInfo& aLocationInfo ) = 0; |
|
63 }; |
|
64 |
|
65 /** |
|
66 * CXmlHandler, a class to parse XML file and then output log information |
|
67 * to a buffer. |
|
68 */ |
|
69 NONSHARABLE_CLASS( CXmlHandler ) : public MContentHandler |
|
70 { |
|
71 public: // Constructors and destructor |
|
72 |
|
73 /** |
|
74 * 1st phase constructor |
|
75 * |
|
76 * @param aObserver The observer class to be notified after xml parsing is done |
|
77 * aAddressInfo The address info |
|
78 */ |
|
79 static CXmlHandler* NewL( MXmlHandlerObserver& aObserver, CInternalAddressInfo *aAddressInfo ); |
|
80 |
|
81 /** |
|
82 * 1st phase constructor pushes the object into cleanup stack |
|
83 * @param aObserver The observer class to be notified after xml parsing is done |
|
84 * aAddressInfo The address info |
|
85 */ |
|
86 static CXmlHandler* NewLC( MXmlHandlerObserver& aObserver, CInternalAddressInfo *aAddressInfo ); |
|
87 |
|
88 /** |
|
89 * Destructor |
|
90 */ |
|
91 virtual ~CXmlHandler(); |
|
92 |
|
93 public: // Public methods |
|
94 |
|
95 /** |
|
96 * Starts parsing the xml content |
|
97 * @param aBuf The xml data |
|
98 */ |
|
99 |
|
100 void StartParsingL( HBufC8 *aBuf ); |
|
101 |
|
102 |
|
103 #ifdef REVERSEGEOCODE_UNIT_TESTCASE |
|
104 public: |
|
105 #else |
|
106 private: |
|
107 #endif |
|
108 |
|
109 /** |
|
110 * @param aObserver The observer class to be notified after xml parsing is done |
|
111 * @param aAddressInfo The address info |
|
112 */ |
|
113 |
|
114 CXmlHandler( MXmlHandlerObserver& aObserver, CInternalAddressInfo *aAddressInfo ); |
|
115 |
|
116 /** |
|
117 * Second phase construction |
|
118 */ |
|
119 void ConstructL(); |
|
120 |
|
121 |
|
122 #ifdef REVERSEGEOCODE_UNIT_TESTCASE |
|
123 public: |
|
124 #else |
|
125 private: |
|
126 #endif |
|
127 // from MContentHandler |
|
128 |
|
129 /** |
|
130 * This method is a callback to indicate the start of the document |
|
131 * @param aDocParam Specifies the various parameters of the document. |
|
132 * @param aErrorCode The error code. If this is not KErrNone then special action may be required. |
|
133 * |
|
134 */ |
|
135 void OnStartDocumentL( const RDocumentParameters &aDocParam, TInt aErrorCode ); |
|
136 |
|
137 /** |
|
138 * This method is a callback to indicate the end of the document |
|
139 * @param aErrorCode The error code. If this is not KErrNone then special action may be required. |
|
140 */ |
|
141 void OnEndDocumentL( TInt aErrorCode ); |
|
142 |
|
143 /** |
|
144 * This method is a callback to indicate an element has been parsed. |
|
145 * @param aElement Is a handle to the element's details. |
|
146 * @param aAttributes Contains the attributes for the element |
|
147 * @param aErrorCode The error code. If this is not KErrNone then special action may be required |
|
148 */ |
|
149 void OnStartElementL( const RTagInfo &aElement, const RAttributeArray &aAttributes, TInt aErrorCode ); |
|
150 |
|
151 /** |
|
152 * This method is a callback to indicate the end of the element has been reached. |
|
153 * @param aElement Is a handle to the element's details. |
|
154 * @param aErrorCode The error code. If this is not KErrNone then special action may be required |
|
155 */ |
|
156 |
|
157 void OnEndElementL( const RTagInfo &aElement, TInt aErrorCode ); |
|
158 |
|
159 /** |
|
160 * This method is a callback that sends the content of the element |
|
161 * @param aBytes the raw content data for the element |
|
162 * @param aErrorCode The error code. If this is not KErrNone then special action may be required |
|
163 */ |
|
164 void OnContentL( const TDesC8 &aBytes, TInt aErrorCode ); |
|
165 |
|
166 /** |
|
167 * This method is a notification of the beginning of the scope of a prefix-URI Namespace mapping |
|
168 * @param aPrefix the Namespace prefix being declared |
|
169 * @param aUri the Namespace URI the prefix is mapped to |
|
170 * @param aErrorCode The error code. If this is not KErrNone then special action may be required |
|
171 */ |
|
172 void OnStartPrefixMappingL( const RString &aPrefix, const RString &aUri, TInt aErrorCode ); |
|
173 |
|
174 /** |
|
175 * This method is a notification of the end of the scope of a prefix-URI mapping |
|
176 * @param aPrefix the Namespace prefix being declared |
|
177 * @param aErrorCode The error code. If this is not KErrNone then special action may be required |
|
178 */ |
|
179 void OnEndPrefixMappingL( const RString &aPrefix, TInt aErrorCode ); |
|
180 |
|
181 /** |
|
182 * This method is a notification of ignorable whitespace in element content |
|
183 * @param aBytes the ignored bytes from the document being parsed |
|
184 * @param aErrorCode The error code. If this is not KErrNone then special action may be required |
|
185 */ |
|
186 void OnIgnorableWhiteSpaceL( const TDesC8 &aBytes, TInt aErrorCode ); |
|
187 |
|
188 /** |
|
189 * This method is a notification of a skipped entity |
|
190 * @param aName the name of the skipped entity. |
|
191 * @param aErrorCode The error code. If this is not KErrNone then special action may be required |
|
192 */ |
|
193 void OnSkippedEntityL( const RString &aName, TInt aErrorCode ); |
|
194 |
|
195 /** |
|
196 * This method is a receive notification of a processing instruction. |
|
197 * @param aTarget the processing instruction target |
|
198 * @param aData the processing instruction data |
|
199 * @param aErrorCode The error code. If this is not KErrNone then special action may be required |
|
200 */ |
|
201 void OnProcessingInstructionL( const TDesC8 &aTarget, const TDesC8 &aData, TInt aErrorCode); |
|
202 |
|
203 /** |
|
204 * This method indicates an error has occurred |
|
205 * @param aErrorCode The error code. |
|
206 */ |
|
207 void OnError( TInt aErrorCode ); |
|
208 |
|
209 /** |
|
210 * This method obtains the interface matching the specified uid. |
|
211 * @param aUid the uid identifying the required interface |
|
212 */ |
|
213 TAny *GetExtendedInterface( const TInt32 aUid ); |
|
214 |
|
215 #ifdef REVERSEGEOCODE_UNIT_TESTCASE |
|
216 public: |
|
217 #else |
|
218 private: // Private data |
|
219 #endif |
|
220 |
|
221 MXmlHandlerObserver& iObserver; |
|
222 CParser* iParser; |
|
223 HBufC8* iBuffer; |
|
224 CInternalAddressInfo *iAddressInfo; |
|
225 xmlhandler::TLocationInfoType iCurrentElement; |
|
226 TBool iThoroughfare ; |
|
227 }; |
|
228 |
|
229 #endif /* __XMLHANDLER_H__ */ |
|
230 |
|
231 // End of File |
|