Thanks for the reply. I had 'getString' originally and got the same
error so I changed to 'getProperty' thinking that might fix it. Since I
am not casting when I use 'getString' don't see why I get the same
error. In any case I will use your suggestion even with 'getString'.
On 10/31/2012 12:09 PM, Greg Thomas wrote:
On 31 October 2012 15:51, Dennis Putnam<[email protected]> wrote:
I am making my first foray into CompositeConfiguration and am struggling
with some basics. I am trying to create a method that returns a specified
property or 'null' if it does not exist:
Public String getProperty(String prop) {
return((String) config.getProperty(prop));
}
You can't cast null objects. Using the same API call, you can re-write
the method as
Public String getProperty(String prop) {
Object val = config.getProperty(prop);
if( val == null ) {
return null;
} else {
return (String)val;
}
}
However, that's a lesson in Java. More practically, why not simply
call getString(prop); - that returns a String directly.
Greg
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
--
*Dennis Putnam*, Systems Administrator
Acquisitions Integration
Data Net IT at Cisco
770-236-6922