@Override
  public Object parse(String value) throws ParseException
  {
    if(value == null || value.isEmpty()) {
      return null;
    }

    String[] parts = value.split("\\s+");
    if(parts.length != 2) {
      throw new ParseException("Invalid file size value. Missing units.", 0);
    }

    Units units = Units.forName(parts[1]);
    if(units == null) {
      throw new ParseException(String.format("Invalid file size value. Not recognized units |%s|.", parts[1]), 0);
    }

    Number fileSize = numberFormat.parse(parts[0]);
    return Math.round(fileSize.doubleValue() * units.value);
  }
@ Override public Object parse ( String value ) throws ParseException { if ( value == null || value . isEmpty ( ) ) { return null ; } String [ ] parts = value . split ( "\\s+" ) ; if ( parts . length != 2 ) { throw new ParseException ( "Invalid file size value. Missing units." , 0 ) ; } Units units = Units . forName ( parts [ 1 ] ) ; if ( units == null ) { throw new ParseException ( String . format ( "Invalid file size value. Not recognized units |%s|." , parts [ 1 ] ) , 0 ) ; } Number fileSize = numberFormat . parse ( parts [ 0 ] ) ; return Math . round ( fileSize . doubleValue ( ) * units . value ) ; }
Parse file size from given string value and return it as {@link Long} instance. Given string <code>value</code>
should have a numeric part followed by units, separated by space. See {@link Units} for supported units.
<p>
Returns null if <code>value</code> argument is null or empty.

@param value formatted file size value.
@return file size as {@link Long} instance, possible null if <code>value</code> argument is null or empty.
@throws ParseException if <code>value</code> is not formated as described above.