1 23 24 package org.enhydra.xml.xmlc.commands.options; 25 26 import org.enhydra.xml.io.ErrorReporter; 27 import org.enhydra.xml.xmlc.XMLCException; 28 29 36 public abstract class Option { 37 40 protected final String name; 41 42 45 protected final int numArgs; 46 47 50 protected final boolean multipleAllowed; 51 52 55 protected String help; 56 57 67 public Option(String name, 68 int numArgs, 69 boolean multipleAllowed, 70 String help) { 71 this.name = name; 72 this.numArgs = numArgs; 73 this.multipleAllowed = multipleAllowed; 74 this.help = help; 75 } 76 77 80 public String getName() { 81 return name; 82 } 83 84 89 public int getNumArgs() { 90 return numArgs; 91 } 92 93 98 public boolean getMultipleAllowed() { 99 return multipleAllowed; 100 } 101 102 105 public String getHelp() { 106 return name + " " + help; 107 } 108 109 117 public boolean equals(Object obj) { 118 if (obj instanceof Option) { 119 return name.equals(((Option)obj).getName()); 120 } else if (obj instanceof String ) { 121 return name.equals((String )obj); 122 } else { 123 return false; 124 } 125 } 126 127 130 public int hashCode() { 131 return name.hashCode(); 132 } 133 134 144 abstract protected void parse(String [] args, 145 ErrorReporter errorReporter, 146 Object clientData) throws XMLCException; 147 } 148 | Popular Tags |