microsoft.exchange.webservices.data.misc
Class MapiTypeConverterMapEntry

java.lang.Object
  extended by microsoft.exchange.webservices.data.misc.MapiTypeConverterMapEntry

public class MapiTypeConverterMapEntry
extends Object

Represents an entry in the MapiTypeConverter map.


Constructor Summary
MapiTypeConverterMapEntry(Class<?> type)
          Initializes a new instance of the MapiTypeConverterMapEntry class.
 
Method Summary
 Object changeType(Object value)
          Change value to a value of compatible type.
 Object convertToValue(String stringValue)
          Converts a string to value consistent with type.
 Object convertToValueOrDefault(String stringValue)
          Converts a string to value consistent with type (or uses the default value if the string is null or empty).
protected  IFunction<Object,String> getConvertToString()
          Gets the string to object converter.
protected  Object getDefaultValue()
          Gets the default value for the type.
static int getDim(Object array)
          Gets the dim.
 boolean getIsArray()
          Gets a value indicating whether this instance is array.
protected  IFunction<String,Object> getParse()
          Gets the string parser.
 Class<?> getType()
          Gets the type.
protected  void setConvertToString(IFunction<Object,String> value)
          Sets the string to object converter.
protected  void setIsArray(boolean value)
          Sets the checks if is array.
protected  void setParse(IFunction<String,Object> value)
          Sets the string parser.
 void setType(Class<?> cls)
          Sets the type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MapiTypeConverterMapEntry

public MapiTypeConverterMapEntry(Class<?> type)
Initializes a new instance of the MapiTypeConverterMapEntry class.

Parameters:
type - The type. y default, converting a type to string is done by calling value.ToString. Instances can override this behavior.

By default, converting a string to the appropriate value type is done by calling Convert.ChangeType Instances may override this behavior.

Method Detail

changeType

public Object changeType(Object value)
                  throws Exception
Change value to a value of compatible type.

The type of a simple value should match exactly or be convertible to the appropriate type. An array value has to be a single dimension (rank), contain at least one value and contain elements that exactly match the expected type. (We could relax this last requirement so that, for example, you could pass an array of Int32 that could be converted to an array of Double but that seems like overkill).

Parameters:
value - The value.
Returns:
New value.
Throws:
Exception - the exception

convertToValue

public Object convertToValue(String stringValue)
                      throws ServiceXmlDeserializationException,
                             FormatException
Converts a string to value consistent with type.

For array types, this method is called for each array element.

Parameters:
stringValue - String to convert to a value.
Returns:
value
Throws:
ServiceXmlDeserializationException - the service xml deserialization exception
FormatException - the format exception

convertToValueOrDefault

public Object convertToValueOrDefault(String stringValue)
                               throws ServiceXmlDeserializationException,
                                      FormatException
Converts a string to value consistent with type (or uses the default value if the string is null or empty).

Parameters:
stringValue - to convert to a value.
Returns:
Value.
Throws:
FormatException
ServiceXmlDeserializationException

getDim

public static int getDim(Object array)
Gets the dim. If `array' is an array object returns its dimensions; otherwise returns 0

Parameters:
array - the array
Returns:
the dim

getType

public Class<?> getType()
Gets the type.

Returns:
the type

setType

public void setType(Class<?> cls)
Sets the type.

Parameters:
cls - the new type

getIsArray

public boolean getIsArray()
Gets a value indicating whether this instance is array.

Returns:
the checks if is array

setIsArray

protected void setIsArray(boolean value)
Sets the checks if is array.

Parameters:
value - the new checks if is array

getConvertToString

protected IFunction<Object,String> getConvertToString()
Gets the string to object converter. For array types, this method is called for each array element.

Returns:
the convert to string

setConvertToString

protected void setConvertToString(IFunction<Object,String> value)
Sets the string to object converter.

Parameters:
value - the value

getParse

protected IFunction<String,Object> getParse()
Gets the string parser. For array types, this method is called for each array element.

Returns:
the parses the

setParse

protected void setParse(IFunction<String,Object> value)
Sets the string parser.

Parameters:
value - the value

getDefaultValue

protected Object getDefaultValue()
Gets the default value for the type.

Returns:
Type


Copyright © 2012–2015 Microsoft. All rights reserved.