/** * {@link FreeMarkerTemplate} data decoder impl. * * @author <a href="mailto:tom.fennelly@jboss.com">tom.fennelly@jboss.com</a> */ @DecodeType(FreeMarkerTemplate.class) public class FreeMarkerTemplateDecoder implements DataDecoder { public Object decode(String data) throws DataDecodeException { return new FreeMarkerTemplate(data); } }
public void setDataType(String dataType) { this.dataType = dataType; if(dataType != null) { decoder = DataDecoder.Factory.create(dataType); DecodeType decodeType = decoder.getClass().getAnnotation(DecodeType.class); if(decodeType != null) { typeClass = decodeType.value()[0]; } } }
public void setDataType(String dataType) { this.dataType = dataType; if(dataType != null) { decoder = DataDecoder.Factory.create(dataType); DecodeType decodeType = decoder.getClass().getAnnotation(DecodeType.class); if(decodeType != null) { typeClass = decodeType.value()[0]; } } }
/** * {@link FreeMarkerTemplate} data decoder impl. * * @author <a href="mailto:tom.fennelly@jboss.com">tom.fennelly@jboss.com</a> */ @DecodeType(FreeMarkerTemplate.class) public class FreeMarkerTemplateDecoder implements DataDecoder { public Object decode(String data) throws DataDecodeException { return new FreeMarkerTemplate(data); } }
public void setDataType(String dataType) { this.dataType = dataType; if(dataType != null) { decoder = DataDecoder.Factory.create(dataType); DecodeType decodeType = decoder.getClass().getAnnotation(DecodeType.class); if(decodeType != null) { typeClass = decodeType.value()[0]; } } }
/** * {@link FreeMarkerTemplate} data decoder impl. * * @author <a href="mailto:tom.fennelly@jboss.com">tom.fennelly@jboss.com</a> */ @DecodeType(FreeMarkerTemplate.class) public class FreeMarkerTemplateDecoder implements DataDecoder { public Object decode(String data) throws DataDecodeException { return new FreeMarkerTemplate(data); } }
public void setDataType(String dataType) { this.dataType = dataType; if(dataType != null) { decoder = DataDecoder.Factory.create(dataType); DecodeType decodeType = decoder.getClass().getAnnotation(DecodeType.class); if(decodeType != null) { typeClass = decodeType.value()[0]; } } }
/** * {@link FreeMarkerTemplate} data decoder impl. * * @author <a href="mailto:tom.fennelly@jboss.com">tom.fennelly@jboss.com</a> */ @DecodeType(FreeMarkerTemplate.class) public class FreeMarkerTemplateDecoder implements DataDecoder { public Object decode(String data) throws DataDecodeException { return new FreeMarkerTemplate(data); } }
private synchronized static void loadInstalledDecoders() throws DataDecodeException { if (installedDecoders == null) { // Attempt to find configured decoders. final List<Class<DataDecoder>> decoders = ClassUtil.getClasses("META-INF/data-decoders.inf", DataDecoder.class); if (decoders.isEmpty()) { throw new DataDecodeException("Failed to find installed DataDecoders on classpath."); } // Prepare to initialize decoders. final Map<Class, Class<? extends DataDecoder>> loadedDecoders = new HashMap<Class, Class<? extends DataDecoder>>(); for (final Class<DataDecoder> decoder : decoders) { final DecodeType decodeType = decoder.getAnnotation(DecodeType.class); if (decodeType != null) { for (final Class type : decodeType.value()) { if (loadedDecoders.containsKey(type)) { logger.warn("More than one DataDecoder for type '" + type.getName() + "' is installed on the classpath. You must manually configure decoding of this type, where required."); loadedDecoders.put(type, null); // We don't remove, because we need to maintain a record of this! } else { loadedDecoders.put(type, decoder); } } } } // Save the loaded decoders so that they can be reused. installedDecoders = loadedDecoders; } }
/** * {@link MVELExpressionEvaluator} data decoder impl. * * @author <a href="mailto:tom.fennelly@jboss.com">tom.fennelly@jboss.com</a> */ @DecodeType(MVELExpressionEvaluator.class) public class MVELExpressionEvaluatorDecoder implements DataDecoder { public Object decode(String data) throws DataDecodeException { MVELExpressionEvaluator expressionEvaluator = new MVELExpressionEvaluator(); expressionEvaluator.setExpression(data); return expressionEvaluator; } }
private synchronized static void loadInstalledDecoders() throws DataDecodeException { if (installedDecoders == null) { // Attempt to find configured decoders. final List<Class<DataDecoder>> decoders = ClassUtil.getClasses("META-INF/data-decoders.inf", DataDecoder.class); if (decoders.isEmpty()) { throw new DataDecodeException("Failed to find installed DataDecoders on classpath."); } // Prepare to initialize decoders. final Map<Class, Class<? extends DataDecoder>> loadedDecoders = new HashMap<Class, Class<? extends DataDecoder>>(); for (final Class<DataDecoder> decoder : decoders) { final DecodeType decodeType = decoder.getAnnotation(DecodeType.class); if (decodeType != null) { for (final Class type : decodeType.value()) { if (loadedDecoders.containsKey(type)) { logger.warn("More than one DataDecoder for type '" + type.getName() + "' is installed on the classpath. You must manually configure decoding of this type, where required."); loadedDecoders.put(type, null); // We don't remove, because we need to maintain a record of this! } else { loadedDecoders.put(type, decoder); } } } } // Save the loaded decoders so that they can be reused. installedDecoders = loadedDecoders; } }
/** * String data decoder. * <p/> * This decoded does nothing. Simply returns the String data unmodified. * * @author <a href="mailto:tom.fennelly@gmail.com">tom.fennelly@gmail.com</a> */ @DecodeType(String.class) public class StringDecoder implements DataDecoder { public Object decode(String data) throws DataDecodeException { return data; } }
private synchronized static void loadInstalledDecoders() throws DataDecodeException { if (installedDecoders == null) { // Attempt to find configured decoders. final List<Class<DataDecoder>> decoders = ClassUtil.getClasses("META-INF/data-decoders.inf", DataDecoder.class); if (decoders.isEmpty()) { throw new DataDecodeException("Failed to find installed DataDecoders on classpath."); } // Prepare to initialize decoders. final Map<Class, Class<? extends DataDecoder>> loadedDecoders = new HashMap<Class, Class<? extends DataDecoder>>(); for (final Class<DataDecoder> decoder : decoders) { final DecodeType decodeType = decoder.getAnnotation(DecodeType.class); if (decodeType != null) { for (final Class type : decodeType.value()) { if (loadedDecoders.containsKey(type)) { logger.warn("More than one DataDecoder for type '" + type.getName() + "' is installed on the classpath. You must manually configure decoding of this type, where required."); loadedDecoders.put(type, null); // We don't remove, because we need to maintain a record of this! } else { loadedDecoders.put(type, decoder); } } } } // Save the loaded decoders so that they can be reused. installedDecoders = loadedDecoders; } }
/** * {@link MVELExpressionEvaluator} data decoder impl. * * @author <a href="mailto:tom.fennelly@jboss.com">tom.fennelly@jboss.com</a> */ @DecodeType(MVELExpressionEvaluator.class) public class MVELExpressionEvaluatorDecoder implements DataDecoder { public Object decode(String data) throws DataDecodeException { MVELExpressionEvaluator expressionEvaluator = new MVELExpressionEvaluator(); expressionEvaluator.setExpression(data); return expressionEvaluator; } }
/** * String data decoder. * <p/> * This decoded does nothing. Simply returns the String data unmodified. * * @author <a href="mailto:tom.fennelly@gmail.com">tom.fennelly@gmail.com</a> */ @DecodeType(String.class) public class StringDecoder implements DataDecoder { public Object decode(String data) throws DataDecodeException { return data; } }
/** * {@link MVELExpressionEvaluator} data decoder impl. * * @author <a href="mailto:tom.fennelly@jboss.com">tom.fennelly@jboss.com</a> */ @DecodeType(MVELExpressionEvaluator.class) public class MVELExpressionEvaluatorDecoder implements DataDecoder { public Object decode(String data) throws DataDecodeException { MVELExpressionEvaluator expressionEvaluator = new MVELExpressionEvaluator(); expressionEvaluator.setExpression(data); return expressionEvaluator; } }
/** * String data decoder. * <p/> * This decoded does nothing. Simply returns the String data unmodified. * * @author <a href="mailto:tom.fennelly@gmail.com">tom.fennelly@gmail.com</a> */ @DecodeType(String.class) public class StringDecoder implements DataDecoder { public Object decode(String data) throws DataDecodeException { return data; } }
/** * {@link MVELExpressionEvaluator} data decoder impl. * * @author <a href="mailto:tom.fennelly@jboss.com">tom.fennelly@jboss.com</a> */ @DecodeType(MVELExpressionEvaluator.class) public class MVELExpressionEvaluatorDecoder implements DataDecoder { public Object decode(String data) throws DataDecodeException { MVELExpressionEvaluator expressionEvaluator = new MVELExpressionEvaluator(); expressionEvaluator.setExpression(data); return expressionEvaluator; } }
/** * {@link Character} data decoder. * * @author <a href="mailto:tom.fennelly@gmail.com">tom.fennelly@gmail.com</a> */ @DecodeType({Character.class, char.class}) public class CharacterDecoder implements DataDecoder { public Object decode(String data) throws DataDecodeException { if(data != null && data.length() > 0) { return data.charAt(0); } return data; } }
/** * {@link Character} data decoder. * * @author <a href="mailto:tom.fennelly@gmail.com">tom.fennelly@gmail.com</a> */ @DecodeType({Character.class, char.class}) public class CharacterDecoder implements DataDecoder { public Object decode(String data) throws DataDecodeException { if(data != null && data.length() > 0) { return data.charAt(0); } return data; } }