Class ConverterValueMap
java.lang.Object
org.openhab.core.config.core.xml.util.ConverterValueMap
The
ConverterValueMap
reads all children elements of a node and provides
them as key-value pair map.
This class should be used for nodes whose children elements only contain simple values (without children) and whose order is unpredictable. There must be only one children with the same name.
- Author:
- Michael Grammling - Initial contribution, Alex Tugarev - Extended for options and filter criteria
-
Constructor Summary
ConstructorDescriptionConverterValueMap
(com.thoughtworks.xstream.io.HierarchicalStreamReader reader, int numberOfValues, com.thoughtworks.xstream.converters.UnmarshallingContext context) Creates a new instance of this class with the specified parameters.ConverterValueMap
(com.thoughtworks.xstream.io.HierarchicalStreamReader reader, com.thoughtworks.xstream.converters.UnmarshallingContext context) Creates a new instance of this class with the specified parameter. -
Method Summary
Modifier and TypeMethodDescription@Nullable Boolean
getBoolean
(String nodeName) Returns the boolean associated with the specified name of the child's node.@Nullable Boolean
getBoolean
(String nodeName, @Nullable Boolean defaultValue) Returns the boolean associated with the specified name of the child's node.@Nullable Integer
getInteger
(String nodeName) Returns the numeric value associated with the specified name of the child's node.@Nullable Integer
getInteger
(String nodeName, @Nullable Integer defaultValue) Returns the numeric value associated with the specified name of the child's node.@Nullable Object
Returns the object associated with the specified name of the child's node.@Nullable Object
Returns the object associated with the specified name of the child's node.@Nullable String
Returns the text associated with the specified name of the child's node.@Nullable String
Returns the text associated with the specified name of the child's node.Returns the key-value map containing all read-in children.readValueMap
(com.thoughtworks.xstream.io.HierarchicalStreamReader reader, int numberOfValues, com.thoughtworks.xstream.converters.UnmarshallingContext context) Reads-inN
children in a key-value map and returns it.
-
Constructor Details
-
ConverterValueMap
public ConverterValueMap(com.thoughtworks.xstream.io.HierarchicalStreamReader reader, com.thoughtworks.xstream.converters.UnmarshallingContext context) Creates a new instance of this class with the specified parameter.- Parameters:
reader
- the reader to be used to read-in all childrencontext
-
-
ConverterValueMap
public ConverterValueMap(com.thoughtworks.xstream.io.HierarchicalStreamReader reader, int numberOfValues, com.thoughtworks.xstream.converters.UnmarshallingContext context) throws com.thoughtworks.xstream.converters.ConversionException Creates a new instance of this class with the specified parameters.- Parameters:
reader
- the reader to be used to read-in all children (must not be null)numberOfValues
- the number of children to be read-in (< 0
= until end of section)context
-- Throws:
com.thoughtworks.xstream.converters.ConversionException
- if not all children could be read-in
-
-
Method Details
-
getValueMap
Returns the key-value map containing all read-in children.- Returns:
- the key-value map containing all read-in children (could be empty)
-
readValueMap
public static Map<String,Object> readValueMap(com.thoughtworks.xstream.io.HierarchicalStreamReader reader, int numberOfValues, com.thoughtworks.xstream.converters.UnmarshallingContext context) throws com.thoughtworks.xstream.converters.ConversionException Reads-inN
children in a key-value map and returns it.- Parameters:
reader
- the reader to be used to read-in the childrennumberOfValues
- the number of children to be read in (< 0
= until end of section)context
-- Returns:
- the key-value map containing the read-in children (not null, could be empty)
- Throws:
com.thoughtworks.xstream.converters.ConversionException
- if not all children could be read-in
-
getObject
Returns the object associated with the specified name of the child's node.- Parameters:
nodeName
- the name of the child's node- Returns:
- the object associated with the specified name of the child's node
-
getObject
Returns the object associated with the specified name of the child's node.- Parameters:
nodeName
- the name of the child's nodedefaultValue
- the value to be returned if the node could not be found- Returns:
- the object associated with the specified name of the child's node
-
getString
Returns the text associated with the specified name of the child's node.- Parameters:
nodeName
- the name of the child's node- Returns:
- the text associated with the specified name of the child's node
-
getString
Returns the text associated with the specified name of the child's node.- Parameters:
nodeName
- the name of the child's nodedefaultValue
- the text to be returned if the node could not be found- Returns:
- the text associated with the specified name of the child's node
-
getBoolean
Returns the boolean associated with the specified name of the child's node.- Parameters:
nodeName
- the name of the child's node- Returns:
- the boolean associated with the specified name of the child's node
-
getBoolean
Returns the boolean associated with the specified name of the child's node.- Parameters:
nodeName
- the name of the child's nodedefaultValue
- the boolean to be returned if the node could not be found- Returns:
- the boolean associated with the specified name of the child's node
-
getInteger
public @Nullable Integer getInteger(String nodeName) throws com.thoughtworks.xstream.converters.ConversionException Returns the numeric value associated with the specified name of the child's node.- Parameters:
nodeName
- the name of the child's node- Returns:
- the numeric value associated with the specified name of the child's node
- Throws:
com.thoughtworks.xstream.converters.ConversionException
- if the value could not be converted to a numeric value
-
getInteger
public @Nullable Integer getInteger(String nodeName, @Nullable Integer defaultValue) throws com.thoughtworks.xstream.converters.ConversionException Returns the numeric value associated with the specified name of the child's node.- Parameters:
nodeName
- the name of the child's nodedefaultValue
- the numeric value to be returned if the node could not be found- Returns:
- the numeric value associated with the specified name of the child's node
- Throws:
com.thoughtworks.xstream.converters.ConversionException
- if the value could not be converted to a numeric value
-