Commit 14c1247c authored by mey's avatar mey
Browse files

AmountUtil.java: added registerConverters method

parent 1f286f94
......@@ -17,6 +17,7 @@ import javax.measure.unit.UnitFormat;
import org.jscience.physics.amount.Amount;
import org.jscience.physics.amount.AmountFormat;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.XStreamException;
import com.thoughtworks.xstream.converters.Converter;
import com.thoughtworks.xstream.converters.SingleValueConverter;
......@@ -194,6 +195,20 @@ public abstract class AmountUtil {
}
/**
* Register custom converters for {@link Amount} and {@link Unit} and alias
* their class name.
*
* @param xStream
* the {@link XStream} instance to be used
*/
public static void registerConverters(XStream xStream) {
xStream.alias("Amount", Amount.class);
xStream.registerConverter(new XmlAmountConverter());
xStream.aliasType("Unit", Unit.class);
xStream.registerConverter(new XmlUnitConverter());
}
/**
* {@link Converter} for {@link Amount} to / from XML.
*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment