Package org.exolab.castor.xml.util

Examples of org.exolab.castor.xml.util.XMLFieldDescriptorImpl


    public ChannelDescriptor() {
        super();
        nsURI = "http://jakarta.apache.org/jetspeed/xml/jetspeed-portal-content";
        xmlName = "channel";
        XMLFieldDescriptorImpl  desc           = null;
        XMLFieldHandler         handler        = null;
        FieldValidator          fieldValidator = null;
        //-- initialize attribute descriptors
       
        //-- initialize element descriptors
       
        //-- _topics
        desc = new XMLFieldDescriptorImpl(Topics.class, "_topics", "topics", NodeType.Element);
        handler = (new XMLFieldHandler() {
            public Object getValue( Object object )
                throws IllegalStateException
            {
                Channel target = (Channel) object;
                return target.getTopics();
            }
            public void setValue( Object object, Object value)
                throws IllegalStateException, IllegalArgumentException
            {
                try {
                    Channel target = (Channel) object;
                    target.setTopics( (Topics) value);
                }
                catch (Exception ex) {
                    throw new IllegalStateException(ex.toString());
                }
            }
            public Object newInstance( Object parent ) {
                return new Topics();
            }
        } );
        desc.setHandler(handler);
        desc.setNameSpaceURI("http://jakarta.apache.org/jetspeed/xml/jetspeed-portal-content");
        desc.setMultivalued(false);
        addFieldDescriptor(desc);
       
        //-- validation code for: _topics
        fieldValidator = new FieldValidator();
        desc.setValidator(fieldValidator);
       
        //-- _itemList
        desc = new XMLFieldDescriptorImpl(Item.class, "_itemList", "item", NodeType.Element);
        handler = (new XMLFieldHandler() {
            public Object getValue( Object object )
                throws IllegalStateException
            {
                Channel target = (Channel) object;
                return target.getItem();
            }
            public void setValue( Object object, Object value)
                throws IllegalStateException, IllegalArgumentException
            {
                try {
                    Channel target = (Channel) object;
                    target.addItem( (Item) value);
                }
                catch (Exception ex) {
                    throw new IllegalStateException(ex.toString());
                }
            }
            public Object newInstance( Object parent ) {
                return new Item();
            }
        } );
        desc.setHandler(handler);
        desc.setNameSpaceURI("http://jakarta.apache.org/jetspeed/xml/jetspeed-portal-content");
        desc.setMultivalued(true);
        addFieldDescriptor(desc);
       
        //-- validation code for: _itemList
        fieldValidator = new FieldValidator();
        fieldValidator.setMinOccurs(0);
        desc.setValidator(fieldValidator);
       
        //-- _title
        desc = new XMLFieldDescriptorImpl(java.lang.String.class, "_title", "title", NodeType.Element);
        desc.setImmutable(true);
        handler = (new XMLFieldHandler() {
            public Object getValue( Object object )
                throws IllegalStateException
            {
                Channel target = (Channel) object;
                return target.getTitle();
            }
            public void setValue( Object object, Object value)
                throws IllegalStateException, IllegalArgumentException
            {
                try {
                    Channel target = (Channel) object;
                    target.setTitle( (java.lang.String) value);
                }
                catch (Exception ex) {
                    throw new IllegalStateException(ex.toString());
                }
            }
            public Object newInstance( Object parent ) {
                return null;
            }
        } );
        desc.setHandler(handler);
        desc.setNameSpaceURI("http://jakarta.apache.org/jetspeed/xml/jetspeed-portal-content");
        desc.setRequired(true);
        desc.setMultivalued(false);
        addFieldDescriptor(desc);
       
        //-- validation code for: _title
        fieldValidator = new FieldValidator();
        fieldValidator.setMinOccurs(1);
        { //-- local scope
            StringValidator sv = new StringValidator();
            sv.setWhiteSpace("preserve");
            fieldValidator.setValidator(sv);
        }
        desc.setValidator(fieldValidator);
       
        //-- _link
        desc = new XMLFieldDescriptorImpl(java.lang.String.class, "_link", "link", NodeType.Element);
        desc.setImmutable(true);
        handler = (new XMLFieldHandler() {
            public Object getValue( Object object )
                throws IllegalStateException
            {
                Channel target = (Channel) object;
                return target.getLink();
            }
            public void setValue( Object object, Object value)
                throws IllegalStateException, IllegalArgumentException
            {
                try {
                    Channel target = (Channel) object;
                    target.setLink( (java.lang.String) value);
                }
                catch (Exception ex) {
                    throw new IllegalStateException(ex.toString());
                }
            }
            public Object newInstance( Object parent ) {
                return null;
            }
        } );
        desc.setHandler(handler);
        desc.setNameSpaceURI("http://jakarta.apache.org/jetspeed/xml/jetspeed-portal-content");
        desc.setRequired(true);
        desc.setMultivalued(false);
        addFieldDescriptor(desc);
       
        //-- validation code for: _link
        fieldValidator = new FieldValidator();
        fieldValidator.setMinOccurs(1);
        { //-- local scope
            StringValidator sv = new StringValidator();
            sv.setWhiteSpace("preserve");
            fieldValidator.setValidator(sv);
        }
        desc.setValidator(fieldValidator);
       
        //-- _description
        desc = new XMLFieldDescriptorImpl(java.lang.String.class, "_description", "description", NodeType.Element);
        desc.setImmutable(true);
        handler = (new XMLFieldHandler() {
            public Object getValue( Object object )
                throws IllegalStateException
            {
                Channel target = (Channel) object;
                return target.getDescription();
            }
            public void setValue( Object object, Object value)
                throws IllegalStateException, IllegalArgumentException
            {
                try {
                    Channel target = (Channel) object;
                    target.setDescription( (java.lang.String) value);
                }
                catch (Exception ex) {
                    throw new IllegalStateException(ex.toString());
                }
            }
            public Object newInstance( Object parent ) {
                return null;
            }
        } );
        desc.setHandler(handler);
        desc.setNameSpaceURI("http://jakarta.apache.org/jetspeed/xml/jetspeed-portal-content");
        desc.setRequired(true);
        desc.setMultivalued(false);
        addFieldDescriptor(desc);
       
        //-- validation code for: _description
        fieldValidator = new FieldValidator();
        fieldValidator.setMinOccurs(1);
        { //-- local scope
            StringValidator sv = new StringValidator();
            sv.setWhiteSpace("preserve");
            fieldValidator.setValidator(sv);
        }
        desc.setValidator(fieldValidator);
       
        //-- _image
        desc = new XMLFieldDescriptorImpl(Image.class, "_image", "image", NodeType.Element);
        handler = (new XMLFieldHandler() {
            public Object getValue( Object object )
                throws IllegalStateException
            {
                Channel target = (Channel) object;
                return target.getImage();
            }
            public void setValue( Object object, Object value)
                throws IllegalStateException, IllegalArgumentException
            {
                try {
                    Channel target = (Channel) object;
                    target.setImage( (Image) value);
                }
                catch (Exception ex) {
                    throw new IllegalStateException(ex.toString());
                }
            }
            public Object newInstance( Object parent ) {
                return new Image();
            }
        } );
        desc.setHandler(handler);
        desc.setNameSpaceURI("http://jakarta.apache.org/jetspeed/xml/jetspeed-portal-content");
        desc.setMultivalued(false);
        addFieldDescriptor(desc);
       
        //-- validation code for: _image
        fieldValidator = new FieldValidator();
        desc.setValidator(fieldValidator);
       
        //-- _textinput
        desc = new XMLFieldDescriptorImpl(Textinput.class, "_textinput", "textinput", NodeType.Element);
        handler = (new XMLFieldHandler() {
            public Object getValue( Object object )
                throws IllegalStateException
            {
                Channel target = (Channel) object;
                return target.getTextinput();
            }
            public void setValue( Object object, Object value)
                throws IllegalStateException, IllegalArgumentException
            {
                try {
                    Channel target = (Channel) object;
                    target.setTextinput( (Textinput) value);
                }
                catch (Exception ex) {
                    throw new IllegalStateException(ex.toString());
                }
            }
            public Object newInstance( Object parent ) {
                return new Textinput();
            }
        } );
        desc.setHandler(handler);
        desc.setNameSpaceURI("http://jakarta.apache.org/jetspeed/xml/jetspeed-portal-content");
        desc.setMultivalued(false);
        addFieldDescriptor(desc);
       
        //-- validation code for: _textinput
        fieldValidator = new FieldValidator();
        desc.setValidator(fieldValidator);
       
        //-- _rating
        desc = new XMLFieldDescriptorImpl(java.lang.String.class, "_rating", "rating", NodeType.Element);
        desc.setImmutable(true);
        handler = (new XMLFieldHandler() {
            public Object getValue( Object object )
                throws IllegalStateException
            {
                Channel target = (Channel) object;
                return target.getRating();
            }
            public void setValue( Object object, Object value)
                throws IllegalStateException, IllegalArgumentException
            {
                try {
                    Channel target = (Channel) object;
                    target.setRating( (java.lang.String) value);
                }
                catch (Exception ex) {
                    throw new IllegalStateException(ex.toString());
                }
            }
            public Object newInstance( Object parent ) {
                return null;
            }
        } );
        desc.setHandler(handler);
        desc.setNameSpaceURI("http://jakarta.apache.org/jetspeed/xml/jetspeed-portal-content");
        desc.setMultivalued(false);
        addFieldDescriptor(desc);
       
        //-- validation code for: _rating
        fieldValidator = new FieldValidator();
        { //-- local scope
            StringValidator sv = new StringValidator();
            sv.setWhiteSpace("preserve");
            fieldValidator.setValidator(sv);
        }
        desc.setValidator(fieldValidator);
       
        //-- _copyright
        desc = new XMLFieldDescriptorImpl(java.lang.String.class, "_copyright", "copyright", NodeType.Element);
        desc.setImmutable(true);
        handler = (new XMLFieldHandler() {
            public Object getValue( Object object )
                throws IllegalStateException
            {
                Channel target = (Channel) object;
                return target.getCopyright();
            }
            public void setValue( Object object, Object value)
                throws IllegalStateException, IllegalArgumentException
            {
                try {
                    Channel target = (Channel) object;
                    target.setCopyright( (java.lang.String) value);
                }
                catch (Exception ex) {
                    throw new IllegalStateException(ex.toString());
                }
            }
            public Object newInstance( Object parent ) {
                return null;
            }
        } );
        desc.setHandler(handler);
        desc.setNameSpaceURI("http://jakarta.apache.org/jetspeed/xml/jetspeed-portal-content");
        desc.setMultivalued(false);
        addFieldDescriptor(desc);
       
        //-- validation code for: _copyright
        fieldValidator = new FieldValidator();
        { //-- local scope
            StringValidator sv = new StringValidator();
            sv.setWhiteSpace("preserve");
            fieldValidator.setValidator(sv);
        }
        desc.setValidator(fieldValidator);
       
        //-- _pubDate
        desc = new XMLFieldDescriptorImpl(java.lang.String.class, "_pubDate", "pubDate", NodeType.Element);
        desc.setImmutable(true);
        handler = (new XMLFieldHandler() {
            public Object getValue( Object object )
                throws IllegalStateException
            {
                Channel target = (Channel) object;
                return target.getPubDate();
            }
            public void setValue( Object object, Object value)
                throws IllegalStateException, IllegalArgumentException
            {
                try {
                    Channel target = (Channel) object;
                    target.setPubDate( (java.lang.String) value);
                }
                catch (Exception ex) {
                    throw new IllegalStateException(ex.toString());
                }
            }
            public Object newInstance( Object parent ) {
                return null;
            }
        } );
        desc.setHandler(handler);
        desc.setNameSpaceURI("http://jakarta.apache.org/jetspeed/xml/jetspeed-portal-content");
        desc.setMultivalued(false);
        addFieldDescriptor(desc);
       
        //-- validation code for: _pubDate
        fieldValidator = new FieldValidator();
        { //-- local scope
            StringValidator sv = new StringValidator();
            sv.setWhiteSpace("preserve");
            fieldValidator.setValidator(sv);
        }
        desc.setValidator(fieldValidator);
       
        //-- _lastBuildDate
        desc = new XMLFieldDescriptorImpl(java.lang.String.class, "_lastBuildDate", "lastBuildDate", NodeType.Element);
        desc.setImmutable(true);
        handler = (new XMLFieldHandler() {
            public Object getValue( Object object )
                throws IllegalStateException
            {
                Channel target = (Channel) object;
                return target.getLastBuildDate();
            }
            public void setValue( Object object, Object value)
                throws IllegalStateException, IllegalArgumentException
            {
                try {
                    Channel target = (Channel) object;
                    target.setLastBuildDate( (java.lang.String) value);
                }
                catch (Exception ex) {
                    throw new IllegalStateException(ex.toString());
                }
            }
            public Object newInstance( Object parent ) {
                return null;
            }
        } );
        desc.setHandler(handler);
        desc.setNameSpaceURI("http://jakarta.apache.org/jetspeed/xml/jetspeed-portal-content");
        desc.setMultivalued(false);
        addFieldDescriptor(desc);
       
        //-- validation code for: _lastBuildDate
        fieldValidator = new FieldValidator();
        { //-- local scope
            StringValidator sv = new StringValidator();
            sv.setWhiteSpace("preserve");
            fieldValidator.setValidator(sv);
        }
        desc.setValidator(fieldValidator);
       
        //-- _docs
        desc = new XMLFieldDescriptorImpl(java.lang.String.class, "_docs", "docs", NodeType.Element);
        desc.setImmutable(true);
        handler = (new XMLFieldHandler() {
            public Object getValue( Object object )
                throws IllegalStateException
            {
                Channel target = (Channel) object;
                return target.getDocs();
            }
            public void setValue( Object object, Object value)
                throws IllegalStateException, IllegalArgumentException
            {
                try {
                    Channel target = (Channel) object;
                    target.setDocs( (java.lang.String) value);
                }
                catch (Exception ex) {
                    throw new IllegalStateException(ex.toString());
                }
            }
            public Object newInstance( Object parent ) {
                return null;
            }
        } );
        desc.setHandler(handler);
        desc.setNameSpaceURI("http://jakarta.apache.org/jetspeed/xml/jetspeed-portal-content");
        desc.setMultivalued(false);
        addFieldDescriptor(desc);
       
        //-- validation code for: _docs
        fieldValidator = new FieldValidator();
        { //-- local scope
            StringValidator sv = new StringValidator();
            sv.setWhiteSpace("preserve");
            fieldValidator.setValidator(sv);
        }
        desc.setValidator(fieldValidator);
       
        //-- _managingEditor
        desc = new XMLFieldDescriptorImpl(java.lang.String.class, "_managingEditor", "managingEditor", NodeType.Element);
        desc.setImmutable(true);
        handler = (new XMLFieldHandler() {
            public Object getValue( Object object )
                throws IllegalStateException
            {
                Channel target = (Channel) object;
                return target.getManagingEditor();
            }
            public void setValue( Object object, Object value)
                throws IllegalStateException, IllegalArgumentException
            {
                try {
                    Channel target = (Channel) object;
                    target.setManagingEditor( (java.lang.String) value);
                }
                catch (Exception ex) {
                    throw new IllegalStateException(ex.toString());
                }
            }
            public Object newInstance( Object parent ) {
                return null;
            }
        } );
        desc.setHandler(handler);
        desc.setNameSpaceURI("http://jakarta.apache.org/jetspeed/xml/jetspeed-portal-content");
        desc.setMultivalued(false);
        addFieldDescriptor(desc);
       
        //-- validation code for: _managingEditor
        fieldValidator = new FieldValidator();
        { //-- local scope
            StringValidator sv = new StringValidator();
            sv.setWhiteSpace("preserve");
            fieldValidator.setValidator(sv);
        }
        desc.setValidator(fieldValidator);
       
        //-- _webMaster
        desc = new XMLFieldDescriptorImpl(java.lang.String.class, "_webMaster", "webMaster", NodeType.Element);
        desc.setImmutable(true);
        handler = (new XMLFieldHandler() {
            public Object getValue( Object object )
                throws IllegalStateException
            {
                Channel target = (Channel) object;
                return target.getWebMaster();
            }
            public void setValue( Object object, Object value)
                throws IllegalStateException, IllegalArgumentException
            {
                try {
                    Channel target = (Channel) object;
                    target.setWebMaster( (java.lang.String) value);
                }
                catch (Exception ex) {
                    throw new IllegalStateException(ex.toString());
                }
            }
            public Object newInstance( Object parent ) {
                return null;
            }
        } );
        desc.setHandler(handler);
        desc.setNameSpaceURI("http://jakarta.apache.org/jetspeed/xml/jetspeed-portal-content");
        desc.setMultivalued(false);
        addFieldDescriptor(desc);
       
        //-- validation code for: _webMaster
        fieldValidator = new FieldValidator();
        { //-- local scope
            StringValidator sv = new StringValidator();
            sv.setWhiteSpace("preserve");
            fieldValidator.setValidator(sv);
        }
        desc.setValidator(fieldValidator);
       
        //-- _language
        desc = new XMLFieldDescriptorImpl(java.lang.String.class, "_language", "language", NodeType.Element);
        desc.setImmutable(true);
        handler = (new XMLFieldHandler() {
            public Object getValue( Object object )
                throws IllegalStateException
            {
                Channel target = (Channel) object;
                return target.getLanguage();
            }
            public void setValue( Object object, Object value)
                throws IllegalStateException, IllegalArgumentException
            {
                try {
                    Channel target = (Channel) object;
                    target.setLanguage( (java.lang.String) value);
                }
                catch (Exception ex) {
                    throw new IllegalStateException(ex.toString());
                }
            }
            public Object newInstance( Object parent ) {
                return null;
            }
        } );
        desc.setHandler(handler);
        desc.setNameSpaceURI("http://jakarta.apache.org/jetspeed/xml/jetspeed-portal-content");
        desc.setMultivalued(false);
        addFieldDescriptor(desc);
       
        //-- validation code for: _language
        fieldValidator = new FieldValidator();
        { //-- local scope
            StringValidator sv = new StringValidator();
            sv.setWhiteSpace("preserve");
            fieldValidator.setValidator(sv);
        }
        desc.setValidator(fieldValidator);
       
    } //-- org.apache.jetspeed.xml.api.jcm.ChannelDescriptor()
