Package com.logicaldoc.util.config
Class XMLBean
java.lang.Object
com.logicaldoc.util.config.XMLBean
- Direct Known Subclasses:
- PluginDescriptorConfigurator,- WebConfigurator
Class for using xml-files.
- Version:
- 1.0
- Author:
- Michael Scholz
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionorg.jdom2.ElementfindElement(String xpathExpression) Finds an element using an XPATH expressionorg.jdom2.ElementfindElement(String xpathExpression, Map<String, String> namespaces) Finds an element using an XPATH expressionList<org.jdom2.Attribute> getAllAttribute(org.jdom2.Element elem) Returns a list of all attributes from an element.List<org.jdom2.Element> getAllChildren(String elemname) Returns a list of all elements with the given element.List<org.jdom2.Element> getAllChildren(String elemname, String attribute, String value) Returns a list of all children with the specific name and the specific attribute valuegetAllChildText(String elemname, String attribute, String value, String separator1, String separator2) This method returns the text of all children in the format childname<separator1>childtext<separator2>org.jdom2.AttributegetAttribute(org.jdom2.Element elem, String attrib) Returns an element attribute.getAttributeValue(org.jdom2.Element elem, String attrib) Returns the value of an elementattribute.org.jdom2.ElementReturns a child element.org.jdom2.ElementThis method finds a child by name and attribute.getChildText(String elemname, String childname, String attribute, String value) This method returns the text of a child element characterized by elementname and attribute.List<org.jdom2.Element> This method returns all direct children of the root element.org.jdom2.ElementReturns the root element.getText(org.jdom2.Element elem) This returns the text between a begining and an ending tag.booleanremoveChild(String elemname) Removes an element.voidsetAttributeValue(org.jdom2.Element elem, String attrib, String value) This method set the value of an elementattribute.voidbooleanThis method saves the xml-file connected by XMLBean.
- 
Constructor Details- 
XMLBeanCreates new XMLBean.- Parameters:
- docPath- Path of xml-file.
 
- 
XMLBeanCreates new XMLBean.- Parameters:
- docname- URL of xml-file.
 
- 
XMLBeanCreates new XMLBean from an input stream; XMLBean is read-only!!!- Parameters:
- is- contents of the XML structure
 
 
- 
- 
Method Details- 
findElementFinds an element using an XPATH expression- Parameters:
- xpathExpression- the expression to evaluate
- Returns:
- the found element
 
- 
findElementFinds an element using an XPATH expression- Parameters:
- xpathExpression- the expression to evaluate
- namespaces- map of namespaces as declared into the XML document
- Returns:
- the found element
 
- 
getRootElementpublic org.jdom2.Element getRootElement()Returns the root element.- Returns:
- the root element
 
- 
getChildReturns a child element.- Parameters:
- elemname- Name of the child.
- Returns:
- the child element
 
- 
getChildThis method finds a child by name and attribute.- Parameters:
- elemname- Name of the child.
- attribute- Name of the child attribute.
- value- Value of the attribute.
- Returns:
- Child
 
- 
getTextThis returns the text between a begining and an ending tag.- Parameters:
- elem- Name of the element.
- Returns:
- Text of the element.
 
- 
getText
- 
getChildTextThis method returns the text of a child element characterized by elementname and attribute.- Parameters:
- elemname- Name of the element.
- childname- Name of the child.
- attribute- Name of the attribute which must element have.
- value- Value of the attribute.
- Returns:
- Text of the child.
 
- 
getAllChildTextpublic String getAllChildText(String elemname, String attribute, String value, String separator1, String separator2) This method returns the text of all children in the format childname<separator1>childtext<separator2>- Parameters:
- elemname- Name of the root element
- attribute- Name of the attribute which must root element have
- value- Value of the attribute
- separator1- string used as first separator
- separator2- string used as second separator
- Returns:
- the children's text
 
- 
getAttributeReturns an element attribute.- Parameters:
- elem- Name of the element.
- attrib- Name of the attribute.
- Returns:
- Attribute
 
- 
getAttributeValueReturns the value of an elementattribute.- Parameters:
- elem- Name of the element.
- attrib- Name of the attribute.
- Returns:
- Value of the attribute.
 
- 
setAttributeValueThis method set the value of an elementattribute.- Parameters:
- elem- Name of the element.
- attrib- Attribute of the element.
- value- New value of the attribute.
 
- 
setText
- 
writeXMLDocpublic boolean writeXMLDoc()This method saves the xml-file connected by XMLBean. NOTE: only call this on an XMLBean _NOT_ created from an InputStream!- Returns:
- true if the file has been completely written
 
- 
getRootChildThis method returns all direct children of the root element.- Returns:
- Childrenlist
 
- 
getAllAttributeReturns a list of all attributes from an element.- Parameters:
- elem- Name of the element.
- Returns:
- Attributelist
 
- 
getAllChildrenReturns a list of all elements with the given element.- Parameters:
- elemname- name of the element
- Returns:
- list of the children elements
 
- 
getAllChildrenReturns a list of all children with the specific name and the specific attribute value- Parameters:
- elemname- name of the element
- attribute- name of the attribute
- value- value of the attribute
- Returns:
- the list of children
 
- 
removeChildRemoves an element.- Parameters:
- elemname- Tag name of the element.
- Returns:
- true if the deletion has been successful
 
 
-