1 23 24 package org.enhydra.xml.xmlc.commands.xmlc; 25 26 import org.enhydra.xml.io.ErrorReporter; 27 import org.enhydra.xml.xmlc.XMLCException; 28 import org.enhydra.xml.xmlc.commands.options.BooleanOption; 29 import org.enhydra.xml.xmlc.commands.options.FlagOption; 30 import org.enhydra.xml.xmlc.commands.options.Option; 31 import org.enhydra.xml.xmlc.commands.options.OptionSet; 32 import org.enhydra.xml.xmlc.metadata.MetaData; 33 34 38 class CompileOptsCmdOptions extends BaseCmdOptions { 39 42 private class VerboseOption extends FlagOption { 43 46 public VerboseOption() { 47 super("-verbose", 48 "- Generate useful output about the compiler process."); 49 } 50 51 54 protected void set(Object clientData) throws XMLCException { 55 ((MetaData)clientData).getCompileOptions().setVerbose(true); 56 } 57 } 58 59 62 private class KeepOption extends FlagOption { 63 66 public KeepOption() { 67 super("-keep", 68 "- Keep the generate java source, do not delete it."); 69 } 70 71 74 protected void set(Object clientData) throws XMLCException { 75 ((MetaData)clientData).getCompileOptions().setKeepGeneratedSource(true); 76 } 77 } 78 79 82 private class NoCompileOption extends FlagOption { 83 86 public NoCompileOption() { 87 super("-nocompile", 88 "- If specified, don't compile the generate java file."); 89 } 90 91 94 protected void set(Object clientData) throws XMLCException { 95 ((MetaData)clientData).getCompileOptions().setCompileSource(false); 96 } 97 } 98 99 102 private class InfoOption extends FlagOption { 103 106 public InfoOption() { 107 super("-info", 108 "- Print useful information about the page object, such as ids and URLs."); 109 } 110 111 114 protected void set(Object clientData) throws XMLCException { 115 ((MetaData)clientData).getCompileOptions().setPrintDocumentInfo(true); 116 } 117 } 118 119 122 private class DumpOption extends FlagOption { 123 126 public DumpOption() { 127 super("-dump", 128 "- Dump out the DOM tree for the page."); 129 } 130 131 134 protected void set(Object clientData) throws XMLCException { 135 ((MetaData)clientData).getCompileOptions().setPrintDOM(true); 136 } 137 } 138 139 142 private class ParseInfoOption extends FlagOption { 143 146 public ParseInfoOption() { 147 super("-parseinfo", 148 "- Print detailed information about the page parsing."); 149 } 150 151 154 protected void set(Object clientData) throws XMLCException { 155 ((MetaData)clientData).getCompileOptions().setPrintParseInfo(true); 156 } 157 } 158 159 162 private class MethodsOption extends FlagOption { 163 166 public MethodsOption() { 167 super("-methods", 168 "- Print the signature of each generated access method."); 169 } 170 171 174 protected void set(Object clientData) throws XMLCException { 175 ((MetaData)clientData).getCompileOptions().setPrintAccessorInfo(true); 176 } 177 } 178 179 182 private class VersionOption extends FlagOption { 183 186 public VersionOption() { 187 super("-version", 188 "- Print the XMLC version number."); 189 } 190 191 194 protected void set(Object clientData) throws XMLCException { 195 ((MetaData)clientData).getCompileOptions().setPrintVersion(true); 196 } 197 } 198 199 202 private class SSIOption extends FlagOption { 203 206 public SSIOption() { 207 super("-ssi", 208 "- Process server-side include directives"); 209 } 210 211 214 protected void set(Object clientData) throws XMLCException { 215 ((MetaData)clientData).getInputDocument().setProcessSSI(true); 216 } 217 } 218 219 223 private class SSIBaseOption extends Option { 224 227 public SSIBaseOption() { 228 super("-ssibase", 1, false, 229 "basedir - Process absolute given ssi directives relative from the specified dir"); 230 } 231 232 235 protected void parse(String [] args, 236 ErrorReporter errorReporter, 237 Object clientData) throws XMLCException { 238 ((MetaData)clientData).getInputDocument().setSSIBase(args[0]); 240 } 241 } 242 244 247 private class DocOutOption extends Option { 248 251 public DocOutOption() { 252 super("-docout", 1, false, 253 "outfile - Write a static document to the outfile instead of generating a class"); 254 } 255 256 259 public void parse(String [] args, 260 ErrorReporter errorReporter, 261 Object clientData) throws XMLCException { 262 MetaData metaData = (MetaData)clientData; 263 metaData.getCompileOptions().setDocumentOutput(args[0]); 264 metaData.getCompileOptions().setCreateSource(false); 265 } 266 } 267 268 271 private class SourceOutputOption extends Option { 272 275 public SourceOutputOption() { 276 super("-sourceout", 1, false, 277 "sourceout - Root directory for generated source files."); 278 } 279 280 283 protected void parse(String [] args, 284 ErrorReporter errorReporter, 285 Object clientData) throws XMLCException { 286 ((MetaData)clientData).getCompileOptions().setSourceOutputRoot(args[0]); 287 } 288 } 289 290 293 private class WarningsOption extends BooleanOption { 294 297 public WarningsOption() { 298 super("-warnings", 299 "yes|no|true|false - Enable or disable warnings"); 300 } 301 302 305 protected void set(boolean value, 306 Object clientData) throws XMLCException { 307 ((MetaData)clientData).getParser().setWarnings(value); 309 ((MetaData)clientData).getCompileOptions().setWarnings(value); 310 } 311 } 312 313 316 public CompileOptsCmdOptions(OptionSet optionSet) { 317 super(optionSet); 318 optionSet.addOption(new VersionOption()); 319 optionSet.addOption(new KeepOption()); 320 optionSet.addOption(new NoCompileOption()); 321 optionSet.addOption(new InfoOption()); 322 optionSet.addOption(new DumpOption()); 323 optionSet.addOption(new VerboseOption()); 324 optionSet.addOption(new ParseInfoOption()); 325 optionSet.addOption(new MethodsOption()); 326 optionSet.addOption(new SSIOption()); 327 optionSet.addOption(new SSIBaseOption()); 329 optionSet.addOption(new DocOutOption()); 331 optionSet.addOption(new SourceOutputOption()); 332 optionSet.addOption(new WarningsOption()); 333 } 334 } 335 | Popular Tags |