Am Mittwoch, den 27.06.2007, 16:32 +0100 schrieb Andrea Smyth:

> >> > +    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?
> >
> But it does return the first alias if there are any - not the last?
> 

Oops--sorry about that!  Yes, I stand corrected, indeed, it does return
the first alias.

Glen


> Andrea.
> 
> >>
> >>
> >
> >
> 
> ----------------------------
> IONA Technologies PLC (registered in Ireland)
> Registered Number: 171387
> Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland

Reply via email to