FileDocCategorySizeDatePackage
ArgHelperOptionsInfo.javaAPI DocGlassfish v2 API7937Fri May 04 22:24:48 BST 2007com.sun.cli.jmx.cmd

ArgHelperOptionsInfo

public class ArgHelperOptionsInfo extends Object implements ArgHelper.OptionsInfo

Fields Summary
final HashMap
mOptionDescriptions
public static final char
MULTIPLE_DELIM
public static final char
NUMVALUES_DELIM
Constructors Summary
public ArgHelperOptionsInfo()

		mOptionDescriptions	= new HashMap();
	
public ArgHelperOptionsInfo(String options)

		mOptionDescriptions	= new HashMap();
		
		addOptions( options );
	
Methods Summary
voidadd(com.sun.cli.jmx.cmd.ArgHelperOptionsInfo$OptionDesc desc)

		checkExists( desc.mName );
		
		mOptionDescriptions.put( desc.mName, desc );
	
public voidaddBoolean(java.lang.String name)

		add( new OptionDesc( name ) );
	
public voidaddNonBoolean(java.lang.String name, int numValues)

		add( new OptionDesc( name, numValues ) );
	
public voidaddOptions(java.lang.String list)

	
		 
	   
		 
	
		final String []	names	= list.split(" ");
		
		for (int i = 0; i < names.length; ++i) {
                     final String[] data = names[i].split("" + NUMVALUES_DELIM);

                     if (data.length == 1) {
                         addBoolean(data[0]);
                     } else {
                         addNonBoolean(data[0],
                                       Integer.valueOf(data[1]).intValue());
                     }
                 }
	
voidcheckExists(java.lang.String optionName)

		if ( exists( optionName ) )
		{
			throw new IllegalArgumentException( "can't add same option twice: " + optionName );
		}
	
public voidcheckLegalOption(java.lang.String token)

		if ( ! isLegalOption( token ) )
		{
			throw new IllegalArgumentException( "illegal option: " + token );
		}
	
private static voiddm(java.lang.Object o)

		System.out.println( o.toString() );
	
booleanexists(java.lang.String optionName)

		return( mOptionDescriptions.get( optionName ) != null );
	
com.sun.cli.jmx.cmd.ArgHelperOptionsInfo$OptionDescfindOptionDesc(java.lang.String token)

		final String	optionName	= tokenToOptionName( OptionDesc.mapName( token ) );
		
		return( (OptionDesc)mOptionDescriptions.get( optionName ) );
	
public voidfoundIllegalOption(java.lang.String token)

		throw new ArgHelper.IllegalOptionException( "illegal option: " + token );
	
public intgetNumValues(java.lang.String token)

		checkLegalOption( token );
		
		final OptionDesc	info	= findOptionDesc( token );
		
		return( info.mNumValues );
	
public booleanisBoolean(java.lang.String token)

		checkLegalOption( token );
		
		final OptionDesc	info	= findOptionDesc( token );
		
		return( info.mIsBoolean );
	
public booleanisLegalOption(java.lang.String token)

		if ( ! token.startsWith( "-" ) )
		{
			return( false );
		}

		final boolean	isLegal	= (findOptionDesc( token ) != null);
		
		return( isLegal );
	
public java.lang.StringtokenToOptionData(java.lang.String token)

		final int	delimIndex	= token.indexOf( '=" );
		
		String	data	= null;	// return null if no data eg "--foo"
		
		if ( delimIndex > 0 )
		{
			// note: form "--foo=" is valid and should result in an empty string
			data	= token.substring( delimIndex + 1, token.length() );
		}
		
		return( data );
	
public java.lang.StringtokenToOptionName(java.lang.String token)

		final int	delimIndex	= token.indexOf( '=" );
		
		String	name	= token;
		
		if ( delimIndex > 0 )
		{
			name	= token.substring( 0, delimIndex );
		}
		
		return( name );