Returns a byte array representation of this union

@param serDe An instance of ArrayOfItemsSerDe
@return a byte array representation of this union
517189
public byte[] toByteArray(final ArrayOfItemsSerDe<T> serDe) {
    if ((gadget_ == null) || (gadget_.getNumSamples() == 0)) {
      return toByteArray(serDe, null);
    } else {
      return toByteArray(serDe, gadget_.getValueAtPosition(0).getClass());
    }
  }
554329
public static final byte[] serialize(Serializable serializable) throws IOException {
	
		if (serializable == null) {
			return null;
		}
		
		ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
		ObjectOutputStream objectOutputStream = null;
		byte[] result = null;

		if (null != _instance ){
			SerializationService ss = _instance.serializationServiceRef.getService();
			if (null != ss){
				objectOutputStream = ss.createObjectOutputStream(byteArrayOutputStream);
			}
		} 
		
		if (null == objectOutputStream){
			objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
		}
		
		try {
			objectOutputStream.writeObject(serializable);
			result = byteArrayOutputStream.toByteArray();
		} finally {

			if (byteArrayOutputStream != null) {
				byteArrayOutputStream.close();
			}
			if (objectOutputStream != null) {
				objectOutputStream.close();
			}
		}

		return result;
	}
236609
public static byte[] getBytes(final int mValue) {
        final byte[] tmpBytes = new byte[5];
        int position = 0;
        tmpBytes[position++] = (byte)(mValue);
        if (mValue > 63 || mValue < -64) {
            tmpBytes[position - 1] |= 128;
            tmpBytes[position++] = (byte)(mValue >> 7);
            if (mValue > 8191 || mValue < -8192) {
                tmpBytes[position - 1] |= 128;
                tmpBytes[position++] = (byte)(mValue >> 14);
                if (mValue > 1048575 || mValue < -1048576) {
                    tmpBytes[position - 1] |= 128;
                    tmpBytes[position++] = (byte)(mValue >> 21);
                    if (mValue > 268435455 || mValue < -268435456) {
                        tmpBytes[position - 1] |= 128;
                        tmpBytes[position++] = (byte)(mValue >> 28);
                    } else {
                        tmpBytes[position - 1] &= 127;
                    }
                } else {
                    tmpBytes[position - 1] &= 127;
                }
            } else {
                tmpBytes[position - 1] &= 127;
            }
        } else {
            tmpBytes[position - 1] &= 127;
        }

        final byte[] bytes = new byte[position];
        System.arraycopy(tmpBytes, 0, bytes, 0, position);
        return bytes;
    }
1228664
public byte[] toByteArray()
	{
		final byte[] data = new byte[7];
		data[0] = (byte) oindex;
		data[1] = (byte) id;
		data[2] = (byte) pindex;
		data[3] = (byte) (write ? 0x80 : 0x00);
		data[3] |= pdt & 0x3f;
		data[4] = (byte) (maxElems >> 8);
		data[5] = (byte) maxElems;
		data[6] = (byte) (rLevel << 4 | (wLevel & 0x0f));
		return data;
	}
538826
@SuppressWarnings("null")
  public byte[] toByteArray(final ArrayOfItemsSerDe<T> serDe) {
    final int preLongs;
    final int outBytes;
    final boolean empty = isEmpty();
    final int activeItems = getNumActiveItems();
    byte[] bytes = null;
    if (empty) {
      preLongs = 1;
      outBytes = 8;
    } else {
      preLongs = Family.FREQUENCY.getMaxPreLongs();
      bytes = serDe.serializeToByteArray(hashMap.getActiveKeys());
      outBytes = ((preLongs + activeItems) << 3) + bytes.length;
    }
    final byte[] outArr = new byte[outBytes];
    final WritableMemory mem = WritableMemory.wrap(outArr);

    // build first preLong empty or not
    long pre0 = 0L;
    pre0 = insertPreLongs(preLongs, pre0);                  //Byte 0
    pre0 = insertSerVer(SER_VER, pre0);                     //Byte 1
    pre0 = insertFamilyID(Family.FREQUENCY.getID(), pre0);  //Byte 2
    pre0 = insertLgMaxMapSize(lgMaxMapSize, pre0);          //Byte 3
    pre0 = insertLgCurMapSize(hashMap.getLgLength(), pre0); //Byte 4
    pre0 = empty ? insertFlags(EMPTY_FLAG_MASK, pre0) : insertFlags(0, pre0); //Byte 5

    if (empty) {
      mem.putLong(0, pre0);
    } else {
      final long pre = 0;
      final long[] preArr = new long[preLongs];
      preArr[0] = pre0;
      preArr[1] = insertActiveItems(activeItems, pre);
      preArr[2] = this.streamWeight;
      preArr[3] = this.offset;
      mem.putLongArray(0, preArr, 0, preLongs);
      final int preBytes = preLongs << 3;
      mem.putLongArray(preBytes, hashMap.getActiveValues(), 0, activeItems);
      mem.putByteArray(preBytes + (this.getNumActiveItems() << 3), bytes, 0, bytes.length);
    }
    return outArr;
  }
