1 package org.opentrafficsim.xml.bindings; 2 3 import org.djunits.value.vdouble.scalar.Length; 4 import org.djutils.logger.CategoryLogger; 5 6 /** 7 * SignedLengthAdapter converts between the XML String for a Length and the DJUnits Length. The length can be positive or 8 * negative. <br> 9 * <br> 10 * Copyright (c) 2003-2018 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See 11 * for project information <a href="https://www.simulation.tudelft.nl/" target="_blank">www.simulation.tudelft.nl</a>. The 12 * source code and binary code of this software is proprietary information of Delft University of Technology. 13 * @author <a href="https://www.tudelft.nl/averbraeck" target="_blank">Alexander Verbraeck</a> 14 */ 15 public class LengthAdapter extends UnitAdapter<Length> 16 { 17 /** {@inheritDoc} */ 18 @Override 19 public Length unmarshal(final String field) throws IllegalArgumentException 20 { 21 try 22 { 23 return Length.valueOf(field); 24 } 25 catch (Exception exception) 26 { 27 CategoryLogger.always().error(exception, "Problem parsing Length '" + field + "'"); 28 throw exception; 29 } 30 } 31 32 }