Admittedly, it's a different usage pattern, but it follows the JDOM pattern of Element.addContent(...), which returns 'this'.
-bob On Fri, 15 Mar 2002, Elliotte Rusty Harold wrote: > The return type of the following method in org.jaxen.BaseXPath is > questionable, IMO: > > public BaseXPath <cid:[EMAIL PROTECTED]> *addNamespace*(String ><http://java.sun.com/products/jdk/1.3/docs/api/java/lang/String.html> prefix, String ><http://java.sun.com/products/jdk/1.3/docs/api/java/lang/String.html> uri) throws J axenException > > > Why does it return BaseXPath? Shouldn't it return void? Does this really create a > new and different object rather than changing the existing object? (The JavaDoc > is regrettably missing.) If it's merely changing an existing object the standard > return type is void. > > I suspect it's trying to allow statements like this: > > > xpath.addNamespace("prefix", "uri").addNamespace("prefix2", >"uri2").addNamespace("prefix3", "uri3"); > > <cid:[EMAIL PROTECTED]> > > Honestly, however, I find this extremely ugly and would never > write code like this, even if I could. It won't even be necessary > in the majority of cases that use zero or one namespace. > Returning an object itself from what amounts to a setter method > is just strange. It is not a normal pattern in Java. I think this method > should simple return void. > > -- > +-----------------------+------------------------+-------------------+ > | Elliotte Rusty Harold | [EMAIL PROTECTED] | Writer/Programmer | > +-----------------------+------------------------+-------------------+ > | The XML Bible, 2nd Edition (IDG Books, 2001) | > | http://www.cafeconleche.org/books/bible2/ | > | http://www.amazon.com/exec/obidos/ISBN=0764547607/cafeaulaitA/ | > +----------------------------------+---------------------------------+ > | Read Cafe au Lait for Java News: http://www.cafeaulait.org/ | > | Read Cafe con Leche for XML News: http://www.cafeconleche.org/ | > +----------------------------------+---------------------------------+ > > _______________________________________________ Jaxen-interest mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jaxen-interest