public
class
TestCustomTypeConversion {
/**
* This Conversion defines how String data is converted to our target type and
* what default is to be applied when no data is available.
*/
private
final
class
CoordinateListConversion
extends
DefaultTypeConverter.Conversion<CoordinateList> {
private
CoordinateListConversion() {
super
(
new
CoordinateList(
""
));
}
@Override
public
CoordinateList convert(
final
String data) {
return
new
CoordinateList(data);
}
}
@Test
public
void
testApplyOffsetToCoordinates()
throws
IOException {
XBProjector projector =
new
XBProjector(
new
DefaultXMLFactoriesConfig().setNamespacePhilosophy(NamespacePhilosophy.AGNOSTIC));
DefaultTypeConverter converter =
new
DefaultTypeConverter(Locale.getDefault(),TimeZone.getDefault()).setConversionForType(CoordinateList.
class
,
new
CoordinateListConversion());
projector.config().setTypeConverter(converter);
KML kml = projector.io().fromURLAnnotation(KML.
class
);
CoordinateList coordinates = kml.getCoordinates();
assertTrue(coordinates.iterator().hasNext());
for
(Coordinate a:coordinates) {
a.setX(a.getX()+
10
);
}
kml.setCoordinates(coordinates);
}
}