예제 #1
0
  /**
   * 判断相等
   *
   * @param params0
   * @param params1
   * @return
   */
  public static boolean equals(Hashtable params0, Hashtable params1) {
    // 相等,包括均为空
    if (params0 == null && params1 == null) {
      return true;
    }
    // 非空
    if (params0 == null || params1 == null) {
      return false;
    }

    if (params0.size() != params1.size()) {
      return false;
    }
    // 键和值相等
    for (Enumeration e = params0.keys(); e.hasMoreElements(); ) {
      String key0 = (String) e.nextElement();
      String val0 = (String) params0.get(key0);

      if (params1.containsKey(key0)) {
        String val1 = (String) params1.get(key0);
        if (!val0.equals(val1)) {
          return false;
        }
      } else {
        return false;
      }
    }
    return true;
  }
예제 #2
0
  /**
   * 合并参数列表
   *
   * @param p0
   * @param p1
   * @return
   */
  public static Hashtable join(Hashtable p0, Hashtable p1) {
    if (p0 != null && p1 != null) {

      Hashtable p = new Hashtable();
      for (Enumeration e = p0.keys(); e.hasMoreElements(); ) {
        String key = (String) e.nextElement();
        String value = (String) p0.get(key);
        p.put(key, value);
      }

      for (Enumeration e = p1.keys(); e.hasMoreElements(); ) {
        String key = (String) e.nextElement();
        if (!p0.containsKey(key)) {
          p.put(key, p1.get(key));
        }
      }

      return p;
    }
    return p0;
  }