804079
byte[] encodeToBytes(EncodingLevel encodingLevel) throws JMSException {

        // If we haven't already got the encoding cached, encode & cache it now.
        if (cachedEncoding[encodingLevel.ordinal()] == null) {
            cachedEncoding[encodingLevel.ordinal()] = destEncoder.getMessageRepresentationFromDest(this, encodingLevel);
        }
        return cachedEncoding[encodingLevel.ordinal()];
    }
366043
public static byte[] serialize(Serializable s) throws IOException {

        HsqlByteArrayOutputStream bo = new HsqlByteArrayOutputStream();
        ObjectOutputStream        os = new ObjectOutputStream(bo);

        os.writeObject(s);

        return bo.toByteArray();
    }
1061216
public static LongDeserializer getDeserializer(int longSize, ByteBuffer fromBuffer, int bufferOffset)
  {
    // The buffer needs to be duplicated since the byte order is changed
    ByteBuffer buffer = fromBuffer.duplicate().order(ByteOrder.BIG_ENDIAN);
    switch (longSize) {
      case 1:
        return new Size1Des(buffer, bufferOffset);
      case 2:
        return new Size2Des(buffer, bufferOffset);
      case 4:
        return new Size4Des(buffer, bufferOffset);
      case 8:
        return new Size8Des(buffer, bufferOffset);
      case 12:
        return new Size12Des(buffer, bufferOffset);
      case 16:
        return new Size16Des(buffer, bufferOffset);
      case 20:
        return new Size20Des(buffer, bufferOffset);
      case 24:
        return new Size24Des(buffer, bufferOffset);
      case 32:
        return new Size32Des(buffer, bufferOffset);
      case 40:
        return new Size40Des(buffer, bufferOffset);
      case 48:
        return new Size48Des(buffer, bufferOffset);
      case 56:
        return new Size56Des(buffer, bufferOffset);
      case 64:
        return new Size64Des(buffer, bufferOffset);
      default:
        throw new IAE("Unsupported size %s", longSize);
    }
  }
880923
@Nullable
  public byte [] getAsByteArray ()
  {
    try (final NonBlockingByteArrayOutputStream aBAOS = new NonBlockingByteArrayOutputStream ())
    {
      if (writeTo (aBAOS).isFailure ())
        return null;
      return aBAOS.getBufferOrCopy ();
    }
  }
1326175
protected byte[] byteBufferToByteArray() {
        if (byteBuffer.hasArray()) {
            return byteBuffer.array();
        } else {
            final byte[] byteArray = new byte[byteBuffer.remaining()];
            byteBuffer.get(byteArray);
            return byteArray;
        }
    }
750475
public byte[] asByteArray() {
        Objects.requireNonNull(data);
        byte[] ret = Arrays.copyOf(data, data.length);
        Arrays.fill(data, (byte) 0);
        data = null;
        return ret;
    }
582693
public static Bytes toBytes(ByteSequence bs) {
    if (bs.length() == 0) {
      return Bytes.EMPTY;
    }

    if (bs.isBackedByArray()) {
      return Bytes.of(bs.getBackingArray(), bs.offset(), bs.length());
    } else {
      return Bytes.of(bs.toArray(), 0, bs.length());
    }
  }
743216
public byte[] getByteArray(final String key, final byte[] def) {
		try {
			final byte[] result = getByteArray(key);
			return result != null ? result : def;
		} catch (final NumberFormatException nfe) {
			return def;
		}
	}
1149757
public static byte[] toByteArray(final ByteString bs) {
    return bs == null || bs.isEmpty() ? null : bs.toByteArray();
  }
1180694
public static byte[] toArray(ByteBuffer buffer) {
        if (buffer.hasArray()) {
            byte[] array = buffer.array();
            int from = buffer.arrayOffset() + buffer.position();
            return Arrays.copyOfRange(array, from, from + buffer.remaining());
        } else {
            byte[] to = new byte[buffer.remaining()];
            buffer.slice().get(to);
            return to;
        }
    }
1162671
public final static byte[] toByteArray(String uid) {
        byte[] result = new byte[16];
        char[] chars = uid.toCharArray();
        int r = 0;
        for (int i = 0; i < chars.length; ++i) {
            if (chars[i] == '-') {
                continue;
            }
            int h1 = Character.digit(chars[i], 16);
            ++i;
            int h2 = Character.digit(chars[i], 16);
            result[(r++)] = (byte) ((h1 << 4 | h2) & 0xFF);
        }
        return result;
    }
1105661
@Override
    public byte[] getBytes(K key) {
        if(key == null) {
            return null;
        }
        
        return _store.get(_keySerializer.serialize(key));
    }