/** * ** Gets all the ddefault properties in <code>RTKey</code> represented ** as an {@link * RTProperties} instance ** @return The <code>RTProperties</code> instance */ public static RTProperties getDefaultProperties() { if (defaultProperties == null) { RTProperties rtp = new RTProperties(); for (Iterator<Entry> v = RTKey.getRuntimeEntryMap().values().iterator(); v.hasNext(); ) { Entry rtk = v.next(); if (!rtk.isHelp()) { String key = rtk.getKey(); Object val = rtk.getDefault(); rtp.setProperty(key, val); } } defaultProperties = rtp; } return defaultProperties; }
/** * ** Prints all the default values from <code>RTKey</code> and {@link RTConfig} ** to the * specified <code>PrintStream</code>. Used for debugging/testing ** @param out The <code> * PrintStream</code> */ public static void printDefaults(PrintStream out) { /* print standard runtime entries */ Set<String> keyList = new OrderedSet<String>(); String keyGrp = null; for (Iterator<Entry> v = RTKey.getRuntimeEntryMap().values().iterator(); v.hasNext(); ) { Entry rtk = v.next(); if (rtk.isHelp()) { out.println(""); out.println("# ===== " + rtk.getHelp()); } else { Object dft = rtk.getDefault(); out.println("# --- " + rtk.getHelp()); out.println("# " + rtk.toString(dft)); String key = rtk.getKey(); keyList.add(key); if (!key.equals(CONFIG_FILE) && RTConfig.hasProperty(key)) { String val = RTConfig.getString(key, null); // if ((val != null) && ((dft == null) || !val.equals(dft.toString()))) { out.println(rtk.toString(val)); // } } } } /* orphaned entries */ RTProperties cmdLineProps = RTConfig.getConfigFileProperties(); if (cmdLineProps != null) { boolean orphanHeader = false; for (Iterator i = cmdLineProps.keyIterator(); i.hasNext(); ) { Object k = i.next(); if (!k.equals(COMMAND_LINE_CONF) && !keyList.contains(k)) { if (!orphanHeader) { out.println(""); out.println("# ===== Other entries"); orphanHeader = true; } Object v = cmdLineProps.getProperty(k, null); out.println(k + "=" + ((v != null) ? v : NULL_VALUE)); } } } /* final blank line */ out.println(""); }