/** * Makes a deep copy of a <code>Map</code> if the values are * <code>Msg</code>, <code>Arg</code>, or <code>Var</code>. Otherwise, * it is a shallow copy. * * @param map The source Map to copy. * * @return A copy of the <code>Map</code> that was passed in. */ public static Map<String, Object> copyMap(Map<String, Object> map) { Map<String, Object> results = new HashMap<String, Object>(); Iterator<Entry<String, Object>> i = map.entrySet().iterator(); while (i.hasNext()) { Entry<String, Object> entry = i.next(); String key = entry.getKey(); Object value = entry.getValue(); if (value instanceof Msg) { results.put(key, ((Msg) value).clone()); } else if (value instanceof Arg) { results.put(key, ((Arg) value).clone()); } else if (value instanceof Var) { results.put(key, ((Var) value).clone()); } else { results.put(key, value); } } return results; }
String validatorName = entry.getKey(); Arg arg = entry.getValue(); argMap.put(validatorName, (Arg) arg.clone());
results.put(key, ((Msg) value).clone()); } else if (value instanceof Arg) { results.put(key, ((Arg) value).clone()); } else if (value instanceof Var) { results.put(key, ((Var) value).clone());
/** * Makes a deep copy of a <code>Map</code> if the values are * <code>Msg</code>, <code>Arg</code>, or <code>Var</code>. Otherwise, * it is a shallow copy. * * @param map The source Map to copy. * * @return A copy of the <code>Map</code> that was passed in. */ public static Map copyMap(Map map) { Map results = new HashMap(); Iterator iter = map.keySet().iterator(); while (iter.hasNext()) { String key = (String) iter.next(); Object value = map.get(key); if (value instanceof Msg) { results.put(key, ((Msg) value).clone()); } else if (value instanceof Arg) { results.put(key, ((Arg) value).clone()); } else if (value instanceof Var) { results.put(key, ((Var) value).clone()); } else { results.put(key, value); } } return results; }
/** * Makes a deep copy of a <code>Map</code> if the values are * <code>Msg</code>, <code>Arg</code>, or <code>Var</code>. Otherwise, * it is a shallow copy. * * @param map The source Map to copy. * * @return A copy of the <code>Map</code> that was passed in. */ @GwtIncompatible("incompatible method") public static Map<String, Object> copyMap(Map<String, Object> map) { Map<String, Object> results = new HashMap<String, Object>(); Iterator<Entry<String, Object>> i = map.entrySet().iterator(); while (i.hasNext()) { Entry<String, Object> entry = i.next(); String key = entry.getKey(); Object value = entry.getValue(); if (value instanceof Msg) { results.put(key, ((Msg) value).clone()); } else if (value instanceof Arg) { results.put(key, ((Arg) value).clone()); } else if (value instanceof Var) { results.put(key, ((Var) value).clone()); } else { results.put(key, value); } } return results; }
/** * Creates and returns a copy of this object. * @return A copy of the Field. */ public Object clone() { Field field = null; try { field = (Field) super.clone(); } catch(CloneNotSupportedException e) { throw new RuntimeException(e.toString()); } field.args = new Map[this.args.length]; for (int i = 0; i < this.args.length; i++) { if (this.args[i] == null) { continue; } Map argMap = new HashMap(this.args[i]); Iterator iter = argMap.keySet().iterator(); while (iter.hasNext()) { String validatorName = (String) iter.next(); Arg arg = (Arg) argMap.get(validatorName); argMap.put(validatorName, arg.clone()); } field.args[i] = argMap; } field.hVars = ValidatorUtils.copyFastHashMap(hVars); field.hMsgs = ValidatorUtils.copyFastHashMap(hMsgs); return field; }
String validatorName = entry.getKey(); Arg arg = entry.getValue(); argMap.put(validatorName, (Arg) arg.clone());
results.put(key, ((Msg) value).clone()); } else if (value instanceof Arg) { results.put(key, ((Arg) value).clone()); } else if (value instanceof Var) { results.put(key, ((Var) value).clone());
results.put(key, ((Msg) value).clone()); } else if (value instanceof Arg) { results.put(key, ((Arg) value).clone()); } else if (value instanceof Var) { results.put(key, ((Var) value).clone());