FileDocCategorySizeDatePackage
CLOption.javaAPI DocApache Axis 1.43743Sat Apr 22 18:57:28 BST 2006org.apache.axis.utils

CLOption

public final class CLOption extends Object
Basic class describing an instance of option.
author
Peter Donald
since
4.0

Fields Summary
public static final int
TEXT_ARGUMENT
Value of {@link #getId} when the option is a text argument.
private final int
m_id
private String[]
m_arguments
Constructors Summary
public CLOption(int id)
Constructor taking an id (that must be a proper character code)

param
id the new id

        m_id = id;
    
public CLOption(String argument)
Constructor taking argument for option.

param
argument the argument

        this( TEXT_ARGUMENT );
        addArgument( argument );
    
Methods Summary
public final voidaddArgument(java.lang.String argument)
Mutator of Argument property.

param
argument the argument

        if( null == m_arguments ) m_arguments = new String[] { argument };
        else
        {
            final String[] arguments = new String[ m_arguments.length + 1 ];
            System.arraycopy( m_arguments, 0, arguments, 0, m_arguments.length );
            arguments[ m_arguments.length ] = argument;
            m_arguments = arguments;
        }
    
public final java.lang.StringgetArgument()
Retrieve argument to option if it takes arguments.

return
the (first) argument


                     
       
    
        return getArgument( 0 );
    
public final java.lang.StringgetArgument(int index)
Retrieve indexed argument to option if it takes arguments.

param
index The argument index, from 0 to {@link #getArgumentCount()}-1.
return
the argument

        if( null == m_arguments || index < 0 || index >= m_arguments.length )
        {
            return null;
        }
        else
        {
            return m_arguments[ index ];
        }
    
public final intgetArgumentCount()
Get number of arguments.

        if( null == m_arguments )
        {
            return 0;
        }
        else
        {
            return m_arguments.length;
        }
    
public final intgetId()
Retrieve id of option. The id is eqivalent to character code if it can be a single letter option.

return
the id

        return m_id;
    
public final java.lang.StringtoString()
Convert to String.

return
the string value

        final StringBuffer sb = new StringBuffer();
        sb.append( "[Option " );
        sb.append( (char)m_id );

        if( null != m_arguments )
        {
            sb.append( ", " );
            sb.append( Arrays.asList( m_arguments ) );
        }

        sb.append( " ]" );

        return sb.toString();