+1 I've thought about something similar, just never did anything about it. I like the idea of being able to exclude some fields from the string build.
On 8/4/05, Gary Gregory <[EMAIL PROTECTED]> wrote: > Hello: > > Right now, I use the code below to exclude password fields from output. > > /** > * Builds a String for a toString method excluding the given field > name. > * > * @param obj > * The object to "toString". > * @param excludeFieldName > * The field name to exclude > * @return The toString String. > */ > public static String toStringExcluding(Object obj, final String > excludeFieldName) { > return (new ReflectionToStringBuilder(obj) { > protected boolean accept(Field f) { > return super.accept(f) && > !f.getName().equals(excludeFieldName); > } > }).toString(); > } > > I could imagine writing my call sites like this instead: > > new ReflectionToStringBuilder(obj).setExcludeFields(new > String[]{"password"}).toString(); > > Which means adding the set/getExcludeFields() feature. > > Any thoughts? > > Gary > > -- Steven Caswell [EMAIL PROTECTED] (c) 404-693-4148 (o) 404-260-2382 Take back the web - http://www.mozilla.org --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]