PerLengthAdapter.java

  1. package org.opentrafficsim.xml.bindings;

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

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

  28. }