Package io.openems.common.utils
Class XmlUtils
java.lang.Object
io.openems.common.utils.XmlUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
getAsBoolean
(NamedNodeMap attrs, String name) Gets the value of a Sub-Node of aNamedNodeMap
with the given name as Boolean.static boolean
getAsBooleanOrElse
(NamedNodeMap attrs, String name, boolean def) Gets the value of a Sub-Node of aNamedNodeMap
with the given name as Boolean; otherwise the alternative value.static <E extends Enum<E>>
EgetAsEnum
(Class<E> enumType, NamedNodeMap attrs, String name) Gets the value of a Sub-Node of aNamedNodeMap
with the given name as Enum.static <E extends Enum<E>>
EgetAsEnumOrElse
(Class<E> enumType, NamedNodeMap attrs, String name, E def) Gets the value of a Sub-Node of aNamedNodeMap
with the given name as Enum; otherwise the alternative value.static int
getAsInt
(NamedNodeMap attrs, String name) Gets the value of a Sub-Node of aNamedNodeMap
with the given name as Integer.static int
getAsIntOrElse
(NamedNodeMap attrs, String name, int def) Gets the value of a Sub-Node of aNamedNodeMap
with the given name as Integer; otherwise the alternative value.static String
getAsString
(NamedNodeMap attrs, String name) Gets the value of a Sub-Node of aNamedNodeMap
with the given name as String.static String
getAsStringOrElse
(NamedNodeMap attrs, String name, String def) Gets the value of a Sub-Node of aNamedNodeMap
with the given name as String; otherwise the alternative value.static int
getContentAsInt
(Node node) Gets the Content of aNode
as Integer.static String
getContentAsString
(Node node) Gets the Content of aNode
.static Node
getSubNode
(NamedNodeMap attrs, String name) Gets the Sub-Node of aNamedNodeMap
with the given name.static String
namedNodeMapToString
(NamedNodeMap attrs) Converts aNamedNodeMap
to a string representative.
-
Constructor Details
-
XmlUtils
public XmlUtils()
-
-
Method Details
-
namedNodeMapToString
Converts aNamedNodeMap
to a string representative.- Parameters:
attrs
- theNamedNodeMap
- Returns:
- a string
-
getSubNode
public static Node getSubNode(NamedNodeMap attrs, String name) throws OpenemsError.OpenemsNamedException Gets the Sub-Node of aNamedNodeMap
with the given name.- Parameters:
attrs
- theNamedNodeMap
name
- the name of the Sub-Node- Returns:
- the
Node
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
getAsString
public static String getAsString(NamedNodeMap attrs, String name) throws OpenemsError.OpenemsNamedException Gets the value of a Sub-Node of aNamedNodeMap
with the given name as String.- Parameters:
attrs
- theNamedNodeMap
name
- the name of the Sub-Node- Returns:
- the value of the
Node
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
getAsStringOrElse
Gets the value of a Sub-Node of aNamedNodeMap
with the given name as String; otherwise the alternative value.- Parameters:
attrs
- theNamedNodeMap
name
- the name of the Sub-Nodedef
- the alternative value- Returns:
- the value of the
Node
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
getAsInt
public static int getAsInt(NamedNodeMap attrs, String name) throws OpenemsError.OpenemsNamedException Gets the value of a Sub-Node of aNamedNodeMap
with the given name as Integer.- Parameters:
attrs
- theNamedNodeMap
name
- the name of the Sub-Node- Returns:
- the value of the
Node
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
getAsIntOrElse
Gets the value of a Sub-Node of aNamedNodeMap
with the given name as Integer; otherwise the alternative value.- Parameters:
attrs
- theNamedNodeMap
name
- the name of the Sub-Nodedef
- the alternative value- Returns:
- the value of the
Node
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
getAsEnum
public static <E extends Enum<E>> E getAsEnum(Class<E> enumType, NamedNodeMap attrs, String name) throws OpenemsError.OpenemsNamedException Gets the value of a Sub-Node of aNamedNodeMap
with the given name as Enum.- Type Parameters:
E
- the type of theEnum
- Parameters:
enumType
- the class of theEnum
attrs
- theNamedNodeMap
name
- the name of the Sub-Node- Returns:
- the value of the
Node
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
getAsEnumOrElse
public static <E extends Enum<E>> E getAsEnumOrElse(Class<E> enumType, NamedNodeMap attrs, String name, E def) Gets the value of a Sub-Node of aNamedNodeMap
with the given name as Enum; otherwise the alternative value.- Type Parameters:
E
- the type of theEnum
- Parameters:
enumType
- the class of theEnum
attrs
- theNamedNodeMap
name
- the name of the Sub-Nodedef
- the alternative value- Returns:
- the value of the
Node
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
getAsBoolean
public static boolean getAsBoolean(NamedNodeMap attrs, String name) throws OpenemsError.OpenemsNamedException Gets the value of a Sub-Node of aNamedNodeMap
with the given name as Boolean.- Parameters:
attrs
- theNamedNodeMap
name
- the name of the Sub-Node- Returns:
- the value of the
Node
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
getAsBooleanOrElse
Gets the value of a Sub-Node of aNamedNodeMap
with the given name as Boolean; otherwise the alternative value.- Parameters:
attrs
- theNamedNodeMap
name
- the name of the Sub-Nodedef
- the alternative value- Returns:
- the value of the
Node
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
getContentAsString
Gets the Content of aNode
.- Parameters:
node
- theNode
- Returns:
- the text content as string
-
getContentAsInt
Gets the Content of aNode
as Integer.- Parameters:
node
- theNode
- Returns:
- the text content as string
-