01: /*
02: * Copyright (C) 2004 Joe Walnes.
03: * Copyright (C) 2006, 2007 XStream Committers.
04: * All rights reserved.
05: *
06: * The software in this package is published under the terms of the BSD
07: * style license a copy of which has been included with this distribution in
08: * the LICENSE.txt file.
09: *
10: * Created on 24. July 2004 by Joe Walnes
11: */
12: package com.thoughtworks.xstream.converters.extended;
13:
14: import java.util.Currency;
15:
16: import com.thoughtworks.xstream.converters.basic.AbstractSingleValueConverter;
17:
18: /**
19: * Converts a java.util.Currency to String. Despite the name of this class, it has nothing to do with converting
20: * currencies between exchange rates! It makes sense in the context of XStream.
21: *
22: * @author Jose A. Illescas
23: * @author Joe Walnes
24: */
25: public class CurrencyConverter extends AbstractSingleValueConverter {
26:
27: public boolean canConvert(Class type) {
28: return type.equals(Currency.class);
29: }
30:
31: public Object fromString(String str) {
32: return Currency.getInstance(str);
33: }
34:
35: }
|