@Override public Object convertInbound(Class paramClass, InboundVariable paramInboundVariable, InboundContext paramInboundContext) throws MarshallException { //Convert from string to Unit try{ //For the ONE unit if(paramInboundVariable.getValue().equals("ONE")) return Unit.ONE; else return UnitUtil.parseLocal(URLDecoder.decode(paramInboundVariable.getValue(), Common.UTF8)); }catch(Exception e){ throw new MarshallException(paramClass); } }
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 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( @SuppressWarnings("unchecked") Class paramType, InboundVariable iv, InboundContext inctx) { String string = LocalUtil.decode(iv.getValue()); try { return datatypeFactory.newXMLGregorianCalendar(string); } catch (IllegalArgumentException iaex) { log.warn("Failed to create XMLGregorianCalendar from string [" //$NON-NLS-1$ + string + "]. Returning [null]."); //$NON-NLS-1$ return null; } }
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."); } }
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 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); } }
String value = data.getValue();
@Override public Object convertInbound( @SuppressWarnings({ "rawtypes" }) Class paramType, InboundVariable data, InboundContext inctx) throws MarshallException { String value = data.getValue(); // If the text is null then the whole bean is null if (value.trim().equals(ProtocolConstants.INBOUND_NULL)) { return null; } if (!value.startsWith(ProtocolConstants.INBOUND_MAP_START)) { throw new MarshallException(paramType, Messages.getString("BeanConverter.FormatError", //$NON-NLS-1$ ProtocolConstants.INBOUND_MAP_START)); } if (!value.endsWith(ProtocolConstants.INBOUND_MAP_END)) { throw new MarshallException(paramType, Messages.getString("BeanConverter.FormatError", //$NON-NLS-1$ ProtocolConstants.INBOUND_MAP_START)); } value = value.substring(1, value.length() - 1); final Map<String, String> tokens = extractInboundTokens(paramType, value); return convertInbound(paramType, data, tokens, inctx, value); }
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; } 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); }
String value = data.getValue(); if (value == null)
String value = data.getValue(); if (value.startsWith(ProtocolConstants.INBOUND_ARRAY_START)) log.error("Found array end without array start: " + data.getValue()); throw new IllegalArgumentException("Could not parse input. See logs for details."); log.error("Found array end without array end: " + data.getValue()); throw new IllegalArgumentException("Could not parse input. See logs for details.");
String value = data.getValue();
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(); } }
String value = data.getValue();
String value = data.getValue();