1 26 27 package org.objectweb.openccm.command.lib; 28 29 import org.objectweb.util.cmdline.lib.DefaultOptionArgument; 31 32 42 43 public class OptionMultipleArguments 44 extends DefaultOptionArgument 45 { 46 52 53 protected String id_; 54 55 56 protected boolean consume_; 57 58 59 protected boolean multiple_; 60 61 62 protected java.util.List arguments_; 63 64 70 81 public 82 OptionMultipleArguments(String id, 83 String [] labels, 84 String arguments, 85 String [] description, 86 String argument, 87 boolean multiple ) 88 { 89 super(labels, arguments, description, argument); 90 id_ = id; 91 multiple_ = multiple; 92 consume_ = true; 93 arguments_ = new java.util.ArrayList (); 94 } 95 96 108 public 109 OptionMultipleArguments(String id, 110 String [] labels, 111 String arguments, 112 String [] description, 113 String argument, 114 boolean multiple, 115 boolean consume ) 116 { 117 super(labels, arguments, description, argument); 118 id_ = id; 119 multiple_ = multiple; 120 consume_ = consume; 121 arguments_ = new java.util.ArrayList (); 122 } 123 124 130 136 142 149 public boolean 150 check(String current) 151 { 152 if ( current.equals(id_) ) 153 return true; 154 155 if ( (current.length()>id_.length()) && (current.startsWith(id_)) && (!consume_)) 156 { 157 setArgument(current.substring(2)); 158 arguments_.add( getArgument() ); 159 return true; 160 } 161 return false; 162 } 163 164 169 public void 170 consume(org.objectweb.util.cmdline.api.Iterator iterator) 171 { 172 if (!multiple_) 173 checkAlreadySet(iterator); 174 if (consume_) 175 arguments_.add(consumeArgument(iterator)); 176 } 177 178 184 189 public String [] 190 getOptionArguments() 191 { 192 return (String [])arguments_.toArray(new String [0]); 193 } 194 195 } 196 | Popular Tags |