FileDocCategorySizeDatePackage
MapConverter.javaAPI DocGlassfish v2 API4687Fri May 04 22:30:32 BST 2007com.sun.appserv.management.client

MapConverter

public final class MapConverter extends Object
Converts Maps obtained from the server back into their proprietary (non-standard) java types.

Fields Summary
Constructors Summary
private MapConverter()

Methods Summary
public static java.lang.Objectconvert(java.util.Map m)
This form should be used where the appropriate class is not known in advance.

        return doConvert( m );
    
public static TconvertToClass(java.util.Map m, java.lang.Class theClass)
This form should be used where the appropriate class is known in advance.

        return theClass.cast( doConvert( m ) );
    
private static java.lang.ObjectdoConvert(java.util.Map m)
Of course there are more elaborate ways to do this, but given the small number of conversions, this straightforward approach is best.

        Object  result  = m;    // don't convert, by default
        
        final String interfaceName = (String)m.get(MAP_CAPABLE_CLASS_NAME_KEY);
        if ( interfaceName != null )
        {
            if ( DEPLOYMENT_PROGRESS_CLASS_NAME.equals( interfaceName ) )
            {
                result  = DeploymentSupport.mapToDeploymentProgress( m );
            }
            else if ( DEPLOYMENT_SOURCE_CLASS_NAME.equals( interfaceName ) )
            {
                result  = DeploymentSupport.mapToDeploymentSource( m );
            }
            else if ( DEPLOYMENT_STATUS_CLASS_NAME.equals( interfaceName ) )
            {
                result  = DeploymentSupport.mapToDeploymentStatus( m );
            }
            else if ( MessageTrace.CLASS_NAME.equals( interfaceName ) )
            {
                result  = new MessageTraceImpl( m, MessageTrace.class.getName());
            }
            else
            {
                // That's OK, we just leave it as a Map
            }
        }
        return result;