1 28 29 package org.objectweb.util.launcher.option; 30 31 32 33 import jregex.Pattern; 34 import jregex.RETokenizer; 35 36 import org.objectweb.util.cmdline.api.Iterator; 37 import org.objectweb.util.cmdline.lib.DefaultOptionArgument; 38 import org.objectweb.util.launcher.CommandFactory; 39 40 41 51 public class OptionProperty 52 extends DefaultOptionArgument 53 { 54 55 public final static String shortTag = "-D" ; 56 57 public final static String longTag = "--prop" ; 58 59 62 public OptionProperty() { 63 super(new String []{shortTag, longTag}, 64 "<name=value>", 65 "The property to set", 66 ""); 67 } 68 69 75 80 public void consume(Iterator iterator) { 81 setArgument(consumeArgument(iterator)); 82 String [] p = (new RETokenizer(new Pattern("="),getArgument())).split(); 83 if (p.length==2) 84 CommandFactory.instance().getDefaultProperties().put(p[0],p[1]); 85 else if (p.length==1) 86 CommandFactory.instance().getDefaultProperties().put(p[0],""); 87 } 88 89 94 public static String create(String name, String value) { 95 return shortTag+" "+name+"="+value+" " ; 96 } 97 } 98 | Popular Tags |