1 16 package org.apache.axis.utils; 19 20 import java.util.Arrays ; 21 22 28 public final class CLOption 29 { 30 33 public static final int TEXT_ARGUMENT = 0; 34 35 private final int m_id; 36 private String [] m_arguments; 37 38 43 public final String getArgument() 44 { 45 return getArgument( 0 ); 46 } 47 48 55 public final String getArgument( final int index ) 56 { 57 if( null == m_arguments || index < 0 || index >= m_arguments.length ) 58 { 59 return null; 60 } 61 else 62 { 63 return m_arguments[ index ]; 64 } 65 } 66 67 74 public final int getId() 75 { 76 return m_id; 77 } 78 79 84 public CLOption( final int id ) 85 { 86 m_id = id; 87 } 88 89 94 public CLOption( final String argument ) 95 { 96 this( TEXT_ARGUMENT ); 97 addArgument( argument ); 98 } 99 100 105 public final void addArgument( final String argument ) 106 { 107 if( null == m_arguments ) m_arguments = new String [] { argument }; 108 else 109 { 110 final String [] arguments = new String [ m_arguments.length + 1 ]; 111 System.arraycopy( m_arguments, 0, arguments, 0, m_arguments.length ); 112 arguments[ m_arguments.length ] = argument; 113 m_arguments = arguments; 114 } 115 } 116 117 120 public final int getArgumentCount() 121 { 122 if( null == m_arguments ) 123 { 124 return 0; 125 } 126 else 127 { 128 return m_arguments.length; 129 } 130 } 131 132 137 public final String toString() 138 { 139 final StringBuffer sb = new StringBuffer (); 140 sb.append( "[Option " ); 141 sb.append( (char)m_id ); 142 143 if( null != m_arguments ) 144 { 145 sb.append( ", " ); 146 sb.append( Arrays.asList( m_arguments ) ); 147 } 148 149 sb.append( " ]" ); 150 151 return sb.toString(); 152 } 153 } 154 | Popular Tags |