eu.etaxonomy.cdm.common
Class XmlHelp

java.lang.Object
  extended by eu.etaxonomy.cdm.common.XmlHelp

public class XmlHelp
extends Object


Constructor Summary
XmlHelp()
           
 
Method Summary
static List<org.jdom.Element> getAttributedChildList(org.jdom.Element parent, String elementName, String attributeName)
           
static List<org.jdom.Element> getAttributedChildListWithValue(org.jdom.Element parent, String elementName, String attributeName, String value)
          Returns a list of children with the given element name and with a given attribute name and a given value for this attribute.
The value comparison is case insensitive.
static org.jdom.Element getBeansRoot(InputStream xmlInput)
          returns the root Element in the File xmlFile
static String getChildAttributeValue(org.jdom.Element element, String childElementName, org.jdom.Namespace childElementNamespace, String childAttributeName, org.jdom.Namespace childAttributeNamespace)
           
static org.jdom.Element getFirstAttributedChild(org.jdom.Element parent, String elementName, String attributeName, String attributeValue)
           
static List<org.jdom.Element> getMultipleChildElement(org.jdom.Element parentElement, String childName, org.jdom.Namespace nsChild, boolean obligatory)
           
static org.jdom.Element getOrAddChild(org.jdom.Element parent, String elementName, String attributeName, String attributeValue)
           
static org.jdom.Element getRoot(InputStream xmlInput)
          returns the root Element in the File xmlFile
static org.jdom.Element getRoot(InputStream xmlInput, String elementName)
          returns the root Element in the File xmlFile
static DoubleResult<org.jdom.Element,Boolean> getSingleChildElement(org.jdom.Element parentElement, String childName, org.jdom.Namespace nsChild, boolean obligatory)
          Gets the child element and tests if there is no other child element exists having the same name.
static org.jdom.Element getSingleChildElement(ResultWrapper<Boolean> success, org.jdom.Element parentElement, String childName, org.jdom.Namespace nsChild, boolean obligatory)
           
static org.jdom.Element insertXmlBean(org.jdom.Element parent, String strId, String strClass)
           
static org.jdom.Element insertXmlRefProperty(org.jdom.Element parent, String strName, String strValue)
           
static org.jdom.Element insertXmlValueProperty(org.jdom.Element parent, String strName, String strValue)
           
static boolean saveToXml(org.jdom.Document doc, OutputStream outStream, org.jdom.output.Format format)
          Writes the Document doc to the specified file
static boolean saveToXml(org.jdom.Document doc, String path, String fileName, org.jdom.output.Format format)
          Writes the Document doc to the specified file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlHelp

public XmlHelp()
Method Detail

saveToXml

public static boolean saveToXml(org.jdom.Document doc,
                                String path,
                                String fileName,
                                org.jdom.output.Format format)
Writes the Document doc to the specified file

Parameters:
doc -
path -
fileName -
Returns:
true, if no error TODO throw the FileNotFoundException and handle in the calling method. That is more likely the place where you can do something about the problem

saveToXml

public static boolean saveToXml(org.jdom.Document doc,
                                OutputStream outStream,
                                org.jdom.output.Format format)
Writes the Document doc to the specified file

Parameters:
doc -
path -
fileName -
Returns:
true, if no error TODO throw the IOException and handle in the calling method. That is more likely the place where you can do something about the problem

getFirstAttributedChild

public static org.jdom.Element getFirstAttributedChild(org.jdom.Element parent,
                                                       String elementName,
                                                       String attributeName,
                                                       String attributeValue)

getAttributedChildList

public static List<org.jdom.Element> getAttributedChildList(org.jdom.Element parent,
                                                            String elementName,
                                                            String attributeName)

getAttributedChildListWithValue

public static List<org.jdom.Element> getAttributedChildListWithValue(org.jdom.Element parent,
                                                                     String elementName,
                                                                     String attributeName,
                                                                     String value)
Returns a list of children with the given element name and with a given attribute name and a given value for this attribute.
The value comparison is case insensitive.

Parameters:
parent -
elementName -
attributeName -
value -
Returns:

getChildAttributeValue

public static String getChildAttributeValue(org.jdom.Element element,
                                            String childElementName,
                                            org.jdom.Namespace childElementNamespace,
                                            String childAttributeName,
                                            org.jdom.Namespace childAttributeNamespace)

getOrAddChild

public static org.jdom.Element getOrAddChild(org.jdom.Element parent,
                                             String elementName,
                                             String attributeName,
                                             String attributeValue)
Parameters:
parent -
elementName -
attributeName -
attributeValue -
Returns:

insertXmlRefProperty

public static org.jdom.Element insertXmlRefProperty(org.jdom.Element parent,
                                                    String strName,
                                                    String strValue)

insertXmlValueProperty

public static org.jdom.Element insertXmlValueProperty(org.jdom.Element parent,
                                                      String strName,
                                                      String strValue)

insertXmlBean

public static org.jdom.Element insertXmlBean(org.jdom.Element parent,
                                             String strId,
                                             String strClass)

getRoot

public static org.jdom.Element getRoot(InputStream xmlInput)
                                throws org.jdom.JDOMException,
                                       IOException
returns the root Element in the File xmlFile

Parameters:
xmlInput -
Returns:
Throws:
org.jdom.JDOMException
IOException

getRoot

public static org.jdom.Element getRoot(InputStream xmlInput,
                                       String elementName)
returns the root Element in the File xmlFile

Parameters:
xmlInput -
elementName -
Returns:
TODO throw the JDOMException and the IOException and handle in the calling method. That is more likely the place where you can do something about the problem

getBeansRoot

public static org.jdom.Element getBeansRoot(InputStream xmlInput)
returns the root Element in the File xmlFile

Parameters:
xmlInput -
Returns:
TODO throw the IOException and handle in the calling method. That is more likely the place where you can do something about the problem

getSingleChildElement

public static DoubleResult<org.jdom.Element,Boolean> getSingleChildElement(org.jdom.Element parentElement,
                                                                           String childName,
                                                                           org.jdom.Namespace nsChild,
                                                                           boolean obligatory)
Gets the child element and tests if there is no other child element exists having the same name. The result is returned as a pair of thd child element and a boolean value that indicates if the elements cardinality was correct.
If there is more then one child element with the child element name or if there is no such element and obligatory is true the second part of the result is false Otherwise it is true.

Parameters:
parentElement - the parent element
childName - name of the child element
nsChild - the namespace for the child element
obligatory - if true, return value is only true if exactly 1 child element with the given name exists
Returns:

getSingleChildElement

public static org.jdom.Element getSingleChildElement(ResultWrapper<Boolean> success,
                                                     org.jdom.Element parentElement,
                                                     String childName,
                                                     org.jdom.Namespace nsChild,
                                                     boolean obligatory)

getMultipleChildElement

public static List<org.jdom.Element> getMultipleChildElement(org.jdom.Element parentElement,
                                                             String childName,
                                                             org.jdom.Namespace nsChild,
                                                             boolean obligatory)


Copyright © 2007-2013 EDIT. All Rights Reserved.