KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > thoughtworks > xstream > converters > extended > CurrencyConverter


1 package com.thoughtworks.xstream.converters.extended;
2
3 import com.thoughtworks.xstream.converters.basic.AbstractBasicConverter;
4
5 import java.sql.Date JavaDoc;
6 import java.util.Currency JavaDoc;
7
8 /**
9  * Converts a java.util.Currency to String. Despite the name of this class, it has nothing to do with converting
10  * currencies between exchange rates! It makes sense in the context of XStream.
11  *
12  * @author Jose A. Illescas
13  * @author Joe Walnes
14  */

15 public class CurrencyConverter extends AbstractBasicConverter {
16
17     public boolean canConvert(Class JavaDoc type) {
18         return type.equals(Currency JavaDoc.class);
19     }
20
21     protected Object JavaDoc fromString(String JavaDoc str) {
22         return Currency.getInstance(str);
23     }
24
25 }
26
Popular Tags