1 23 24 package org.enhydra.xml.driver; 25 import java.io.File ; 26 import java.util.Properties ; 27 28 30 33 public class TestProperties { 34 35 public static final String XMLC_TEST_ROOT = "xmlc.test.root"; 36 public static final String XMLC_TEST_UPDATE = "xmlc.test.update"; 37 public static final String XMLC_TEST_VERBOSE = "xmlc.test.verbose"; 38 public static final String XMLC_TEST_PARSER = "xmlc.test.parser"; 39 public static final String XMLC_TEST_DOM = "xmlc.test.dom"; 40 public static final String XMLC_TEST_RELOADING = "xmlc.test.reloading"; 41 public static final String XMLC_TEST_DEFERREDPARSING = "xmlc.test.deferredparsing"; 42 public static final String XMLC_TEST_JAVAC_CLASSPATH 43 = "xmlc.test.javac.classpath"; 44 45 46 private static boolean getBooleanProp(String name) { 47 Properties props = System.getProperties(); 48 String val = props.getProperty(name, Boolean.FALSE.toString()); 49 if (val == null) { 50 return false; 51 } else if (val.equalsIgnoreCase("true") 52 || val.equalsIgnoreCase("on") 53 || val.equalsIgnoreCase("1")) { 54 return true; 55 } else { 56 return false; 57 } 58 } 59 60 61 private static void setBooleanProp(String name, 62 boolean val) { 63 Properties props = System.getProperties(); 64 props.setProperty(name, (val ? Boolean.TRUE.toString() 65 : Boolean.FALSE.toString())); 66 } 67 68 72 public static void setTestRoot(String dir) { 73 Properties props = System.getProperties(); 74 props.setProperty(XMLC_TEST_ROOT, dir); 75 } 76 77 81 public static File getTestRoot() { 82 Properties props = System.getProperties(); 83 String dir = props.getProperty(XMLC_TEST_ROOT); 84 if (dir == null) { 85 dir = "."; 86 } 87 return new File (dir); 88 } 89 90 91 public static boolean getUpdate() { 92 return getBooleanProp(XMLC_TEST_UPDATE); 93 } 94 95 96 public static void setUpdate(boolean val) { 97 setBooleanProp(XMLC_TEST_UPDATE, val); 98 } 99 100 101 public static boolean getVerbose() { 102 return getBooleanProp(XMLC_TEST_VERBOSE); 103 } 104 105 106 public static void setVerbose(boolean val) { 107 setBooleanProp(XMLC_TEST_VERBOSE, val); 108 } 109 110 111 public static String getParser(String defVal) { 112 Properties props = System.getProperties(); 113 return props.getProperty(XMLC_TEST_PARSER, defVal); 114 } 115 116 117 public static void setParser(String val) { 118 Properties props = System.getProperties(); 119 props.setProperty(XMLC_TEST_PARSER, val); 120 } 121 122 123 public static String getDom(String defVal) { 124 Properties props = System.getProperties(); 125 return props.getProperty(XMLC_TEST_DOM, defVal); 126 } 127 128 129 public static void setDom(String val) { 130 Properties props = System.getProperties(); 131 props.setProperty(XMLC_TEST_DOM, val); 132 } 133 134 135 public static boolean getReloading() { 136 return getBooleanProp(XMLC_TEST_RELOADING); 137 } 138 139 140 public static void setReloading(boolean val) { 141 setBooleanProp(XMLC_TEST_RELOADING, val); 142 } 143 144 145 public static boolean getDeferredParsing() { 146 return getBooleanProp(XMLC_TEST_DEFERREDPARSING); 147 } 148 149 150 public static void setDeferredParsing(boolean val) { 151 setBooleanProp(XMLC_TEST_DEFERREDPARSING, val); 152 } 153 154 155 public static String getJavacClassPath() { 156 Properties props = System.getProperties(); 157 return props.getProperty(XMLC_TEST_JAVAC_CLASSPATH); 158 } 159 160 161 public static void setJavacClassPath(String val) { 162 Properties props = System.getProperties(); 163 props.setProperty(XMLC_TEST_JAVAC_CLASSPATH, val); 164 } 165 } 166 | Popular Tags |