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; }
Class<? extends DataDecoder> decoder = DataDecoder.Factory.getInstance(type);
/** * Get the full set of installed decoders, keyed by the decode type. * * @return The set of installed decoders, keyed by the decode type. */ public static Map<Class, Class<? extends DataDecoder>> getInstalledDecoders() { loadInstalledDecoders(); return Collections.unmodifiableMap(installedDecoders); }
Class<? extends DataDecoder> decoder = DataDecoder.Factory.getInstance(type);
Class<? extends DataDecoder> decoder = DataDecoder.Factory.getInstance(type);
if (dataDecoder == null) { Class<?> dataType = bindingMethod.getParameterTypes()[0]; dataDecoder = DataDecoder.Factory.create(dataType);
if (dataDecoder == null) { Class<?> dataType = bindingMethod.getParameterTypes()[0]; dataDecoder = DataDecoder.Factory.create(dataType);
try { String type = populatorConfig.getStringParameter("type"); DataDecoder decoder = DataDecoder.Factory.create(type); String reType = UUID.randomUUID().toString();
try { String type = populatorConfig.getStringParameter("type"); DataDecoder decoder = DataDecoder.Factory.create(type); String reType = UUID.randomUUID().toString();
if (dataDecoder == null) { Class<?> dataType = bindingMethod.getParameterTypes()[0]; dataDecoder = DataDecoder.Factory.create(dataType);
try { String type = populatorConfig.getStringParameter("type"); DataDecoder decoder = DataDecoder.Factory.create(type); String reType = UUID.randomUUID().toString();
/** * Attempt to construct a decoder instance from it's type alias based on the * packaging and naming convention used in the {@link org.milyn.javabean.decoders} package. * * @param typeAlias Decoder alias used to construct an instance by prefixing the * alias with the "decoders" package and suffixing it with the word "Decoder". * @return The DateDecoder instance, or null if no such instance is available. * @throws DataDecodeException Failed to load alias decoder. */ public static DataDecoder create(String typeAlias) throws DataDecodeException { if (typeAlias == null) { return new StringDecoder(); } String className = StringDecoder.class.getPackage().getName() + "." + typeAlias + "Decoder"; try { Class decoderType = ClassUtil.forName(className, DataDecoder.class); return newInstance(decoderType); } catch (ClassNotFoundException e) { try { Class decoderType = ClassUtil.forName(typeAlias, DataDecoder.class); return newInstance(decoderType); } catch (ClassNotFoundException e1) { throw new DataDecodeException("DataDecoder Class '" + className + "' is not available on the classpath."); } } }
try { String type = populatorConfig.getStringParameter("type"); DataDecoder decoder = DataDecoder.Factory.create(type); String reType = UUID.randomUUID().toString();
/** * Attempt to construct a decoder instance from it's type alias based on the * packaging and naming convention used in the {@link org.milyn.javabean.decoders} package. * * @param typeAlias Decoder alias used to construct an instance by prefixing the * alias with the "decoders" package and suffixing it with the word "Decoder". * @return The DateDecoder instance, or null if no such instance is available. * @throws DataDecodeException Failed to load alias decoder. */ public static DataDecoder create(String typeAlias) throws DataDecodeException { if (typeAlias == null) { return new StringDecoder(); } String className = StringDecoder.class.getPackage().getName() + "." + typeAlias + "Decoder"; try { Class decoderType = ClassUtil.forName(className, DataDecoder.class); return newInstance(decoderType); } catch (ClassNotFoundException e) { try { Class decoderType = ClassUtil.forName(typeAlias, DataDecoder.class); return newInstance(decoderType); } catch (ClassNotFoundException e1) { throw new DataDecodeException("DataDecoder Class '" + className + "' is not available on the classpath."); } } }
/** * Attempt to construct a decoder instance from it's type alias based on the * packaging and naming convention used in the {@link org.milyn.javabean.decoders} package. * * @param typeAlias Decoder alias used to construct an instance by prefixing the * alias with the "decoders" package and suffixing it with the word "Decoder". * @return The DateDecoder instance, or null if no such instance is available. * @throws DataDecodeException Failed to load alias decoder. */ public static DataDecoder create(String typeAlias) throws DataDecodeException { if (typeAlias == null) { return new StringDecoder(); } String className = StringDecoder.class.getPackage().getName() + "." + typeAlias + "Decoder"; try { Class decoderType = ClassUtil.forName(className, DataDecoder.class); return newInstance(decoderType); } catch (ClassNotFoundException e) { try { Class decoderType = ClassUtil.forName(typeAlias, DataDecoder.class); return newInstance(decoderType); } catch (ClassNotFoundException e1) { throw new DataDecodeException("DataDecoder Class '" + className + "' is not available on the classpath."); } } }
private static <U> DataDecoder createDecoder(Member member, Class type, Class<? extends DataDecoder> decoderClass) { DataDecoder decoder; if(decoderClass.isAssignableFrom(DataDecoder.class)) { // No decoder specified via annotation. Infer from the field type... decoder = DataDecoder.Factory.create(type); if(decoder == null) { throw new SmooksConfigurationException("ContentHandler class member '" + getLongMemberName(member) + "' must define a decoder through it's @ConfigParam annotation. Unable to automatically determine DataDecoder from member type."); } } else { // Decoder specified on annotation... try { decoder = decoderClass.newInstance(); } catch (InstantiationException e) { throw new SmooksConfigurationException("Failed to create DataDecoder instance from class '" + decoderClass.getName() + "'. Make sure the DataDecoder implementation has a public default constructor.", e); } catch (IllegalAccessException e) { throw new SmooksConfigurationException("Failed to create DataDecoder instance from class '" + decoderClass.getName() + "'. Make sure the DataDecoder implementation has a public default constructor.", e); } } return decoder; }
private static <U> DataDecoder createDecoder(Member member, Class type, Class<? extends DataDecoder> decoderClass) { DataDecoder decoder; if(decoderClass.isAssignableFrom(DataDecoder.class)) { // No decoder specified via annotation. Infer from the field type... decoder = DataDecoder.Factory.create(type); if(decoder == null) { throw new SmooksConfigurationException("ContentHandler class member '" + getLongMemberName(member) + "' must define a decoder through it's @ConfigParam annotation. Unable to automatically determine DataDecoder from member type."); } } else { // Decoder specified on annotation... try { decoder = decoderClass.newInstance(); } catch (InstantiationException e) { throw new SmooksConfigurationException("Failed to create DataDecoder instance from class '" + decoderClass.getName() + "'. Make sure the DataDecoder implementation has a public default constructor.", e); } catch (IllegalAccessException e) { throw new SmooksConfigurationException("Failed to create DataDecoder instance from class '" + decoderClass.getName() + "'. Make sure the DataDecoder implementation has a public default constructor.", e); } } return decoder; }
private static <U> DataDecoder createDecoder(Member member, Class type, Class<? extends DataDecoder> decoderClass) { DataDecoder decoder; if(decoderClass.isAssignableFrom(DataDecoder.class)) { // No decoder specified via annotation. Infer from the field type... decoder = DataDecoder.Factory.create(type); if(decoder == null) { throw new SmooksConfigurationException("ContentHandler class member '" + getLongMemberName(member) + "' must define a decoder through it's @ConfigParam annotation. Unable to automatically determine DataDecoder from member type."); } } else { // Decoder specified on annotation... try { decoder = decoderClass.newInstance(); } catch (InstantiationException e) { throw new SmooksConfigurationException("Failed to create DataDecoder instance from class '" + decoderClass.getName() + "'. Make sure the DataDecoder implementation has a public default constructor.", e); } catch (IllegalAccessException e) { throw new SmooksConfigurationException("Failed to create DataDecoder instance from class '" + decoderClass.getName() + "'. Make sure the DataDecoder implementation has a public default constructor.", e); } } return decoder; }
public boolean validateType(String value, List<Map.Entry<String,String>> parameters) { DataDecoder decoder; // Get DataDecoder. if (parameters != null && parameters.size() > 0 && this.name().equals("Custom")) { decoder = DataDecoder.Factory.create(parameters.get(0).getValue()); } else { decoder = DataDecoder.Factory.create(typeAlias); } // If DataDecoder implements Configurable set format. if (decoder instanceof Configurable && parameters != null) { Properties properties = getProperties(parameters); Configurable configurable = (Configurable)decoder; configurable.setConfiguration(properties); } try { decoder.decode(value); } catch (DataDecodeException e) { return false; } return true; }
public boolean validateType(String value, List<Map.Entry<String,String>> parameters) { DataDecoder decoder; // Get DataDecoder. if (parameters != null && parameters.size() > 0 && this.name().equals("Custom")) { decoder = DataDecoder.Factory.create(parameters.get(0).getValue()); } else { decoder = DataDecoder.Factory.create(typeAlias); } // If DataDecoder implements Configurable set format. if (decoder instanceof Configurable && parameters != null) { Properties properties = getProperties(parameters); Configurable configurable = (Configurable)decoder; configurable.setConfiguration(properties); } try { decoder.decode(value); } catch (DataDecodeException e) { return false; } return true; }