Package org.exolab.castor.mapping

Examples of org.exolab.castor.mapping.TypeConvertor



    protected TypeInfo getTypeInfo(final Class fieldType, final CollectionHandler colHandler,
            final FieldMapping fieldMap) throws MappingException {
        Class internalFieldType = fieldType;
        TypeConvertor convertorTo = null;
        TypeConvertor convertorFrom = null;
        String        typeName = null;
        Class         sqlType = null;
        String        sqlParam = null;

        internalFieldType = Types.typeFromPrimitive(internalFieldType);
View Full Code Here


                }
                if ((sqlClass != null) && !sqlClass.isAssignableFrom(valueClass)) {
                    // First convert the actual value to the field value
                    if (fieldClass != valueClass) {
                        try {
                            TypeConvertor tc = getTypeConvertorRegistry().getConvertor(
                                    valueClass, fieldClass, null);
                            internalValue = tc.convert(internalValue);
                        } catch (MappingException e) {
                            throw new IllegalArgumentException("Query parameter "
                                    + (_fieldNum + 1) + " cannot be converted from " + valueClass
                                    + " to " + paramClass + ", because no convertor can be found.");
                        }
View Full Code Here

     */
    public void testTimestamp2Date() throws MappingException {
        DateFormat format = new SimpleDateFormat ("yyyy-MM-dd hh:mm:ss.SSS");
        Timestamp timeStamp = new Timestamp (new java.util.Date().getTime());
        LOG.debug ("time stamp = " + format.format (timeStamp));
        TypeConvertor convertor = _registry.getConvertor(
                Timestamp.class, java.util.Date.class, null);
        java.util.Date date = (java.util.Date) convertor.convert(timeStamp);
        LOG.debug("date = " + format.format(date));
       
        assertEquals(timeStamp.getTime(), date.getTime());
    }
View Full Code Here

     */
    public void testDate2Timestamp() throws MappingException {
        DateFormat format = new SimpleDateFormat ("yyyy-MM-dd hh:mm:ss.SSS");
        java.util.Date date = new java.util.Date();
        LOG.debug("date = " + format.format(date));
        TypeConvertor convertor = _registry.getConvertor(
                java.util.Date.class, Timestamp.class, null);
        Timestamp timeStamp = (Timestamp) convertor.convert(date);
        LOG.debug ("time stamp = " + format.format (timeStamp));
       
        assertEquals(timeStamp.getTime(), date.getTime());
    }
View Full Code Here

                }
                if ( sqlClass != null && ! sqlClass.isAssignableFrom( valueClass ) ) {
                    // First convert the actual value to the field value
                    if ( fieldClass != valueClass ) {
                        try {
                            TypeConvertor tc = SQLTypes.getConvertor( valueClass, fieldClass );
                            value = tc.convert( value, null );
                        } catch ( MappingException e ) {
                            throw new IllegalArgumentException( "Query parameter "
                                                                + ( _fieldNum + 1 )
                                                                + " cannot be converted from "
                                                                + valueClass + " to "
View Full Code Here


    protected TypeInfo getTypeInfo( Class fieldType, CollectionHandler colHandler, FieldMapping fieldMap )
        throws MappingException
    {
        TypeConvertor convertorTo = null;
        TypeConvertor convertorFrom = null;
        String        convertorParam = null;
        String        typeName = null;
        Class         sqlType = null;

        fieldType = Types.typeFromPrimitive( fieldType );
View Full Code Here

                }
                if ( sqlClass != null && ! sqlClass.isAssignableFrom( valueClass ) ) {
                    // First convert the actual value to the field value
                    if ( fieldClass != valueClass ) {
                        try {
                            TypeConvertor tc = SQLTypes.getConvertor( valueClass, fieldClass );
                            value = tc.convert( value, null );
                        } catch ( MappingException e ) {
                            throw new IllegalArgumentException( "Query parameter "
                                                                + ( _fieldNum + 1 )
                                                                + " cannot be converted from "
                                                                + valueClass + " to "
View Full Code Here

TOP

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

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.