LengthAdapter.java

  1. package org.opentrafficsim.xml.bindings;

  2. import org.djunits.value.vdouble.scalar.Length;
  3. import org.djutils.logger.CategoryLogger;

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

  29. }