Package org.exolab.castor.xml

Examples of org.exolab.castor.xml.XMLFieldHandler


public class CategoryDescriptor extends BaseHarnessDescriptor {
    public CategoryDescriptor() {
        _xmlName = "category";
        _nsPrefix = "jtf";
        XMLFieldDescriptorImpl desc = null;
        XMLFieldHandler handler = null;
        //-- initialize attribute descriptors
       
        _attributeDescriptors = new XMLFieldDescriptorImpl[2];
        //-- _name
        desc = new XMLFieldDescriptorImpl(String.class, "_name", "name", NodeType.Attribute);
        desc.setImmutable(true);
        desc.setHandler(new XMLFieldHandler() {
            public Object getValue(final Object object) throws IllegalStateException {
                Category target = (Category) object;
                return target.getName();
            }
            public void setValue(final Object object, final Object value)
            throws IllegalStateException, IllegalArgumentException {
                try {
                    Category target = (Category) object;
                    target.setName((String) value);
                } catch (Exception ex) {
                    throw new IllegalStateException(ex.toString());
                }
            }
            public Object newInstance(final Object parent) {
                return null;
            }
        });
        _attributeDescriptors[0] = desc;
       
        //-- _name
        desc = new XMLFieldDescriptorImpl(String.class, "_className", "class", NodeType.Attribute);
        desc.setImmutable(true);
        desc.setHandler(new XMLFieldHandler() {
            public Object getValue(final Object object) throws IllegalStateException {
                Category target = (Category) object;
                return target.getClassName();
            }
            public void setValue(final Object object, final Object value)
            throws IllegalStateException, IllegalArgumentException {
                try {
                    Category target = (Category) object;
                    target.setClassName((String) value);
                } catch (Exception ex) {
                    throw new IllegalStateException(ex.toString());
                }
            }
            public Object newInstance(final Object parent) {
                return null;
            }
        });
        _attributeDescriptors[1] = desc;

        //-- initialize element descriptors
       
        _elementDescriptors = new XMLFieldDescriptorImpl[3];
        //-- _description
        desc = new XMLFieldDescriptorImpl(
                String.class, "_description", "description", NodeType.Element);
        desc.setImmutable(true);
        handler = (new XMLFieldHandler() {
            public Object getValue(final Object object) throws IllegalStateException {
                Category target = (Category) object;
                return target.getDescription();
            }
            public void setValue(final Object object, final Object value)
            throws IllegalStateException, IllegalArgumentException {
                try {
                    Category target = (Category) object;
                    target.setDescription((String) value);
                } catch (Exception ex) {
                    throw new IllegalStateException(ex.toString());
                }
            }
            public Object newInstance(final Object parent) {
                return null;
            }
        });
        desc.setHandler(handler);
        desc.setMultivalued(false);
        _elementDescriptors[0] = desc;
               
        //-- _case
        desc = new XMLFieldDescriptorImpl(Case.class, "_case", "case", NodeType.Element);
        desc.setImmutable(false);
        handler = (new XMLFieldHandler() {
            public Object getValue(final Object object) throws IllegalStateException {
                Category target = (Category) object;
                return target.getCase();
            }
            public void setValue(final Object object, final Object value)
            throws IllegalStateException, IllegalArgumentException {
                try {
                    Category target = (Category) object;
                    target.addCase((Case) value);
                } catch (Exception ex) {
                    throw new IllegalStateException(ex.toString());
                }
            }
            public Object newInstance(final Object parent) {
                return null;
            }
        });
        desc.setHandler(handler);
        desc.setMultivalued(true);
        _elementDescriptors[1] = desc;

        //-- _object
        desc = (new XMLFieldDescriptorImpl(
                Object.class, "_object", (String) null, NodeType.Element) {
            public boolean matches(final String xmlName) {
                return true;
            }
        });
        desc.setImmutable(false);
        handler = (new XMLFieldHandler() {
            public Object getValue(final Object object) throws IllegalStateException {
                Category target = (Category) object;
                return target.getObject();
            }
            public void setValue(final Object object, final Object value)
View Full Code Here


        //-- _class
        desc = new XMLFieldDescriptorImpl(
                java.lang.String.class, "_className", "class", NodeType.Attribute);
        desc.setImmutable(true);
        desc.setHandler(new XMLFieldHandler() {
            public Object getValue(final Object object) throws IllegalStateException {
                Case target = (Case) object;
                return target.getClassName();
            }
            public void setValue(final Object object, final Object value)
View Full Code Here

public class HarnessDescriptor extends BaseHarnessDescriptor {
    public HarnessDescriptor() {
        _xmlName = "harness";
        _nsPrefix = "jtf";
        XMLFieldDescriptorImpl desc = null;
        XMLFieldHandler handler = null;
        //-- initialize attribute descriptors
       
        _attributeDescriptors = new XMLFieldDescriptorImpl[1];
        //-- _name
        desc = new XMLFieldDescriptorImpl(
                String.class, "_name", "name", NodeType.Attribute);
        desc.setImmutable(true);
        desc.setHandler(new XMLFieldHandler() {
            public Object getValue(final Object object) throws IllegalStateException {
                Harness target = (Harness) object;
                return target.getName();
            }
            public void setValue(final Object object, final Object value)
            throws IllegalStateException, IllegalArgumentException {
                try {
                    Harness target = (Harness) object;
                    target.setName((String) value);
                } catch (Exception ex) {
                    throw new IllegalStateException(ex.toString());
                }
            }
            public Object newInstance(final Object parent) {
                return null;
            }
        });
        _attributeDescriptors[0] = desc;
       
        //-- initialize element descriptors
       
        _elementDescriptors = new XMLFieldDescriptorImpl[2];
        //-- _description
        desc = new XMLFieldDescriptorImpl(
                String.class, "_description", "description", NodeType.Element);
        desc.setImmutable(true);
        handler = (new XMLFieldHandler() {
            public Object getValue(final Object object) throws IllegalStateException {
                Harness target = (Harness) object;
                return target.getDescription();
            }
            public void setValue(final Object object, final Object value)
            throws IllegalStateException, IllegalArgumentException {
                try {
                    Harness target = (Harness) object;
                    target.setDescription((String) value);
                } catch (Exception ex) {
                    throw new IllegalStateException(ex.toString());
                }
            }
            public Object newInstance(final Object parent) {
                return null;
            }
        });
        desc.setHandler(handler);
        desc.setMultivalued(false);
        _elementDescriptors[0] = desc;
       
        //-- _category
        desc = new XMLFieldDescriptorImpl(
                Category.class, "_category", "category", NodeType.Element);
        handler = (new XMLFieldHandler() {
            public Object getValue(final Object object) throws IllegalStateException {
                Harness target = (Harness) object;
                return target.getCategory();
            }
            public void setValue(final Object object, final Object value)
View Full Code Here

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

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

            /**
             * {@inheritDoc}
             */
            public Object getValue(final Object object) throws IllegalStateException {
View Full Code Here

        XMLFieldDescriptorImpl desc
            = new XMLFieldDescriptorImpl(Object.class, "item", _xmlName, NodeType.Element);

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

            /**
             * {@inheritDoc}
             */
            public Object getValue(final Object object) throws IllegalStateException {
View Full Code Here

        //-- create element descriptor

        XMLFieldDescriptorImpl desc = new XMLFieldDescriptorImpl(Object.class,
                "_elements", null, NodeType.Element);

        FieldHandler handler = (new XMLFieldHandler() {

            /**
             * {@inheritDoc}
             */
            public Object getValue(final Object object) throws IllegalStateException {
View Full Code Here

        _javaClass = array.getComponentType();

        //-- create element descriptor
        XMLFieldDescriptorImpl desc = new XMLFieldDescriptorImpl(_javaClass,
                "_elements", null, NodeType.Element);
        FieldHandler handler = (new XMLFieldHandler() {

            /**
             * {@inheritDoc}
             */
            public Object getValue(final Object object) throws IllegalStateException {
View Full Code Here

                "content", "content", NodeType.Text);

            _contentDescriptor.setImmutable(true);
            //-- setHandler
            _contentDescriptor.setHandler(new DateFieldHandler(
                new XMLFieldHandler() {

                    public Object getValue( Object object )
                        throws IllegalStateException
                    {
                        return object;
View Full Code Here

            _contentDescriptor.setImmutable(true);
            //-- setHandler
            SQLTimeFieldHandler sqlTimeHandler = new SQLTimeFieldHandler();
           
            XMLFieldHandler handler = new XMLFieldHandler() {
               
               
                public Object getValue(Object object) {
                    return object;
                }
View Full Code Here

            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

TOP

Related Classes of org.exolab.castor.xml.XMLFieldHandler

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.