org.apache.commons.lang.BooleanUtils.toBooleanObject()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(13.9k)|赞(0)|评价(0)|浏览(79)

本文整理了Java中org.apache.commons.lang.BooleanUtils.toBooleanObject()方法的一些代码示例,展示了BooleanUtils.toBooleanObject()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BooleanUtils.toBooleanObject()方法的具体详情如下:
包路径:org.apache.commons.lang.BooleanUtils
类名称:BooleanUtils
方法名:toBooleanObject

BooleanUtils.toBooleanObject介绍

[英]Converts an int to a Boolean using the convention that zero is false.

BooleanUtils.toBoolean(0) = Boolean.FALSE 
BooleanUtils.toBoolean(1) = Boolean.TRUE 
BooleanUtils.toBoolean(2) = Boolean.TRUE

[中]使用zerofalse的约定将整型转换为布尔型。

BooleanUtils.toBoolean(0) = Boolean.FALSE 
BooleanUtils.toBoolean(1) = Boolean.TRUE 
BooleanUtils.toBoolean(2) = Boolean.TRUE

代码示例

代码示例来源:origin: commons-lang/commons-lang

/**
 * Gets the value as a Boolean instance.
 * 
 * @return the value as a Boolean, never null
 */
public Object getValue() {
  return BooleanUtils.toBooleanObject(this.value);
}

代码示例来源:origin: commons-lang/commons-lang

/**
 * Gets this mutable as an instance of Boolean.
 *
 * @return a Boolean instance containing the value from this mutable, never null
 * @since 2.5
 */
public Boolean toBoolean() {
  return  BooleanUtils.toBooleanObject(this.value);
}

代码示例来源:origin: commons-lang/commons-lang

/**
 * <p>Append to the <code>toString</code> an <code>Object</code>
 * value.</p>
 *
 * @param fieldName  the field name
 * @param obj  the value 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, Object obj, boolean fullDetail) {
  style.append(buffer, fieldName, obj, BooleanUtils.toBooleanObject(fullDetail));
  return this;
}

代码示例来源:origin: commons-lang/commons-lang

/**
 * <p>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;
}

代码示例来源:origin: commons-lang/commons-lang

/**
 * <p>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;
}

代码示例来源:origin: commons-lang/commons-lang

/**
 * <p>Append to the <code>toString</code> a <code>long</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, long[] array, boolean fullDetail) {
  style.append(buffer, fieldName, array, BooleanUtils.toBooleanObject(fullDetail));
  return this;
}

代码示例来源:origin: commons-lang/commons-lang

/**
 * <p>Append to the <code>toString</code> a <code>short</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, short[] array, boolean fullDetail) {
  style.append(buffer, fieldName, array, BooleanUtils.toBooleanObject(fullDetail));
  return this;
}

代码示例来源:origin: commons-lang/commons-lang

/**
 * <p>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;
}

代码示例来源:origin: commons-lang/commons-lang

/**
 * <p>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;
}

代码示例来源:origin: commons-lang/commons-lang

/**
 * <p>Append to the <code>toString</code> an <code>Object</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, Object[] array, boolean fullDetail) {
  style.append(buffer, fieldName, array, BooleanUtils.toBooleanObject(fullDetail));
  return this;
}

代码示例来源:origin: commons-lang/commons-lang

/**
 * <p>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;
}

代码示例来源:origin: commons-lang/commons-lang

/**
 * <p>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;
}

代码示例来源:origin: commons-lang/commons-lang

/**
 * <p>Converts a String to a boolean (optimised for performance).</p>
 * 
 * <p><code>'true'</code>, <code>'on'</code> or <code>'yes'</code>
 * (case insensitive) will return <code>true</code>. Otherwise,
 * <code>false</code> is returned.</p>
 * 
 * <p>This method performs 4 times faster (JDK1.4) than
 * <code>Boolean.valueOf(String)</code>. However, this method accepts
 * 'on' and 'yes' as true values.
 *
 * <pre>
 *   BooleanUtils.toBoolean(null)    = false
 *   BooleanUtils.toBoolean("true")  = true
 *   BooleanUtils.toBoolean("TRUE")  = true
 *   BooleanUtils.toBoolean("tRUe")  = true
 *   BooleanUtils.toBoolean("on")    = true
 *   BooleanUtils.toBoolean("yes")   = true
 *   BooleanUtils.toBoolean("false") = false
 *   BooleanUtils.toBoolean("x gti") = false
 * </pre>
 *
 * @param str  the String to check
 * @return the boolean value of the string, <code>false</code> if no match or the String is null
 */
public static boolean toBoolean(String str) {
  return toBoolean(toBooleanObject(str));
}

代码示例来源:origin: commons-lang/commons-lang

