[jdom-interest] Extending Element

Jason Hunter jhunter at servlets.com
Sat Aug 2 10:18:02 PDT 2003


Attributes aren't returned in the getContent() call.  Nor will you be 
copying the name, namespace, and other features like that.  The standard 
way to extend Element is to "extends Element".  Then you don't have to 
worry about copying things, just extending.

-jh-

Charles Havranek wrote:

> Been searching the archives and can't find a good answer or example for 
> extending an element to add my own helper methods.  Trying :
>    public xdeElement() {
>    }
>    public static void main(String[] arg){
>        org.jdom.Element name = new org.jdom.Element("name");
>        name.setAttribute("language", "English");
>        xdeElement tmp= new xdeElement(name);
>    }
>    /** Create a new Element based on existing Element */
>    public xdeElement(Element existingElement){
>        super.setContent(existingElement.getContent());
>        System.out.println("Original: "+ 
> existingElement.getAttributeValue("language"));
>        System.out.println("This: "+ this.getAttributeValue("language"));
>        System.out.println("Super: "+ super.getAttributeValue("language"));
>    }
> 
> when run, it Outputs :
> Original: English
> This: null
> Super: null
> 
> Sure I'm doing something wrong ... but what?
> 
> Thanks much!
> Charles Havranek
> 
> 
> 
> 
> 
> 
> _______________________________________________
> 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