FileDocCategorySizeDatePackage
AliasMgr.javaAPI DocGlassfish v2 API5667Fri May 04 22:24:52 BST 2007com.sun.cli.jmx.support

AliasMgr

public final class AliasMgr extends Object implements AliasMgrMBean

Fields Summary
final AliasMgrSPI
mImpl
Constructors Summary
public AliasMgr(AliasMgrSPI impl)

		mImpl	= impl;
	
Methods Summary
private static voidcheckLegalAlias(java.lang.String aliasName)

		if ( ! isValidAlias( aliasName ) )
		{
			throw new IllegalArgumentException( "illegal alias name: \"" + aliasName + "\"");
		}
	
public voidcreateAlias(java.lang.String aliasName, java.lang.String objectName)

		checkLegalAlias( aliasName );
		
		if ( resolveAlias( aliasName ) != null )
		{
			// illegal to create an already-existing alias
			throw new IllegalArgumentException( "alias already exists: " + aliasName );
		}
		
		mImpl.create( aliasName, objectName );
	
public voiddeleteAlias(java.lang.String aliasName)

		checkLegalAlias( aliasName );
		
		mImpl.delete( aliasName );
	
public java.lang.String[]getAliases()

		return( listAliases( ) );
	
public static booleanisValidAlias(java.lang.String str)

		final int strLength	= str.length();

		boolean	isValid	= strLength != 0;
		if ( isValid )
		{
			// this can be done more efficiently with a BitMap or Set, but who cares
			for( int i = 0; i < strLength; ++i )
			{
				final char theChar = str.charAt( i );
				
				if ( ! LegalAliasChars.isLegalAliasChar( theChar ) )
				{
					isValid	= false;
					break;
				}
				
			}
		}
		
		return( isValid );
	
public java.lang.String[]listAliases()

		return( listAliases( false ) );
	
public java.lang.String[]listAliases(boolean showValues)

		final Set		keys	= mImpl.getNames();
		final int		numKeys	= keys.size();
		
		final String []	aliases	= new String[ numKeys ];
		final Iterator	iter	= keys.iterator();
		
		for( int i = 0; i < numKeys; ++i )
		{
			final String	key	= (String)iter.next();
			
			if ( showValues )
			{
				aliases[ i ]	= key + "=" + resolveAlias( key );
			}
			else
			{
				aliases[ i ]	= key;
			}
		}
		
		Arrays.sort( aliases );
		
		return( aliases );
	
public java.lang.StringresolveAlias(java.lang.String aliasName)

		checkLegalAlias( aliasName );
		
		final String	result	= (String)mImpl.get( aliasName );
		
		return( result );