List of usage examples for org.apache.commons.lang BooleanUtils toBoolean
public static boolean toBoolean(String str)
Converts a String to a boolean (optimised for performance).
'true'
, 'on'
or 'yes'
(case insensitive) will return true
.
From source file:org.apache.cocoon.components.pipeline.impl.CachingPointProcessingPipeline.java
/** * The <code>CachingPointProcessingPipeline</code> is configurable. * * <p>The autoCachingPoint algorithm (if enabled) will automatically cache * common elements of the pipeline currently being processed - as well as the * entire cacheable pipeline according to the "longest cacheable key" * algorithm. This feature is especially useful for pipelines that branch at * some point (this is the case with <tt><map:select></tt> or * <tt><map:act></tt>). * * <p>The option <tt>autoCachingPoint</tt> can be switched on/off in the * sitemap.xmap (on by default). For linear pipelines, one can switch "Off" * <tt>autoCachingPoint</tt> and use attribute * <tt>pipeline-hints="caching-point"</tt> to manually indicate that certain * pipeline components (eg on <tt><map:generator></tt>) should be * considered as cache points. Both options (automatic at branch points and * manual with pipeline hints) can coexist in the same pipeline.</p> * * <p>Works by requesting the pipeline processor to try shorter keys when * looking for a cached content for the pipeline.</p> *///from ww w. ja va 2 s .co m public void parameterize(Parameters config) throws ParameterException { super.parameterize(config); this.autoCachingPointSwitch = config.getParameter("autoCachingPoint", null); if (this.getLogger().isDebugEnabled()) { getLogger().debug("Auto caching-point is set to = '" + this.autoCachingPointSwitch + "'"); } // Default is that auto caching-point is on if (this.autoCachingPointSwitch == null) { this.autoCachingPoint = true; } else { this.autoCachingPoint = BooleanUtils.toBoolean(this.autoCachingPointSwitch); } }
From source file:org.apache.cocoon.components.pipeline.impl.CachingPointProcessingPipeline.java
/** * Set the generator./*from www .j a va 2 s. c om*/ */ public void setGenerator(String role, String source, Parameters param, Parameters hintParam) throws ProcessingException { super.setGenerator(role, source, param, hintParam); // check the hint param for a "caching-point" hint String pipelinehint = null; try { pipelinehint = hintParam.getParameter("caching-point", null); if (this.getLogger().isDebugEnabled()) { getLogger().debug("generator caching-point pipeline-hint is set to: " + pipelinehint); } } catch (Exception ex) { if (this.getLogger().isWarnEnabled()) { getLogger().warn("caching-point hint Exception, pipeline-hint ignored: " + ex); } } // if this generator is manually set to "caching-point" (via pipeline-hint) // then ensure the next component is caching. this.nextIsCachePoint = BooleanUtils.toBoolean(pipelinehint); }
From source file:org.apache.cocoon.components.pipeline.impl.CachingPointProcessingPipeline.java
/** * Add a transformer.//from ww w .j ava2 s.c o m */ public void addTransformer(String role, String source, Parameters param, Parameters hintParam) throws ProcessingException { super.addTransformer(role, source, param, hintParam); // check the hint param for a "caching-point" hint String pipelinehint = null; try { pipelinehint = hintParam.getParameter("caching-point", null); if (this.getLogger().isDebugEnabled()) { getLogger().debug("transformer caching-point pipeline-hint is set to: " + pipelinehint); } } catch (Exception ex) { if (this.getLogger().isWarnEnabled()) { getLogger().warn("caching-point hint Exception, pipeline-hint ignored: " + ex); } } // add caching point flag // default value is false this.isCachePoint.add(BooleanUtils.toBooleanObject(this.nextIsCachePoint)); // if this transformer is manually set to "caching-point" (via pipeline-hint) // then ensure the next component is caching. this.nextIsCachePoint = BooleanUtils.toBoolean(pipelinehint); }
From source file:org.apache.cocoon.components.source.impl.ContextSourceFactory.java
/** * @see org.apache.excalibur.source.SourceFactory#getSource(java.lang.String, java.util.Map) */// w ww .ja v a2 s . c o m public Source getSource(String location, Map parameters) throws IOException { if (getLogger().isDebugEnabled()) { getLogger().debug("Creating source object for " + location); } // Lookup resolver SourceResolver resolver = null; try { resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE); // Remove the protocol and the first '/' final int pos = location.indexOf(":/"); final String scheme = location.substring(0, pos); final String path = location.substring(pos + 2); // fix for #24093, we don't give access to files outside the context: if (path.indexOf("../") != -1) { throw new MalformedURLException("Invalid path ('../' is not allowed) : " + path); } URL u; // Try to get a file first and fall back to a resource URL String actualPath = this.servletContext.getRealPath(path); if (actualPath != null) { u = new File(actualPath).toURL(); } else { u = this.servletContext.getResource(path); } if (u != null) { Source source = resolver.resolveURI(u.toExternalForm()); if (parameters != null && BooleanUtils.toBoolean("force-traversable") && this.servletContext != null && !(source instanceof TraversableSource)) { final Set children = this.servletContext.getResourcePaths(path + '/'); if (children != null) { source = new TraversableContextSource(source, children, this, path, scheme); } } return source; } final String message = location + " could not be found. (possible context problem)"; getLogger().info(message); throw new MalformedURLException(message); } catch (ServiceException se) { throw new SourceException("Unable to lookup source resolver.", se); } finally { this.manager.release(resolver); } }
From source file:org.apache.cocoon.faces.samples.components.taglib.MapTag.java
protected void setProperties(UIComponent component) { super.setProperties(component); MapComponent map = (MapComponent) component; // if (current != null) { // map.setCurrent(current); // }// ww w. ja va 2s.c om if (styleClass != null) { if (FacesUtils.isExpression(styleClass)) { ValueBinding vb = FacesContext.getCurrentInstance().getApplication().createValueBinding(styleClass); map.setValueBinding("styleClass", vb); } else { map.getAttributes().put("styleClass", styleClass); } } if (actionListener != null) { if (FacesUtils.isExpression(actionListener)) { Class args[] = { ActionEvent.class }; MethodBinding mb = FacesContext.getCurrentInstance().getApplication() .createMethodBinding(actionListener, args); map.setActionListener(mb); } else { Object params[] = { actionListener }; throw new javax.faces.FacesException(); } } if (action != null) { if (FacesUtils.isExpression(action)) { MethodBinding vb = FacesContext.getCurrentInstance().getApplication().createMethodBinding(action, null); map.setAction(vb); } else { map.setAction(Util.createConstantMethodBinding(action)); } } if (immediate != null) { if (FacesUtils.isExpression(immediate)) { ValueBinding vb = FacesContext.getCurrentInstance().getApplication().createValueBinding(immediate); map.setValueBinding("immediate", vb); } else { map.setImmediate(BooleanUtils.toBoolean(immediate)); } } }
From source file:org.apache.cocoon.faces.taglib.html.CommandButtonTag.java
protected void setProperties(UIComponent component) { super.setProperties(component); UICommand command;//from w w w . j a v a 2 s.com try { command = (UICommand) component; } catch (ClassCastException cce) { throw new FacesException("Tag <" + getClass().getName() + "> expected UICommand. " + "Got <" + component.getClass().getName() + ">"); } if (action != null) { MethodBinding vb; if (FacesUtils.isExpression(action)) { vb = getApplication().createMethodBinding(action, null); } else { vb = new ConstantMethodBinding(action); } command.setAction(vb); } if (actionListener != null) { if (FacesUtils.isExpression(actionListener)) { MethodBinding vb = getApplication().createMethodBinding(actionListener, new Class[] { ActionEvent.class }); command.setActionListener(vb); } else { throw new FacesException("Tag <" + getClass().getName() + "> actionListener must be an expression. " + "Got <" + actionListener + ">"); } } if (immediate != null) { if (FacesUtils.isExpression(immediate)) { command.setValueBinding("immediate", createValueBinding(immediate)); } else { command.setImmediate(BooleanUtils.toBoolean(immediate)); } } if (value != null) { if (FacesUtils.isExpression(value)) { command.setValueBinding("value", createValueBinding(value)); } else { command.setValue(value); } } setProperty(component, "accesskey", accesskey); setProperty(component, "alt", alt); setProperty(component, "dir", dir); setBooleanProperty(component, "disabled", disabled); setProperty(component, "image", image); setProperty(component, "lang", lang); setProperty(component, "onblur", onblur); setProperty(component, "onchange", onchange); setProperty(component, "onclick", onclick); setProperty(component, "ondblclick", ondblclick); setProperty(component, "onfocus", onfocus); setProperty(component, "onkeydown", onkeydown); setProperty(component, "onkeypress", onkeypress); setProperty(component, "onkeyup", onkeyup); setProperty(component, "onmousedown", onmousedown); setProperty(component, "onmousemove", onmousemove); setProperty(component, "onmouseout", onmouseout); setProperty(component, "onmouseover", onmouseover); setProperty(component, "onmouseup", onmouseup); setProperty(component, "onselect", onselect); setBooleanProperty(component, "readonly", readonly); setProperty(component, "style", style); setProperty(component, "styleClass", styleClass); setProperty(component, "tabindex", tabindex); setProperty(component, "title", title); setProperty(component, "type", type); }
From source file:org.apache.cocoon.faces.taglib.html.CommandLinkTag.java
protected void setProperties(UIComponent component) { super.setProperties(component); UICommand command;/*w ww .ja v a2s . co m*/ try { command = (UICommand) component; } catch (ClassCastException cce) { throw new FacesException("Tag <" + getClass().getName() + "> expected UICommand. " + "Got <" + component.getClass().getName() + ">"); } if (action != null) { MethodBinding vb; if (FacesUtils.isExpression(action)) { vb = getApplication().createMethodBinding(action, null); } else { vb = new ConstantMethodBinding(action); } command.setAction(vb); } if (actionListener != null) { if (FacesUtils.isExpression(actionListener)) { MethodBinding vb = getApplication().createMethodBinding(actionListener, new Class[] { ActionEvent.class }); command.setActionListener(vb); } else { throw new FacesException("Tag <" + getClass().getName() + "> actionListener must be an expression. " + "Got <" + actionListener + ">"); } } if (immediate != null) { if (FacesUtils.isExpression(immediate)) { command.setValueBinding("immediate", createValueBinding(immediate)); } else { command.setImmediate(BooleanUtils.toBoolean(immediate)); } } if (value != null) { if (FacesUtils.isExpression(value)) { command.setValueBinding("value", createValueBinding(value)); } else { command.setValue(value); } } setProperty(component, "accesskey", accesskey); setProperty(component, "charset", charset); setProperty(component, "coords", coords); setProperty(component, "dir", dir); setProperty(component, "hreflang", hreflang); setProperty(component, "lang", lang); setProperty(component, "onblur", onblur); setProperty(component, "ondblclick", ondblclick); setProperty(component, "onfocus", onfocus); setProperty(component, "onkeydown", onkeydown); setProperty(component, "onkeypress", onkeypress); setProperty(component, "onkeyup", onkeyup); setProperty(component, "onmousedown", onmousedown); setProperty(component, "onmousemove", onmousemove); setProperty(component, "onmouseout", onmouseout); setProperty(component, "onmouseover", onmouseover); setProperty(component, "onmouseup", onmouseup); setProperty(component, "rel", rel); setProperty(component, "rev", rev); setProperty(component, "shape", shape); setProperty(component, "style", style); setProperty(component, "styleClass", styleClass); setProperty(component, "tabindex", tabindex); setProperty(component, "target", target); setProperty(component, "title", title); setProperty(component, "type", type); }
From source file:org.apache.cocoon.faces.taglib.html.InputHiddenTag.java
protected void setProperties(UIComponent component) { super.setProperties(component); UIInput input = null;/*from ww w .j av a2 s . c om*/ try { input = (UIInput) component; } catch (ClassCastException cce) { throw new FacesException("Tag <" + getClass().getName() + "> expected UIInput. " + "Got <" + component.getClass().getName() + ">"); } if (converter != null) { if (FacesUtils.isExpression(converter)) { input.setValueBinding("converter", createValueBinding(converter)); } else { input.setConverter(getApplication().createConverter(converter)); } } if (immediate != null) { if (FacesUtils.isExpression(immediate)) { input.setValueBinding("immediate", createValueBinding(immediate)); } else { input.setImmediate(BooleanUtils.toBoolean(immediate)); } } if (required != null) { if (FacesUtils.isExpression(required)) { input.setValueBinding("required", createValueBinding(required)); } else { input.setRequired(BooleanUtils.toBoolean(required)); } } if (validator != null) { if (FacesUtils.isExpression(validator)) { MethodBinding vb = getApplication().createMethodBinding(validator, new Class[] { FacesContext.class, UIComponent.class, Object.class }); input.setValidator(vb); } else { throw new FacesException("Tag <" + getClass().getName() + "> validator must be an expression. " + "Got <" + validator + ">"); } } if (value != null) { if (FacesUtils.isExpression(value)) { input.setValueBinding("value", createValueBinding(value)); } else { input.setValue(value); } } if (valueChangeListener != null) { if (FacesUtils.isExpression(valueChangeListener)) { MethodBinding vb = getApplication().createMethodBinding(valueChangeListener, new Class[] { ValueChangeEvent.class }); input.setValueChangeListener(vb); } else { throw new FacesException("Tag <" + getClass().getName() + "> valueChangeListener must be an expression. " + "Got <" + valueChangeListener + ">"); } } }
From source file:org.apache.cocoon.faces.taglib.html.MessagesTag.java
protected void setProperties(UIComponent component) { super.setProperties(component); UIMessages messages = null;// ww w. ja v a 2 s. com try { messages = (UIMessages) component; } catch (ClassCastException cce) { throw new FacesException("Tag <" + getClass().getName() + "> expected UIMessages. " + "Got <" + component.getClass().getName() + ">"); } if (globalOnly != null) { if (FacesUtils.isExpression(globalOnly)) { messages.setValueBinding("globalOnly", createValueBinding(globalOnly)); } else { messages.setGlobalOnly(BooleanUtils.toBoolean(globalOnly)); } } if (showDetail != null) { if (FacesUtils.isExpression(showDetail)) { messages.setValueBinding("showDetail", createValueBinding(showDetail)); } else { messages.setShowDetail(BooleanUtils.toBoolean(showDetail)); } } if (showSummary != null) { if (FacesUtils.isExpression(showSummary)) { messages.setValueBinding("showSummary", createValueBinding(showSummary)); } else { messages.setShowSummary(BooleanUtils.toBoolean(showSummary)); } } setProperty(component, "errorClass", errorClass); setProperty(component, "errorStyle", errorStyle); setProperty(component, "fatalClass", fatalClass); setProperty(component, "fatalStyle", fatalStyle); setProperty(component, "infoClass", infoClass); setProperty(component, "infoStyle", infoStyle); setProperty(component, "layout", layout); setProperty(component, "style", style); setProperty(component, "styleClass", styleClass); setProperty(component, "title", title); setBooleanProperty(component, "tooltip", tooltip); setProperty(component, "warnClass", warnClass); setProperty(component, "warnStyle", warnStyle); }
From source file:org.apache.cocoon.faces.taglib.html.MessageTag.java
protected void setProperties(UIComponent component) { super.setProperties(component); UIMessage message = null;/*w w w . j av a 2 s . c om*/ try { message = (UIMessage) component; } catch (ClassCastException cce) { throw new FacesException("Tag <" + getClass().getName() + "> expected UIMessage. " + "Got <" + component.getClass().getName() + ">"); } if (_for != null) { // FIXME Should it be "for"? if (FacesUtils.isExpression(_for)) { message.setValueBinding("_for", createValueBinding(_for)); } else { message.setFor(_for); } } if (showDetail != null) { if (FacesUtils.isExpression(showDetail)) { message.setValueBinding("showDetail", createValueBinding(showDetail)); } else { message.setShowDetail(BooleanUtils.toBoolean(showDetail)); } } if (showSummary != null) { if (FacesUtils.isExpression(showSummary)) { message.setValueBinding("showSummary", createValueBinding(showSummary)); } else { message.setShowSummary(BooleanUtils.toBoolean(showSummary)); } } setProperty(component, "errorClass", errorClass); setProperty(component, "errorStyle", errorStyle); setProperty(component, "fatalClass", fatalClass); setProperty(component, "fatalStyle", fatalStyle); setProperty(component, "infoClass", infoClass); setProperty(component, "infoStyle", infoStyle); setProperty(component, "layout", layout); setProperty(component, "style", style); setProperty(component, "styleClass", styleClass); setProperty(component, "title", title); setBooleanProperty(component, "tooltip", tooltip); setProperty(component, "warnClass", warnClass); setProperty(component, "warnStyle", warnStyle); }