FileDocCategorySizeDatePackage
OfflineDottedNamePrefixes.javaAPI DocGlassfish v2 API6779Fri May 04 22:23:40 BST 2007com.sun.enterprise.management.offline

OfflineDottedNamePrefixes

public final class OfflineDottedNamePrefixes extends Object

Fields Summary
private final Map
mTemplates
private static OfflineDottedNamePrefixes
INSTANCE
private static final String
VAR
private static final String
PAR
private static final String
PART_DELIM
private static final String
NAME_VAR
private static final Object[]
TEMPLATES
Constructors Summary
private OfflineDottedNamePrefixes()

	    mTemplates  = initTemplates();
	
Methods Summary
private static java.lang.StringPAR(java.lang.String s)

	
	      
	    
	
	    return PAR + s;
	
private static java.lang.StringVAR(java.lang.String s)

	    return VAR + s;
	
private java.lang.Stringconcat(java.lang.String prefix, java.lang.String part)

        String  result  = null;
        
        if ( prefix == null || prefix.length() == 0 )
        {
            result  = part;
        }
        else
        {
            result  = prefix + PART_DELIM + part;
        }
        return( result );
    
public static synchronized com.sun.enterprise.management.offline.OfflineDottedNamePrefixesgetInstance()

	
	       
	
	
	    if ( INSTANCE == null )
	    {
	        INSTANCE    = new OfflineDottedNamePrefixes();
	    }
	    return INSTANCE; 
	
public java.lang.StringgetPrefix(javax.management.ObjectName objectName)

	    final String    j2eeType    = objectName.getKeyProperty( J2EE_TYPE_KEY );
	    if ( j2eeType == null )
	    {
	        throw new IllegalArgumentException( "" + objectName );
	    }
	    
	    String  prefix  = null;

	    final String[]  template    = getTemplate( j2eeType );
	    if ( template != null )
	    {
	        for( final String part : template )
	        {
	            String value    = null;
	            
	            if ( part.startsWith( VAR ) )
	            {
	                final String prop   = varName( part );
	                value   = objectName.getKeyProperty( prop );
	                if ( value == null )
	                {
	                    throw new IllegalArgumentException(
	                        "No property " + prop + " in " + objectName );
	                }
	            }
	            else
	            {
	                value   = part;
	            }
	            
	            prefix  = concat( prefix, value );
	        }
	    }
	    
	    return prefix;
	
private java.lang.String[]getTemplate(java.lang.String j2eeType)

        return mTemplates.get( j2eeType );
    
private java.util.MapinitTemplates()

	
	
	      
	
	
	    final Map<String,String[]>  templates   = new HashMap<String,String[]>();
	    
	    for( int i = 0; i < TEMPLATES.length; i += 2 )
	    {
	        final String    j2eeType    = (String)TEMPLATES[ i ];
	        final String[]  template    = (String[])TEMPLATES[ i + 1 ];
	        
	        templates.put( j2eeType, template );
	    }
	    
	    return templates;
	
private static java.lang.StringvarName(java.lang.String s)

	    if ( ! s.startsWith( VAR ) )
	    {
	        throw new IllegalArgumentException( s );
	    }
	    
	    return s.substring( VAR.length(), s.length() );