IteratorStringifierBasepublic abstract class IteratorStringifierBase extends Object implements StringifierStringifies an Iterator, using an optional element Stringifier.
Must be subclassed to provide Stringification of an element. |
Fields Summary |
---|
public final String | mDelim | public final Stringifier | mElementStringifier | public static final IteratorStringifier | DEFAULT |
Constructors Summary |
---|
public IteratorStringifierBase()
this( ObjectStringifier.DEFAULT );
| public IteratorStringifierBase(String delim)
this( delim, new SmartStringifier( delim ) );
| public IteratorStringifierBase(Stringifier elementStringifier)
this( ",", elementStringifier );
| public IteratorStringifierBase(String delim, Stringifier elementStringifier)
mDelim = delim;
mElementStringifier = elementStringifier;
|
Methods Summary |
---|
public java.lang.String | stringify(java.lang.Object o)
assert( o != null );
Iterator iter = (Iterator)o;
return( this.stringify( iter, mDelim, mElementStringifier ) );
| public java.lang.String | stringify(java.util.Iterator iter, java.lang.String delim, Stringifier stringifier)
assert( iter != null );
StringBuffer buf = new StringBuffer();
while ( iter.hasNext() )
{
final Object elem = iter.next();
stringifyElement( elem, delim, buf );
buf.append( delim );
}
// strip trailing delimiter
final int length = buf.length();
if ( length != 0 )
{
buf.setLength( length - delim.length() );
}
return( buf.toString() );
| protected abstract void | stringifyElement(java.lang.Object elem, java.lang.String delim, java.lang.StringBuffer buf)
|
|