@@ -0,0 +1,2071 @@
+package com.j256.ormlite.field.types;%0A%0Aimport java.sql.SQLException;%0Aimport java.util.Currency;%0A%0Aimport com.j256.ormlite.field.FieldType;%0Aimport com.j256.ormlite.field.SqlType;%0Aimport com.j256.ormlite.field.types.BaseDataType;%0Aimport com.j256.ormlite.misc.SqlExceptionUtil;%0Aimport com.j256.ormlite.support.DatabaseResults;%0A%0A/**%0A * Type that persists a %7B@link Currency%7D object.%0A * %0A * @author Ian Kirk%0A */%0Apublic class CurrencyPersister extends BaseDataType %7B%0A%0A%09public static int DEFAULT_WIDTH = 3;%0A%0A%09private static final CurrencyPersister singleTon = new CurrencyPersister();%0A%0A%09public static CurrencyPersister getSingleton() %7B%0A%09%09return singleTon;%0A%09%7D%0A%0A%09public CurrencyPersister() %7B%0A%09%09super(SqlType.STRING);%0A%09%7D%0A%0A%09public CurrencyPersister(final SqlType sqlType, final Class%3C?%3E%5B%5D classes) %7B%0A%09%09super(sqlType, classes);%0A%09%7D%0A%0A%09@Override%0A%09public int getDefaultWidth() %7B%0A%09%09return DEFAULT_WIDTH;%0A%09%7D%0A%0A%09@Override%0A%09public Object javaToSqlArg(final FieldType fieldType, final Object javaObject) throws SQLException %7B%0A%09%09final Currency currency = (Currency) javaObject;%0A%09%09return currency.getCurrencyCode();%0A%09%7D%0A%0A%09@Override%0A%09public Object parseDefaultString(final FieldType fieldType, final String defaultStr) throws SQLException %7B%0A%09%09try %7B%0A%09%09%09return Currency.getInstance(defaultStr);%0A%09%09%7D catch (NullPointerException%7CIllegalArgumentException e) %7B%0A%09%09%09throw SqlExceptionUtil.create(%22Problems with field %22 + fieldType + %22 parsing default Country string '%22%0A%09%09%09%09%09, e);%0A%09%09%7D%0A%09%7D%0A%0A%09@Override%0A%09public Object resultToSqlArg(final FieldType fieldType, final DatabaseResults results, final int columnPos) throws SQLException %7B%0A%09%09return results.getString(columnPos);%0A%09%7D%0A%0A%09@Override%0A%09public Object sqlArgToJava(final FieldType fieldType, final Object sqlArg, final int columnPos) throws SQLException %7B%0A%09%09final String currencyStr = (String) sqlArg;%0A%0A%09%09try %7B%0A%09%09%09return Currency.getInstance(currencyStr);%0A%09%09%7D catch (NullPointerException %7C IllegalArgumentException e) %7B%0A%09%09%09throw SqlExceptionUtil.create(%22Problems with column %22 + columnPos + %22 parsing Currency-string '%22 + currencyStr %0A%09%09%09%09%09+ %22'%22, e);%0A%09%09%7D%0A%09%7D%0A%7D%0A

Add support for java.util.Currency (#161)