axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Glen Daniels <g...@thoughtcraft.com>
Subject Re: [Axis2] Qnames
Date Tue, 01 Nov 2005 13:36:36 GMT
>>>>Is there a utility function to map string->qname in the context of an 
>>>>Element?
>>>
>>>If there isn't yet, we should add one (Axis 1's MessageElement has this, 
>>>and it's generally hugely useful).
>>
>>I've done it, just dont know

Thanks Steve!

>>1. where to put it
> 
> Shouldn't it be OMElement.resolve (String)? Eran?

OMElement.getQNameFromString(String) or
OMElement.resolveQName(String)

either works for me.

>>2. what the failure policy should be. Return null vs throw exception?
> 
> Exception seems more right to me.

Really?  I was thinking null would be better to avoid a ton of try/catch 
blocks.

QName foo = element.resolveQName("foo:bar");
if (foo != null) {
   // do something useful
}

vs.

QName foo = null;
try {
   foo = element.resolveQName("foo:bar");
} catch (NoNamespaceException e) {
   // fail
}
// do something useful

I just find it easier to write code like the first style, where I can 
declare and assign the variable in the same place without wrapping 
*everything* in try/catch.

--Glen

Mime
View raw message