/** * Returns the Unit of the given length. * @param length the <code>Unit</code> should be obtained from * @return Returns a <code>Unit</code> object representing the specified Length unit. */ public static Unit parseUnit(String length) { Unit lengthUnit = null; if (length == null) { throw new NumberFormatException("The input length should not be null!"); } else { boolean identifiedInput = false; for (Unit unit : Unit.values()) { if (length.contains(unit.abbr())) { lengthUnit = unit; identifiedInput = true; break; } } if (!identifiedInput) { throw new NumberFormatException("The input length " + length + " has no valid Unit!"); } } return lengthUnit; }
/** * Returns the Unit of the given length. * @param length the <code>Unit</code> should be obtained from * @return Returns a <code>Unit</code> object representing the specified Length unit. */ public static Unit parseUnit(String length) { Unit lengthUnit = null; if (length == null) { throw new NumberFormatException("The input length should not be null!"); } else { boolean identifiedInput = false; for (Unit unit : Unit.values()) { if (length.contains(unit.abbr())) { lengthUnit = unit; identifiedInput = true; break; } if (!identifiedInput) { throw new NumberFormatException("The input length " + length + " has no valid Unit!"); } } } return lengthUnit; }
/** * Returns the Unit of the given length. * @param length the <code>Unit</code> should be obtained from * @return Returns a <code>Unit</code> object representing the specified Length unit. */ public static Unit parseUnit(String length) { Unit lengthUnit = null; if (length == null) { throw new NumberFormatException("The input length should not be null!"); } else { boolean identifiedInput = false; for (Unit unit : Unit.values()) { if (length.contains(unit.abbr())) { lengthUnit = unit; identifiedInput = true; break; } } if (!identifiedInput) { throw new NumberFormatException("The input length " + length + " has no valid Unit!"); } } return lengthUnit; }
boolean identifiedInput = false; for (Unit unit : Unit.values()) { if (length.contains(unit.abbr())) { Double value = Double.valueOf(length.substring(0, length.indexOf(unit.abbr())));
boolean identifiedInput = false; for (Unit unit : Unit.values()) { if (length.contains(unit.abbr())) { Double value = Double.valueOf(length.substring(0, length.indexOf(unit.abbr())));
boolean identifiedInput = false; for (Unit unit : Unit.values()) { if (length.contains(unit.abbr())) { Double value = Double.valueOf(length.substring(0, length.indexOf(unit.abbr())));
boolean identifiedInput = false; for (Unit unit : Unit.values()) { if (length.contains(unit.abbr())) { Double value = Double.valueOf(length.substring(0, length.indexOf(unit.abbr())));
boolean identifiedInput = false; for (Unit unit : Unit.values()) { if (length.contains(unit.abbr())) { Double value = Double.valueOf(length.substring(0, length.indexOf(unit.abbr())));
boolean identifiedInput = false; for (Unit unit : Unit.values()) { if (length.contains(unit.abbr())) { Double value = Double.valueOf(length.substring(0, length.indexOf(unit.abbr())));