Here you can find the source of toBooleanArray(byte[] array)
Parameter | Description |
---|---|
array | bytes array to convert. |
public static boolean[] toBooleanArray(byte[] array)
//package com.java2s; /*//w ww .java 2 s . co m * The MIT License (MIT) * * Copyright (c) 2016. Diorite (by Bart?omiej Mazur (aka GotoFinal)) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ public class Main { /** * Coverts given bytes array to array of booleans. * * @param array * bytes array to convert. * * @return converted array of booleans. */ public static boolean[] toBooleanArray(byte[] array) { boolean[] result = new boolean[array.length]; for (int i = 0; i < array.length; i++) { result[i] = array[i] > 0; } return result; } /** * Coverts given shorts array to array of booleans. * * @param array * shorts array to convert. * * @return converted array of booleans. */ public static boolean[] toBooleanArray(short[] array) { boolean[] result = new boolean[array.length]; for (int i = 0; i < array.length; i++) { result[i] = array[i] > 0; } return result; } /** * Coverts given chars array to array of booleans. * * @param array * chars array to convert. * * @return converted array of booleans. */ public static boolean[] toBooleanArray(char[] array) { boolean[] result = new boolean[array.length]; for (int i = 0; i < array.length; i++) { result[i] = array[i] > 0; } return result; } /** * Coverts given ints array to array of booleans. * * @param array * ints array to convert. * * @return converted array of booleans. */ public static boolean[] toBooleanArray(int[] array) { boolean[] result = new boolean[array.length]; for (int i = 0; i < array.length; i++) { result[i] = array[i] > 0; } return result; } /** * Coverts given longs array to array of booleans. * * @param array * longs array to convert. * * @return converted array of booleans. */ public static boolean[] toBooleanArray(long[] array) { boolean[] result = new boolean[array.length]; for (int i = 0; i < array.length; i++) { result[i] = array[i] > 0; } return result; } /** * Coverts given floats array to array of booleans. * * @param array * floats array to convert. * * @return converted array of booleans. */ public static boolean[] toBooleanArray(float[] array) { boolean[] result = new boolean[array.length]; for (int i = 0; i < array.length; i++) { result[i] = array[i] > 0; } return result; } /** * Coverts given doubles array to array of booleans. * * @param array * doubles array to convert. * * @return converted array of booleans. */ public static boolean[] toBooleanArray(double[] array) { boolean[] result = new boolean[array.length]; for (int i = 0; i < array.length; i++) { result[i] = array[i] > 0; } return result; } /** * Coverts given booleans array to array of booleans. * * @param array * booleans array to convert. * * @return converted array of booleans. */ public static boolean[] toBooleanArray(Boolean[] array) { boolean[] result = new boolean[array.length]; for (int i = 0; i < array.length; i++) { result[i] = array[i]; } return result; } /** * Coverts given numbers array to array of booleans. * * @param array * numbers array to convert. * * @return converted array of booleans. */ public static boolean[] toBooleanArray(Number[] array) { boolean[] result = new boolean[array.length]; for (int i = 0; i < array.length; i++) { result[i] = array[i].doubleValue() > 0; } return result; } /** * Coverts given bytes array to array of booleans. * * @param array * bytes array to convert. * * @return converted array of booleans. */ public static boolean[] toBooleanArray(Byte[] array) { boolean[] result = new boolean[array.length]; for (int i = 0; i < array.length; i++) { result[i] = array[i] > 0; } return result; } /** * Coverts given shorts array to array of booleans. * * @param array * shorts array to convert. * * @return converted array of booleans. */ public static boolean[] toBooleanArray(Short[] array) { boolean[] result = new boolean[array.length]; for (int i = 0; i < array.length; i++) { result[i] = array[i] > 0; } return result; } /** * Coverts given chars array to array of booleans. * * @param array * chars array to convert. * * @return converted array of booleans. */ public static boolean[] toBooleanArray(Character[] array) { boolean[] result = new boolean[array.length]; for (int i = 0; i < array.length; i++) { result[i] = array[i] > 0; } return result; } /** * Coverts given ints array to array of booleans. * * @param array * ints array to convert. * * @return converted array of booleans. */ public static boolean[] toBooleanArray(Integer[] array) { boolean[] result = new boolean[array.length]; for (int i = 0; i < array.length; i++) { result[i] = array[i] > 0; } return result; } /** * Coverts given longs array to array of booleans. * * @param array * longs array to convert. * * @return converted array of booleans. */ public static boolean[] toBooleanArray(Long[] array) { boolean[] result = new boolean[array.length]; for (int i = 0; i < array.length; i++) { result[i] = array[i] > 0; } return result; } /** * Coverts given floats array to array of booleans. * * @param array * floats array to convert. * * @return converted array of booleans. */ public static boolean[] toBooleanArray(Float[] array) { boolean[] result = new boolean[array.length]; for (int i = 0; i < array.length; i++) { result[i] = array[i] > 0; } return result; } /** * Coverts given doubles array to array of booleans. * * @param array * doubles array to convert. * * @return converted array of booleans. */ public static boolean[] toBooleanArray(Double[] array) { boolean[] result = new boolean[array.length]; for (int i = 0; i < array.length; i++) { result[i] = array[i] > 0; } return result; } }