public final class XMLUtils extends Object
Modifier and Type | Method and Description |
---|---|
static <T> T |
getInstance(SongContext songContext,
Class<T> superclazz,
Node node,
long parentRandomSeed,
int salt)
Tries to instantiate an instance from the class defined by the node's attribute "class" by calling its nullary (empty) constructor.
|
static Node |
getNode(String path,
Node node)
Returns the node found at the given path.
|
static NodeList |
getNodeList(String path,
Node node)
Returns the node list found at the given path.
|
static boolean |
parseBoolean(Random random,
Node node)
Tries to parse the text content of the given node as a boolean.
|
static boolean |
parseBoolean(Random random,
String path,
Node node)
Searches for the element pointed to by path and tries to parse it as a boolean.
|
static double |
parseDouble(Random random,
Node node)
Tries to parse the text content of the given node as an integer.
|
static double |
parseDouble(Random random,
String path,
Node node)
Searches for the element pointed to by path and tries to parse it as an integer.
|
static int |
parseInteger(Random random,
Node node)
Tries to parse the text content of the given node as an integer.
|
static int |
parseInteger(Random random,
String path,
Node node)
Searches for the element pointed to by path and tries to parse it as an integer.
|
static int[] |
parseIntegerListString(Random random,
String path,
Node node)
Searches for the element pointed to by path and tries to parse it as an integer list.
|
static String |
parseString(Random random,
Node node)
Tries to parse the given node as a string.
|
static String |
parseString(Random random,
String path,
Node node)
Searches for the element pointed to by path and tries to parse it as a string.
|
static String[] |
parseStringList(Random random,
Node node,
char separatorChar)
Tries to parse the given node as a string.
|
static String[] |
parseStringList(Random random,
String path,
Node node,
char separatorChar)
Searches for the element pointed to by path and tries to parse it as a string list, split by the given separator character.
|
public static Node getNode(String path, Node node) throws XPathExpressionException
path
- the XPath expression relative to the nodenode
- the nodeXPathExpressionException
- in case of an XPath expression problempublic static NodeList getNodeList(String path, Node node) throws XPathExpressionException
path
- the XPath expression relative to the nodenode
- the nodeXPathExpressionException
- in case of an XPath expression problempublic static int parseInteger(Random random, String path, Node node)
random
- the random generatorpath
- the XPath expression relative to the nodenode
- the nodepublic static int parseInteger(Random random, Node node)
random
- the random generatornode
- the node to parsepublic static double parseDouble(Random random, String path, Node node)
random
- the random generatorpath
- the XPath expression relative to the nodenode
- the nodepublic static double parseDouble(Random random, Node node)
random
- the random generatornode
- the node to parsepublic static boolean parseBoolean(Random random, String path, Node node)
random
- the random generatorpath
- the XPath expression relative to the nodenode
- the nodepublic static boolean parseBoolean(Random random, Node node)
random
- the random generatornode
- the node to parsepublic static String parseString(Random random, String path, Node node)
random
- the random generatorpath
- the XPath expression relative to the nodenode
- the nodepublic static String[] parseStringList(Random random, String path, Node node, char separatorChar)
random
- the random generatorpath
- the XPath expression relative to the nodenode
- the nodeseparatorChar
- the separator characterpublic static String parseString(Random random, Node node)
random
- the random generatornode
- the nodepublic static String[] parseStringList(Random random, Node node, char separatorChar)
random
- the random generatornode
- the nodeseparatorChar
- the separator characterpublic static int[] parseIntegerListString(Random random, String path, Node node)
random
- the random generatorpath
- the XPath expression relative to the nodenode
- the nodepublic static <T> T getInstance(SongContext songContext, Class<T> superclazz, Node node, long parentRandomSeed, int salt) throws InstantiationException, XPathException, IllegalAccessException, ClassNotFoundException
T
- the typesongContext
- the song contextsuperclazz
- the superclassnode
- the node to use for configurationparentRandomSeed
- the random seed origin to use (the random seed of the parent component)salt
- the random salt (each instance created by the parent should use a different salt value)InstantiationException
- if the class cannot be instantiatedXPathException
- in case of an XPath problemClassNotFoundException
- if the class cannot be foundIllegalAccessException
- if the class cannot be instantiated