@ConfigParam (name = "name", use = ConfigParam.Use.OPTIONAL) public SetElementData setElementName(String elementQName) { this.elementQName = elementQName; return this; }
private static <U> void applyConfigParam(ConfigParam configParam, Member member, Class type, U instance, SmooksResourceConfiguration config) throws SmooksConfigurationException { String name = configParam.name(); String paramValue; paramValue = configParam.defaultVal(); if(AnnotationConstants.NULL_STRING.equals(paramValue)) { String[] choices = configParam.choice(); assertValidChoice(choices, name, AnnotationConstants.NULL_STRING); setMember(member, instance, null); String[] choices = configParam.choice(); Class<? extends DataDecoder> decoderClass; DataDecoder decoder; decoderClass = configParam.decoder(); decoder = createDecoder(member, type, decoderClass); throw new SmooksConfigurationException("Failed to set paramater configuration value on '" + getLongMemberName(member) + "'.", e); } else if(configParam.use() == ConfigParam.Use.REQUIRED) { throw new SmooksConfigurationException("<param> '" + name + "' not specified on resource configuration:\n" + config);
if(configParamAnnotation.use() == ConfigParam.Use.REQUIRED) { String defaultVal = configParamAnnotation.defaultVal(); Class<? extends DataDecoder> decoderClass = configParamAnnotation.decoder(); DataDecoder decoder = createDecoder(field, field.getType(), decoderClass);
@ConfigParam (defaultVal = "ERROR") public void setOnFail(final OnFail onFail) { this.onFail = onFail; }
@ConfigParam(defaultVal = "false") public RemoveElement setKeepChildren(boolean keepChildren) { this.keepChildren = keepChildren; return this; }
@ConfigParam (name = "namespace", use = ConfigParam.Use.OPTIONAL) public SetElementData setElementNamespace(String namespace) { this.elementNamespace = namespace; return this; }
@ConfigParam public RemoveAttribute setName(String attributeName) { this.qName = attributeName; return this; }
@ConfigParam(defaultVal = "1000") // Default pause of 1 second public Pause setPeriod(long period) { this.period = period; return this; }
/** * @param terminateBefore the terminateBefore to set */ @ConfigParam(use = Use.OPTIONAL) public TerminateVisitor setTerminateBefore(boolean terminateBefore) { this.terminateBefore = terminateBefore; return this; }
/** * Omit the XML Declaration from the serialized fragments. * @param omitXMLDeclaration True if the XML declaration is to be omitted, otherwise false. * @return this instance. */ @ConfigParam(defaultVal = "false") public FragmentSerializer setOmitXMLDeclaration(boolean omitXMLDeclaration) { this.omitXMLDeclaration = omitXMLDeclaration; return this; }
/** * Set the bind-to beanId for the serialized fragment. * @param bindTo The bind-to beanId for the serialized fragment. * @return this instance. */ @ConfigParam public FragmentSerializer setBindTo(String bindTo) { this.bindTo = bindTo; return this; }
@ConfigParam (use = ConfigParam.Use.OPTIONAL) public RemoveAttribute setNamespace(String attributeNamespace) { this.namespace = attributeNamespace; return this; }
@ConfigParam(name = Filter.ENTITIES_REWRITE, defaultVal = "true") public void setRewriteEntities(boolean rewriteEntities) { this.rewriteEntities = rewriteEntities; }
@ConfigParam(name = Filter.ENTITIES_REWRITE, defaultVal = "true") public void setRewriteEntities(boolean rewriteEntities) { this.rewriteEntities = rewriteEntities; }
@ConfigParam(defaultVal = "false") public void setCloseEmptyElements(boolean closeEmptyElements) { this.closeEmptyElements = closeEmptyElements; }
/** * Retain the fragment bean in the {@link BeanContext} after it's creating fragment * has been processed. * * @param retain True if the fragment bean is to be retained in the {@link org.dhatim.javabean.context.BeanContext}, * otherwise false. * @return this instance. */ @ConfigParam(defaultVal = "false") public FragmentSerializer setRetain(boolean retain) { this.retain = retain; return this; }
/** * Set whether or not the child content only should be serialized. * <p/> * This variable is, by default, false. * * @param childContentOnly True if the child content only (exclude * the targeted element itself), otherwise false. * @return this instance. */ @ConfigParam(defaultVal = "false") public FragmentSerializer setChildContentOnly(boolean childContentOnly) { this.childContentOnly = childContentOnly; return this; }
/** * Expression Binding initVal setter. * @author <a href="mailto:tom.fennelly@gmail.com">tom.fennelly@gmail.com</a> */ public class InitValExpressionSetter implements DOMVisitBefore { @ConfigParam private String initValAttrib; public void visitBefore(Element element, ExecutionContext executionContext) throws SmooksException { String initValExpression = DomUtils.getAttributeValue(element, initValAttrib); if(initValExpression != null) { ExtensionContext extensionContext = ExtensionContext.getExtensionContext(executionContext); SmooksResourceConfiguration creatorConfig = extensionContext.getResourceByName(BeanInstanceCreator.class.getName()); String propertyName = DomUtils.getAttributeValue(element, "property"); creatorConfig.setParameter(BeanInstanceCreator.INIT_VAL_EXPRESSION, "this." + propertyName + " = (" + initValExpression + ");"); } } }
/** * Regex record parser factory. * * @author <a href="mailto:tom.fennelly@gmail.com">tom.fennelly@gmail.com</a> */ public class RegexParserFactory extends VariableFieldRecordParserFactory { @ConfigParam(decoder = RegexPatternDecoder.class) private Pattern regexPattern; public RecordParser newRecordParser() { return new RegexParser(); } /** * Get the Regex Pattern instance to be used for parsing. * @return The Regex Pattern instance to be used for parsing. */ public Pattern getRegexPattern() { return regexPattern; } public static class RegexPatternDecoder implements DataDecoder { public Object decode(String data) throws DataDecodeException { return Pattern.compile(data, (Pattern.MULTILINE | Pattern.DOTALL)); } } }
@ConfigParam private String setOn; @ConfigParam private String value;