List of usage examples for org.apache.commons.lang BooleanUtils toBooleanObject
public static Boolean toBooleanObject(String str)
Converts a String to a Boolean.
'true'
, 'on'
or 'yes'
(case insensitive) will return true
.
From source file:org.opencastproject.workflow.handler.composer.ConcatWorkflowOperationHandler.java
private Map<Integer, Tuple<TrackSelector, Boolean>> getTrackSelectors(WorkflowOperationInstance operation) throws WorkflowOperationException { Map<Integer, Tuple<TrackSelector, Boolean>> trackSelectors = new HashMap<Integer, Tuple<TrackSelector, Boolean>>(); for (String key : operation.getConfigurationKeys()) { String tags = null;//from ww w. ja va 2 s. co m String flavor = null; Boolean mandatory = true; int number = -1; if (key.startsWith(SOURCE_TAGS_PREFIX) && !key.endsWith(MANDATORY_SUFFIX)) { number = NumberUtils.toInt(key.substring(SOURCE_TAGS_PREFIX.length()), -1); tags = operation.getConfiguration(key); mandatory = BooleanUtils.toBooleanObject(operation.getConfiguration( SOURCE_TAGS_PREFIX.concat(Integer.toString(number)).concat(MANDATORY_SUFFIX))); } else if (key.startsWith(SOURCE_FLAVOR_PREFIX) && !key.endsWith(MANDATORY_SUFFIX)) { number = NumberUtils.toInt(key.substring(SOURCE_FLAVOR_PREFIX.length()), -1); flavor = operation.getConfiguration(key); mandatory = BooleanUtils.toBooleanObject(operation.getConfiguration( SOURCE_FLAVOR_PREFIX.concat(Integer.toString(number)).concat(MANDATORY_SUFFIX))); } if (number < 0) continue; Tuple<TrackSelector, Boolean> selectorTuple = trackSelectors.get(number); if (selectorTuple == null) { selectorTuple = Tuple.tuple(new TrackSelector(), BooleanUtils.toBooleanDefaultIfNull(mandatory, false)); } else { selectorTuple = Tuple.tuple(selectorTuple.getA(), selectorTuple.getB() || BooleanUtils.toBooleanDefaultIfNull(mandatory, false)); } TrackSelector trackSelector = selectorTuple.getA(); if (StringUtils.isNotBlank(tags)) { for (String tag : StringUtils.split(tags, ",")) { trackSelector.addTag(tag); } } if (StringUtils.isNotBlank(flavor)) { try { trackSelector.addFlavor(flavor); } catch (IllegalArgumentException e) { throw new WorkflowOperationException("Source flavor '" + flavor + "' is malformed"); } } trackSelectors.put(number, selectorTuple); } return trackSelectors; }
From source file:org.opencastproject.workflow.handler.ConcatWorkflowOperationHandler.java
private Map<Integer, Tuple<TrackSelector, Boolean>> getTrackSelectors(WorkflowOperationInstance operation) throws WorkflowOperationException { Map<Integer, Tuple<TrackSelector, Boolean>> trackSelectors = new HashMap<Integer, Tuple<TrackSelector, Boolean>>(); for (String key : operation.getConfigurationKeys()) { String tags = null;/*ww w . j a v a2 s . c o m*/ String flavor = null; Boolean mandatory = true; int number = -1; if (key.startsWith(SOURCE_TAGS_PREFIX) && !key.endsWith(MANDATORY_SUFFIX)) { number = NumberUtils.toInt(key.substring(SOURCE_TAGS_PREFIX.length()), -1); tags = operation.getConfiguration(key); mandatory = BooleanUtils.toBooleanObject(operation.getConfiguration( SOURCE_TAGS_PREFIX.concat(Integer.toString(number)).concat(MANDATORY_SUFFIX))); } else if (key.startsWith(SOURCE_FLAVOR_PREFIX) && !key.endsWith(MANDATORY_SUFFIX)) { number = NumberUtils.toInt(key.substring(SOURCE_FLAVOR_PREFIX.length()), -1); flavor = operation.getConfiguration(key); mandatory = BooleanUtils.toBooleanObject(operation.getConfiguration( SOURCE_FLAVOR_PREFIX.concat(Integer.toString(number)).concat(MANDATORY_SUFFIX))); } if (number < 0) continue; Tuple<TrackSelector, Boolean> selectorTuple = trackSelectors.get(number); if (selectorTuple == null) { selectorTuple = Tuple.tuple(new TrackSelector(), BooleanUtils.toBooleanDefaultIfNull(mandatory, true)); } else { selectorTuple = Tuple.tuple(selectorTuple.getA(), selectorTuple.getB() && BooleanUtils.toBooleanDefaultIfNull(mandatory, true)); } TrackSelector trackSelector = selectorTuple.getA(); if (StringUtils.isNotBlank(tags)) { for (String tag : StringUtils.split(tags, ",")) { trackSelector.addTag(tag); } } if (StringUtils.isNotBlank(flavor)) { try { trackSelector.addFlavor(flavor); } catch (IllegalArgumentException e) { throw new WorkflowOperationException("Source flavor '" + flavor + "' is malformed"); } } trackSelectors.put(number, selectorTuple); } return trackSelectors; }
From source file:org.openmrs.web.taglib.functions.Util.java
/** * This method will make untrusted strings safe for use as JavaScript booleans * * @param s/* www. ja va 2s . com*/ * @return string representation of a boolean (guaranteed safe for use in JS) */ public static String getSafeJsBoolean(String s) { return Boolean.toString(BooleanUtils.toBooleanObject(s)); }
From source file:org.pentaho.di.trans.step.StepOption.java
public static void checkBoolean(List<CheckResultInterface> remarks, StepMeta stepMeta, VariableSpace space, String identifier, String value) { if (!StringUtil.isEmpty(space.environmentSubstitute(value)) && null == BooleanUtils.toBooleanObject(space.environmentSubstitute(value))) { remarks.add(new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "StepOption.CheckResult.NotABoolean", identifier), stepMeta)); }/*from w ww . j a v a 2 s.com*/ }
From source file:stc.app.bean.lang.ToStringBuilder.java
/** * <p>//from w w w . jav a2s . co m * Append to the <code>toString</code> a <code>boolean</code> array. * </p> * * <p> * A boolean parameter controls the level of detail to show. Setting <code>true</code> will output * the array in full. Setting <code>false</code> will output a summary, typically the size of the * array. * </p> * * @param fieldName the field name * @param array the array to add to the <code>toString</code> * @param fullDetail <code>true</code> for detail, <code>false</code> for summary info * @return this */ public ToStringBuilder append(String fieldName, boolean[] array, boolean fullDetail) { style.append(buffer, fieldName, array, BooleanUtils.toBooleanObject(fullDetail)); return this; }
From source file:stc.app.bean.lang.ToStringBuilder.java
/** * <p>/*from w w w . j a va 2 s . c o m*/ * Append to the <code>toString</code> a <code>byte</code> array. * </p> * * <p> * A boolean parameter controls the level of detail to show. Setting <code>true</code> will output * the array in full. Setting <code>false</code> will output a summary, typically the size of the * array. * * @param fieldName the field name * @param array the array to add to the <code>toString</code> * @param fullDetail <code>true</code> for detail, <code>false</code> for summary info * @return this */ public ToStringBuilder append(String fieldName, byte[] array, boolean fullDetail) { style.append(buffer, fieldName, array, BooleanUtils.toBooleanObject(fullDetail)); return this; }
From source file:stc.app.bean.lang.ToStringBuilder.java
/** * <p>//from www . j a v a2 s. c o m * Append to the <code>toString</code> a <code>char</code> array. * </p> * * <p> * A boolean parameter controls the level of detail to show. Setting <code>true</code> will output * the array in full. Setting <code>false</code> will output a summary, typically the size of the * array. * </p> * * @param fieldName the field name * @param array the array to add to the <code>toString</code> * @param fullDetail <code>true</code> for detail, <code>false</code> for summary info * @return this */ public ToStringBuilder append(String fieldName, char[] array, boolean fullDetail) { style.append(buffer, fieldName, array, BooleanUtils.toBooleanObject(fullDetail)); return this; }
From source file:stc.app.bean.lang.ToStringBuilder.java
/** * <p>/* w ww . j a v a 2s. c om*/ * Append to the <code>toString</code> a <code>double</code> array. * </p> * * <p> * A boolean parameter controls the level of detail to show. Setting <code>true</code> will output * the array in full. Setting <code>false</code> will output a summary, typically the size of the * array. * </p> * * @param fieldName the field name * @param array the array to add to the <code>toString</code> * @param fullDetail <code>true</code> for detail, <code>false</code> for summary info * @return this */ public ToStringBuilder append(String fieldName, double[] array, boolean fullDetail) { style.append(buffer, fieldName, array, BooleanUtils.toBooleanObject(fullDetail)); return this; }
From source file:stc.app.bean.lang.ToStringBuilder.java
/** * <p>/*from w w w.ja v a 2 s. com*/ * Append to the <code>toString</code> a <code>float</code> array. * </p> * * <p> * A boolean parameter controls the level of detail to show. Setting <code>true</code> will output * the array in full. Setting <code>false</code> will output a summary, typically the size of the * array. * </p> * * @param fieldName the field name * @param array the array to add to the <code>toString</code> * @param fullDetail <code>true</code> for detail, <code>false</code> for summary info * @return this */ public ToStringBuilder append(String fieldName, float[] array, boolean fullDetail) { style.append(buffer, fieldName, array, BooleanUtils.toBooleanObject(fullDetail)); return this; }
From source file:stc.app.bean.lang.ToStringBuilder.java
/** * <p>// ww w . jav a 2s . c om * Append to the <code>toString</code> an <code>int</code> array. * </p> * * <p> * A boolean parameter controls the level of detail to show. Setting <code>true</code> will output * the array in full. Setting <code>false</code> will output a summary, typically the size of the * array. * </p> * * @param fieldName the field name * @param array the array to add to the <code>toString</code> * @param fullDetail <code>true</code> for detail, <code>false</code> for summary info * @return this */ public ToStringBuilder append(String fieldName, int[] array, boolean fullDetail) { style.append(buffer, fieldName, array, BooleanUtils.toBooleanObject(fullDetail)); return this; }