Beispiel #1
0
 /**
  * ** Returns true if the specified key name is equal to the current key name. ** @param otherKey
  * The key name to test for equality ** @return True if equals, false otherwise
  */
 public boolean equals(Object otherKey) {
   if (otherKey instanceof RTKey) {
     RTKey otherRTKey = (RTKey) otherKey;
     return this.getName().equals(otherRTKey.getName());
   } else {
     return false;
   }
 }
Beispiel #2
0
 /**
  * ** Sets the default property value of the property associated with the ** specified key
  * ** @param key The key of the property to set ** @param val The value to set the property to
  */
 public static void setDefaultProperty(String key, Object val) {
   Entry rtKey = RTKey.getRuntimeEntry(key);
   if (rtKey != null) {
     rtKey.setDefault(val);
   } else {
     RTKey.addRuntimeEntry(new Entry(key, val));
   }
 }
Beispiel #3
0
 /**
  * ** Compares two RTKeys lexicographically. ** @param otherKey The key name to compare ** @return
  * 0 if the keys are equal, less-than 0 if this key is lexicographically ** less than the argument
  * key, and greater-than 0 if this key is ** lexicographically greater-than the key argument.
  */
 public int compareTo(RTKey otherKey) {
   if (otherKey == null) {
     return 1;
   } else {
     return this.getName().compareTo(otherKey.getName());
   }
 }
Beispiel #4
0
 /** ** Adds an entry ({@link Entry}) to <code>RTKey</code> */
 public static void addRuntimeEntry(Entry dftEntry) {
   if (dftEntry != null) {
     String rtKey = dftEntry.getKey();
     if (rtKey != null) {
       RTKey.getRuntimeEntryMap().put(rtKey, dftEntry);
       defaultProperties = null;
     }
   }
 }
Beispiel #5
0
 public static void addRuntimeEntries(Entry dftEntry[]) {
   if (dftEntry != null) {
     Map<String, Entry> gblmap = RTKey.getRuntimeEntryMap();
     for (int i = 0; i < dftEntry.length; i++) {
       String rtKey = dftEntry[i].getKey();
       if (rtKey != null) {
         gblmap.put(rtKey, dftEntry[i]);
       }
     }
     defaultProperties = null;
   }
 }
Beispiel #6
0
 /**
  * ** 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;
 }
Beispiel #7
0
  /**
   * ** 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("");
  }
Beispiel #8
0
 /**
  * ** Apply the specified partial key as a suffix to the key name contained in this RTKey
  * ** @param rtSfx Property key suffix ** @return The combine property key from this RTKey and the
  * specified suffix.
  */
 public RTKey rtSuffix(RTKey rtSfx) {
   String sfx = (rtSfx != null) ? rtSfx.toString() : "";
   return new RTKey(this.suffix(sfx));
 }
Beispiel #9
0
 /**
  * ** Returns true if the specified key is null, or contains an empty String ** @param key The
  * RTKey to test ** @return True if the specified key is null, or contains an empty String
  */
 public static boolean isBlank(RTKey key) {
   return (key == null) ? true : key.isBlank();
 }
Beispiel #10
0
 /**
  * ** Gets the default property value associated with the specified key. ** Returns <code>dft
  * </code> if none was found ** @param key The key of the property to get ** @param dft The value
  * to return if no propetry value was found
  */
 public static Object getDefaultProperty(String key, Object dft) {
   Entry rtKey = RTKey.getRuntimeEntry(key);
   return (rtKey != null) ? rtKey.getDefault() : dft;
 }
Beispiel #11
0
 /**
  * ** Returns true if the specified default property key is defined ** @param key A property key
  * ** @return True if the specified default property key is defined
  */
 public static boolean hasDefault(String key) {
   return (RTKey.getRuntimeEntry(key) != null);
 }
Beispiel #12
0
 /**
  * ** Gets the entry associated with the specified key ** @param key The key of the entry to get
  * ** @return The entry
  */
 protected static Entry getRuntimeEntry(String key) {
   return (key != null) ? RTKey.getRuntimeEntryMap().get(key) : null;
 }
Beispiel #13
0
 /** ** Gets an iterator over all of the entries ** @return The iterator over the entries */
 public static Iterator<String> getRuntimeKeyIterator() {
   return RTKey.getRuntimeEntryMap().keySet().iterator();
 }