1 8 package org.jboss.axis.utils; 11 12 import java.util.Arrays ; 13 14 20 public final class CLOption 21 { 22 25 public static final int TEXT_ARGUMENT = 0; 26 27 private final int m_id; 28 private String [] m_arguments; 29 30 35 public final String getArgument() 36 { 37 return getArgument(0); 38 } 39 40 47 public final String getArgument(final int index) 48 { 49 if (null == m_arguments || index < 0 || index >= m_arguments.length) 50 { 51 return null; 52 } 53 else 54 { 55 return m_arguments[index]; 56 } 57 } 58 59 66 public final int getId() 67 { 68 return m_id; 69 } 70 71 76 public CLOption(final int id) 77 { 78 m_id = id; 79 } 80 81 86 public CLOption(final String argument) 87 { 88 this(TEXT_ARGUMENT); 89 addArgument(argument); 90 } 91 92 97 public final void addArgument(final String argument) 98 { 99 if (null == m_arguments) 100 m_arguments = new String []{argument}; 101 else 102 { 103 final String [] arguments = new String [m_arguments.length + 1]; 104 System.arraycopy(m_arguments, 0, arguments, 0, m_arguments.length); 105 arguments[m_arguments.length] = argument; 106 m_arguments = arguments; 107 } 108 } 109 110 113 public final int getArgumentCount() 114 { 115 if (null == m_arguments) 116 { 117 return 0; 118 } 119 else 120 { 121 return m_arguments.length; 122 } 123 } 124 125 130 public final String toString() 131 { 132 final StringBuffer sb = new StringBuffer (); 133 sb.append("[Option "); 134 sb.append((char)m_id); 135 136 if (null != m_arguments) 137 { 138 sb.append(", "); 139 sb.append(Arrays.asList(m_arguments)); 140 } 141 142 sb.append(" ]"); 143 144 return sb.toString(); 145 } 146 } 147 | Popular Tags |