Lets assume sometimes I got a dom4j Document and sometimes I got a dom4j Element. I want to apply the code of the following function
public List<Element> getElements(Document doc4j){
//do
}
on my object of type Element as well. But that would only work if I can convert this Element to a Document. I cant use the method getDocument
, because I only want to apply the code under //do for the sub tree which represented by the object of type Element.
From the docs, it looks like Document and Element both extend Branch, can you not make your method take a Branch as below?
public List<Element> getElements(Branch branch) {
//do
}