Package org.exolab.castor.mapping

Examples of org.exolab.castor.mapping.FieldHandler


                                //-- for xml we simply need to make sure the toString()
                                //-- method is called during getValue()
                                //FieldHandler handler = xmlDesc.getHandler();
                                //handler = new EnumFieldHandler(fieldType, handler);

                                FieldHandler handler = new ToStringFieldHandler(fieldType, xmlDesc.getHandler());

                                xmlDesc.setHandler(handler);
                                xmlDesc.setImmutable(true);
                            }
                        }
View Full Code Here


        // of fieldDesc with our new classDesc
        fieldDesc.setClassDescriptor(classDesc);

        //-- wrap the field handler in a special container field
        //-- handler that will actually do the delgation work
        FieldHandler handler = new ContainerFieldHandler(fieldDesc.getHandler());
        newFieldDesc.setHandler(handler);
        fieldDesc.setHandler(handler);

        //-- Change fieldType of original field descriptor and
        //-- return new descriptor
View Full Code Here

        FieldMapping idFM = new FieldMapping();
        TypeInfo idType = new TypeInfo(java.lang.Integer.class);
        // Set columns required (=not null)
        idType.setRequired(true);
       
        FieldHandler idHandler;
        try {
            idHandler = new FieldHandlerImpl(idFieldName, null, null,
                    Address.class.getMethod("getId", null), Address.class
                            .getMethod("setId", new Class[] { int.class }),
                    idType);
View Full Code Here

        // Don't validate "transient" fields.
        if (_descriptor.isTransient()) {
            return;
        }

        FieldHandler handler = _descriptor.getHandler();
        if (handler == null) {
            return;
        }

        // Get the value of the field
        Object value = handler.getValue(object);
        if (value == null) {
            if (!_descriptor.isRequired() || _descriptor.isNillable()) {
                return;
            }
            // deal with lenient id/idref validation accordingly, skipping exception handling
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

        JPAFieldNature jpaNature = new JPAFieldNature(fieldInfo);

        String name = fieldInfo.getFieldName();
        TypeInfo typeInfo = new TypeInfo(fieldInfo.getFieldType());

        FieldHandler handler = fieldInfo.getFieldHandler();

        boolean isTransient = false;
        // isTransient = jpaNature.isTransient ();

        FieldDescriptorImpl descriptor = new FieldDescriptorImpl(name,
View Full Code Here

        if (!getFieldType().equals(descriptor.getFieldType())) {
            return false;
        }

        // check field handler
        FieldHandler tmpHandler = descriptor.getHandler();
        if (getHandler() == null) {
            return (tmpHandler == null);
        } else if (tmpHandler == null) {
            return false;
        }
View Full Code Here

                throw new MappingException(Messages.format("mapping.dupFieldHandler", name));
            }
           
           
            Class clazz = resolveType(def.getClazz());
            FieldHandler fieldHandler = null;
            try {
                if (!FieldHandler.class.isAssignableFrom(clazz)) {
                    throw new MappingException(Messages.format("mapping.classNotFieldHandler",
                            name, def.getClazz()));
                }
View Full Code Here

        }

        TypeInfo typeInfo = getTypeInfo(fieldType, colHandler, fieldMap);

        ExtendedFieldHandler exfHandler = null;
        FieldHandler handler = null;

        // Check for user supplied FieldHandler
        if (fieldMap.getHandler() != null) {
            handler = getFieldHandler(fieldMap);

            // ExtendedFieldHandler?
            if (handler instanceof ExtendedFieldHandler) {
                exfHandler = (ExtendedFieldHandler) handler;
            }

            // Fix for CastorJDO from Steve Vaughan, CastorJDO requires FieldHandlerImpl
            // or a ClassCastException will be thrown... [KV 20030131 - also make sure
            // this new handler doesn't use it's own CollectionHandler otherwise it'll
            // cause unwanted calls to the getValue method during unmarshalling]
            colHandler = typeInfo.getCollectionHandler();
            typeInfo.setCollectionHandler(null);
            handler = new FieldHandlerImpl(handler, typeInfo);
            typeInfo.setCollectionHandler(colHandler);
            // End Castor JDO fix
        }

        boolean generalized = (exfHandler instanceof GeneralizedFieldHandler);

        // If generalized we need to change the fieldType to whatever is specified in the
        // GeneralizedFieldHandler so that the correct getter/setter methods can be found
        if (generalized) {
            fieldType = ((GeneralizedFieldHandler)exfHandler).getFieldType();
        }

        if (generalized || (handler == null)) {
            // Create TypeInfoRef to get new TypeInfo from call to createFieldHandler
            FieldHandler custom = handler;
            TypeInfoReference typeInfoRef = new TypeInfoReference();
            typeInfoRef.typeInfo = typeInfo;
            handler = createFieldHandler(javaClass, fieldType, fieldMap, typeInfoRef);
            if (custom != null) {
                ((GeneralizedFieldHandler) exfHandler).setFieldHandler(handler);
View Full Code Here

TOP

Related Classes of org.exolab.castor.mapping.FieldHandler

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.