private ParameterValue newParameterValuePlaceHolder() { return new ParameterValue(locale, "PLACEHOLDER"); }
public WebSocketContext(List<WebSocketConnection> connections, WebSocketConnection connection, Map<String, String> pathParameters) { this.connections = connections; this.connection = connection; this.pathParameters = new HashMap<>(pathParameters.size()); for (String name : pathParameters.keySet()) { this.pathParameters.put(name, new ParameterValue(pathParameters.get(name))); } }
private ParameterValue buildParameterValue(final String... values) { return new ParameterValue(getLocale(), values); }
/** * Returns one path parameter. */ public ParameterValue getPathParameter(String name) { if (!getPathParameters().containsKey(name)) { return new ParameterValue(); } return getPathParameters().get(name); }
public Object objectFromString(String value, Class<?> objectClass) throws ParseException { if (value == null) { return null; } else if (objectClass.isAssignableFrom(value.getClass())) { return value; } // re-use the infinitely useful ParameterValue class ParameterValue pv = new ParameterValue(value); if (objectClass.isEnum()) { return pv.toEnum((Class) objectClass); } else if (java.sql.Date.class.isAssignableFrom(objectClass)) { return pv.toSqlDate(); } else if (java.sql.Time.class.isAssignableFrom(objectClass)) { return pv.toSqlTime(); } else if (java.sql.Timestamp.class.isAssignableFrom(objectClass)) { return pv.toSqlTimestamp(); } else if (Date.class.isAssignableFrom(objectClass)) { return pv.toDate(datePattern); } return pv.to(objectClass); }
@Override @SuppressWarnings("unchecked") public Object extract(MethodParameter parameter, RouteContext routeContext) { Header annotation = parameter.getAnnotation(Header.class); String name = getParameterName(parameter, annotation); String pattern = annotation.pattern(); ParameterValue parameterValue = new ParameterValue(routeContext.getRequest().getLocale(), routeContext.getHeader(name)); Class<?> parameterType = parameter.getParameterType(); if (Collection.class.isAssignableFrom(parameterType)) { Class<? extends Collection> collectionType = (Class<? extends Collection>) parameterType; Class<?> objectType = parameter.getParameterGenericType(); return parameterValue.toCollection(collectionType, objectType, pattern); } return parameterValue.to(parameterType, pattern); }
String contentType = new ParameterValue(context.getRequest().getLocale(), context.getHeader("Content-Type")).toString("").toLowerCase(); contentType = StringUtils.getPrefix(contentType, ';').trim(); if (!guardedTypes.contains(contentType)) {
@Override public void setObjectType(Class<?> objectType) { ParameterValue testValue = new ParameterValue(); testValue.to(objectType); this.objectType = objectType; }
@Override public void setObjectType(Class<?> objectType) { ParameterValue testValue = new ParameterValue(); testValue.to(objectType); this.objectType = objectType; }
@Override public Object extract(Context context) { ParameterValue pv = new ParameterValue(context.getHeader(name)); if (collectionType == null) { Object o = pv.to(objectType, pattern); return o; } Object o = pv.toCollection(collectionType, objectType, pattern); return o; } }
@Override public Object extract(Context context) { ParameterValue pv = new ParameterValue(context.getHeader(name)); if (collectionType == null) { Object o = pv.to(objectType, pattern); return o; } Object o = pv.toCollection(collectionType, objectType, pattern); return o; } }
@Override public Object extract(Context context) { ParameterValue pv = context.getParameter(name); if (suffixes != null) { // automatically strip the suffix, if we can String value = pv.toString(); if (value != null) { String ext = Files.getFileExtension(value); if (!Strings.isNullOrEmpty(ext) && suffixes.contains(ext.toLowerCase())) { pv = new ParameterValue(Files.getNameWithoutExtension(value)); } } } if (collectionType == null) { Object o = pv.to(objectType, pattern); return o; } Object o = pv.toCollection(collectionType, objectType, pattern); return o; } }
@Override public Object extract(Context context) { ParameterValue pv = context.getParameter(name); if (suffixes != null) { // automatically strip the suffix, if we can String value = pv.toString(); if (value != null) { String ext = Files.getFileExtension(value); if (!Strings.isNullOrEmpty(ext) && suffixes.contains(ext.toLowerCase())) { pv = new ParameterValue(Files.getNameWithoutExtension(value)); } } } if (collectionType == null) { Object o = pv.to(objectType, pattern); return o; } Object o = pv.toCollection(collectionType, objectType, pattern); return o; } }
@Override @SuppressWarnings("unchecked") public Object extract(MethodParameter parameter, RouteContext routeContext) { Header annotation = parameter.getAnnotation(Header.class); String name = getParameterName(parameter, annotation); String pattern = annotation.pattern(); ParameterValue parameterValue = new ParameterValue(routeContext.getRequest().getLocale(), routeContext.getHeader(name)); Class<?> parameterType = parameter.getParameterType(); if (Collection.class.isAssignableFrom(parameterType)) { Class<? extends Collection> collectionType = (Class<? extends Collection>) parameterType; Class<?> objectType = parameter.getParameterGenericType(); return parameterValue.toCollection(collectionType, objectType, pattern); } return parameterValue.to(parameterType, pattern); }