/** * Converts the given value into a long. * This method fails if the value does not represent a long. * * @param value the value to be converted * @return the value as a long * @exception DataFormatException if the given value does not represent * a long */ public static long asLong(String value) throws DataFormatException { try { return Long.parseLong(value); } catch (NumberFormatException e) { throw new DataFormatException(e.getMessage()); } }
/** * Converts the given value into an int. * This method fails if the value does not represent an int. * * @param value the value to be converted * @return the value as an int * @exception DataFormatException if the given value does not represent * an int */ public static int asInt(String value) throws DataFormatException { try { return Integer.parseInt(value); } catch (NumberFormatException e) { throw new DataFormatException(e.getMessage()); } }
/** * Converts the given value into an int. * This method fails if the value does not represent an int. * * @param value the value to be converted * @return the value as an int * @exception DataFormatException if the given value does not represent * an int */ public static int asInt(String value) throws DataFormatException { try { return Integer.parseInt(value); } catch (NumberFormatException e) { throw new DataFormatException(e.getMessage()); } }
/** * Converts the given value into a long. * This method fails if the value does not represent a long. * * @param value the value to be converted * @return the value as a long * @exception DataFormatException if the given value does not represent * a long */ public static long asLong(String value) throws DataFormatException { try { return Long.parseLong(value); } catch (NumberFormatException e) { throw new DataFormatException(e.getMessage()); } }
/** * Converts the given value into a double. * This method fails if the value does not represent a double. * * @param value the value to be converted * @return the value as a double * @exception DataFormatException if the given value does not represent * a double */ public static double asDouble(String value) throws DataFormatException { try { return (Double.valueOf(value)).doubleValue(); } catch (NumberFormatException e) { throw new DataFormatException(e.getMessage()); } }
/** * Converts the given value into a float. * This method fails if the value does not represent a float. * * @param value the value to be converted * @return the value as a float * @exception DataFormatException if the given value does not represent * a float */ public static float asFloat(String value) throws DataFormatException { try { return (Float.valueOf(value)).floatValue(); } catch (NumberFormatException e) { throw new DataFormatException(e.getMessage()); } }
/** * Converts the given value into a long. * This method fails if the value does not represent a long. * * @param value the value to be converted * @return the value as a long * @exception DataFormatException if the given value does not represent * a long */ public static long asLong(String value) throws DataFormatException { try { return Long.parseLong(value); } catch (NumberFormatException e) { throw new DataFormatException(e.getMessage()); } }
/** * Converts the given value into an int. * This method fails if the value does not represent an int. * * @param value the value to be converted * @return the value as an int * @exception DataFormatException if the given value does not represent * an int */ public static int asInt(String value) throws DataFormatException { try { return Integer.parseInt(value); } catch (NumberFormatException e) { throw new DataFormatException(e.getMessage()); } }
/** * Converts the given value into a double. * This method fails if the value does not represent a double. * * @param value the value to be converted * @return the value as a double * @exception DataFormatException if the given value does not represent * a double */ public static double asDouble(String value) throws DataFormatException { try { return (Double.valueOf(value)).doubleValue(); } catch (NumberFormatException e) { throw new DataFormatException(e.getMessage()); } }
/** * Converts the given value into a float. * This method fails if the value does not represent a float. * * @param value the value to be converted * @return the value as a float * @exception DataFormatException if the given value does not represent * a float */ public static float asFloat(String value) throws DataFormatException { try { return (Float.valueOf(value)).floatValue(); } catch (NumberFormatException e) { throw new DataFormatException(e.getMessage()); } }
/** * Converts the given value into a float. * This method fails if the value does not represent a float. * * @param value the value to be converted * @return the value as a float * @exception DataFormatException if the given value does not represent * a float */ public static float asFloat(String value) throws DataFormatException { try { return (Float.valueOf(value)).floatValue(); } catch (NumberFormatException e) { throw new DataFormatException(e.getMessage()); } }
/** * Converts the given value into a double. * This method fails if the value does not represent a double. * * @param value the value to be converted * @return the value as a double * @exception DataFormatException if the given value does not represent * a double */ public static double asDouble(String value) throws DataFormatException { try { return (Double.valueOf(value)).doubleValue(); } catch (NumberFormatException e) { throw new DataFormatException(e.getMessage()); } }
throw new DataFormatException( "Null doesn't represent a valid point"); //$NON-NLS-1$ yval = Integer.parseInt(y); } catch (NumberFormatException e) { throw new DataFormatException(e.getMessage());
/** * Converts the given value into a boolean. * This method fails if the value does not represent a boolean. * <p> * Valid representations of <code>true</code> include the strings * "<code>t</code>", "<code>true</code>", or equivalent in mixed * or upper case. * Similarly, valid representations of <code>false</code> include the strings * "<code>f</code>", "<code>false</code>", or equivalent in mixed * or upper case. * </p> * * @param value the value to be converted * @return the value as a boolean * @exception DataFormatException if the given value does not represent * a boolean */ public static boolean asBoolean(String value) throws DataFormatException { String v = value.toLowerCase(); if (v.equals("t") || v.equals("true")) { //$NON-NLS-1$ //$NON-NLS-2$ return true; } if (value.equals("f") || v.equals("false")) { //$NON-NLS-1$ //$NON-NLS-2$ return false; } throw new DataFormatException( "Value " + value + "doesn't represent a boolean"); //$NON-NLS-2$//$NON-NLS-1$ }
throw new DataFormatException( "Null doesn't represent a valid point"); //$NON-NLS-1$ yval = Integer.parseInt(y); } catch (NumberFormatException e) { throw new DataFormatException(e.getMessage());
throw new DataFormatException( "Null doesn't represent a valid point"); //$NON-NLS-1$ yval = Integer.parseInt(y); } catch (NumberFormatException e) { throw new DataFormatException(e.getMessage());
/** * Converts the given value into a boolean. * This method fails if the value does not represent a boolean. * <p> * Valid representations of <code>true</code> include the strings * "<code>t</code>", "<code>true</code>", or equivalent in mixed * or upper case. * Similarly, valid representations of <code>false</code> include the strings * "<code>f</code>", "<code>false</code>", or equivalent in mixed * or upper case. * </p> * * @param value the value to be converted * @return the value as a boolean * @exception DataFormatException if the given value does not represent * a boolean */ public static boolean asBoolean(String value) throws DataFormatException { String v = value.toLowerCase(); if (v.equals("t") || v.equals("true")) { //$NON-NLS-1$ //$NON-NLS-2$ return true; } if (value.equals("f") || v.equals("false")) { //$NON-NLS-1$ //$NON-NLS-2$ return false; } throw new DataFormatException( "Value " + value + "doesn't represent a boolean"); //$NON-NLS-2$//$NON-NLS-1$ }
/** * Converts the given value into a boolean. * This method fails if the value does not represent a boolean. * <p> * Valid representations of <code>true</code> include the strings * "<code>t</code>", "<code>true</code>", or equivalent in mixed * or upper case. * Similarly, valid representations of <code>false</code> include the strings * "<code>f</code>", "<code>false</code>", or equivalent in mixed * or upper case. * </p> * * @param value the value to be converted * @return the value as a boolean * @exception DataFormatException if the given value does not represent * a boolean */ public static boolean asBoolean(String value) throws DataFormatException { String v = value.toLowerCase(); if (v.equals("t") || v.equals("true")) { //$NON-NLS-1$ //$NON-NLS-2$ return true; } if (value.equals("f") || v.equals("false")) { //$NON-NLS-1$ //$NON-NLS-2$ return false; } throw new DataFormatException( "Value " + value + "doesn't represent a boolean"); //$NON-NLS-2$//$NON-NLS-1$ }
throw new DataFormatException("Null doesn't represent a valid RGB"); //$NON-NLS-1$ bval = Integer.parseInt(blue); } catch (NumberFormatException e) { throw new DataFormatException(e.getMessage()); throw new DataFormatException(e.getMessage()); } catch (NoSuchElementException e) { throw new DataFormatException(e.getMessage());
throws DataFormatException { if (value == null) { throw new DataFormatException( "Null doesn't represent a valid rectangle"); //$NON-NLS-1$ hval = Integer.parseInt(height); } catch (NumberFormatException e) { throw new DataFormatException(e.getMessage());