private DataDecoder getDecoder(ExecutionContext executionContext) throws DataDecodeException { @SuppressWarnings("unchecked") List decoders = executionContext.getDeliveryConfig().getObjects("decoder:" + typeAlias); if (decoders == null || decoders.isEmpty()) { decoder = DataDecoder.Factory.create(typeAlias); } else if (!(decoders.get(0) instanceof DataDecoder)) { throw new DataDecodeException("Configured decoder '" + typeAlias + ":" + decoders.get(0).getClass().getName() + "' is not an instance of " + DataDecoder.class.getName()); } else { decoder = (DataDecoder) decoders.get(0); } return decoder; }
public Object decode(String data) throws DataDecodeException { ResultSetScope scope; data = data.trim(); try { scope = ResultSetScope.valueOf(data); } catch (IllegalArgumentException e) { throw new DataDecodeException("Failed to decode ResultSetScope value '" + data + "'. Allowed values are " + Arrays.asList(ResultSetScope.values()) + "."); } return scope; } }
private Object decodeDataString(String dataString, ExecutionContext executionContext) throws DataDecodeException { if((dataString == null || dataString.length() == 0) && defaultValue != null) { if(defaultValue.equals("null")) { return null; } dataString = defaultValue; } try { return getDecoder(executionContext).decode(dataString); } catch(DataDecodeException e) { throw new DataDecodeException("Failed to decode the value '" + dataString + "' for the bean id '" + beanIdName +"'.", e); } }
private DataDecoder getDecoder(ExecutionContext executionContext) throws DataDecodeException { if(decoder == null) { @SuppressWarnings("unchecked") List decoders = executionContext.getDeliveryConfig().getObjects("decoder:" + typeAlias); if (decoders == null || decoders.isEmpty()) { decoder = DataDecoder.Factory.create(typeAlias); } else if (!(decoders.get(0) instanceof DataDecoder)) { throw new DataDecodeException("Configured decoder '" + typeAlias + ":" + decoders.get(0).getClass().getName() + "' is not an instance of " + DataDecoder.class.getName()); } else { decoder = (DataDecoder) decoders.get(0); } } return decoder; }
public Object decode(String data) throws DataDecodeException { DecimalFormat decimalFormat = getDecimalFormat(); setDecimalPointFormat(decimalFormat, getContextDelimiters()); final Number number; try { number = decimalFormat.parse(data.trim()); } catch (final ParseException e) { throw new DataDecodeException("Failed to decode BigDecimal value '" + data + "' using NumberFormat instance " + decimalFormat + ".", e); } return (BigDecimal) number; }
private Object decodeDataString(String dataString, ExecutionContext executionContext) throws DataDecodeException { if((dataString == null || dataString.length() == 0) && defaultVal != null) { if(defaultVal.equals("null")) { return null; } dataString = defaultVal; } if (decoder == null) { decoder = getDecoder(executionContext); } try { return decoder.decode(dataString); } catch(DataDecodeException e) { throw new DataDecodeException("Failed to decode binding value '" + dataString + "' for property '" + property + "' on bean '" + beanId.getName() +"'.", e); } }
public DataDecoder getDecoder(ContentDeliveryConfig deliveryConfig) { @SuppressWarnings("unchecked") List decoders = deliveryConfig.getObjects("decoder:" + typeAlias); if (decoders == null || decoders.isEmpty()) { if(typeAlias != null) { decoder = DataDecoder.Factory.create(typeAlias); } else { decoder = resolveDecoderReflectively(); } } else if (!(decoders.get(0) instanceof DataDecoder)) { throw new DataDecodeException("Configured decoder '" + typeAlias + ":" + decoders.get(0).getClass().getName() + "' is not an instance of " + DataDecoder.class.getName()); } else { decoder = (DataDecoder) decoders.get(0); } if(decoder instanceof PreprocessDecoder) { PreprocessDecoder preprocessDecoder = (PreprocessDecoder) decoder; if(preprocessDecoder.getBaseDecoder() == null) { preprocessDecoder.setBaseDecoder(resolveDecoderReflectively()); } } return decoder; }