[jdom-interest] Important proposal: Element/Document changes

Chris Atkins atkicd at nm.usa.alcatel.com
Wed Jul 26 06:44:10 PDT 2000


> Element getChild(String name)
> Element getChild(String name, Namespace ns)
> List getChildren()
> List getChildren(String name)
> List getChildren(String name, Nmespace ns)
> -- or --
> Element getChildElement(String name)
> Element getChildElement(String name, Namespace ns)
> List getChildElements()
> List getChildElements(String name)
> List getChildElements(String name, Namespace ns)

Being explicit in the name may help with getting up to speed quicker, cut
down on errors and legibility.

> Element addContent(String text)
> Element addContent(Element element)
> Element addContent(ProcessingInstruction pi)
> Element addContent(Entity entity)
> Element addContent(Comment comment)
>   Adds the given content to the element.  Replaces the various
> addChild() methods because we're not treating Comments and such as
> "children".  (Before you could call addChild(pi) and then call
> getChildren() and wouldn't find the method returning the pi!)
>
Why do we have addContent(String) when we just added setText().  Would we
not want addText(String) to be consistent?

> boolean removeContent(String text)
> boolean removeContent(Element element)
> boolean removeContent(ProcessingInstruction pi)
> boolean removeContent(Entity entity)
> boolean removeContent(Comment comment)
>   Removes the given item.  Does a == check to compare, so
> presumably the
> item would have been just retrieved with a getMixedContent().
>  Replaces
> the current removeChild() methods that were accepting non-elements.
>
I do not see how removeContent(String) is really going to work.  It seems
you are making an assumption that each String item in the content has a
unique value.  This is not necessarily true.  In that case, you need to be
able to specify which one.

> boolean removeChild(String name)
> boolean removeChild(String name, Namespace ns)
> boolean removeChildren(String name)
> boolean removeChildren(String name, Namespace ns)
> -- or --
> boolean removeChildElement(String name)
> boolean removeChildElement(String name, Namespace ns)
> boolean removeChildElements(String name)
> boolean removeChildElements(String name, Namespace ns)
>   Removes the given child or children elements.  These methods already
> exist.  We'll remove the methods removeChild(String name, String uri)
> and removeChildren(String name, String uri).  Again, let us know which
> naming style you prefer and why.
>
Like the Element versions for same reason as add.  If more that one child
element exists with the same name, removeChildElement(name) would remove the
first one?




More information about the jdom-interest mailing list