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

ArgHelperOptionInfoImplBase

public class ArgHelperOptionInfoImplBase extends Object implements ArgHelper.OptionsInfo

Fields Summary
final ArrayList
mOptionDescriptions
public static final char
MULTIPLE_DELIM
public static final char
NUMVALUES_DELIM
Constructors Summary
public ArgHelperOptionInfoImplBase()

		mOptionDescriptions	= new ArrayList();
	
public ArgHelperOptionInfoImplBase(String options)

		mOptionDescriptions	= new ArrayList();
		
		addOptions( options );
	
Methods Summary
public voidaddBoolean(java.lang.String name)

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

		mOptionDescriptions.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());
                     }
                 }
	
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() );
	
com.sun.cli.jmx.cmd.ArgHelperOptionInfoImplBase$OptionDescfindOptionDesc(java.lang.String token)

		OptionDesc		info	= null;
		
		final String	optionName	= tokenToOptionName( OptionDesc.mapName( token ) );
		
		final Iterator iter	= mOptionDescriptions.iterator();
		while( iter.hasNext() )
		{
			final OptionDesc	optionDesc	= (OptionDesc)iter.next();
			
			if ( optionDesc.mName.equalsIgnoreCase( optionName ) )
			{
				info	= optionDesc;
				break;
			}
		}
		return( info );
	
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)

		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 );