[jdom-interest] Element constructors?
Jason Hunter
jhunter at servlets.com
Thu Jul 24 16:54:09 PDT 2003
You can just say:
Element e = new Element("mytag").setText("some content");
-jh-
William Krick wrote:
> Does JDOM have some sort of way to create a new element with content?
>
> I'm envisioning something like...
>
> Element element = new Element("MYTAG", "some content text");
>
>
> I looked through the docs and I don't see anything like that.
>
>
> The alternative is to make helper methods that do the same thing for me...
>
> Element makeElement(String name, String value){
> Element element = new Element(name);
> element.setText(value);
> return element;
> }
>
> of course, since there's not a Variant type in Java yet (as far as I know),
> there would need to be versions for the other basic types...
>
>
> Element makeElement(String name, boolean value){
> Element element = new Element(name);
> element.setText(String.valueOf(value));
> return element;
> }
>
> Element makeElement(String name, int value){
> Element element = new Element(name);
> element.setText(String.valueOf(value));
> return element;
> }
>
> Element makeElement(String name, float value){
> Element element = new Element(name);
> element.setText(String.valueOf(value));
> return element;
> }
>
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com
>
More information about the jdom-interest
mailing list