@Test public void testSanitizeAttributesBecauseOfKeys() { HashMap<String, Object> attributes = new HashMap<String, Object>(); attributes.put(dollarkey, validAttributes[0]); attributes.put(validkey, validAttributes[2]); attributes.put(dotkey, validAttributes[3]); attributes.put(nullcharkey, validAttributes[4]); attributes = LQModel.sanitizeAttributes(attributes, false); assertTrue("Number of attributes should be 1, but its " + attributes.size(), 1 == attributes.size()); }
public static HashMap<String, Object> sanitizeAttributes(Map<String, Object> attributes, boolean raiseException) { if (attributes == null) { return null; } HashMap<String, Object> attrs = new HashMap<String, Object>(); for (String key : attributes.keySet()) { if (LQModel.validKey(key, raiseException) && LQModel.validValue(attributes.get(key), raiseException)) { attrs.put(key, attributes.get(key)); } } return attrs; }
LQModel implements Serializable { public static HashMap<String, Object> sanitizeAttributes(Map<String, Object> attributes, boolean raiseException) { if (attributes == null) { return null; } HashMap<String, Object> attrs = new HashMap<String, Object>(); for (String key : attributes.keySet()) { if (LQModel.validKey(key, raiseException) && LQModel.validValue(attributes.get(key), raiseException)) { attrs.put(key, attributes.get(key)); } } return attrs; } }
LQModel implements Serializable { public static HashMap<String, Object> sanitizeAttributes(Map<String, Object> attributes, boolean raiseException) { if (attributes == null) { return null; } HashMap<String, Object> attrs = new HashMap<String, Object>(); for (String key : attributes.keySet()) { if (LQModel.validKey(key, raiseException) && LQModel.validValue(attributes.get(key), raiseException)) { attrs.put(key, attributes.get(key)); } } return attrs; }  }
LQModel implements Serializable { public static HashMap<String, Object> sanitizeAttributes(Map<String, Object> attributes, boolean raiseException) { if (attributes == null) { return null; } HashMap<String, Object> attrs = new HashMap<String, Object>(); for (String key : attributes.keySet()) { if (LQModel.validKey(key, raiseException) && LQModel.validValue(attributes.get(key), raiseException)) { attrs.put(key, attributes.get(key)); } } return attrs; }  static String newIdentifier(); static boolean validKey(String key, boolean raiseException); static boolean validValue(Object attribute, boolean raiseException); static HashMap<String, Object> sanitizeAttributes(Map<String, Object> attributes, boolean raiseException); void save(Context context, String path); static JSONObject retriveFromFile(Context context, String path); static List<Object> toList(JSONArray array, String[] excludedKeys); abstract JSONObject toJSON(); }
LQModel implements Serializable { public static HashMap<String, Object> sanitizeAttributes(Map<String, Object> attributes, boolean raiseException) { if (attributes == null) { return null; } HashMap<String, Object> attrs = new HashMap<String, Object>(); for (String key : attributes.keySet()) { if (LQModel.validKey(key, raiseException) && LQModel.validValue(attributes.get(key), raiseException)) { attrs.put(key, attributes.get(key)); } } return attrs; }  static String newIdentifier(); static boolean validKey(String key, boolean raiseException); static boolean validValue(Object attribute, boolean raiseException); static HashMap<String, Object> sanitizeAttributes(Map<String, Object> attributes, boolean raiseException); void save(Context context, String path); static JSONObject retriveFromFile(Context context, String path); static List<Object> toList(JSONArray array, String[] excludedKeys); abstract JSONObject toJSON();  }