public static int toInt( String str, int def ) {
    int retval;
    if ( str == null ) {
      retval = def;
    } else {
      try {
        retval = Integer.parseInt( str );
      } catch ( Exception e ) {
        retval = def;
      }
    }
    return retval;
  }
@Test
  public void testToInt() {
    assertEquals( 123, Const.toInt( "123", -12 ) );
    assertEquals( -12, Const.toInt( "123f", -12 ) );
    assertEquals( -12, Const.toInt( "", -12 ) );
    assertEquals( -12, Const.toInt( null, -12 ) );
  }