Package jodd.typeconverter

Examples of jodd.typeconverter.TypeConversionException


      try {
        File tempFile = FileUtil.createTempFile();
        FileUtil.writeBytes(tempFile, (byte[])value);
        return tempFile;
      } catch (IOException ioex) {
        throw new TypeConversionException(ioex);
      }
    }
    if (type == String.class) {
      try {
        File tempFile = FileUtil.createTempFile();
        FileUtil.writeString(tempFile, value.toString());
        return tempFile;
      } catch (IOException ioex) {
        throw new TypeConversionException(ioex);
      }
    }
    throw new TypeConversionException(value);
  }
View Full Code Here


      if (StringUtil.startsWithChar(stringValue, '+')) {
        stringValue = stringValue.substring(1);
      }
      return Short.valueOf(stringValue);
    } catch (NumberFormatException nfex) {
      throw new TypeConversionException(value, nfex);
    }
  }
View Full Code Here

      return (Class) value;
    }
    try {
      return ClassLoaderUtil.loadClass(value.toString().trim());
    } catch (ClassNotFoundException cnfex) {
      throw new TypeConversionException(value, cnfex);
    }
  }
View Full Code Here

      if (type == byte[].class) {
        byte[] valueArray = (byte[]) value;
        try {
          return new String(valueArray, 0, valueArray.length, JoddCore.encoding);
        } catch (UnsupportedEncodingException ueex) {
          throw new TypeConversionException(ueex);
        }
      }
      if (type == char[].class) {
        char[] charArray = (char[]) value;
        return new String(charArray);
      }
      return CsvUtil.toCsvString((Object[])value);
    }
    if (value instanceof Clob) {
      Clob clob = (Clob) value;
      try {
        long length = clob.length();
        if (length > Integer.MAX_VALUE) {
          throw new TypeConversionException("Clob is too big.");
        }
        return clob.getSubString(1, (int) length);
      } catch (SQLException sex) {
        throw new TypeConversionException(value, sex);
      }
    }
    return value.toString();
  }
View Full Code Here

      if (StringUtil.startsWithChar(stringValue, '+')) {
        stringValue = stringValue.substring(1);
      }
      return Byte.valueOf(stringValue);
    } catch (NumberFormatException nfex) {
      throw new TypeConversionException(value, nfex);
    }
  }
View Full Code Here

      if (StringUtil.startsWithChar(stringValue, '+')) {
        stringValue = stringValue.substring(1);
      }
      return Float.valueOf(stringValue);
    } catch (NumberFormatException nfex) {
      throw new TypeConversionException(value, nfex);
    }
  }
View Full Code Here

      if (StringUtil.startsWithChar(stringValue, '+')) {
        stringValue = stringValue.substring(1);
      }
      return Integer.valueOf(stringValue);
    } catch (NumberFormatException nfex) {
      throw new TypeConversionException(value, nfex);
    }
  }
View Full Code Here

      return null;
    }
    if (value instanceof FileUpload) {
      return (FileUpload) value;
    }
    throw new TypeConversionException(value);
  }
View Full Code Here

      if (StringUtil.startsWithChar(stringValue, '+')) {
        stringValue = stringValue.substring(1);
      }
      return Long.valueOf(stringValue);
    } catch (NumberFormatException nfex) {
      throw new TypeConversionException(value, nfex);
    }
  }
View Full Code Here

      if (StringUtil.startsWithChar(stringValue, '+')) {
        stringValue = stringValue.substring(1);
      }
      return Double.valueOf(stringValue);
    } catch (NumberFormatException nfex) {
      throw new TypeConversionException(value, nfex);
    }
  }
View Full Code Here

TOP

Related Classes of jodd.typeconverter.TypeConversionException

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.