Reconstruct a serialized object from the specified byte array.

@param array the byte array from which the object should be reconstructed
@return a serialized object from the specified byte array
514038
private P byteArrayToPage(byte[] array) {
    try {
      ByteArrayInputStream bais = new ByteArrayInputStream(array);
      ObjectInputStream ois = new ObjectInputStream(bais);
      int type = ois.readInt();
      if(type == EMPTY_PAGE) {
        return null;
      }
      else if(type == FILLED_PAGE) {
        P page;
        try {
          page = pageclass.newInstance();
          page.readExternal(ois);
        }
        catch(InstantiationException|IllegalAccessException|ClassNotFoundException e) {
          throw new AbortException("Error instanciating an index page", e);
        }
        return page;
      }
      else {
        throw new IllegalArgumentException("Unknown type: " + type);
      }
    }
    catch(IOException e) {
      throw new AbortException("IO Error in page file", e);
    }
  }
126997
public static ByteBuf copiedBuffer(byte[]... arrays) {
        switch (arrays.length) {
        case 0:
            return EMPTY_BUFFER;
        case 1:
            if (arrays[0].length == 0) {
                return EMPTY_BUFFER;
            } else {
                return copiedBuffer(arrays[0]);
            }
        }

        // Merge the specified arrays into one array.
        int length = 0;
        for (byte[] a: arrays) {
            if (Integer.MAX_VALUE - length < a.length) {
                throw new IllegalArgumentException(
                        "The total length of the specified arrays is too big.");
            }
            length += a.length;
        }

        if (length == 0) {
            return EMPTY_BUFFER;
        }

        byte[] mergedArray = PlatformDependent.allocateUninitializedArray(length);
        for (int i = 0, j = 0; i < arrays.length; i ++) {
            byte[] a = arrays[i];
            System.arraycopy(a, 0, mergedArray, j, a.length);
            j += a.length;
        }

        return wrappedBuffer(mergedArray);
    }
192975
public static List<Object> array2ObjectList(final Object array) {
        final int length = Array.getLength(array);
        final List<Object> list = new ArrayList<Object>(length);
        for (int i = 0; i < length; ++i) {
            list.add(Array.get(array, i));
        }
        return list;
    }
770556
public static function arrayUnique(array $array)
    {
        // Serialize each array's value
        foreach ($array as &$value) {
            $value = serialize($value);
        }

        // Now remove duplicate strings
        $array = array_unique($array);

        // Now restore to its previous state with removed strings
        foreach ($array as &$value) {
            $value = unserialize($value);
        }

        return $array;
    }
390761
private static BitSet byteArrayToBitSet(byte[] array) {

    BitSet bitSet = new BitSet();
    int index = 0;
    for (byte b : array) {
      int b1 = ((int)b) + 128;

      bitSet.set(index++, (b1 >> 7) % 2 == 1);
      bitSet.set(index++, (b1 >> 6) % 2 == 1);
      bitSet.set(index++, (b1 >> 5) % 2 == 1);
      bitSet.set(index++, (b1 >> 4) % 2 == 1);
      bitSet.set(index++, (b1 >> 3) % 2 == 1);
      bitSet.set(index++, (b1 >> 2) % 2 == 1);
      bitSet.set(index++, (b1 >> 1) % 2 == 1);
      bitSet.set(index++, b1 % 2 == 1);
    }

    return bitSet;
  }
345662
public static BufferedImage readQuietly(final byte[] byteArray)
	{
		BufferedImage img = null;
		try
		{
			img = read(byteArray);
		}
		catch (IOException e)
		{
			log.log(Level.SEVERE, "Reading image failed.", e);
		}
		return img;
	}
384211
public final static Object toObjectArray(final Object array) {
        if (!array.getClass().isArray()) {
            return array;
        }
        final Class<?> clazz = PRIMITIVE_TO_OBJ.get(array.getClass().getComponentType());
        return setArray(clazz, array);
    }
244858
public static function serializedObjectToArray(array &$array, array &$mappings)
    {
        foreach ($array as $key => &$value) {
            if ($key === Serializer::CLASS_IDENTIFIER_KEY) {
                $type = $array[Serializer::CLASS_IDENTIFIER_KEY];
                if (empty($mappings[$type])) {
                    unset($array[Serializer::CLASS_IDENTIFIER_KEY]);
                }
            }
            if (is_array($value)) {
                foreach($value as $k => &$v) {
                    if (is_array($v)) {
                        $v = self::serializedObjectToArray($v, $mappings);
                    }
                }
            }
        }
        return $array;
    }
1087507
public static String fromNullTerminatedByteArray(byte[] array) {
        int stringSize = array.length;
        for (int i = 0; i < array.length; i++) {
            if (array[i] == 0) {
                stringSize = i;
                break;
            }
        }

        return new String(array, 0, stringSize);
    }
515078
public static String[][] invert(final String[][] array) {
        final String[][] newarray = new String[array.length][2];
        for(int i = 0; i<array.length; i++) {
            newarray[i][0] = array[i][1];
            newarray[i][1] = array[i][0];
        }
        return newarray;
    }
293413
public static byte[] toByteArray( Serializable object )
	{
	    try
	    {
            ByteArrayOutputStream buf = new ByteArrayOutputStream(1024);
            ObjectOutputStream objOut = new ObjectOutputStream(buf);
            objOut.writeObject(object);
            objOut.close();
            return buf.toByteArray();
	    }
	    catch (IOException e)
	    {
	        throw new IllegalArgumentException("Cannot serialize object : "+e.toString());
	    }
	}
246310
private function deserializeArrayRecursively(array $array): array
    {
        $data = [];
        foreach ($array as $key => $value) {
            $data[$key] = $this->deserializeValue($value);
        }

        return $data;
    }
632056
def WriteSerializableArray(self, array):
        
        if array is None:
            self.WriteByte(0)
        else:
            self.WriteVarInt(len(array))
            for item in array:
                item.Serialize(self)
156019
public static final String arrayToString(final Object[] array) {
        final StringBuilder builder = new StringBuilder();
        builder.append(ARRAY_START);
        if (array != null && array.length > 0) {
            appendNonEmptyArrayToString(array, builder);
        }
        builder.append(ARRAY_END);
        return builder.toString();
    }
1291850
protected Object[] _transform(final Object[] array) {
        Object[] result = new Object[array.length];
        for (Object object : array) {
            ArrayUtils.add(result, transform(object));
        }
        return result;
    }
696387
private WrappedByteArray deserializeObj(String key) throws Exception {
      byte[] data = Base64.getDecoder().decode(key);
      return new WrappedByteArray(data);
   }
1272528
public static String encodeByteArray(byte[] byteArray) {
		try {
			return new String(Base64.encodeBase64(byteArray), UTF8_ENCODING);
		} catch(UnsupportedEncodingException e) {
			throw new MappingException("Could not encode byteArray to UTF8 encoding", e);
		}
	}