You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by do...@apache.org on 2010/02/10 23:20:55 UTC
svn commit: r908686 -
/ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/NumberConverters.java
Author: doogie
Date: Wed Feb 10 22:20:48 2010
New Revision: 908686
URL: http://svn.apache.org/viewvc?rev=908686&view=rev
Log:
Add Byte converters.
Modified:
ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/NumberConverters.java
Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/NumberConverters.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/NumberConverters.java?rev=908686&r1=908685&r2=908686&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/NumberConverters.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/NumberConverters.java Wed Feb 10 22:20:48 2010
@@ -222,6 +222,85 @@
}
}
+ public static class ByteToDouble extends AbstractConverter<Byte, Double> {
+ public ByteToDouble() {
+ super(Byte.class, Double.class);
+ }
+
+ public Double convert(Byte obj) throws ConversionException {
+ return obj.doubleValue();
+ }
+ }
+
+ public static class ByteToFloat extends AbstractConverter<Byte, Float> {
+ public ByteToFloat() {
+ super(Byte.class, Float.class);
+ }
+
+ public Float convert(Byte obj) throws ConversionException {
+ return obj.floatValue();
+ }
+ }
+
+ public static class ByteToInteger extends AbstractConverter<Byte, Integer> {
+ public ByteToInteger() {
+ super(Byte.class, Integer.class);
+ }
+
+ public Integer convert(Byte obj) throws ConversionException {
+ return obj.intValue();
+ }
+ }
+
+ public static class ByteToList extends AbstractConverter<Byte, List<Byte>> {
+ public ByteToList() {
+ super(Byte.class, List.class);
+ }
+
+ public List<Byte> convert(Byte obj) throws ConversionException {
+ List<Byte> tempList = FastList.newInstance();
+ tempList.add(obj);
+ return tempList;
+ }
+ }
+
+ public static class ByteToLong extends AbstractConverter<Byte, Long> {
+ public ByteToLong() {
+ super(Byte.class, Long.class);
+ }
+
+ public Long convert(Byte obj) throws ConversionException {
+ return obj.longValue();
+ }
+ }
+
+ public static class ByteToSet extends AbstractConverter<Byte, Set<Byte>> {
+ public ByteToSet() {
+ super(Byte.class, Set.class);
+ }
+
+ public Set<Byte> convert(Byte obj) throws ConversionException {
+ Set<Byte> tempSet = FastSet.newInstance();
+ tempSet.add(obj);
+ return tempSet;
+ }
+ }
+
+ public static class ByteToString extends AbstractToNumberConverter<Byte, String> {
+ public ByteToString() {
+ super(Byte.class, String.class);
+ }
+
+ public String convert(Byte obj) throws ConversionException {
+ return obj.toString();
+ }
+
+ public String convert(Byte obj, Locale locale, TimeZone timeZone) throws ConversionException {
+ NumberFormat nf = NumberFormat.getNumberInstance(locale);
+ return nf.format(obj.floatValue());
+ }
+ }
+
public static class StringToBigInteger extends AbstractToNumberConverter<String, BigInteger> {
public StringToBigInteger() {
super(String.class, BigInteger.class);
@@ -398,6 +477,16 @@
}
}
+ public static class IntegerToByte extends AbstractConverter<Integer, Byte> {
+ public IntegerToByte() {
+ super(Integer.class, Byte.class);
+ }
+
+ public Byte convert(Integer obj) throws ConversionException {
+ return obj.byteValue();
+ }
+ }
+
public static class IntegerToDouble extends AbstractConverter<Integer, Double> {
public IntegerToDouble() {
super(Integer.class, Double.class);
@@ -487,6 +576,16 @@
}
}
+ public static class LongToByte extends AbstractConverter<Long, Byte> {
+ public LongToByte() {
+ super(Long.class, Byte.class);
+ }
+
+ public Byte convert(Long obj) throws ConversionException {
+ return obj.byteValue();
+ }
+ }
+
public static class LongToDouble extends AbstractConverter<Long, Double> {
public LongToDouble() {
super(Long.class, Double.class);
@@ -663,6 +762,16 @@
}
}
+ public static class StringToByte extends AbstractConverter<String, Byte> {
+ public StringToByte() {
+ super(String.class, Byte.class);
+ }
+
+ public Byte convert(String obj) throws ConversionException {
+ return Byte.valueOf(obj);
+ }
+ }
+
public static class StringToDouble extends AbstractToNumberConverter<String, Double> {
public StringToDouble() {
super(String.class, Double.class);