Examples of TypeConvertor


Examples of org.apache.bsf.util.type.TypeConvertor

    Object fieldVal = null;
    boolean okeydokey = true;
    if (fieldType.isAssignableFrom (value.type)) {
    fieldVal = value.value;
    } else if (tcr != null) {
    TypeConvertor cvtor = tcr.lookup (value.type, fieldType);
    if (cvtor != null) {
      fieldVal = cvtor.convert (value.type, fieldType, value.value);
    } else {
      okeydokey = false;
    }
    } else {
    okeydokey = false;
View Full Code Here

Examples of org.apache.bsf.util.type.TypeConvertor

  Object propVal = null;
  boolean okeydokey = true;
  if (propType.isAssignableFrom (valueType)) {
    propVal = value;
  } else if (tcr != null) {
    TypeConvertor cvtor = tcr.lookup (valueType, propType);
    if (cvtor != null) {
    propVal = cvtor.convert (valueType, propType, value);
    } else {
    okeydokey = false;
    }
  } else {
    okeydokey = false;
View Full Code Here

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

Examples of org.exolab.castor.mapping.TypeConvertor

                }
                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

Examples of org.exolab.castor.mapping.TypeConvertor

     */
    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

Examples of org.exolab.castor.mapping.TypeConvertor

     */
    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

Examples of org.exolab.castor.mapping.TypeConvertor

                }
                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

Examples of org.exolab.castor.mapping.TypeConvertor


    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

Examples of org.exolab.castor.mapping.TypeConvertor

                }
                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

Examples of org.jdbf.castor.TypeConvertor

       

        //first convert from java.sql.Date to java.util.Date

        TypeConvertor convertor = Types.getConvertor(fromClass,toClass);           

        propertyValue = convertor.convert(propertyValue,null);           

        fromClass = toClass;

        toClass = ReflectionManager.getPropertyType(object,item.getPropertyName());

       

        //then convert from java.util.Date in specific class

        convertor = Types.getConvertor(fromClass,toClass);

        String formatPattern = item.getFormatPattern();

        propertyValue = convertor.convert(propertyValue,formatPattern);       

    }

    catch(ClassNotFoundException e){

       logger.throwing(className,"convertValue()",

           new MappingException(e));

       //throw new MappingException(e);

    }

      }

      else{

          TypeConvertor convertor = Types.getConvertor(fromClass,toClass);           

    propertyValue = convertor.convert(propertyValue,null);     

      }

  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.