Encodes the given byte array and then GZIP compresses it.

@param value byte array input
@return compressed byte array output
@throws IOException
196597
public static byte[] compressBytesNonBase64(byte[] value) throws IOException {
        ByteArrayOutputStream baos = new ByteArrayOutputStream(value.length);
        try (GZIPOutputStream gos = new GZIPOutputStream(baos)) {
            gos.write(value);
        }
        byte[] compressed = baos.toByteArray();
        baos.close();
        return compressed;
    }
728638
public static long fromBytes(byte[] value){
        if (value == null) return 0;
        long out = 0;
        int length = value.length;
        if (length > 8) length = 8;
        for (int i = 0; i < length; i++){
            out = (out << 8) + (value[i] & 0xff);
        }
        return out;
    }
721680
public final Object encode(Object value) {
      if (value == null) {
         return null;
      }
      if (value instanceof Val) {
         return encodeImpl(Cast.<Val>as(value).get());
      }
      return encodeImpl(value);
   }
184723
private function serialize($value)
    {
        $compressed = gzcompress($value);
        if ($compressed === false) {
            return false;
        }

        $encoded = base64_encode($compressed);
        return $encoded;
    }
755358
public static byte[] serialize(Object value) throws IOException {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    serialize(value, out);
    return out.toByteArray();
  }
837505
protected String convertDigestEncoding(String value) {

        byte[] data = new byte[value.length() / 2];

        for (int i = 0; i < data.length; i++) {
            data[i] = (byte)(Integer.parseInt(value.substring(i * 2, (i * 2) + 2), 16) - 128);
        }
        return new String(Base64.encodeBase64(data));
    }
778462
public static String base64Decode(final String value) {
        validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER);
        return new String(Base64.getDecoder().decode(value), StandardCharsets.UTF_8);
    }
372674
public static final byte[] toAsciiBytes(final String value) 
        {
        byte[] result = new byte[value.length()];
        for (int i = 0; i < value.length(); i++) 
            {
            result[i] = (byte) value.charAt(i);
            }
        return result;
        }
1175634
private byte[] getBytes(String value, boolean unicode)
   {
      byte[] result;
      if (unicode)
      {
         int start = 0;
         // Get the bytes in UTF-16
         byte[] bytes;

         try
         {
            bytes = value.getBytes("UTF-16");
         }
         catch (UnsupportedEncodingException e)
         {
            bytes = value.getBytes();
         }

         if (bytes.length > 2 && bytes[0] == -2 && bytes[1] == -1)
         {
            // Skip the unicode identifier
            start = 2;
         }
         result = new byte[bytes.length - start];
         for (int loop = start; loop < bytes.length - 1; loop += 2)
         {
            // Swap the order here
            result[loop - start] = bytes[loop + 1];
            result[loop + 1 - start] = bytes[loop];
         }
      }
      else
      {
         result = new byte[value.length() + 1];
         System.arraycopy(value.getBytes(), 0, result, 0, value.length());
      }
      return (result);
   }
55501
public static byte [] serialize(Serializable serializable, boolean compress) throws IOException {
        requireNonNull(serializable);

        try (ByteArrayOutputStream o = new ByteArrayOutputStream();
             ObjectOutputStream oos = new ObjectOutputStream(compress ? new GZIPOutputStream(o) : o)) {
            oos.writeObject(serializable);
            oos.flush();
            oos.close();  //must close before getting bytes because GZip streams require it.
            return o.toByteArray();
        }
    }
663759
public static byte[] toBytes(long value, int length) {
        if (length <= 0) return new byte[0];
        if (length > 8) length = 8;
        byte[] out = new byte[length];
        for (int i = length - 1; i >= 0; i--){
            out[i] = (byte)(value & 0xFFL);
            value = value >> 8;
        }
        return out;
    }
879221
public static String writeByte(Byte value) {
		if (value==null) return null;
		
		return Byte.toString(value);			
	}
539105
public JBBPTextWriter Byte(final int value) throws IOException {
    ensureValueMode();

    String convertedByExtras = null;
    for (final Extra e : this.extras) {
      convertedByExtras = e.doConvertByteToStr(this, value & 0xFF);
      if (convertedByExtras != null) {
        break;
      }
    }

    if (convertedByExtras == null) {
      printValueString(JBBPUtils.ensureMinTextLength(JBBPUtils.ulong2str(value & 0xFF, this.radix, CHAR_BUFFER), this.maxCharsRadixForByte, '0', 0));
    } else {
      printValueString(convertedByExtras);
    }

    return this;
  }
1344196
public void fill(byte value)
    {
        int offset = 0;
        int length = size;
        long longValue = Longs.fromBytes(value, value, value, value, value, value, value, value);
        while (length >= SizeOf.SIZE_OF_LONG) {
            unsafe.putLong(base, address + offset, longValue);
            offset += SizeOf.SIZE_OF_LONG;
            length -= SizeOf.SIZE_OF_LONG;
        }

        while (length > 0) {
            unsafe.putByte(base, address + offset, value);
            offset++;
            length--;
        }
    }
966576
private static byte[] base64Decode(String value) {
    if (value == null) {
      return null;
    }
    
    try {
      return Base64.decodeBase64(value.getBytes("UTF-8"));
    }
    catch (UnsupportedEncodingException e) {
      throw new RuntimeException(e);
    }
  }
246504
public static byte[] inflater(final byte[] inputByte) throws IOException {
		int compressedDataLength = 0;
		Inflater compresser = new Inflater(false);
		compresser.setInput(inputByte, 0, inputByte.length);
		ByteArrayOutputStream o = new ByteArrayOutputStream(inputByte.length);
		byte[] result = new byte[1024];
		try {
			while (!compresser.finished()) {
				compressedDataLength = compresser.inflate(result);
				if (compressedDataLength == 0) {
					break;
				}
				o.write(result, 0, compressedDataLength);
			}
		} catch (Exception ex) {
			System.err.println("Data format error!\n");
			ex.printStackTrace();
		} finally {
			o.close();
		}
		compresser.end();
		return o.toByteArray();
	}
751290
public static void encode(int value, byte[] dst, int dstOffset) {
        value ^= 0x80000000;
        dst[dstOffset    ] = (byte)(value >> 24);
        dst[dstOffset + 1] = (byte)(value >> 16);
        dst[dstOffset + 2] = (byte)(value >> 8);
        dst[dstOffset + 3] = (byte)value;
    }