cds.util
Class Conv

java.lang.Object
  extended bycds.util.Conv

public class Conv
extends java.lang.Object

Class containing static methods for some particular conversions Some comments:
The methods converting strings to intorlong are faster that the regular Java classes (Integer.parseInt() or Long.parseLong())

Version:
1.0 Jul 1999, 2.0 Apr 2002
Author:
Marc Wenger (CDS)

Constructor Summary
Conv()
           
 
Method Summary
static int str2int(java.lang.String str)
          Converts a String into an integer.
static int str2int(java.lang.String str, int begin, int end)
          Converts a subset of a String into an integer The substring must contain only digits, and can begin with a + ou - sign.
static long str2long(java.lang.String str)
          Converts a String into an long The string must contain only digits, and can begin with a + ou - sign.
static long str2long(java.lang.String str, int begin, int end)
          Converts a subset of a String into an long The substring must contain only digits, and can begin with a + ou - sign.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Conv

public Conv()
Method Detail

str2int

public static final int str2int(java.lang.String str)
Converts a String into an integer. The string must contain only digits, and can begin with a + ou - sign.

Parameters:
str - String to convert
Returns:
the resulting integer

str2int

public static int str2int(java.lang.String str,
                          int begin,
                          int end)
Converts a subset of a String into an integer The substring must contain only digits, and can begin with a + ou - sign.

Parameters:
str - String to convert
begin - first character to use in the String (counted from 0)
end - first char after the number (= first char not to use)
Returns:
the resulting integer
Throws:
java.lang.NumberFormatException - if the string contains non digit characters

str2long

public static final long str2long(java.lang.String str)
Converts a String into an long The string must contain only digits, and can begin with a + ou - sign.

Parameters:
str - String to convert
Returns:
the resulting long
Throws:
java.lang.NumberFormatException - if the string contains non digit characters

str2long

public static final long str2long(java.lang.String str,
                                  int begin,
                                  int end)
Converts a subset of a String into an long The substring must contain only digits, and can begin with a + ou - sign.

Parameters:
str - String to convert
begin - first character to use in the String (counted from 0)
end - first char after the number (= first char not to use)
Returns:
the resulting long
Throws:
java.lang.NumberFormatException - if the string contains non digit characters