Thanks for the helpful comments Glen. I'll fix the first/last bug you
mentioned.
I didn't write the code below, does anyone know what the multiple name logic
is for?
> + protected String getIdOrName(Element elem) {
> + String id = elem.getAttribute(
BeanDefinitionParserDelegate.ID_ATTRIBUTE);
> +
> + if (null == id || "".equals(id)) {
> + String names = elem.getAttribute(BeanConstants.NAME_ATTR);
> + if (null != names) {
> + StringTokenizer st =
> + new StringTokenizer(names,
BeanDefinitionParserDelegate.BEAN_NAME_DELIMITERS);
> + if (st.countTokens() > 0) {
> + id = st.nextToken();
> + }
> + }
> + }
> + return id;
> + }
> +
> +}
Since an id="" is invalid here (it causes one to search for the names
instead), you might wish for this method to return null for an id=""
with no names found (presently it will return an empty string). This
way the caller of this method needs only to check for 'null' (not both
'null' or an 'empty string').
Also, I don't know enough about the business logic, but, just to
confirm, are you certain you would want to return the last name in the
set if there are multiple names--instead of the first name available,
or, actually, to raise an exception if more than one name is present?
--
Dan Diephouse
Envoi Solutions
http://envoisolutions.com | http://netzooid.com/blog