(file) Return to IndicationFormatter.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2