public Object convertInbound(Class<?> paramType, InboundVariable data) throws ConversionException { if (data.isNull()) { return null; } return data.urlDecode().toCharArray(); }
public Object convertInbound(Class<?> paramType, InboundVariable data) throws ConversionException { if (data.isNull()) { return null; } String urlString = data.urlDecode(); try { return new URL(urlString); } catch (MalformedURLException ex) { log.warn("Failed to create URL from string '" + urlString + "'. Returning null"); return null; } }
public Object convertInbound(Class<?> paramType, InboundVariable data) throws ConversionException { if (data.isNull()) { return null; } String uriString = data.urlDecode(); try { return new URI(uriString); } catch (URISyntaxException ex) { log.warn("Failed to create URL from string '" + uriString + "'. Returning null"); return null; } }
public Object convertInbound(Class<?> paramType, InboundVariable data) { if (data.isNull()) { return null; } try { Constructor<?> converter = paramType.getConstructor(String.class); return converter.newInstance(data.getValue()); } catch (Exception ex) { throw new IllegalArgumentException(ex.toString()); } }
/** * Parses a locale string that matches language_country_variant. */ public Object convertInbound(Class<?> paramType, InboundVariable data) throws ConversionException { return data.isNull() ? null : LocalUtil.parseLocaleString(data.urlDecode()); }
public Object convertInbound(Class<?> paramType, InboundVariable data) throws ConversionException { if (data.isNull()) { return null; } ScriptSession session = WebContextFactory.get().getScriptSession(); String id = data.getValue(); DefaultJavascriptObject object = new DefaultJavascriptObject(session, id); return Proxy.newProxyInstance(paramType.getClassLoader(), new Class[] { paramType }, object); }
public Object convertInbound(Class<?> paramType, InboundVariable data) throws ConversionException { if (data.isNull()) { return null; } String value = data.getValue(); if (value == null || value.length() == 0) { return null; } try { if (paramType == BigDecimal.class) { return new BigDecimal(value.trim()); } if (paramType == BigInteger.class) { return new BigInteger(value.trim()); } throw new ConversionException(paramType); } catch (NumberFormatException ex) { log.debug("Error converting " + value + " to a number."); throw new ConversionException(paramType, "Format error converting number."); } }
/** * Parses a currency ISO code. */ public Object convertInbound(Class<?> paramType, InboundVariable data) throws ConversionException { if (data.isNull()) { return null; } try { Currency currency = Currency.getInstance(data.getValue()); if (currency == null) { throw new IllegalArgumentException(data.getValue() + " is not a valid java.util.Currency value"); } return currency; } catch (Exception ex) { throw new ConversionException(Currency.class, ex); } }
public Object convertInbound(Class<?> paramType, InboundVariable data) throws ConversionException { if (data.isNull()) { return null; } String value = data.getValue(); // If the text is null then the whole bean is null if (value.trim().equals(ProtocolConstants.INBOUND_NULL)) { return null; } try { long millis = 0; if (value.length() > 0) { millis = Long.parseLong(value); } if (paramType == DateTime.class) { return new DateTime(millis); } else if (paramType == LocalDateTime.class) { return new LocalDateTime(new Date(millis)); } else { throw new ConversionException(paramType); } } catch (ConversionException ex) { throw ex; } catch (Exception ex) { throw new ConversionException(paramType, ex); } }
public Object convertInbound(Class<?> paramType, InboundVariable data) throws ConversionException { if (data.isNull()) { return null; } String value = data.getValue().trim(); try { return LocalUtil.simpleConvert(value, paramType); } catch (NumberFormatException ex) { log.debug("Error converting " + value + " to a number."); throw new ConversionException(paramType, "Format error converting number."); } catch (IllegalArgumentException ex) { throw new ConversionException(paramType); } }
public Object convertInbound(Class<?> paramType, InboundVariable data) throws ConversionException { if (data.isNull()) { return null; } String value = data.urlDecode(); try { Method getter = paramType.getMethod("valueOf", String.class); Object reply = getter.invoke(paramType, value); if (reply == null) { throw new ConversionException(paramType); } return reply; } catch (NoSuchMethodException ex) { // We would like to have done: if (!paramType.isEnum()) // But this catch block has the same effect throw new ConversionException(paramType); } catch (Exception ex) { throw new ConversionException(paramType, ex); } }
public Object convertInbound(Class<?> paramType, InboundVariable data) throws ConversionException { if (data.isNull()) { return null; } ScriptSession session = WebContextFactory.get().getScriptSession(); String id = data.getValue(); return new DefaultJavascriptObject(session, id); }
public Object convertInbound(Class<?> paramType, InboundVariable data) throws ConversionException { if (data.isNull()) { return null; } ScriptSession session = WebContextFactory.get().getScriptSession(); String id = data.getValue(); return new DefaultJavascriptFunction(session, id); }
public Object convertInbound(Class<?> paramType, InboundVariable data) throws ConversionException if (data.isNull())
public Object convertInbound(Class<?> paramType, InboundVariable data) throws ConversionException if (data.isNull())
public Object convertInbound(Class<?> paramType, InboundVariable data) throws ConversionException { if (data.isNull()) { return null; } if (data.getFormField().isFile()) { // Data from file uploads is not URL encoded return data.getValue(); } else { return data.urlDecode(); } }
public Object convertInbound(Class<?> paramType, InboundVariable data) throws ConversionException if (data.isNull())
public Object convertInbound(Class<?> paramType, InboundVariable data) throws ConversionException if (data.isNull())
public Object convertInbound(Class<?> paramType, InboundVariable data) throws ConversionException if (data.isNull())
public Object convertInbound(@SuppressWarnings("rawtypes") Class paramType, InboundVariable iv, InboundContext inctx, TypeHintContext incc) throws MarshallException { Object converted = inctx.getConverted(iv, paramType); if (converted == null) { // Was the inbound variable marshalled as an Object in the client // (could mean that this is an instance of one of our generated // JavaScript classes) Converter converter = getNamedConverter(paramType, iv.getType()); // Fall back to the standard way of locating a converter if we // didn't find anything above if (converter == null) { converter = getConverter(paramType); } if (converter == null) { throw new MarshallException(paramType, Messages.getString("DefaultConverterManager.MissingConverter", paramType)); } // We only think about doing a null conversion ourselves once we are // sure that there is a converter available. This prevents hackers // from passing null to things they are not allowed to convert if (iv.isNull()) { return null; } inctx.pushContext(incc); converted = converter.convertInbound(paramType, iv, inctx); inctx.popContext(); } return converted; }