/** * Puts a byte into this byte vector. The byte vector is automatically enlarged if necessary. * * @param byteValue a byte. * @return this byte vector. */ public ByteVector putByte(final int byteValue) { int currentLength = length; if (currentLength + 1 > data.length) { enlarge(1); } data[currentLength++] = (byte) byteValue; length = currentLength; return this; }
/** * Puts a short into this byte vector. The byte vector is automatically enlarged if necessary. * * @param shortValue a short. * @return this byte vector. */ public ByteVector putShort(final int shortValue) { int currentLength = length; if (currentLength + 2 > data.length) { enlarge(2); } byte[] currentData = data; currentData[currentLength++] = (byte) (shortValue >>> 8); currentData[currentLength++] = (byte) shortValue; length = currentLength; return this; }
/** * Puts a byte and a short into this byte vector. The byte vector is automatically enlarged if * necessary. * * @param byteValue a byte. * @param shortValue a short. * @return this byte vector. */ final ByteVector put12(final int byteValue, final int shortValue) { int currentLength = length; if (currentLength + 3 > data.length) { enlarge(3); } byte[] currentData = data; currentData[currentLength++] = (byte) byteValue; currentData[currentLength++] = (byte) (shortValue >>> 8); currentData[currentLength++] = (byte) shortValue; length = currentLength; return this; }
/** * Puts two bytes and a short into this byte vector. The byte vector is automatically enlarged if * necessary. * * @param byteValue1 a byte. * @param byteValue2 another byte. * @param shortValue a short. * @return this byte vector. */ final ByteVector put112(final int byteValue1, final int byteValue2, final int shortValue) { int currentLength = length; if (currentLength + 4 > data.length) { enlarge(4); } byte[] currentData = data; currentData[currentLength++] = (byte) byteValue1; currentData[currentLength++] = (byte) byteValue2; currentData[currentLength++] = (byte) (shortValue >>> 8); currentData[currentLength++] = (byte) shortValue; length = currentLength; return this; }
/** * Puts two bytes into this byte vector. The byte vector is automatically enlarged if necessary. * * @param byteValue1 a byte. * @param byteValue2 another byte. * @return this byte vector. */ final ByteVector put11(final int byteValue1, final int byteValue2) { int currentLength = length; if (currentLength + 2 > data.length) { enlarge(2); } byte[] currentData = data; currentData[currentLength++] = (byte) byteValue1; currentData[currentLength++] = (byte) byteValue2; length = currentLength; return this; }
/** * Puts an int into this byte vector. The byte vector is automatically enlarged if necessary. * * @param intValue an int. * @return this byte vector. */ public ByteVector putInt(final int intValue) { int currentLength = length; if (currentLength + 4 > data.length) { enlarge(4); } byte[] currentData = data; currentData[currentLength++] = (byte) (intValue >>> 24); currentData[currentLength++] = (byte) (intValue >>> 16); currentData[currentLength++] = (byte) (intValue >>> 8); currentData[currentLength++] = (byte) intValue; length = currentLength; return this; }
/** * Puts a long into this byte vector. The byte vector is automatically enlarged if necessary. * * @param longValue a long. * @return this byte vector. */ public ByteVector putLong(final long longValue) { int currentLength = length; if (currentLength + 8 > data.length) { enlarge(8); } byte[] currentData = data; int intValue = (int) (longValue >>> 32); currentData[currentLength++] = (byte) (intValue >>> 24); currentData[currentLength++] = (byte) (intValue >>> 16); currentData[currentLength++] = (byte) (intValue >>> 8); currentData[currentLength++] = (byte) intValue; intValue = (int) longValue; currentData[currentLength++] = (byte) (intValue >>> 24); currentData[currentLength++] = (byte) (intValue >>> 16); currentData[currentLength++] = (byte) (intValue >>> 8); currentData[currentLength++] = (byte) intValue; length = currentLength; return this; }
/** * Puts one byte and two shorts into this byte vector. The byte vector is automatically enlarged * if necessary. * * @param byteValue a byte. * @param shortValue1 a short. * @param shortValue2 another short. * @return this byte vector. */ final ByteVector put122(final int byteValue, final int shortValue1, final int shortValue2) { int currentLength = length; if (currentLength + 5 > data.length) { enlarge(5); } byte[] currentData = data; currentData[currentLength++] = (byte) byteValue; currentData[currentLength++] = (byte) (shortValue1 >>> 8); currentData[currentLength++] = (byte) shortValue1; currentData[currentLength++] = (byte) (shortValue2 >>> 8); currentData[currentLength++] = (byte) shortValue2; length = currentLength; return this; }
/** * Puts an array of bytes into this byte vector. The byte vector is automatically enlarged if * necessary. * * @param byteArrayValue an array of bytes. May be {@literal null} to put {@code byteLength} null * bytes into this byte vector. * @param byteOffset index of the first byte of byteArrayValue that must be copied. * @param byteLength number of bytes of byteArrayValue that must be copied. * @return this byte vector. */ public ByteVector putByteArray( final byte[] byteArrayValue, final int byteOffset, final int byteLength) { if (length + byteLength > data.length) { enlarge(byteLength); } if (byteArrayValue != null) { System.arraycopy(byteArrayValue, byteOffset, data, length, byteLength); } length += byteLength; return this; }
enlarge(byteLength - offset);
enlarge(2 + charLength);
/** * Puts a byte into this byte vector. The byte vector is automatically enlarged if necessary. * * @param byteValue a byte. * @return this byte vector. */ public ByteVector putByte(final int byteValue) { int currentLength = length; if (currentLength + 1 > data.length) { enlarge(1); } data[currentLength++] = (byte) byteValue; length = currentLength; return this; }
/** * Puts a short into this byte vector. The byte vector is automatically enlarged if necessary. * * @param shortValue a short. * @return this byte vector. */ public ByteVector putShort(final int shortValue) { int currentLength = length; if (currentLength + 2 > data.length) { enlarge(2); } byte[] currentData = data; currentData[currentLength++] = (byte) (shortValue >>> 8); currentData[currentLength++] = (byte) shortValue; length = currentLength; return this; }
/** * Puts two bytes into this byte vector. The byte vector is automatically enlarged if necessary. * * @param byteValue1 a byte. * @param byteValue2 another byte. * @return this byte vector. */ final ByteVector put11(final int byteValue1, final int byteValue2) { int currentLength = length; if (currentLength + 2 > data.length) { enlarge(2); } byte[] currentData = data; currentData[currentLength++] = (byte) byteValue1; currentData[currentLength++] = (byte) byteValue2; length = currentLength; return this; }
/** * Puts an int into this byte vector. The byte vector is automatically enlarged if necessary. * * @param intValue an int. * @return this byte vector. */ public ByteVector putInt(final int intValue) { int currentLength = length; if (currentLength + 4 > data.length) { enlarge(4); } byte[] currentData = data; currentData[currentLength++] = (byte) (intValue >>> 24); currentData[currentLength++] = (byte) (intValue >>> 16); currentData[currentLength++] = (byte) (intValue >>> 8); currentData[currentLength++] = (byte) intValue; length = currentLength; return this; }
/** * Puts a byte and a short into this byte vector. The byte vector is automatically enlarged if * necessary. * * @param byteValue a byte. * @param shortValue a short. * @return this byte vector. */ final ByteVector put12(final int byteValue, final int shortValue) { int currentLength = length; if (currentLength + 3 > data.length) { enlarge(3); } byte[] currentData = data; currentData[currentLength++] = (byte) byteValue; currentData[currentLength++] = (byte) (shortValue >>> 8); currentData[currentLength++] = (byte) shortValue; length = currentLength; return this; }
/** * Puts two bytes and a short into this byte vector. The byte vector is automatically enlarged if * necessary. * * @param byteValue1 a byte. * @param byteValue2 another byte. * @param shortValue a short. * @return this byte vector. */ final ByteVector put112(final int byteValue1, final int byteValue2, final int shortValue) { int currentLength = length; if (currentLength + 4 > data.length) { enlarge(4); } byte[] currentData = data; currentData[currentLength++] = (byte) byteValue1; currentData[currentLength++] = (byte) byteValue2; currentData[currentLength++] = (byte) (shortValue >>> 8); currentData[currentLength++] = (byte) shortValue; length = currentLength; return this; }
/** * Puts a long into this byte vector. The byte vector is automatically enlarged if necessary. * * @param longValue a long. * @return this byte vector. */ public ByteVector putLong(final long longValue) { int currentLength = length; if (currentLength + 8 > data.length) { enlarge(8); } byte[] currentData = data; int intValue = (int) (longValue >>> 32); currentData[currentLength++] = (byte) (intValue >>> 24); currentData[currentLength++] = (byte) (intValue >>> 16); currentData[currentLength++] = (byte) (intValue >>> 8); currentData[currentLength++] = (byte) intValue; intValue = (int) longValue; currentData[currentLength++] = (byte) (intValue >>> 24); currentData[currentLength++] = (byte) (intValue >>> 16); currentData[currentLength++] = (byte) (intValue >>> 8); currentData[currentLength++] = (byte) intValue; length = currentLength; return this; }
/** * Puts one byte and two shorts into this byte vector. The byte vector is automatically enlarged * if necessary. * * @param byteValue a byte. * @param shortValue1 a short. * @param shortValue2 another short. * @return this byte vector. */ final ByteVector put122(final int byteValue, final int shortValue1, final int shortValue2) { int currentLength = length; if (currentLength + 5 > data.length) { enlarge(5); } byte[] currentData = data; currentData[currentLength++] = (byte) byteValue; currentData[currentLength++] = (byte) (shortValue1 >>> 8); currentData[currentLength++] = (byte) shortValue1; currentData[currentLength++] = (byte) (shortValue2 >>> 8); currentData[currentLength++] = (byte) shortValue2; length = currentLength; return this; }
/** * Puts an array of bytes into this byte vector. The byte vector is automatically enlarged if * necessary. * * @param byteArrayValue an array of bytes. May be {@literal null} to put {@code byteLength} null * bytes into this byte vector. * @param byteOffset index of the first byte of byteArrayValue that must be copied. * @param byteLength number of bytes of byteArrayValue that must be copied. * @return this byte vector. */ public ByteVector putByteArray( final byte[] byteArrayValue, final int byteOffset, final int byteLength) { if (length + byteLength > data.length) { enlarge(byteLength); } if (byteArrayValue != null) { System.arraycopy(byteArrayValue, byteOffset, data, length, byteLength); } length += byteLength; return this; }