FileDocCategorySizeDatePackage
IteratorStringifierBase.javaAPI DocGlassfish v2 API4084Fri May 04 22:25:02 BST 2007com.sun.cli.util.stringifier

IteratorStringifierBase

public abstract class IteratorStringifierBase extends Object implements Stringifier

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();
			assert( elem != null );
			
			stringifyElement( elem, delim, buf );
		}
		
		// strip trailing delimiter
		final int	length	= buf.length();
		if ( length != 0 )
		{
			buf.setLength( length - delim.length() );
		}

		return( buf.toString() );
	
public static java.lang.Stringstringify(java.util.Iterator iter, java.lang.String delim)

		final IteratorStringifier	stringifier	= new IteratorStringifier( delim );
		
		return( stringifier.stringify( iter, delim, SmartStringifier.DEFAULT ) );
	
public abstract voidstringifyElement(java.lang.Object elem, java.lang.String delim, java.lang.StringBuffer buf)