@Test public void testKeyNullCharInvalid() { boolean valid = LQModel.validKey(nullcharkey, false); assertFalse("Should be an invalid key", valid); try { valid = LQModel.validKey(nullcharkey, true); fail("Should throw exception because is a invalid key"); } catch (IllegalArgumentException e) { assertFalse(valid); } }
public static boolean validKey(String key, boolean raiseException) { boolean isValid = (!key.contains("$") && !key.contains(".") && !key.contains("\0")); if(!isValid) { LiquidTools.exceptionOrLog(raiseException, "Key: (" + key + ") contains invalid chars: (. $ \\0)"); } return isValid; }
LQModel implements Serializable { public static boolean validKey(String key, boolean raiseException) { boolean isValid = (!key.contains("$") && !key.contains(".") && !key.contains("\0")); if(!isValid) { LiquidTools.exceptionOrLog(raiseException, "Key: (" + key + ") contains invalid chars: (. $ \\0)"); } return isValid; } }
LQModel implements Serializable { public static boolean validKey(String key, boolean raiseException) { boolean isValid = (!key.contains("$") && !key.contains(".") && !key.contains("\0")); if(!isValid) { LiquidTools.exceptionOrLog(raiseException, "Key: (" + key + ") contains invalid chars: (. $ \\0)"); } return isValid; }  }
LQModel implements Serializable { public static boolean validKey(String key, boolean raiseException) { boolean isValid = (!key.contains("$") && !key.contains(".") && !key.contains("\0")); if(!isValid) { LiquidTools.exceptionOrLog(raiseException, "Key: (" + key + ") contains invalid chars: (. $ \\0)"); } return isValid; }  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 boolean validKey(String key, boolean raiseException) { boolean isValid = (!key.contains("$") && !key.contains(".") && !key.contains("\0")); if(!isValid) { LiquidTools.exceptionOrLog(raiseException, "Key: (" + key + ") contains invalid chars: (. $ \\0)"); } return isValid; }  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();  }