Jörg Schaible wrote:
> Max Bowsher wrote on Thursday, March 29, 2007 1:46 PM:
>> private static HashMap commonDecimalModes = new HashMap() {{  
>>   add("420"); add("436");
>>   add("493");
>>   add("509");
>> }}
>>
>> .....
>>
>> if ( commonDecimalModes.contains( mode ) )
>>   return Integer.parseInt( mode, 10 );
>> else
>>   return Integer.parseInt( mode, 8 );
> 
> Why not letting Java decide? It handles decimal, octal and hex values 
> automatically:
> 
>     public Integer fromString(String str) {
>       long value = Long.decode(str).longValue();
>       if(value < Integer.MIN_VALUE || value > 0xFFFFFFFFl) {
>               throw new NumberFormatException("For input string: \"" + str + 
> '"');
>       }
>         return new Integer((int)value);
>     }
>
> Note: Integer.decode(String) is not used here because it will not
> handle negative hex-coded integer values. With this approach you can
> express -1 as 0xFFFFFFFF ...

The whole point here is to maximize compatibility with
maven-assembly-plugin-2.1 behaviour. That's why we, not Java, should be
making the decision.

Furthermore, we are talking about Unix permission mode bits. Neither
negative values, nor hexadecimal values, are relevant. Decimal values
are only relevant to the extent of supporting existing assembly
descriptors written for the buggy behaviour of maven-assembly-plugin-2.1.

Max.


Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to