@Test public void testBuildURLParameters() { final SystemCodes sc = new SystemCodes(); Assert.assertEquals("", CrudUtil.buildURLParameters(sc)); sc.setValue(""); Assert.assertEquals("", CrudUtil.buildURLParameters(sc)); sc.setKey("PH"); Assert.assertEquals("key=PH", CrudUtil.buildURLParameters(sc)); sc.setValue("Aloe Vera"); Assert.assertEquals( "value=Aloe+Vera&key=PH", CrudUtil.buildURLParameters(sc)); }
public static String buildURLParameters(final BaseEntity object) { final Map<String, Object> map = buildMapValues(object); final StringBuilder parameter = new StringBuilder(""); int count = 0; try { for (final String key : map.keySet()) { if (count > 0) { parameter.append("&"); } parameter .append(key) .append("=") .append(URLEncoder.encode(map.get(key).toString(), URL_ENCODING)); count++; } } catch (final UnsupportedEncodingException ex) { _log.error(URL_ENCODING + " is not supported", ex); } if (count > 0) { return parameter.toString(); } else { return ""; } }
CrudUtil { public static String buildURLParameters(final BaseEntity object) { final Map<String, Object> map = buildMapValues(object); final StringBuilder parameter = new StringBuilder(""); int count = 0; try { for (final String key : map.keySet()) { if (count > 0) { parameter.append("&"); } parameter .append(key) .append("=") .append(URLEncoder.encode(map.get(key).toString(), URL_ENCODING)); count++; } } catch (final UnsupportedEncodingException ex) { _log.error(URL_ENCODING + " is not supported", ex); } if (count > 0) { return parameter.toString(); } else { return ""; } } }
CrudUtil { public static String buildURLParameters(final BaseEntity object) { final Map<String, Object> map = buildMapValues(object); final StringBuilder parameter = new StringBuilder(""); int count = 0; try { for (final String key : map.keySet()) { if (count > 0) { parameter.append("&"); } parameter .append(key) .append("=") .append(URLEncoder.encode(map.get(key).toString(), URL_ENCODING)); count++; } } catch (final UnsupportedEncodingException ex) { _log.error(URL_ENCODING + " is not supported", ex); } if (count > 0) { return parameter.toString(); } else { return ""; } } private  CrudUtil(); }
CrudUtil { public static String buildURLParameters(final BaseEntity object) { final Map<String, Object> map = buildMapValues(object); final StringBuilder parameter = new StringBuilder(""); int count = 0; try { for (final String key : map.keySet()) { if (count > 0) { parameter.append("&"); } parameter .append(key) .append("=") .append(URLEncoder.encode(map.get(key).toString(), URL_ENCODING)); count++; } } catch (final UnsupportedEncodingException ex) { _log.error(URL_ENCODING + " is not supported", ex); } if (count > 0) { return parameter.toString(); } else { return ""; } } private  CrudUtil(); static String buildCreateMessage(final BaseEntity obj); static List<String> getUpdatedFields(final BaseEntity oldObject,
			final BaseEntity newObject); static String convertAuditableFieldsToJson(BaseEntity obj); @SuppressWarnings({ "rawtypes", "unchecked" }) static String buildUpdateMessage(final BaseEntity oldObject,
			final BaseEntity newObject); static String buildDeleteMessage(final BaseEntity obj); static Map<String, Object> buildMapValues(final BaseEntity object); @SuppressWarnings("rawtypes") static Map<String, Object> buildMapValues(final BaseEntity object,
			final List<String> fields); static String buildURLParameters(final BaseEntity object); @SuppressWarnings("rawtypes") static String buildJpaQueryString(final BaseEntity example,
			final boolean exactMatch); @SuppressWarnings("rawtypes") static Object retrieveObjectValue(final Object obj,
			final String property); static Object retrieveNullableObjectValue(final Object obj,
			final String property); static Class<?> retrieveObjectType(final Object obj,
			final String property); static Boolean evaluateExpression(final Object obj,
			final String expression); @SuppressWarnings("unchecked") static String replaceSQLParameters(String sql, final Object obj); @SuppressWarnings({ "rawtypes" }) static List<Field> getAllFields(final Class clazz); @SuppressWarnings({ "rawtypes" }) static List<Field> getAllFields(final Class clazz,
			final boolean includeParent); @SuppressWarnings({ "rawtypes" }) static List<Method> getAllMethods(final Class clazz); @SuppressWarnings({ "rawtypes" }) static List<Method> getAllMethods(final Class clazz,
			final boolean includeParent); static List<MessageResponse> convertErrorMessage(
			final BindingResult bindingResult, final Locale locale,
			final MessageSource messageSource); static List<MessageResponse> buildSuccessMessage(
			final BaseEntity object, final String code, final Locale locale,
			final MessageSource messageSource); static boolean isCollection(final Object ob); static BaseEntity clone(final BaseEntity source); }
CrudUtil { public static String buildURLParameters(final BaseEntity object) { final Map<String, Object> map = buildMapValues(object); final StringBuilder parameter = new StringBuilder(""); int count = 0; try { for (final String key : map.keySet()) { if (count > 0) { parameter.append("&"); } parameter .append(key) .append("=") .append(URLEncoder.encode(map.get(key).toString(), URL_ENCODING)); count++; } } catch (final UnsupportedEncodingException ex) { _log.error(URL_ENCODING + " is not supported", ex); } if (count > 0) { return parameter.toString(); } else { return ""; } } private  CrudUtil(); static String buildCreateMessage(final BaseEntity obj); static List<String> getUpdatedFields(final BaseEntity oldObject,
			final BaseEntity newObject); static String convertAuditableFieldsToJson(BaseEntity obj); @SuppressWarnings({ "rawtypes", "unchecked" }) static String buildUpdateMessage(final BaseEntity oldObject,
			final BaseEntity newObject); static String buildDeleteMessage(final BaseEntity obj); static Map<String, Object> buildMapValues(final BaseEntity object); @SuppressWarnings("rawtypes") static Map<String, Object> buildMapValues(final BaseEntity object,
			final List<String> fields); static String buildURLParameters(final BaseEntity object); @SuppressWarnings("rawtypes") static String buildJpaQueryString(final BaseEntity example,
			final boolean exactMatch); @SuppressWarnings("rawtypes") static Object retrieveObjectValue(final Object obj,
			final String property); static Object retrieveNullableObjectValue(final Object obj,
			final String property); static Class<?> retrieveObjectType(final Object obj,
			final String property); static Boolean evaluateExpression(final Object obj,
			final String expression); @SuppressWarnings("unchecked") static String replaceSQLParameters(String sql, final Object obj); @SuppressWarnings({ "rawtypes" }) static List<Field> getAllFields(final Class clazz); @SuppressWarnings({ "rawtypes" }) static List<Field> getAllFields(final Class clazz,
			final boolean includeParent); @SuppressWarnings({ "rawtypes" }) static List<Method> getAllMethods(final Class clazz); @SuppressWarnings({ "rawtypes" }) static List<Method> getAllMethods(final Class clazz,
			final boolean includeParent); static List<MessageResponse> convertErrorMessage(
			final BindingResult bindingResult, final Locale locale,
			final MessageSource messageSource); static List<MessageResponse> buildSuccessMessage(
			final BaseEntity object, final String code, final Locale locale,
			final MessageSource messageSource); static boolean isCollection(final Object ob); static BaseEntity clone(final BaseEntity source);  }