Directions.java

  1. package org.opentrafficsim.core.network.factory.xml.units;

  2. import org.opentrafficsim.core.network.LongitudinalDirectionality;
  3. import org.opentrafficsim.core.network.NetworkException;

  4. /**
  5.  * <p>
  6.  * Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
  7.  * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
  8.  * <p>
  9.  * $LastChangedDate: 2015-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) $, @version $Revision: 1147 $, by $Author: averbraeck $,
  10.  * initial version Jul 23, 2015 <br>
  11.  * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
  12.  */
  13. public final class Directions
  14. {
  15.     /** Utility class. */
  16.     private Directions()
  17.     {
  18.         // do not instantiate
  19.     }

  20.     /**
  21.      * @param dirStr String; the direction.
  22.      * @return the directionality.
  23.      * @throws NetworkException in case of unknown model.
  24.      */
  25.     public static LongitudinalDirectionality parseDirection(final String dirStr) throws NetworkException
  26.     {
  27.         if (dirStr.equals("FORWARD"))
  28.         {
  29.             return LongitudinalDirectionality.DIR_PLUS;
  30.         }
  31.         else if (dirStr.equals("BACKWARD"))
  32.         {
  33.             return LongitudinalDirectionality.DIR_MINUS;
  34.         }
  35.         else if (dirStr.equals("BOTH"))
  36.         {
  37.             return LongitudinalDirectionality.DIR_BOTH;
  38.         }
  39.         throw new NetworkException("Unknown directionality: " + dirStr);
  40.     }

  41. }