001/*
002 * Copyright (c) 2018 Chris K Wensel <chris@wensel.net>. All Rights Reserved.
003 *
004 * This Source Code Form is subject to the terms of the Mozilla Public
005 * License, v. 2.0. If a copy of the MPL was not distributed with this
006 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
007 */
008
009package heretical.parser.common.util;
010
011import org.parboiled.support.Var;
012
013/**
014 *
015 */
016public class IntegerVar extends Var<Integer>
017  {
018  public IntegerVar()
019    {
020    }
021
022  public IntegerVar( Integer number )
023    {
024    super( number );
025    }
026
027  public boolean set( String integerString )
028    {
029    integerString = integerString.replaceAll( ",", "" );
030
031    try
032      {
033      return set( Integer.valueOf( integerString ) );
034      }
035    catch( NumberFormatException exception )
036      {
037      return false;
038      }
039    }
040  }