/**
 * <p>Inserts the specified element at the specified position in the array.
 * Shifts the element currently at that position (if any) and any subsequent
 * elements to the right (adds one to their indices).</p>
 *
 * <p>This method returns a new array with the same elements of the input
 * array plus the given element on the specified position. The component
 * type of the returned array is always the same as that of the input
 * array.</p>
 *
 * <p>If the input array is <code>null</code>, a new one element array is returned
 *  whose component type is the same as the element.</p>
 *
 * <pre>
 * ArrayUtils.add(null, 0, true)          = [true]
 * ArrayUtils.add([true], 0, false)       = [false, true]
 * ArrayUtils.add([false], 1, true)       = [false, true]
 * ArrayUtils.add([true, false], 1, true) = [true, true, false]
 * </pre>
 *
 * @param array  the array to add the element to, may be <code>null</code>
 * @param index  the position of the new object
 * @param element  the object to add
 * @return A new array containing the existing elements and the new element
 * @throws IndexOutOfBoundsException if the index is out of range
 * (index < 0 || index > array.length).
 */
public static boolean[] add(boolean[] array, int index, boolean element) {
  return (boolean[]) add(array, index, BooleanUtils.toBooleanObject(element), Boolean.TYPE);
}

代码示例来源:origin: apache/hive

/**
  * Default is disabling the double quoting for separated value
  */
 private boolean isQuotingDisabled() {
  Boolean quotingDisabled = Boolean.TRUE;
  String quotingDisabledStr = System.getProperty(SeparatedValuesOutputFormat.DISABLE_QUOTING_FOR_SV);

  if (StringUtils.isNotBlank(quotingDisabledStr)) {
   quotingDisabled = BooleanUtils.toBooleanObject(quotingDisabledStr);

   if (quotingDisabled == null) {
    beeLine.error("System Property " + SeparatedValuesOutputFormat.DISABLE_QUOTING_FOR_SV + " is now "
     + quotingDisabledStr + " which only accepts boolean values");
    quotingDisabled = Boolean.TRUE;
   }
  }
  return quotingDisabled;
 }
}

代码示例来源:origin: apache/storm

/**
 * Handles '/deepSearch' request.
 */
@GET
@Path("/deepSearch/{topoId}")
public Response deepSearch(@PathParam("topoId") String topologyId,
              @Context HttpServletRequest request) {
  String user = httpCredsHandler.getUserName(request);
  String searchString = request.getParameter("search-string");
  String numMatchesStr = request.getParameter("num-matches");
  String portStr = request.getParameter("port");
  String startFileOffset = request.getParameter("start-file-offset");
  String startByteOffset = request.getParameter("start-byte-offset");
  String searchArchived = request.getParameter("search-archived");
  String callback = request.getParameter(StormApiResource.callbackParameterName);
  String origin = request.getHeader("Origin");
  Boolean alsoSearchArchived = BooleanUtils.toBooleanObject(searchArchived);
  if (BooleanUtils.isTrue(alsoSearchArchived)) {
    numDeepSearchArchived.mark();
  } else {
    numDeepSearchNonArchived.mark();
  }
  try (Timer.Context t = deepSearchRequestDuration.time()) {
    return logSearchHandler.deepSearchLogsForTopology(topologyId, user, searchString, numMatchesStr, portStr, startFileOffset,
      startByteOffset, alsoSearchArchived, callback, origin);
  }
}

代码示例来源:origin: apache/hive

/**
 * Convert a boolean value returned from the RDBMS to a Java Boolean object.
 * MySQL has booleans, but e.g. Derby uses 'Y'/'N' mapping.
 *
 * @param value
 *          column value from the database
 * @return The Boolean value of the database column value, null if the column
 *         value is null
 * @throws MetaException
 *           if the column value cannot be converted into a Boolean object
 */
static Boolean extractSqlBoolean(Object value) throws MetaException {
 if (value == null) {
  return null;
 }
 if (value instanceof Boolean) {
  return (Boolean)value;
 }
 if (value instanceof String) {
  try {
   return BooleanUtils.toBooleanObject((String) value, "Y", "N", null);
  } catch (IllegalArgumentException iae) {
   // NOOP
  }
 }
 throw new MetaException("Cannot extract boolean from column value " + value);
}

代码示例来源:origin: pentaho/pentaho-kettle

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 ) );
  }
 }
}

代码示例来源:origin: alibaba/yugong

tableOnce = BooleanUtils.toBooleanObject(tableOnceStr);

代码示例来源:origin: gentics/mesh

/**
 * Return the flag which indicates whether the created schema version should automatically be assigned to the branches which reference the schema.
 * 
 * @return
 */
default boolean getUpdateAssignedBranches() {
  String value = getParameter(UPDATE_ASSIGNED_BRANCHES_QUERY_PARAM_KEY);
  return BooleanUtils.toBooleanDefaultIfNull(BooleanUtils.toBooleanObject(value), true);
}

相关文章