示例#1
0
  /** @see java.util.Map#containsValue(java.lang.Object) */
  public boolean containsValue(Object value) {
    validateValue(value);

    boolean containsValue = false;

    Set entrySet = entrySet();
    for (Iterator i = entrySet.iterator(); !containsValue && i.hasNext(); ) {
      Map.Entry e = (Map.Entry) i.next();

      Object entryValue = e.getValue();
      containsValue = (entryValue != null) && entryValue.equals(value);
    }

    return containsValue;
  }
示例#2
0
  /**
   * Associates the given key with the given value. If the given key has multiple levels (consists
   * of multiple strings separated by '.'), the property value is stored such that it can be
   * retrieved either directly, by calling get() and passing the entire key; or indirectly, by
   * decomposing the key into its separate levels and calling get() successively on the result of
   * the previous level's get. <br>
   * For example, given <br>
   * <code>
   * PropertyTree tree = new PropertyTree();
   * tree.set( "a.b.c", "something" );
   * </code> the following statements are equivalent ways to retrieve the value: <br>
   * <code>
   * Object one = tree.get( "a.b.c" );
   * </code> <code>
   * Object two = tree.get( "a" ).get( "b" ).get( "c" );
   * </code><br>
   * Note: since I can't have the get method return both a PropertyTree and a String, getting an
   * actual String requires calling toString on the PropertyTree returned by get.
   *
   * @param key
   * @param value
   * @throws IllegalArgumentException if the key is null
   * @throws IllegalArgumentException if the value is null
   */
  public void setProperty(String key, String value) {
    validateKey(key);
    validateValue(value);

    if (parent == null) {
      LOG.debug("setting (k,v) (" + key + "," + value + ")");
    }

    if (StringUtils.contains(key, '.')) {
      String prefix = StringUtils.substringBefore(key, ".");
      String suffix = StringUtils.substringAfter(key, ".");

      PropertyTree node = getChild(prefix);
      node.setProperty(suffix, value);
    } else {
      PropertyTree node = getChild(key);
      node.setDirectValue(value);
    }
  }
示例#3
0
  /**
   * Sets the directValue of this PropertyTree to the given value.
   *
   * @param value
   */
  private void setDirectValue(String value) {
    validateValue(value);

    this.directValue = value;
  }