View Full Code Here


    //----------------/

    public DateClassDescriptor() {
        super();
        if (_contentDescriptor == null) {
            _contentDescriptor = new XMLFieldDescriptorImpl(String.class,
                "content", "content", NodeType.Text);

            _contentDescriptor.setImmutable(true);
            //-- setHandler
            _contentDescriptor.setHandler(new DateFieldHandler(
View Full Code Here

    //----------------/

    public SQLTimeClassDescriptor() {
        super();
        if (_contentDescriptor == null) {
            _contentDescriptor = new XMLFieldDescriptorImpl(String.class,
                "content", "content", NodeType.Text);

            _contentDescriptor.setImmutable(true);
            //-- setHandler
            SQLTimeFieldHandler sqlTimeHandler = new SQLTimeFieldHandler();
View Full Code Here

        super();

        _xmlName = xmlName;

        //-- Create FieldDescriptor
        XMLFieldDescriptorImpl _desc
            = new XMLFieldDescriptorImpl(Object.class, "item", _xmlName,
                NodeType.Element);

        _desc.setMultivalued(true);
        _desc.setMatches("*");
        _desc.setHandler( new XMLFieldHandler() {

            public Object getValue( Object object )
                throws IllegalStateException
            {
                List list = (java.util.List)object;
View Full Code Here

       
        if (_fields == null) {
           
           
            //-- Create FieldDescriptor for country
            XMLFieldDescriptorImpl fdCountry
                = new XMLFieldDescriptorImpl(String.class, "country", "country",
                    NodeType.Attribute);
   
            fdCountry.setConstructorArgumentIndex(1);
            fdCountry.setHandler( new XMLFieldHandler() {
   
                public Object getValue( Object object )
                    throws IllegalStateException
                {
                    return ((java.util.Locale)object).getCountry();
                }
   
                public void setValue( Object object, Object value)
                    throws IllegalStateException, IllegalArgumentException
                {
                    //-- do nothing, can only be set via constructor
                }
                public Object newInstance( Object parent ) {
                    //-- not applicable
                    return null;
                }
            } );
               
            //-- Create FieldDescriptor for language
            XMLFieldDescriptorImpl fdLanguage
                = new XMLFieldDescriptorImpl(String.class, "language", "language",
                    NodeType.Attribute);
   
            fdLanguage.setConstructorArgumentIndex(0);
            fdLanguage.setHandler( new XMLFieldHandler() {
           
   
                public Object getValue( Object object )
                    throws IllegalStateException
                {
View Full Code Here

    public ParamDescriptor() {
        super();
        nsURI = "http://castor.exolab.org/";
        xmlName = "param";
        XMLFieldDescriptorImpl  desc           = null;
        XMLFieldHandler         handler        = null;
        FieldValidator          fieldValidator = null;
        //-- initialize attribute descriptors

        //-- _name
        desc = new XMLFieldDescriptorImpl(java.lang.String.class, "_name", "name", NodeType.Attribute);
        desc.setImmutable(true);
        handler = (new XMLFieldHandler() {
            public Object getValue( Object object )
                throws IllegalStateException
            {
                Param target = (Param) object;
                return target.getName();
            }
            public void setValue( Object object, Object value)
                throws IllegalStateException, IllegalArgumentException
            {
                try {
                    Param target = (Param) object;
                    target.setName( (java.lang.String) value);
                }
                catch (Exception ex) {
                    throw new IllegalStateException(ex.toString());
                }
            }
            public Object newInstance( Object parent ) {
                return null;
            }
        } );
        desc.setHandler(handler);
        desc.setNameSpaceURI("http://castor.exolab.org/");
        desc.setRequired(true);
        addFieldDescriptor(desc);

        //-- validation code for: _name
        fieldValidator = new FieldValidator();
        fieldValidator.setMinOccurs(1);
        { //-- local scope
            StringValidator sv = new StringValidator();
            sv.setWhiteSpace("preserve");
            fieldValidator.setValidator(sv);
        }
        desc.setValidator(fieldValidator);

        //-- _value
        desc = new XMLFieldDescriptorImpl(java.lang.String.class, "_value", "value", NodeType.Attribute);
        desc.setImmutable(true);
        handler = (new XMLFieldHandler() {
            public Object getValue( Object object )
                throws IllegalStateException
            {
                Param target = (Param) object;
                return target.getValue();
            }
            public void setValue( Object object, Object value)
                throws IllegalStateException, IllegalArgumentException
            {
                try {
                    Param target = (Param) object;
                    target.setValue( (java.lang.String) value);
                }
                catch (Exception ex) {
                    throw new IllegalStateException(ex.toString());
                }
            }
            public Object newInstance( Object parent ) {
                return null;
            }
        } );
        desc.setHandler(handler);
        desc.setNameSpaceURI("http://castor.exolab.org/");
        desc.setRequired(true);
        addFieldDescriptor(desc);

        //-- validation code for: _value
        fieldValidator = new FieldValidator();
        fieldValidator.setMinOccurs(1);
        { //-- local scope
            StringValidator sv = new StringValidator();
            sv.setWhiteSpace("preserve");
            fieldValidator.setValidator(sv);
        }
        desc.setValidator(fieldValidator);

        //-- initialize element descriptors

    } //-- org.exolab.castor.mapping.xml.ParamDescriptor()
View Full Code Here

    public FieldMappingDescriptor() {
        super();
        nsURI = "http://castor.exolab.org/";
        xmlName = "field";
        XMLFieldDescriptorImpl  desc           = null;
        XMLFieldHandler         handler        = null;
        FieldValidator          fieldValidator = null;
        //-- initialize attribute descriptors

        //-- _name
        desc = new XMLFieldDescriptorImpl(java.lang.String.class, "_name", "name", NodeType.Attribute);
        handler = (new XMLFieldHandler() {
            public Object getValue( Object object )
                throws IllegalStateException
            {
                FieldMapping target = (FieldMapping) object;
                return target.getName();
            }
            public void setValue( Object object, Object value)
                throws IllegalStateException, IllegalArgumentException
            {
                try {
                    FieldMapping target = (FieldMapping) object;
                    target.setName( (java.lang.String) value);
                }
                catch (Exception ex) {
                    throw new IllegalStateException(ex.toString());
                }
            }
            public Object newInstance( Object parent ) {
                return new java.lang.String();
            }
        } );
        desc.setHandler(handler);
        desc.setNameSpaceURI("http://castor.exolab.org/");
        desc.setRequired(true);
        addFieldDescriptor(desc);

        //-- validation code for: _name
        fieldValidator = new FieldValidator();
        fieldValidator.setMinOccurs(1);
        fieldValidator.setValidator(new NameValidator(NameValidator.CDATA));
        desc.setValidator(fieldValidator);

        //-- _type
        desc = new XMLFieldDescriptorImpl(java.lang.String.class, "_type", "type", NodeType.Attribute);
        handler = (new XMLFieldHandler() {
            public Object getValue( Object object )
                throws IllegalStateException
            {
                FieldMapping target = (FieldMapping) object;
                return target.getType();
            }
            public void setValue( Object object, Object value)
                throws IllegalStateException, IllegalArgumentException
            {
                try {
                    FieldMapping target = (FieldMapping) object;
                    target.setType( (java.lang.String) value);
                }
                catch (Exception ex) {
                    throw new IllegalStateException(ex.toString());
                }
            }
            public Object newInstance( Object parent ) {
                return new java.lang.String();
            }
        } );
        desc.setHandler(handler);
        desc.setNameSpaceURI("http://castor.exolab.org/");
        addFieldDescriptor(desc);

        //-- validation code for: _type
        fieldValidator = new FieldValidator();
        fieldValidator.setValidator(new NameValidator(NameValidator.CDATA));
        desc.setValidator(fieldValidator);

        //-- _required
        desc = new XMLFieldDescriptorImpl(java.lang.Boolean.TYPE, "_required", "required", NodeType.Attribute);
        handler = (new XMLFieldHandler() {
            public Object getValue( Object object )
                throws IllegalStateException
            {
                FieldMapping target = (FieldMapping) object;
                if(!target.hasRequired())
                    return null;
                return new Boolean(target.getRequired());
            }
            public void setValue( Object object, Object value)
                throws IllegalStateException, IllegalArgumentException
            {
                try {
                    FieldMapping target = (FieldMapping) object;
                    // if null, use delete method for optional primitives
                    if (value == null) {
                        target.deleteRequired();
                        return;
                    }
                    target.setRequired( ((Boolean)value).booleanValue());
                }
                catch (Exception ex) {
                    throw new IllegalStateException(ex.toString());
                }
            }
            public Object newInstance( Object parent ) {
                return null;
            }
        } );
        desc.setHandler(handler);
        desc.setNameSpaceURI("http://castor.exolab.org/");
        addFieldDescriptor(desc);

        //-- validation code for: _required
        fieldValidator = new FieldValidator();
        desc.setValidator(fieldValidator);

        //-- _transient
        desc = new XMLFieldDescriptorImpl(java.lang.Boolean.TYPE, "_transient", "transient", NodeType.Attribute);
        handler = (new XMLFieldHandler() {
            public Object getValue( Object object )
                throws IllegalStateException
            {
                FieldMapping target = (FieldMapping) object;
                if(!target.hasTransient())
                    return null;
                return new Boolean(target.getTransient());
            }
            public void setValue( Object object, Object value)
                throws IllegalStateException, IllegalArgumentException
            {
                try {
                    FieldMapping target = (FieldMapping) object;
                    // if null, use delete method for optional primitives
                    if (value == null) {
                        target.deleteTransient();
                        return;
                    }
                    target.setTransient( ((Boolean)value).booleanValue());
                }
                catch (Exception ex) {
                    throw new IllegalStateException(ex.toString());
                }
            }
            public Object newInstance( Object parent ) {
                return null;
            }
        } );
        desc.setHandler(handler);
        desc.setNameSpaceURI("http://castor.exolab.org/");
        addFieldDescriptor(desc);

        //-- validation code for: _transient
        fieldValidator = new FieldValidator();
        desc.setValidator(fieldValidator);

        //-- _direct
        desc = new XMLFieldDescriptorImpl(java.lang.Boolean.TYPE, "_direct", "direct", NodeType.Attribute);
        handler = (new XMLFieldHandler() {
            public Object getValue( Object object )
                throws IllegalStateException
            {
                FieldMapping target = (FieldMapping) object;
                if(!target.hasDirect())
                    return null;
                return new Boolean(target.getDirect());
            }
            public void setValue( Object object, Object value)
                throws IllegalStateException, IllegalArgumentException
            {
                try {
                    FieldMapping target = (FieldMapping) object;
                    // if null, use delete method for optional primitives
                    if (value == null) {
                        target.deleteDirect();
                        return;
                    }
                    target.setDirect( ((Boolean)value).booleanValue());
                }
                catch (Exception ex) {
                    throw new IllegalStateException(ex.toString());
                }
            }
            public Object newInstance( Object parent ) {
                return null;
            }
        } );
        desc.setHandler(handler);
        desc.setNameSpaceURI("http://castor.exolab.org/");
        addFieldDescriptor(desc);

        //-- validation code for: _direct
        fieldValidator = new FieldValidator();
        desc.setValidator(fieldValidator);


        //-- _lazy
        desc = new XMLFieldDescriptorImpl(java.lang.Boolean.TYPE, "_lazy", "lazy", NodeType.Attribute);
        handler = (new XMLFieldHandler() {
            public Object getValue( Object object )
                throws IllegalStateException
            {
                FieldMapping target = (FieldMapping) object;
                if(!target.hasLazy())
                    return null;
                return new Boolean(target.getLazy());
            }
            public void setValue( Object object, Object value)
                throws IllegalStateException, IllegalArgumentException
            {
                try {
                    FieldMapping target = (FieldMapping) object;
                    // if null, use delete method for optional primitives
                    if (value == null) {
                        target.deleteLazy();
                        return;
                    }
                    target.setLazy( ((Boolean)value).booleanValue());
                }
                catch (Exception ex) {
                    throw new IllegalStateException(ex.toString());
                }
            }
            public Object newInstance( Object parent ) {
                return null;
            }
        } );
        desc.setHandler(handler);
        desc.setNameSpaceURI("http://castor.exolab.org/");
        addFieldDescriptor(desc);

        //-- validation code for: _lazy
        fieldValidator = new FieldValidator();
        desc.setValidator(fieldValidator);

        //-- _container
        desc = new XMLFieldDescriptorImpl(java.lang.Boolean.TYPE, "_container", "container", NodeType.Attribute);
        handler = (new XMLFieldHandler() {
            public Object getValue( Object object )
                throws IllegalStateException
            {
                FieldMapping target = (FieldMapping) object;
                if(!target.hasContainer())
                    return null;
                return new Boolean(target.getContainer());
            }
            public void setValue( Object object, Object value)
                throws IllegalStateException, IllegalArgumentException
            {
                try {
                    FieldMapping target = (FieldMapping) object;
                    // if null, use delete method for optional primitives
                    if (value == null) {
                        target.deleteContainer();
                        return;
                    }
                    target.setContainer( ((Boolean)value).booleanValue());
                }
                catch (Exception ex) {
                    throw new IllegalStateException(ex.toString());
                }
            }
            public Object newInstance( Object parent ) {
                return null;
            }
        } );
        desc.setHandler(handler);
        desc.setNameSpaceURI("http://castor.exolab.org/");
        addFieldDescriptor(desc);

        //-- validation code for: _container
        fieldValidator = new FieldValidator();
        desc.setValidator(fieldValidator);

        //-- _getMethod
        desc = new XMLFieldDescriptorImpl(java.lang.String.class, "_getMethod", "get-method", NodeType.Attribute);
        handler = (new XMLFieldHandler() {
            public Object getValue( Object object )
                throws IllegalStateException
            {
                FieldMapping target = (FieldMapping) object;
                return target.getGetMethod();
            }
            public void setValue( Object object, Object value)
                throws IllegalStateException, IllegalArgumentException
            {
                try {
                    FieldMapping target = (FieldMapping) object;
                    target.setGetMethod( (java.lang.String) value);
                }
                catch (Exception ex) {
                    throw new IllegalStateException(ex.toString());
                }
            }
            public Object newInstance( Object parent ) {
                return new java.lang.String();
            }
        } );
        desc.setHandler(handler);
        desc.setNameSpaceURI("http://castor.exolab.org/");
        addFieldDescriptor(desc);

        //-- validation code for: _getMethod
        fieldValidator = new FieldValidator();
        fieldValidator.setValidator(new NameValidator(NameValidator.CDATA));
        desc.setValidator(fieldValidator);

        //-- _handler
        desc = new XMLFieldDescriptorImpl(java.lang.String.class, "_handler", "handler", NodeType.Attribute);
        handler = (new XMLFieldHandler() {
            public Object getValue( Object object )
                throws IllegalStateException
            {
                FieldMapping target = (FieldMapping) object;
                return target.getHandler();
            }
            public void setValue( Object object, Object value)
                throws IllegalStateException, IllegalArgumentException
            {
                try {
                    FieldMapping target = (FieldMapping) object;
                    target.setHandler( (java.lang.String) value);
                }
                catch (Exception ex) {
                    throw new IllegalStateException(ex.toString());
                }
            }
            public Object newInstance( Object parent ) {
                return new java.lang.String();
            }
        } );
        desc.setHandler(handler);
        desc.setNameSpaceURI("http://castor.exolab.org/");
        addFieldDescriptor(desc);

        //-- validation code for: _handler
        fieldValidator = new FieldValidator();
        fieldValidator.setValidator(new NameValidator(NameValidator.CDATA));
        desc.setValidator(fieldValidator);
       
        //-- _hasMethod
        desc = new XMLFieldDescriptorImpl(java.lang.String.class, "_hasMethod", "has-method", NodeType.Attribute);
        handler = (new XMLFieldHandler() {
            public Object getValue( Object object )
                throws IllegalStateException
            {
                FieldMapping target = (FieldMapping) object;
                return target.getHasMethod();
            }
            public void setValue( Object object, Object value)
                throws IllegalStateException, IllegalArgumentException
            {
                try {
                    FieldMapping target = (FieldMapping) object;
                    target.setHasMethod( (java.lang.String) value);
                }
                catch (Exception ex) {
                    throw new IllegalStateException(ex.toString());
                }
            }
            public Object newInstance( Object parent ) {
                return new java.lang.String();
            }
        } );
        desc.setHandler(handler);
        desc.setNameSpaceURI("http://castor.exolab.org/");
        addFieldDescriptor(desc);

        //-- validation code for: _hasMethod
        fieldValidator = new FieldValidator();
        fieldValidator.setValidator(new NameValidator(NameValidator.CDATA));
        desc.setValidator(fieldValidator);
       
        //-- _setMethod
        desc = new XMLFieldDescriptorImpl(java.lang.String.class, "_setMethod", "set-method", NodeType.Attribute);
        handler = (new XMLFieldHandler() {
            public Object getValue( Object object )
                throws IllegalStateException
            {
                FieldMapping target = (FieldMapping) object;
                return target.getSetMethod();
            }
            public void setValue( Object object, Object value)
                throws IllegalStateException, IllegalArgumentException
            {
                try {
                    FieldMapping target = (FieldMapping) object;
                    target.setSetMethod( (java.lang.String) value);
                }
                catch (Exception ex) {
                    throw new IllegalStateException(ex.toString());
                }
            }
            public Object newInstance( Object parent ) {
                return new java.lang.String();
            }
        } );
        desc.setHandler(handler);
        desc.setNameSpaceURI("http://castor.exolab.org/");
        addFieldDescriptor(desc);

        //-- validation code for: _setMethod
        fieldValidator = new FieldValidator();
        fieldValidator.setValidator(new NameValidator(NameValidator.CDATA));
        desc.setValidator(fieldValidator);

        //-- _createMethod
        desc = new XMLFieldDescriptorImpl(java.lang.String.class, "_createMethod", "create-method", NodeType.Attribute);
        handler = (new XMLFieldHandler() {
            public Object getValue( Object object )
                throws IllegalStateException
            {
                FieldMapping target = (FieldMapping) object;
                return target.getCreateMethod();
            }
            public void setValue( Object object, Object value)
                throws IllegalStateException, IllegalArgumentException
            {
                try {
                    FieldMapping target = (FieldMapping) object;
                    target.setCreateMethod( (java.lang.String) value);
                }
                catch (Exception ex) {
                    throw new IllegalStateException(ex.toString());
                }
            }
            public Object newInstance( Object parent ) {
                return new java.lang.String();
            }
        } );
        desc.setHandler(handler);
        desc.setNameSpaceURI("http://castor.exolab.org/");
        addFieldDescriptor(desc);

        //-- validation code for: _createMethod
        fieldValidator = new FieldValidator();
        fieldValidator.setValidator(new NameValidator(NameValidator.CDATA));
        desc.setValidator(fieldValidator);

        //-- _collection
        desc = new XMLFieldDescriptorImpl(org.exolab.castor.mapping.xml.types.CollectionType.class, "_collection", "collection", NodeType.Attribute);
        handler = (new XMLFieldHandler() {
            public Object getValue( Object object )
                throws IllegalStateException
            {
                FieldMapping target = (FieldMapping) object;
                return target.getCollection();
            }
            public void setValue( Object object, Object value)
                throws IllegalStateException, IllegalArgumentException
            {
                try {
                    FieldMapping target = (FieldMapping) object;
                    target.setCollection( (org.exolab.castor.mapping.xml.types.CollectionType) value);
                }
                catch (Exception ex) {
                    throw new IllegalStateException(ex.toString());
                }
            }
            public Object newInstance( Object parent ) {
                return null;
            }
        } );
        desc.setHandler( new EnumFieldHandler(org.exolab.castor.mapping.xml.types.CollectionType.class, handler));
        desc.setImmutable(true);
        desc.setNameSpaceURI("http://castor.exolab.org/");
        addFieldDescriptor(desc);

        //-- validation code for: _collection
        fieldValidator = new FieldValidator();
        desc.setValidator(fieldValidator);

        //-- initialize element descriptors

        //-- _description
        desc = new XMLFieldDescriptorImpl(java.lang.String.class, "_description", "description", NodeType.Element);
        desc.setImmutable(true);
        handler = (new XMLFieldHandler() {
            public Object getValue( Object object )
                throws IllegalStateException
            {
                FieldMapping target = (FieldMapping) object;
                return target.getDescription();
            }
            public void setValue( Object object, Object value)
                throws IllegalStateException, IllegalArgumentException
            {
                try {
                    FieldMapping target = (FieldMapping) object;
                    target.setDescription( (java.lang.String) value);
                }
                catch (Exception ex) {
                    throw new IllegalStateException(ex.toString());
                }
            }
            public Object newInstance( Object parent ) {
                return null;
            }
        } );
        desc.setHandler(handler);
        desc.setNameSpaceURI("http://castor.exolab.org/");
        desc.setMultivalued(false);
        addFieldDescriptor(desc);

        //-- validation code for: _description
        fieldValidator = new FieldValidator();
        { //-- local scope
            StringValidator sv = new StringValidator();
            sv.setWhiteSpace("preserve");
            fieldValidator.setValidator(sv);
        }
        desc.setValidator(fieldValidator);

        //-- _sql
        desc = new XMLFieldDescriptorImpl(Sql.class, "_sql", "sql", NodeType.Element);
        handler = (new XMLFieldHandler() {
            public Object getValue( Object object )
                throws IllegalStateException
            {
                FieldMapping target = (FieldMapping) object;
                return target.getSql();
            }
            public void setValue( Object object, Object value)
                throws IllegalStateException, IllegalArgumentException
            {
                try {
                    FieldMapping target = (FieldMapping) object;
                    target.setSql( (Sql) value);
                }
                catch (Exception ex) {
                    throw new IllegalStateException(ex.toString());
                }
            }
            public Object newInstance( Object parent ) {
                return new Sql();
            }
        } );
        desc.setHandler(handler);
        desc.setNameSpaceURI("http://castor.exolab.org/");
        desc.setMultivalued(false);
        addFieldDescriptor(desc);

        //-- validation code for: _sql
        fieldValidator = new FieldValidator();
        desc.setValidator(fieldValidator);

        //-- _bindXml
        desc = new XMLFieldDescriptorImpl(BindXml.class, "_bindXml", "bind-xml", NodeType.Element);
        //BACKWARD COMPATIBILITY
        desc.setMatches("bind-xml xml");
        handler = (new XMLFieldHandler() {
            public Object getValue( Object object )
                throws IllegalStateException
            {
                FieldMapping target = (FieldMapping) object;
                return target.getBindXml();
            }
            public void setValue( Object object, Object value)
                throws IllegalStateException, IllegalArgumentException
            {
                try {
                    FieldMapping target = (FieldMapping) object;
                    target.setBindXml( (BindXml) value);
                }
                catch (Exception ex) {
                    throw new IllegalStateException(ex.toString());
                }
            }
            public Object newInstance( Object parent ) {
                return new BindXml();
            }
        } );
        desc.setHandler(handler);
        desc.setNameSpaceURI("http://castor.exolab.org/");
        desc.setMultivalued(false);
        addFieldDescriptor(desc);

        //-- validation code for: _bindXml
        fieldValidator = new FieldValidator();
        desc.setValidator(fieldValidator);

        //-- _ldap
        desc = new XMLFieldDescriptorImpl(Ldap.class, "_ldap", "ldap", NodeType.Element);
        handler = (new XMLFieldHandler() {
            public Object getValue( Object object )
                throws IllegalStateException
            {
                FieldMapping target = (FieldMapping) object;
                return target.getLdap();
            }
            public void setValue( Object object, Object value)
                throws IllegalStateException, IllegalArgumentException
            {
                try {
                    FieldMapping target = (FieldMapping) object;
                    target.setLdap( (Ldap) value);
                }
                catch (Exception ex) {
                    throw new IllegalStateException(ex.toString());
                }
            }
            public Object newInstance( Object parent ) {
                return new Ldap();
            }
        } );
        desc.setHandler(handler);
        desc.setNameSpaceURI("http://castor.exolab.org/");
        desc.setMultivalued(false);
        addFieldDescriptor(desc);

        //-- validation code for: _ldap
        fieldValidator = new FieldValidator();
        desc.setValidator(fieldValidator);

    } //-- org.exolab.castor.mapping.xml.FieldMappingDescriptor()
View Full Code Here

            catch (MappingException mx) {
                throw new MarshalException(mx);
            }
                   
           
            XMLFieldDescriptorImpl fieldDesc
                = createFieldDescriptor(type, methodSet.fieldName, xmlName);
                       
            if (isCollection) {
                fieldDesc.setMultivalued(true);
                fieldDesc.setNodeType(NodeType.Element);
            }
           
            //-- check for instances of java.util.Date
            if (java.util.Date.class.isAssignableFrom(type)) {
                //handler = new DateFieldHandler(handler);
                if (!customHandler) {
                    dateDescriptors.add(fieldDesc);
                }
            }
           
            fieldDesc.setHandler(handler);
           
            //-- Wrap collections?
            if (isCollection && _wrapCollectionsInContainer) {
                String fieldName = COLLECTION_WRAPPER_PREFIX + methodSet.fieldName;
                //-- If we have a field 'c' that is a collection and
                //-- we want to wrap that field in an element <e>, we
                //-- need to create a field descriptor for
                //-- an object that represents the element <e> and
                //-- acts as a go-between from the parent of 'c'
                //-- denoted as P(c) and 'c' itself
                // 
                //   object model: P(c) -> c
                //   xml : <p><e><c></e><p>
               
                //-- Make new class descriptor for the field that
                //-- will represent the container element <e>
                Class cType = ContainerElement.class;
                XMLClassDescriptorImpl containerClassDesc = new XMLClassDescriptorImpl(cType);
               
                //-- add the field descriptor to our new class descriptor
                containerClassDesc.addFieldDescriptor(fieldDesc);       
                //-- nullify xmlName so that auto-naming will be enabled,
                //-- we can't do this in the constructor because
                //-- XMLFieldDescriptorImpl will create a default one.
                fieldDesc.setXMLName(null);
                fieldDesc.setMatches("*");
                               
                //-- wrap the field handler in a special container field
                //-- handler that will actually do the delgation work
                FieldHandler cHandler = new ContainerFieldHandler(handler);
                fieldDesc.setHandler(cHandler);
               
                fieldDesc = createFieldDescriptor(cType, fieldName, xmlName);
                fieldDesc.setClassDescriptor(containerClassDesc);
                fieldDesc.setHandler(cHandler);
            }
            //-- add FieldDescriptor to ClassDescriptor
            classDesc.addFieldDescriptor(fieldDesc);

           
        } //-- end of method loop
       
        //-- If we didn't find any methods we can try
        //-- direct field access
        if (methodCount == 0) {          
           
            Field[] fields = c.getFields();           
            Hashtable descriptors = new Hashtable();
            for (int i = 0; i < fields.length; i++) {               
                Field field = fields[i];
               
                Class owner = field.getDeclaringClass();
               
                //-- ignore fields from super-class, that will be
                //-- introspected separately, if necessary
                if (owner != c) {
                    //-- if declaring class is anything but
                    //-- an interface, than just continue,
                    //-- the field comes from a super class
                    //-- (e.g. java.lang.Object)
                    if (!owner.isInterface()) continue;
                   
                    //-- owner is an interface, is it an
                    //-- interface this class implements
                    //-- or a parent class?
                    if (interfaces.length > 0) {
                        boolean found = false;
                        for (int count = 0; count < interfaces.length; count++) {
                            if (interfaces[count] == owner) {
                                found = true;
                                break;
                            }
                        }
                        if (!found) continue;
                    }
                }
           
                //-- make sure field is not transient or static final
                int modifiers = field.getModifiers();
                if (Modifier.isTransient(modifiers)) continue;
                if (Modifier.isFinal(modifiers) &&
                    Modifier.isStatic(modifiers))
                    continue;
               
                Class type = field.getType();
               
               
               
                if (!isDescriptable(type)) continue;
               
                //-- Built-in support for JDK 1.1 Collections
                //-- we need to a pluggable interface for
                //-- JDK 1.2+
                boolean isCollection = isCollection(type);
               
               
                TypeInfo typeInfo = null;
                CollectionHandler colHandler = null;
               
                //-- If the type is a collection and there is no add method,
                //-- then we obtain a CollectionHandler
                if (isCollection) {
                   
                    try {
                        colHandler = CollectionHandlers.getHandler(type);
                    }
                    catch(MappingException mx) {
                        //-- No CollectionHandler available, continue
                        //-- without one...
                    }
                   
                    //-- Find component type
                    if (type.isArray()) {
                        //-- Byte arrays are handled as a special case
                        //-- so don't use CollectionHandler
                        if (type.getComponentType() == Byte.TYPE) {
                            colHandler = null;
                        }
                        else type = type.getComponentType();
                       
                    }
                }
               
                String fieldName = field.getName();
                String xmlName = _naming.toXMLName(fieldName);
               
                //-- Create FieldHandler first, before the XMLFieldDescriptor
                //-- in case we need to use a custom handler
               
                typeInfo = new TypeInfo(type, null, null, false, null, colHandler);
               
                FieldHandler handler = null;
                boolean customHandler = false;
                try {
                    handler = new FieldHandlerImpl(field, typeInfo);
                   
                    //-- handle Hashtable/Map
                    if (isCollection && _saveMapKeys && isMapCollection(type)) {
                        ((FieldHandlerImpl)handler).setConvertFrom(new IdentityConvertor());
                    }
                       
                    //-- look for GeneralizedFieldHandler
                    FieldHandlerFactory factory = getHandlerFactory(type);
                    if (factory != null) {
                        GeneralizedFieldHandler gfh = factory.createFieldHandler(type);
                        if (gfh != null) {
                            gfh.setFieldHandler(handler);
                            handler = gfh;
                            customHandler = true;
                            //-- swap type with the type specified by the
                            //-- custom field handler
                            if (gfh.getFieldType() != null) {
                                type = gfh.getFieldType();
                            }
                        }
                    }
                }
                catch (MappingException mx) {
                    throw new MarshalException(mx);
                }
               
                XMLFieldDescriptorImpl fieldDesc =
                        createFieldDescriptor(type, fieldName, xmlName);
                       
                if (isCollection) {
                    fieldDesc.setNodeType(NodeType.Element);
                    fieldDesc.setMultivalued(true);
                }
                descriptors.put(xmlName, fieldDesc);
                classDesc.addFieldDescriptor(fieldDesc);
                fieldDesc.setHandler(handler);
                  
                //-- check for instances of java.util.Date
                if (java.util.Date.class.isAssignableFrom(type)) {
                    if (!customHandler) {
                        dateDescriptors.add(fieldDesc);
                    }
                }
               
            }           
        } //-- end of direct field access
       
       
        //-- A temporary fix for java.util.Date
        if (dateDescriptors != null) {
            for (int i = 0; i < dateDescriptors.size(); i++) {
                XMLFieldDescriptorImpl fieldDesc =
                    (XMLFieldDescriptorImpl) dateDescriptors.get(i);
                FieldHandler handler = fieldDesc.getHandler();
                fieldDesc.setImmutable(true);
                DateFieldHandler dfh = new DateFieldHandler(handler);
               
                //-- patch for java.sql.Date
                Class type = fieldDesc.getFieldType();
                if (java.sql.Date.class.isAssignableFrom(type)) {
                    dfh.setUseSQLDate(true);
                }
                fieldDesc.setHandler(dfh);
            }
        }
       
        //-- Add reference to superclass...if necessary
        if ((superClass != null) &&
View Full Code Here

   
    private XMLFieldDescriptorImpl createFieldDescriptor
        (Class type, String fieldName, String xmlName)
    {

        XMLFieldDescriptorImpl fieldDesc =
            new XMLFieldDescriptorImpl(type, fieldName, xmlName, null);
           
        if (type.isArray()) {
            fieldDesc.setNodeType(NodeType.Element);
        }
        //-- primitive types are converted to attributes by default
        else if (type.isPrimitive()) {
            fieldDesc.setNodeType(_primitiveNodeType);
        }
        else {
            fieldDesc.setNodeType(NodeType.Element);
        }
       
        //-- wildcard?
        if (type == java.lang.Object.class) {
            fieldDesc.setMatches(xmlName + " *");
        }
       
        return fieldDesc;
    } //-- createFieldDescriptor
View Full Code Here

     * Creates a new RootArrayDescriptor
     */
    public EnumerationDescriptor() {
        super(java.util.Enumeration.class);
        //-- create element descriptor
        XMLFieldDescriptorImpl desc = null;
        FieldHandler handler = null;
       
        desc = new XMLFieldDescriptorImpl(Object.class, "_elements", null, NodeType.Element);
        handler = (new XMLFieldHandler() {
            public Object getValue( Object object )
                throws IllegalStateException
            {
                return object;
            }
            public void setValue( Object object, Object value)
                throws IllegalStateException, IllegalArgumentException
            {
                //-- do nothing
            }
            public Object newInstance( Object parent ) {
                //-- not used
                return null;
            }
        } );
        desc.setHandler(handler);
        desc.setMultivalued(true);
        addFieldDescriptor(desc);
       
    } //-- EnumerationDescriptor()
View Full Code Here

TOP

Related Classes of org.exolab.castor.xml.util.XMLFieldDescriptorImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.