org.openmuc.core.datamanager.impl
Class XMLUtils

java.lang.Object
  extended by org.openmuc.core.datamanager.impl.XMLUtils

public class XMLUtils
extends java.lang.Object


Constructor Summary
XMLUtils()
           
 
Method Summary
static void addTagWithValue(org.w3c.dom.Element parent, org.w3c.dom.Document document, java.lang.String tag, java.lang.String value)
           
static java.lang.String dateToString(java.util.Date date)
           
static void deleteElementWithAttributeValue(org.w3c.dom.Document doc, java.lang.String elementName, java.lang.String attributeName, java.lang.String value)
          Delete an element with a given attribute value from an XML DOM
static void deleteElementWithSubElementValue(org.w3c.dom.Document doc, java.lang.String elementName, java.lang.String subElementName, java.lang.String value)
          Delete an element with a given subelement text value form an XML DOM
static java.lang.String getAttributeValue(org.w3c.dom.Node element, java.lang.String attributeName)
           
static org.w3c.dom.Document getDocumentFromFile(java.io.File xmlFile)
           
static org.w3c.dom.Document getDocumentFromStream(java.io.InputStream xmlStream)
           
static boolean hasAttributeValue(org.w3c.dom.Node element, java.lang.String attributeName, java.lang.String attributeValue)
          Test if the given element has the given attribute and attribute value
static org.w3c.dom.Node hasTagAsChild(org.w3c.dom.Element parent, java.lang.String tag)
           
static org.w3c.dom.Node hasTagAsChildWithAttributeValue(org.w3c.dom.Element parent, java.lang.String tag, java.lang.String attribute, java.lang.String value)
           
static java.util.Date parseDateTime(java.lang.String datetime)
          parses date or time in ISO 8601 standard and UTC HH:mm:ss yy-MM-dd yy-MM-dd HH:mm:ss
static java.lang.String storageType(int storageType)
           
static long timeToMilliSec(java.lang.String time)
           
static void updateAttributeValue(org.w3c.dom.Node element, java.lang.String attributeName, java.lang.String attributeValue)
           
static void updateTagWithValue(org.w3c.dom.Element parent, org.w3c.dom.Document document, java.lang.String tag, java.lang.String value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLUtils

public XMLUtils()
Method Detail

getDocumentFromFile

public static org.w3c.dom.Document getDocumentFromFile(java.io.File xmlFile)

getDocumentFromStream

public static org.w3c.dom.Document getDocumentFromStream(java.io.InputStream xmlStream)

updateTagWithValue

public static void updateTagWithValue(org.w3c.dom.Element parent,
                                      org.w3c.dom.Document document,
                                      java.lang.String tag,
                                      java.lang.String value)

addTagWithValue

public static void addTagWithValue(org.w3c.dom.Element parent,
                                   org.w3c.dom.Document document,
                                   java.lang.String tag,
                                   java.lang.String value)

hasTagAsChild

public static org.w3c.dom.Node hasTagAsChild(org.w3c.dom.Element parent,
                                             java.lang.String tag)

hasTagAsChildWithAttributeValue

public static org.w3c.dom.Node hasTagAsChildWithAttributeValue(org.w3c.dom.Element parent,
                                                               java.lang.String tag,
                                                               java.lang.String attribute,
                                                               java.lang.String value)

deleteElementWithAttributeValue

public static void deleteElementWithAttributeValue(org.w3c.dom.Document doc,
                                                   java.lang.String elementName,
                                                   java.lang.String attributeName,
                                                   java.lang.String value)
Delete an element with a given attribute value from an XML DOM

Parameters:
doc - the XML document
elementName - the name of the element to delete
attributeName - the name of the elements attribute
value - the attribute value

deleteElementWithSubElementValue

public static void deleteElementWithSubElementValue(org.w3c.dom.Document doc,
                                                    java.lang.String elementName,
                                                    java.lang.String subElementName,
                                                    java.lang.String value)
Delete an element with a given subelement text value form an XML DOM

Parameters:
doc - the XML document
elementName - the name of the element to delete
subElementName - he name of the elements subelement
value - the value of the sub element

hasAttributeValue

public static boolean hasAttributeValue(org.w3c.dom.Node element,
                                        java.lang.String attributeName,
                                        java.lang.String attributeValue)
Test if the given element has the given attribute and attribute value

Parameters:
element - element to test
attributeName - attribute name
attributeValue - attribute value

updateAttributeValue

public static void updateAttributeValue(org.w3c.dom.Node element,
                                        java.lang.String attributeName,
                                        java.lang.String attributeValue)

getAttributeValue

public static java.lang.String getAttributeValue(org.w3c.dom.Node element,
                                                 java.lang.String attributeName)

storageType

public static java.lang.String storageType(int storageType)

parseDateTime

public static java.util.Date parseDateTime(java.lang.String datetime)
parses date or time in ISO 8601 standard and UTC HH:mm:ss yy-MM-dd yy-MM-dd HH:mm:ss

Parameters:
datetime -
Returns:
parsed Date. returns default date, if datetime is in wrong format

dateToString

public static java.lang.String dateToString(java.util.Date date)

timeToMilliSec

public static long timeToMilliSec(java.lang.String time)
                           throws java.lang.NumberFormatException
Throws:
java.lang.NumberFormatException