1 yi.zhou 1.1 //%2005////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
6 // IBM Corp.; EMC Corporation, The Open Group.
7 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
9 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
11 //
12 // Permission is hereby granted, free of charge, to any person obtaining a copy
13 // of this software and associated documentation files (the "Software"), to
14 // deal in the Software without restriction, including without limitation the
15 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
16 // sell copies of the Software, and to permit persons to whom the Software is
17 // furnished to do so, subject to the following conditions:
18 //
19 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
20 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
21 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
22 yi.zhou 1.1 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
23 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
25 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28 //==============================================================================
29 //
30 // Author: Yi Zhou, Hewlett-Packard Company (yi.zhou@hp.com)
31 //
32 // Modified By:
33 //
34 //%/////////////////////////////////////////////////////////////////////////////
35
36 #ifndef Pegasus_IndicationFormatter_h
37 #define Pegasus_IndicationFormatter_h
38
39 #include <Pegasus/Common/Config.h>
40 #include <Pegasus/Common/Linkage.h>
41 #include <Pegasus/Common/String.h>
42 #include <Pegasus/Common/CIMMessage.h>
43 yi.zhou 1.1 #include <Pegasus/Common/Constants.h>
44
|
45 yi.zhou 1.3 #if defined(PEGASUS_HAS_ICU) && defined(PEGASUS_INDFORMATTER_USE_ICU)
|
46 yi.zhou 1.2 #include <unicode/locid.h>
47 #include <unicode/datefmt.h>
48 #include <unicode/unistr.h>
49 #endif
50
|
51 yi.zhou 1.1
52 PEGASUS_NAMESPACE_BEGIN
53
54 /**
55 The IndicationFormatter class formats an indication message.
56
57 @author Hewlett-Packard Company
58
59 */
60 class PEGASUS_COMMON_LINKAGE IndicationFormatter
61 {
62 public:
63
64 /**
|
65 yi.zhou 1.2 Based on subscription instance, gets the formatted indication text
66 message from the received indication instance.
|
67 yi.zhou 1.1
|
68 yi.zhou 1.2 @param subscription the subscription instance
69 @param indication the received indication instance
70 @param contentLangs the Content-Languages in the
71 subscription instance
|
72 yi.zhou 1.1
|
73 yi.zhou 1.2 @return String containing the formatted indication text message
|
74 yi.zhou 1.1 */
|
75 yi.zhou 1.2 static String getFormattedIndText(
76 const CIMInstance & subscription,
77 const CIMInstance & indication,
78 const ContentLanguages & contentLangs);
|
79 yi.zhou 1.1
80
81 /**
82 Validates the syntax and the provided type for the property
83 TextFormat in the instance.
84 If the value of the property has a syntax error, or the
85 provided type does not match the property type,
86 an exception is thrown.
87
88 This function is called by the _canCreate function, and is used to
89 validate the syntax and the provided type for the property
90 TextFormat in the Formatted Subscription instance.
91
92 @param textFormatStr the string to be validated
93 @param indicationClass the indication class
94 @param textFormatParams the value of the TextFormatParameters
95
96 @throw CIM_ERR_INVALID_PARAMETER if there is a syntax error
97 for the value of property
98 TextFormat or type mismatch
99 */
100 yi.zhou 1.1 static void validateTextFormat (
101 const String & textFormatStr,
102 const CIMClass & indicationClass,
103 const Array<String> & textFormatParams);
104
105 /**
106 Validates the value of the property TextFormatParameters in the
107 subscriptionInstance.
108 If the property name in the TextFormatParameters is not the name
109 contained in the select clause of the associated filter query
110 in the filterInstance, an exception is thrown.
111
112 @param propertyList the list of properties to be validated
113 @param indicationClass the indication class
114 @param textFormatParams the value of the property
115 TextFormatParameters
116
117 @throw CIM_ERR_INVALID_PARAMETER if the select clause of the
118 filter query does not contain
119 the provided property name
120 */
121 yi.zhou 1.1 static void validateTextFormatParameters (
122 const CIMPropertyList & propertyList,
123 const CIMClass & indicationClass,
124 const Array<String> & textFormatParams);
125
126 private:
127
128 /**
129 gets specified indication property value from the received
130 indication instance.
131
132 @param propertyName the specified property name
133 @param arrayIndexStr the specified index string of the array
134 @param indication the received indication instance
|
135 yi.zhou 1.2 @param contentLangs the Content Languages
|
136 yi.zhou 1.1 @return String containing property value
137 */
138
139 static String _getIndPropertyValue(
140 const String & propertyName,
141 const String & arrayIndexStr,
|
142 yi.zhou 1.2 const CIMInstance & indication,
143 const ContentLanguages & contentLangs);
|
144 yi.zhou 1.1
145 /**
146 Retrieves the array values referenced by the specified
147 CIMValue.
148
149 @param propertyValue the CIMValue
150 @param indexStr the array index
|
151 yi.zhou 1.2 @param contentLangs the Content Languages
|
152 yi.zhou 1.1 @return String containing array values referenced by the specified
153 CIMValue
154 */
155 static String _getArrayValues(
156 const CIMValue & propertyValue,
|
157 yi.zhou 1.2 const String & indexStr,
158 const ContentLanguages & contentLangs);
|
159 yi.zhou 1.1
160 /**
161 Validates the index string
162
163 Index string only can be an integer. Otherwise,
164 an exception is thrown.
165
166 @param indexStr index string to be validated
167
168 @throw CIM_ERR_INVALID_PARAMETER if the index is invalid
169 */
170 static void _isValidIndex(
171 const char * indexStr);
172
173 /**
174 Validates the provided property type string.
175 If the provided property type does not match the type of the property,
176 or the provided property type is not valid type, or the dynamic
177 content with an array index refers to a non array type, an
178 exception is thrown.
179
180 yi.zhou 1.1 This function is called by the _validatePropertySyntaxAndType
181 function, and is used to validate the provided property type.
182
183 @param indicationClass the indication class
184 @param propertyParam the provided property
185 @param propertyTypeStr the provided property type
186 @param isArray indicates whether refers to an array type
187
188 @throw CIM_ERR_INVALID_PARAMETER if the provided property type is
189 unexpected
190 */
191 static void _validatePropertyType (
192 const CIMClass & indicationClass,
193 const String & propertyParam,
194 const String & propertyTypeStr,
195 const Boolean & isArray);
196
|
197 yi.zhou 1.2 /**
198 Converts the CIMValue of the boolean to be string "true" or "false"
199
200 @param booleanCIMValue Boolean CIMValue to be converted
201
202 @return the string representing the boolean CIMValue
203 */
204 static String _getBooleanStr(
205 const CIMValue & booleanCIMValue);
206
207 /**
208 Converts the boolean value to be string "true" or "false"
209
210 @param booleanValue Boolean value to be converted
211
212 @return the string representing the boolean value
213 */
214 static String _getBooleanStr(
215 const Boolean & booleanValue);
216
217 /**
218 yi.zhou 1.2 Constructs a default indication text message from the received
219 indication instance.
220
221 @param indication the received indication instance
222 @param contentLangs the Content-Languages in the
223 subscription instance
224
225 @return String containing default indication text message
226 */
227 static String _formatDefaultIndicationText(
228 const CIMInstance & indication,
229 const ContentLanguages & contentLangs);
230
231 /**
232 Constructs a human readable indication text message from the
233 specified indication textFormat, textFormatParams, and
234 received indication instance.
235
236 @param textFormat the specified indication textFormat
237 @param textFormatParams the indexed array containing the names
238 of properties defined in the select
239 yi.zhou 1.2 clause of the associated
240 CIM_IndicationFilter Query
241 @param indication the received indication instance
242 @param contentLangs the Content-Languages in the
243 subscription instance
244
245 @return String containing a human readable indication text message
246 */
247 static String _formatIndicationText(
248 const String & textFormat,
249 const Array<String>& textFormatParams,
250 const CIMInstance & indication,
251 const ContentLanguages & contentLangs);
252
|
253 yi.zhou 1.3 #if defined(PEGASUS_HAS_ICU) && defined(PEGASUS_INDFORMATTER_USE_ICU)
|
254 yi.zhou 1.2 /**
255 Determines if a property value can be localized.
256 A property value can only be localized if the subscription
257 ContentLanguages includes no more than one language tag.
258
259 @param contentLangs the Content-Languages in the
260 subscription instance
261 @param locale locale to be set on return if return
262 value is true
263
264 @return True, if valid locale returned
265 False, Otherwise
266 */
267 static Boolean _canLocalize(
268 const ContentLanguages & contentLangs,
269 Locale & locale);
270
271 /**
272 Localizes the CIMTYPE_DATETIME property value
273
274 @param dateTimeValue the value of datetime to be localized
275 yi.zhou 1.2 @param locale locale to be used in the localization
276
277 @return the string representation of the datetime value
278 */
279 static String _localizeDateTime(
280 const CIMDateTime & dateTimeValue,
281 const Locale & locale);
282
283 /**
284 Localizes the CIMTYPE_BOOLEAN property value
285
286 @param booleanValue the value of the boolean to be localized
287 @param locale locale to be used in the localization
288
289 @return the string representation of the boolean value
290 */
291 static String _localizeBooleanStr(
292 const Boolean & booleanValue,
293 const Locale & locale);
294
295 #endif
296 yi.zhou 1.2
|
297 yi.zhou 1.1 };
298
299 PEGASUS_NAMESPACE_END
300
301 #endif /* Pegasus_IndicationFormatter_h */
|