util
Clone or download
Modified Files
--- 'a/src/main/java/com/StreamPi/Util/XMLConfigHelper/XMLConfigHelper.java'
+++ b/src/main/java/com/StreamPi/Util/XMLConfigHelper/XMLConfigHelper.java
@@ -2,37 +2,32 @@ package com.StreamPi.Util.XMLConfigHelpe
import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import org.w3c.dom.Node;
public class XMLConfigHelper {
- public XMLConfigHelper()
- {
-
- }
-
-
- public String getStringProperty(Element parentElement, String propertyName) throws Exception
+ public static String getStringProperty(Element parentElement, String propertyName) throws Exception
{
return getProperty(parentElement, propertyName);
}
- public int getIntProperty(Element parentElement, String propertyName) throws Exception
+ public static int getIntProperty(Element parentElement, String propertyName) throws Exception
{
return Integer.parseInt(getProperty(parentElement, propertyName));
}
- public boolean getBooleanProperty(Element parentElement, String propertyName) throws Exception
+ public static boolean getBooleanProperty(Element parentElement, String propertyName) throws Exception
{
return getProperty(parentElement, propertyName).equals("true");
}
- public String getProperty(Element parentElement, String propertyName) throws Exception
+ public static String getProperty(Element parentElement, String propertyName) throws Exception
{
return parentElement.getElementsByTagName(propertyName).item(0).getTextContent();
}
- public String getStringProperty(Element parentElement, String propertyName, String ifNotPresent, boolean printStackTrace)
+ public static String getStringProperty(Element parentElement, String propertyName, String ifNotPresent, boolean printStackTrace)
{
String tbr = ifNotPresent;
@@ -50,12 +45,18 @@ public class XMLConfigHelper {
return tbr;
}
- public String getStringProperty(Element parentElement, String propertyName, String ifNotPresent)
+
+ public static void removeChilds(Node node) {
+ while (node.hasChildNodes())
+ node.removeChild(node.getFirstChild());
+ }
+
+ public static String getStringProperty(Element parentElement, String propertyName, String ifNotPresent)
{
return getStringProperty(parentElement, propertyName, ifNotPresent, true);
}
- public int getIntProperty(Element parentElement, String propertyName, int ifNotPresent)
+ public static int getIntProperty(Element parentElement, String propertyName, int ifNotPresent)
{
int tbr = ifNotPresent;
@@ -72,7 +73,7 @@ public class XMLConfigHelper {
return tbr;
}
- public boolean getBooleanProperty(Element parentElement, String propertyName, boolean ifNotPresent)
+ public static boolean getBooleanProperty(Element parentElement, String propertyName, boolean ifNotPresent)
{
boolean tbr = ifNotPresent;
@@ -88,12 +89,12 @@ public class XMLConfigHelper {
return tbr;
}
- public boolean doesElementExist(Element parent, String nameOfElement)
+ public static boolean doesElementExist(Element parent, String nameOfElement)
{
return parent.getElementsByTagName(nameOfElement).getLength() > 0;
}
- public boolean doesElementExist(Document document, String nameOfElement)
+ public static boolean doesElementExist(Document document, String nameOfElement)
{
return document.getElementsByTagName(nameOfElement).getLength() > 0;
}