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

InterfacesStringifier

public class InterfacesStringifier extends Object implements Stringifier
Stringifies an object based on specified interfaces.

Fields Summary
private final StringifierRegistry
mRegistry
private final Class[]
mInterfaces
Constructors Summary
public InterfacesStringifier(Class[] interfaces)

		this( StringifierRegistryImpl.DEFAULT, interfaces );
	
public InterfacesStringifier(StringifierRegistry registry, Class[] interfaces)

		mRegistry	= registry;
		mInterfaces	= interfaces;
	
Methods Summary
public java.lang.Stringstringify(java.lang.Object o)

		String	result	= "";
		
		for( int i = 0; i < mInterfaces.length; ++i )
		{
			final Class<?> intf	= mInterfaces[ i ];
			
			final String s	= stringifyAs( o, intf );
			if ( s != null )
			{
				result	= result + intf.getName() + ": " + s + "\n";
			}
		}
		
		if ( result == null || result.length() == 0)
		{
			result	= o.toString();
		}
	
		return( result );
	
private java.lang.StringstringifyAs(java.lang.Object o, java.lang.Class theClass)

		String	result	= null;
		if ( theClass.isAssignableFrom( o.getClass() ) )
		{
			final Stringifier	stringifier	= mRegistry.lookup( theClass );
			if ( stringifier != null )
			{
				result	= stringifier.stringify( o );
			}
		}
		return( result );