示例#1
0
 /**
  * Returns the enum representation of a string. This is case sensitive.
  *
  * @param str toString representation of a default field
  * @return default field associated with a string
  * @throws IllegalArgumentException if argument is not represented by a default field.
  */
 public static Default fromString(String str) {
   for (Default field : Default.values()) {
     if (str.equals(field.toString())) {
       return field;
     }
   }
   throw new IllegalArgumentException();
 }
示例#2
0
  /**
   * Retrieves default values from xml.
   *
   * @param list the configuration list
   */
  private static void parseDefaults(NodeList list) {
    for (int i = 0; i < list.getLength(); ++i) {
      NamedNodeMap mapping = list.item(i).getAttributes();
      String attribute = mapping.getNamedItem("attribute").getNodeValue();
      String value = mapping.getNamedItem("value").getNodeValue();

      try {
        Default field = Default.fromString(attribute);
        DEFAULTS.put(field, value);
      } catch (IllegalArgumentException exc) {
        logger.warn("Unrecognized default attribute: " + attribute);
      }
    }
  }