1 23 24 package org.enhydra.xml.xmlc.metadata; 25 26 import java.io.File ; 27 28 import org.enhydra.xml.xmlc.XMLCException; 29 import org.enhydra.xml.xmlc.codegen.JavaLang; 30 import org.w3c.dom.Document ; 31 32 35 public class CompileOptions extends MetaDataElement { 36 39 public static final String TAG_NAME = "compileOptions"; 40 41 44 private static final String VERBOSE_ATTR = "verbose"; 45 private static final String PRINT_VERSION_ATTR = "printVersion"; 46 private static final String PRINT_DOCUMENT_INFO_ATTR = "printDocumentInfo"; 47 private static final String PRINT_PARSE_INFO_ATTR = "printParseInfo"; 48 private static final String PRINT_DOM_ATTR = "printDOM"; 49 private static final String PRINT_ACCESSOR_INFO_ATTR = "printAccessorInfo"; 50 private static final String KEEP_GENERATED_SOURCE_ATTR = "keepGeneratedSource"; 51 private static final String CREATE_SOURCE_ATTR = "createSource"; 52 private static final String COMPILE_SOURCE_ATTR = "compileSource"; 53 private static final String SOURCE_OUTPUT_ROOT_ATTR = "sourceOutputRoot"; 54 private static final String CLASS_OUTPUT_ROOT_ATTR = "classOutputRoot"; 55 private static final String DOCUMENT_OUTPUT_ATTR = "documentOutput"; 56 private static final String WARNINGS_ATTR = "warnings"; 57 58 63 private static final String INPUT_DOCUMENT_ATTR = "inputDocument"; 64 private static final String PROCESS_SSI_ATTR = "processSSI"; 65 private static final String DOCUMENT_FORMAT_ATTR = "documentFormat"; 66 67 70 public CompileOptions(Document ownerDoc) { 71 super(ownerDoc, TAG_NAME); 72 } 73 74 77 public boolean getVerbose() { 78 return getBooleanAttribute(VERBOSE_ATTR); 79 } 80 81 84 public void setVerbose(boolean value) { 85 setBooleanAttribute(VERBOSE_ATTR, value); 86 } 87 88 91 public boolean getPrintVersion() { 92 return getBooleanAttribute(PRINT_VERSION_ATTR); 93 } 94 95 98 public void setPrintVersion(boolean value) { 99 setBooleanAttribute(PRINT_VERSION_ATTR, value); 100 } 101 102 105 public boolean getPrintDocumentInfo() { 106 return getBooleanAttribute(PRINT_DOCUMENT_INFO_ATTR); 107 } 108 109 112 public void setPrintDocumentInfo(boolean value) { 113 setBooleanAttribute(PRINT_DOCUMENT_INFO_ATTR, value); 114 } 115 116 119 public boolean getPrintParseInfo() { 120 return getBooleanAttribute(PRINT_PARSE_INFO_ATTR); 121 } 122 123 126 public void setPrintParseInfo(boolean value) { 127 setBooleanAttribute(PRINT_PARSE_INFO_ATTR, value); 128 } 129 130 133 public boolean getPrintDOM() { 134 return getBooleanAttribute(PRINT_DOM_ATTR); 135 } 136 137 140 public void setPrintDOM(boolean value) { 141 setBooleanAttribute(PRINT_DOM_ATTR, value); 142 } 143 144 147 public boolean getPrintAccessorInfo() { 148 return getBooleanAttribute(PRINT_ACCESSOR_INFO_ATTR); 149 } 150 151 154 public void setPrintAccessorInfo(boolean value) { 155 setBooleanAttribute(PRINT_ACCESSOR_INFO_ATTR, value); 156 } 157 158 161 public boolean getKeepGeneratedSource() { 162 return getBooleanAttribute(KEEP_GENERATED_SOURCE_ATTR); 163 } 164 165 168 public void setKeepGeneratedSource(boolean value) { 169 setBooleanAttribute(KEEP_GENERATED_SOURCE_ATTR, value); 170 } 171 172 176 public boolean getCompileSource() { 177 return getBooleanAttribute(COMPILE_SOURCE_ATTR, true); 178 } 179 180 183 public void setCompileSource(boolean value) { 184 setBooleanAttribute(COMPILE_SOURCE_ATTR, value, true); 185 } 186 187 190 public boolean isCompileSourceSpecified() { 191 return isAttributeSpecified(COMPILE_SOURCE_ATTR); 192 } 193 194 198 public boolean getCreateSource() { 199 return getBooleanAttribute(CREATE_SOURCE_ATTR, true); 200 } 201 202 205 public void setCreateSource(boolean value) { 206 setBooleanAttribute(CREATE_SOURCE_ATTR, value, true); 207 } 208 209 212 public boolean isCreateSourceSpecified() { 213 return isAttributeSpecified(CREATE_SOURCE_ATTR); 214 } 215 216 219 public String getSourceOutputRoot() { 220 return getAttributeNull(SOURCE_OUTPUT_ROOT_ATTR); 221 } 222 223 226 public void setSourceOutputRoot(String value) { 227 setRemoveAttribute(SOURCE_OUTPUT_ROOT_ATTR, value); 228 } 229 230 233 public String getClassOutputRoot() { 234 return getAttributeNull(CLASS_OUTPUT_ROOT_ATTR); 235 } 236 237 240 public void setClassOutputRoot(String value) { 241 setRemoveAttribute(CLASS_OUTPUT_ROOT_ATTR, value); 242 } 243 244 249 public File getPackageOutputDir() { 250 String outputRoot = getClassOutputRoot(); 251 if (outputRoot == null) { 252 outputRoot = getSourceOutputRoot(); 253 if (outputRoot == null) { 254 return null; 255 } 256 } 257 String packageName = getMetaData().getDocumentClass().getPackageName(); 258 return new File (new File (outputRoot), 259 JavaLang.packageNameToFileName(packageName)); 260 } 261 262 265 public String getDocumentOutput() { 266 return getAttributeNull(DOCUMENT_OUTPUT_ATTR); 267 } 268 269 272 public void setDocumentOutput(String value) { 273 setRemoveAttribute(DOCUMENT_OUTPUT_ATTR, value); 274 } 275 276 279 public boolean getWarnings() { 280 return getBooleanAttribute(WARNINGS_ATTR, true); 281 } 282 283 286 public void setWarnings(boolean warnings) { 287 setBooleanAttribute(WARNINGS_ATTR, warnings, true); 288 } 289 290 293 private void moveToInputDocument() { 294 InputDocument inputDoc = getMetaData().getInputDocument(); 295 String value = getAttributeNull(INPUT_DOCUMENT_ATTR); 296 if (value != null) { 297 inputDoc.setUrl(value); 298 removeAttribute(INPUT_DOCUMENT_ATTR); 299 } 300 if (isAttributeSpecified(PROCESS_SSI_ATTR)) { 301 inputDoc.setProcessSSI(getBooleanAttribute(PROCESS_SSI_ATTR)); 302 removeAttribute(PROCESS_SSI_ATTR); 303 } 304 value = getAttributeNull(DOCUMENT_FORMAT_ATTR); 305 if (value != null) { 306 inputDoc.setDocumentFormat(DocumentFormat.getType(value)); 307 removeAttribute(DOCUMENT_FORMAT_ATTR); 308 } 309 } 310 311 314 protected void completeModifications() throws XMLCException { 315 if (isAttributeSpecified(INPUT_DOCUMENT_ATTR) 316 || isAttributeSpecified(PROCESS_SSI_ATTR) 317 || isAttributeSpecified(DOCUMENT_FORMAT_ATTR)) { 318 moveToInputDocument(); 319 } 320 } 321 322 327 public String getInputDocument() { 328 return getMetaData().getInputDocument().getUrl(); 329 } 330 331 336 public void setInputDocument(String value) { 337 getMetaData().getInputDocument().setUrl(value); 338 } 339 } 340 | Popular Tags |