public Object decode(String data) throws DataDecodeException { try { return Charset.forName(data); } catch(UnsupportedCharsetException e) { throw new DataDecodeException("Unsupported character set '" + data + "'."); } } }
public Object decode(String data) throws DataDecodeException { try { return Charset.forName(data); } catch(UnsupportedCharsetException e) { throw new DataDecodeException("Unsupported character set '" + data + "'."); } } }
private static DataDecoder newInstance(Class decoderType) throws DataDecodeException { try { return (DataDecoder) decoderType.newInstance(); } catch (ClassCastException e) { throw new DataDecodeException("Class '" + decoderType.getName() + "' is not a valid DataDecoder. It doesn't implement " + DataDecoder.class.getName()); } catch (IllegalAccessException e) { throw new DataDecodeException("Failed to load DataDecoder Class '" + decoderType.getName() + "'.", e); } catch (InstantiationException e) { throw new DataDecodeException("Failed to load DataDecoder Class '" + decoderType.getName() + "'.", e); } } }
public Object decode(String data) throws DataDecodeException { try { return new File(data); } catch (Exception e) { throw new DataDecodeException("Unable to decode '" + data + "' as a "+ File.class.getName() + " instance.", e); } } }
public Object decode(String data) throws DataDecodeException { Matcher binaryMatcher = BINARY_PATTERN.matcher(data); if (binaryMatcher.matches()) { return data; } else { throw new DataDecodeException("Failed to decode binary sequence '" + data + "'."); } } }
public Object decode(String data) throws DataDecodeException { try { return Byte.parseByte(data.trim()); } catch(NumberFormatException e) { throw new DataDecodeException("Failed to decode Byte value '" + data + "'.", e); } } }
public Object decode(String data) throws DataDecodeException { try { return new URI(data.trim()); } catch (URISyntaxException e) { throw new DataDecodeException("Failed to decode URI value '" + data + "'.", e); } } }
public Object decode(String data) throws DataDecodeException { try { // Must be sync'd - DateFormat is not synchronized. synchronized(decoder) { return decoder.parse(data.trim()); } } catch (ParseException e) { throw new DataDecodeException("Error decoding Date data value '" + data + "' with decode format '" + format + "'.", e); } }
public Object decode(String data) throws DataDecodeException { Matcher binaryMatcher = BINARY_PATTERN.matcher(data); if (binaryMatcher.matches()) { return data; } else { throw new DataDecodeException("Failed to decode binary sequence '" + data + "'."); } } }
@Override public Object decode(String data) throws DataDecodeException { Date date = (Date) super.decode(data); try { GregorianCalendar gregCal = new GregorianCalendar(); gregCal.setTime(date); return DatatypeFactory.newInstance().newXMLGregorianCalendar(gregCal); } catch (DatatypeConfigurationException e) { throw new DataDecodeException("Error decoding XMLGregorianCalendar data value '" + data + "' with decode format '" + format + "'.", e); } }
@Override public Object decode(String data) throws DataDecodeException { Date date = (Date) super.decode(data); try { GregorianCalendar gregCal = new GregorianCalendar(); gregCal.setTime(date); return DatatypeFactory.newInstance().newXMLGregorianCalendar(gregCal); } catch (DatatypeConfigurationException e) { throw new DataDecodeException("Error decoding XMLGregorianCalendar data value '" + data + "' with decode format '" + format + "'.", e); } }
public Object decode(String data) throws DataDecodeException { try { return ClassUtil.forName(data.trim(), ClassDecoder.class); } catch (ClassNotFoundException e) { throw new DataDecodeException("Failed to decode '" + data + "' as a Java Class.", e); } } }
public Object decode(String data) throws DataDecodeException { try { return ClassUtil.forName(data.trim(), ClassDecoder.class); } catch (ClassNotFoundException e) { throw new DataDecodeException("Failed to decode '" + data + "' as a Java Class.", e); } } }
public String encode(Object date) throws DataDecodeException { AssertArgument.isNotNull(date, "date"); if(!(date instanceof Date)) { throw new DataDecodeException("Cannot encode Object type '" + date.getClass().getName() + "'. Must be type '" + Date.class.getName() + "'."); } // Must be sync'd - DateFormat is not synchronized. synchronized(decoder) { return decoder.format((Date) date); } } }
public String encode(Object date) throws DataDecodeException { AssertArgument.isNotNull(date, "date"); if(!(date instanceof Date)) { throw new DataDecodeException("Cannot encode Object type '" + date.getClass().getName() + "'. Must be type '" + Date.class.getName() + "'."); } // Must be sync'd - DateFormat is not synchronized. synchronized(decoder) { return decoder.format((Date) date); } } }
@Override public String encode(Object date) throws DataDecodeException { if(!(date instanceof XMLGregorianCalendar)) { throw new DataDecodeException("Cannot encode Object type '" + date.getClass().getName() + "'. Must be type '" + XMLGregorianCalendar.class.getName() + "'."); } return super.encode(((XMLGregorianCalendar)date).toGregorianCalendar().getTime()); } }
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 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; } }
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; }