Magnus ?or Torfason wrote:
>> Yea, I just noticed this as well the other day...the problem with
>> doing that
>> is that there could be a case where you would want that Exception to be
>> thrown...therefore, write your code like this:
>>
>> try
>> {
>> return getString()
>> }
>> catch (ClassCastException cce)
>> {
>> String s = getVector().toString();
>> return s.substring (1,s.length()-1);
>> }
>>
>> -jon
>
>
> WHY would you want a ClassCastException when checking the values of property
> files. There must be more reasonable exceptions to throw.
>
ExtendedProperties uses "," to separate multiple values. So, you ask for a String, and
it has
a Vector. The same error happens when an entry is duplicated in two separate lines in
the file.
It has happened to me.
Alternatives can be found:
- throwing IllegalArgumentException with message "Asked for String, but XXX is a
Vector"
(suggesting something wrong with property/argument, instead of internal failure)
- Returning all the vector elements, comma separated (it solves the problem
with strings containing unescaped "," (this is the suggested solution here)
The general solution is to have a comment in TR.p pointing to the fact
that commas MUST be escaped when not element separators.
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?: [EMAIL PROTECTED]