FileDocCategorySizeDatePackage
IteratorStringifierBase.javaAPI DocGlassfish v2 API3884Fri May 04 22:31:06 BST 2007com.sun.appserv.management.util.stringifier

IteratorStringifierBase

public abstract class IteratorStringifierBase extends Object implements Stringifier
Stringifies 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.Stringstringify(java.lang.Object o)

		assert( o != null );
		Iterator	iter	= (Iterator)o;
		
		return( this.stringify( iter, mDelim, mElementStringifier ) );
	
public java.lang.Stringstringify(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 voidstringifyElement(java.lang.Object elem, java.lang.String delim, java.lang.StringBuffer buf)