1 26 27 package org.objectweb.util.cmdline.lib; 28 29 30 import jregex.Pattern; 31 32 import org.objectweb.util.cmdline.api.RegExOptionArgument ; 33 34 35 43 44 public class DefaultRegExOptionArgument 45 extends DefaultOptionArgument 46 implements RegExOptionArgument 47 { 48 49 protected Pattern pattern; 50 51 52 58 64 public 65 DefaultRegExOptionArgument() 66 { 67 this("", "", (String [])null, null,".*"); 68 } 69 70 79 public 80 DefaultRegExOptionArgument(String label, 81 String arguments, 82 String description, 83 String argument, 84 String pattern) 85 { 86 this(new String [] { label }, arguments, 87 new String [] { description }, argument, pattern); 88 } 89 90 99 public 100 DefaultRegExOptionArgument(String [] labels, 101 String arguments, 102 String description, 103 String argument, 104 String pattern) 105 { 106 this(labels, arguments, new String []{description}, argument, pattern); 107 } 108 109 118 public 119 DefaultRegExOptionArgument(String label, 120 String arguments, 121 String [] description, 122 String argument, 123 String pattern) 124 { 125 this(new String []{label}, arguments, description, argument, pattern); 126 } 127 128 137 public 138 DefaultRegExOptionArgument(String [] labels, 139 String arguments, 140 String [] description, 141 String argument, 142 String pattern) 143 { 144 super(labels, arguments, description,argument); 145 setPattern(new Pattern(pattern)); 146 } 147 148 149 150 151 157 162 public void 163 consume(org.objectweb.util.cmdline.api.Iterator iterator) 164 { 165 checkAlreadySet(iterator); 166 String arg = consumeArgument(iterator); 167 if (getPattern().matches(arg)) 168 setArgument(arg); 169 } 170 171 177 182 public Pattern 183 getPattern() { return pattern; } 184 185 190 public void 191 setPattern(Pattern pattern) { this.pattern = pattern; } 192 } 193 | Popular Tags |