- java.lang.Object
-
- org.refcodes.serial.ByteArraySequence
-
- All Implemented Interfaces:
Iterable<Byte>
,org.refcodes.mixin.Clearable
,org.refcodes.mixin.InputStreamAccessor
,org.refcodes.mixin.LengthAccessor
,org.refcodes.mixin.OutputStreamAccessor
,Sequence
public class ByteArraySequence extends Object implements Sequence
AByteArraySequence
implements theSequence
interface by using chunks of byte arrays, therewith reducing array copy operations when working with byte fields. AByteArraySequence
is a one dimensional representation of a byte array of byte arrays (a two dimensional byte array). Each byte array inside the byte array (of byte arrays) is called a chunk. Using this technique we easily can create ourSequence
instances consisting of many chunks while reducing the copying and concatenating efforts (and buffer allocations), providing for a low memory footprint.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
ByteArraySequence.SequenceIterator
Implements theIterator
interface being appied to an instancoe of theByteArraySequence
type.-
Nested classes/interfaces inherited from interface org.refcodes.mixin.InputStreamAccessor
org.refcodes.mixin.InputStreamAccessor.InputStreamBuilder<B extends org.refcodes.mixin.InputStreamAccessor.InputStreamBuilder<?>>, org.refcodes.mixin.InputStreamAccessor.InputStreamMutator, org.refcodes.mixin.InputStreamAccessor.InputStreamProperty
-
Nested classes/interfaces inherited from interface org.refcodes.mixin.LengthAccessor
org.refcodes.mixin.LengthAccessor.LengthBuilder<B extends org.refcodes.mixin.LengthAccessor.LengthBuilder<B>>, org.refcodes.mixin.LengthAccessor.LengthMutator, org.refcodes.mixin.LengthAccessor.LengthProperty
-
Nested classes/interfaces inherited from interface org.refcodes.mixin.OutputStreamAccessor
org.refcodes.mixin.OutputStreamAccessor.OutputStreamBuilder<B extends org.refcodes.mixin.OutputStreamAccessor.OutputStreamBuilder<?>>, org.refcodes.mixin.OutputStreamAccessor.OutputStreamMutator, org.refcodes.mixin.OutputStreamAccessor.OutputStreamProperty
-
-
Constructor Summary
Constructors Constructor Description ByteArraySequence()
Constructs an emptyByteArraySequence
.ByteArraySequence(byte aByte)
Constructs aByteArraySequence
from the provided byte.ByteArraySequence(byte... aBytes)
Constructs aByteArraySequence
from the provided byte chunk.ByteArraySequence(byte[]... aBytes)
Constructs aByteArraySequence
from the provided byte chunks.ByteArraySequence(byte[][]... aBytes)
Constructs aByteArraySequence
from the provided byte chunks.ByteArraySequence(byte[] aBytes, int aOffset, int aLength)
Constructs aByteArraySequence
from the provided byte chunk.ByteArraySequence(int aLength)
Constructs aByteArraySequence
of the given initial length.ByteArraySequence(InputStream aInputStream)
Constructs theByteArraySequence
from the content of the providedInputStream
.ByteArraySequence(Sequence aSequence)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
append(byte[] aBytes, int aOffset, int aLength)
Appends the given bytes to the end of thisSequence
.void
append(Sequence aSequence)
void
empty()
Empties theSequence
to end up being of length 0.boolean
equals(Object obj)
byte
getByteAt(int aIndex)
Returns the byte at the given index in theSequence
.int
getLength()
int
hashCode()
Iterator<Byte>
iterator()
void
prepend(byte[] aBytes, int aOffset, int aLength)
Prepends the given bytes to the beginning of thisSequence
.void
prepend(Sequence aSequence)
void
replace(byte[] aBytes)
Replaces the content of thisSequence
with the content of the given byte array.void
replace(byte[] aBytes, int aOffset, int aLength)
Replaces the given bytes with this byte array.void
replace(Sequence aSequence)
void
replace(Sequence aSequence, int aOffset, int aLength)
Replaces the given bytes with thisSequence
.void
setByteAt(int aIndex, byte aByte)
Sets the byte at the given index in theSequence
.ByteArraySequence
toAppend(byte... aBytes)
Appends the given bytes to the end of thisSequence
.ByteArraySequence
toAppend(byte[] aBytes, int aOffset, int aLength)
Appends the given bytes to the end of thisSequence
.ByteArraySequence
toAppend(Sequence aSequence)
ByteArraySequence
toClone()
Creates a deep clone of thisSequence
.ByteArraySequence
toConcatenate(org.refcodes.mixin.ConcatenateMode aConcatenateMode, byte... aBytes)
Concatenates the given bytes with thisSequence
according to the providedConcatenateMode
.ByteArraySequence
toConcatenate(Sequence aSequence, org.refcodes.mixin.ConcatenateMode aConcatenateMode)
byte[]
toCrcBytes(long aCrcChecksum, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.numerical.Endianess aEndianess)
Calculates the CRC checksum as byte array for thisSequence
.byte[]
toCrcBytes(org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.numerical.Endianess aEndianess)
Calculates the CRC checksum as byte array for thisSequence
.long
toCrcChecksum(long aCrcChecksum, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm)
Calculates the CRC checksum for thisSequence
.long
toCrcChecksum(org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm)
Calculates the CRC checksum for thisSequence
.ByteArraySequence
toOverwrite(byte[] aBytes)
Writes the given bytes into a copy of thisSequence
.ByteArraySequence
toOverwrite(int aOffset, byte[] aBytes, int aBytesOffset, int aLength)
Writes the given bytes into a copy of thisSequence
.ByteArraySequence
toOverwrite(int aOffset, Sequence aSequence)
Writes the given bytes into a copy of thisSequence
.ByteArraySequence
toOverwrite(int aOffset, Sequence aSeqquence, int aBytesOffset, int aLength)
ByteArraySequence
toOverwrite(Sequence aSequence)
Writes the given bytes into a copy of thisSequence
.ByteArraySequence
toPrepend(byte... aBytes)
Prepends the given bytes to the beginning of thisSequence
.ByteArraySequence
toPrepend(byte[] aBytes, int aOffset, int aLength)
Prepends the given bytes to the beginning of thisSequence
.ByteArraySequence
toPrepend(Sequence aSequence)
ByteArraySequence
toSequence(int aOffset, int aLength)
String
toString()
ByteArraySequence
toTruncate(int aLength, org.refcodes.mixin.TruncateMode aTruncateMode)
Returns a newSequence
truncated by the given number of bytes from the right or from the left of both, according to the givenTruncateMode
.ByteArraySequence
toTruncateHead(int aLength)
Returns a newSequence
truncated by the given number of bytes from the left.ByteArraySequence
toTruncateTail(int aLength)
Returns a newSequence
truncated by the given number of bytes from the right.void
truncateHead(int aLength)
Truncates theSequence
by the given number of bytes from the left.void
truncateTail(int aLength)
Truncates theSequence
by the given number of bytes from the right.ByteArraySequence
withAppend(byte... aBytes)
Builder method for theSequence.append(byte...)
method.ByteArraySequence
withAppend(byte[] aBytes, int aOffset, int aLength)
Builder method for theSequence.append(byte...)
method.ByteArraySequence
withAppend(Sequence aSequence)
Builder method for theSequence.append(Sequence)
method.ByteArraySequence
withConcatenate(org.refcodes.mixin.ConcatenateMode aConcatenateMode, byte... aBytes)
Builder method for theSequence.concatenate(ConcatenateMode, byte...)
method.ByteArraySequence
withConcatenate(Sequence aSequence, org.refcodes.mixin.ConcatenateMode aConcatenateMode)
Builder method for theSequence.concatenate(Sequence, ConcatenateMode)
method.ByteArraySequence
withOverwrite(byte[] aBytes)
Builder method for theSequence.overwrite(byte[])
method.ByteArraySequence
withOverwrite(int aOffset, byte[] aBytes)
Builder method for theSequence.overwrite(int, byte[])
method.ByteArraySequence
withOverwrite(int aOffset, byte[] aBytes, int aBytesOffset, int aLength)
Builder method for theSequence.overwrite(int, byte[], int, int)
method.ByteArraySequence
withOverwrite(int aOffset, Sequence aSequence)
Builder method for theSequence.overwrite(int, Sequence)
method.ByteArraySequence
withOverwrite(int aOffset, Sequence aSequence, int aSequenceOffset, int aLength)
Builder method for theSequence.overwrite(int, Sequence, int, int)
method.ByteArraySequence
withOverwrite(Sequence aSequence)
Builder method for theSequence.overwrite(Sequence)
method.ByteArraySequence
withPrepend(byte... aBytes)
Builder method for theSequence.prepend(byte...)
method.ByteArraySequence
withPrepend(byte[] aBytes, int aOffset, int aLength)
Builder method for theSequence.prepend(byte...)
method.ByteArraySequence
withPrepend(Sequence aSequence)
Builder method for theSequence.prepend(Sequence)
method.ByteArraySequence
withReplace(byte[] aBytes)
Builder method for theSequence.replace(byte[])
method.ByteArraySequence
withReplace(byte[] aBytes, int aOffset, int aLength)
Builder method for theSequence.replace(byte[], int, int)
method.ByteArraySequence
withReplace(Sequence aSequence)
Builder method for theSequence.replace(Sequence)
method.ByteArraySequence
withReplace(Sequence aSequence, int aOffset, int aLength)
Builder method for theSequence.replace(Sequence, int, int)
method.ByteArraySequence
withTruncate(int aLength, org.refcodes.mixin.TruncateMode aTruncateMode)
Builder method for theSequence.truncate(int, TruncateMode)
method.ByteArraySequence
withTruncateHead(int aLength)
Builder method for theSequence.truncateHead(int)
method.ByteArraySequence
withTruncateTail(int aLength)
Builder method for theSequence.truncateTail(int)
method.void
writeTo(OutputStream aOutputStream)
Writes the content of the Sequence to the providedOutputStream
.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface org.refcodes.serial.Sequence
append, clear, clear, concatenate, concatenate, concatenate, getInputStream, getOutputStream, overwrite, overwrite, overwrite, overwrite, overwrite, overwrite, overwrite, overwrite, prepend, replace, replace, toBytes, toBytes, toBytes, toConcatenate, toHexString, toHexString, toInputStream, toOverwrite, toOverwrite, toOverwrite, truncate, withOverwrite, withOverwrite, withReplace, withReplace
-
-
-
-
Constructor Detail
-
ByteArraySequence
public ByteArraySequence()
Constructs an emptyByteArraySequence
.
-
ByteArraySequence
public ByteArraySequence(byte aByte)
Constructs aByteArraySequence
from the provided byte.- Parameters:
aByte
- The only byte out of which theByteArraySequence
consists.
-
ByteArraySequence
public ByteArraySequence(byte... aBytes)
Constructs aByteArraySequence
from the provided byte chunk.- Parameters:
aBytes
- The only chunk out of which theByteArraySequence
consists.
-
ByteArraySequence
public ByteArraySequence(byte[]... aBytes)
Constructs aByteArraySequence
from the provided byte chunks.- Parameters:
aBytes
- The byte chunks (a two dimensional byte array) out of which theByteArraySequence
consists.
-
ByteArraySequence
public ByteArraySequence(byte[] aBytes, int aOffset, int aLength)
Constructs aByteArraySequence
from the provided byte chunk.- Parameters:
aBytes
- The only chunk out of which theByteArraySequence
consists.aOffset
- The offset from where to take the chunk data.aLength
- The number of bytes to take, beginning at the provided offset.
-
ByteArraySequence
public ByteArraySequence(byte[][]... aBytes)
Constructs aByteArraySequence
from the provided byte chunks.- Parameters:
aBytes
- The byte chunks (many two dimensional byte arrays) out of which theByteArraySequence
consists.
-
ByteArraySequence
public ByteArraySequence(InputStream aInputStream) throws IOException
Constructs theByteArraySequence
from the content of the providedInputStream
.- Parameters:
aInputStream
- TheInputStream
from which's data to construct this instance.- Throws:
IOException
- thrown in case reading from theInputStream
caused problems.
-
ByteArraySequence
public ByteArraySequence(int aLength)
Constructs aByteArraySequence
of the given initial length.- Parameters:
aLength
- The initial length of theSequence
.
-
-
Method Detail
-
append
public void append(byte[] aBytes, int aOffset, int aLength)
Appends the given bytes to the end of thisSequence
. Beware: ThisSequence
is modified! If you do not wish to modify thisSequence
, please useSequence.toAppend(byte[], int, int)
.
-
append
public void append(Sequence aSequence)
Appends the givenSequence
to the end of thisSequence
. Beware: ThisSequence
is modified! If you do not wish to modify thisSequence
, please useSequence.toAppend(Sequence)
.
-
empty
public void empty()
Empties theSequence
to end up being of length 0.
-
getByteAt
public byte getByteAt(int aIndex) throws IndexOutOfBoundsException
Returns the byte at the given index in theSequence
.- Specified by:
getByteAt
in interfaceSequence
- Parameters:
aIndex
- The index of the byte to retrieve.- Returns:
- The byte being retrieved.
- Throws:
IndexOutOfBoundsException
- thrown in case the given index is out of bounds.
-
getLength
public int getLength()
- Specified by:
getLength
in interfaceorg.refcodes.mixin.LengthAccessor
-
prepend
public void prepend(byte[] aBytes, int aOffset, int aLength)
Prepends the given bytes to the beginning of thisSequence
. Beware: ThisSequence
is modified! If you do not wish to modify thisSequence
, please useSequence.toPrepend(byte[], int, int)
.
-
prepend
public void prepend(Sequence aSequence)
Prepends the givenSequence
to the beginning of thisSequence
. Beware: ThisSequence
is modified! If you do not wish to modify thisSequence
, please useSequence.toPrepend(Sequence)
.
-
replace
public void replace(byte[] aBytes)
Replaces the content of thisSequence
with the content of the given byte array.
-
replace
public void replace(Sequence aSequence)
-
replace
public void replace(byte[] aBytes, int aOffset, int aLength)
Replaces the given bytes with this byte array. CAUTION: If possible, this method avoids array copying, so if the offset is 0 and the length the same as the byte array's length, then the given byte array is used internally!
-
replace
public void replace(Sequence aSequence, int aOffset, int aLength)
Replaces the given bytes with thisSequence
.
-
setByteAt
public void setByteAt(int aIndex, byte aByte) throws IndexOutOfBoundsException
Sets the byte at the given index in theSequence
.- Specified by:
setByteAt
in interfaceSequence
- Parameters:
aIndex
- The index of the byte to set.aByte
- The byte to set at the given index.- Throws:
IndexOutOfBoundsException
- thrown in case the given index is out of bounds.
-
toAppend
public ByteArraySequence toAppend(byte... aBytes)
-
toAppend
public ByteArraySequence toAppend(byte[] aBytes, int aOffset, int aLength)
-
toAppend
public ByteArraySequence toAppend(Sequence aSequence)
-
toClone
public ByteArraySequence toClone()
Creates a deep clone of thisSequence
.
-
toConcatenate
public ByteArraySequence toConcatenate(org.refcodes.mixin.ConcatenateMode aConcatenateMode, byte... aBytes)
Concatenates the given bytes with thisSequence
according to the providedConcatenateMode
. ThisSequence
is not modified and a newSequence
is returned.- Specified by:
toConcatenate
in interfaceSequence
- Parameters:
aConcatenateMode
- The concatenation mode to be used.aBytes
- The bytes to be concatenated with.- Returns:
- The according
Sequence
.
-
toConcatenate
public ByteArraySequence toConcatenate(Sequence aSequence, org.refcodes.mixin.ConcatenateMode aConcatenateMode)
Concatenates the givenSequence
with thisSequence
according to the providedConcatenateMode
. ThisSequence
is not modified and a newSequence
is returned.- Specified by:
toConcatenate
in interfaceSequence
- Parameters:
aSequence
- TheSequence
to be concatenated with.aConcatenateMode
- The concatenation mode to be used.- Returns:
- The according
Sequence
.
-
toCrcBytes
public byte[] toCrcBytes(org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.numerical.Endianess aEndianess)
Calculates the CRC checksum as byte array for thisSequence
.- Specified by:
toCrcBytes
in interfaceSequence
- Parameters:
aCrcAlgorithm
- TheCrcAlgorithm
to be used when calculating the CRC checksum.aEndianess
- TheEndianess
(little endian or big endian) to be used for the byte array representation of the CRC checksum.- Returns:
- The CRC checksum of the
Sequence
.
-
toCrcBytes
public byte[] toCrcBytes(long aCrcChecksum, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.numerical.Endianess aEndianess)
Calculates the CRC checksum as byte array for thisSequence
.- Specified by:
toCrcBytes
in interfaceSequence
- Parameters:
aCrcChecksum
- The CRC checksum from which to continue calculating the checksum,aCrcAlgorithm
- TheCrcAlgorithm
to be used when calculating the CRC checksum.aEndianess
- TheEndianess
(little endian or big endian) to be used for the byte array representation of the CRC checksum.- Returns:
- The CRC checksum of the
Sequence
.
-
toCrcChecksum
public long toCrcChecksum(org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm)
Calculates the CRC checksum for thisSequence
.- Specified by:
toCrcChecksum
in interfaceSequence
- Parameters:
aCrcAlgorithm
- TheCrcAlgorithm
to be used when calculating the CRC checksum.- Returns:
- The CRC checksum of the
Sequence
.
-
toCrcChecksum
public long toCrcChecksum(long aCrcChecksum, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm)
Calculates the CRC checksum for thisSequence
.- Specified by:
toCrcChecksum
in interfaceSequence
- Parameters:
aCrcChecksum
- The CRC checksum from which to continue calculating the checksum,aCrcAlgorithm
- TheCrcAlgorithm
to be used when calculating the CRC checksum.- Returns:
- The CRC checksum of the
Sequence
.
-
toPrepend
public ByteArraySequence toPrepend(byte... aBytes)
-
toPrepend
public ByteArraySequence toPrepend(byte[] aBytes, int aOffset, int aLength)
-
toPrepend
public ByteArraySequence toPrepend(Sequence aSequence)
-
toSequence
public ByteArraySequence toSequence(int aOffset, int aLength)
Retrieves a newSequence
from thisSequence
, starting with the byte at the given offset and containing the given number of bytes.- Specified by:
toSequence
in interfaceSequence
- Parameters:
aOffset
- The offset from where to start collecting the bytes.aLength
- The length of the byte array to be returned.- Returns:
- The according
TransmissionSequenceException
.
-
toTruncate
public ByteArraySequence toTruncate(int aLength, org.refcodes.mixin.TruncateMode aTruncateMode)
Returns a newSequence
truncated by the given number of bytes from the right or from the left of both, according to the givenTruncateMode
. If the number of bytes exceeds the actual length of theSequence
, then the Sequence will end up being empty.- Specified by:
toTruncate
in interfaceSequence
- Parameters:
aLength
- The number of bytes to truncate according to theTruncateMode
.aTruncateMode
- TheTruncateMode
to use for truncating theSequence
.- Returns:
- The newly created truncated
Sequence
.
-
toTruncateHead
public ByteArraySequence toTruncateHead(int aLength)
Returns a newSequence
truncated by the given number of bytes from the left. If the number of bytes exceeds the actual length of theSequence
, then the newSequence
will end up being empty.- Specified by:
toTruncateHead
in interfaceSequence
- Parameters:
aLength
- The number of bytes to truncate from the left.- Returns:
- The newly created truncated
Sequence
.
-
toTruncateTail
public ByteArraySequence toTruncateTail(int aLength)
Returns a newSequence
truncated by the given number of bytes from the right. If the number of bytes exceeds the actual length of theSequence
, then the newSequence
will end up being empty.- Specified by:
toTruncateTail
in interfaceSequence
- Parameters:
aLength
- The number of bytes to truncate from the right.- Returns:
- The newly created truncated
Sequence
.
-
toOverwrite
public ByteArraySequence toOverwrite(byte[] aBytes)
Writes the given bytes into a copy of thisSequence
. If theSequence
is too small for the bytes to fit into, then theSequence
is extended accordingly.- Specified by:
toOverwrite
in interfaceSequence
- Parameters:
aBytes
- The byte array where to copy the bytes from.- Returns:
- The according
Sequence
.
-
toOverwrite
public ByteArraySequence toOverwrite(int aOffset, Sequence aSeqquence, int aBytesOffset, int aLength)
Writes the givenSequence
into a copy of thisSequence
. If theSequence
is too small for the bytes to fit into, then theSequence
is extended accordingly.- Specified by:
toOverwrite
in interfaceSequence
- Parameters:
aOffset
- The offset where to start writing the bytes to.aSeqquence
- TheSequence
where to copy the bytes from.aBytesOffset
- The offset in theSequence
where to start copying.aLength
- The number of bytes to be copied.- Returns:
- The according
Sequence
.
-
toOverwrite
public ByteArraySequence toOverwrite(int aOffset, byte[] aBytes, int aBytesOffset, int aLength)
Writes the given bytes into a copy of thisSequence
. If theSequence
is too small for the bytes to fit into, then theSequence
is extended accordingly.- Specified by:
toOverwrite
in interfaceSequence
- Parameters:
aOffset
- The offset where to start writing the bytes to.aBytes
- The byte array where to copy the bytes from.aBytesOffset
- The offset in the byte array where to start copying.aLength
- The number of bytes to be copied.- Returns:
- The according
Sequence
.
-
toOverwrite
public ByteArraySequence toOverwrite(int aOffset, Sequence aSequence)
Writes the given bytes into a copy of thisSequence
. If theSequence
is too small for the bytes to fit into, then theSequence
is extended accordingly.- Specified by:
toOverwrite
in interfaceSequence
- Parameters:
aOffset
- The offset where to start writing the bytes to.aSequence
- TheSequence
where to copy the bytes from.- Returns:
- The according
Sequence
.
-
toOverwrite
public ByteArraySequence toOverwrite(Sequence aSequence)
Writes the given bytes into a copy of thisSequence
. If theSequence
is too small for the bytes to fit into, then theSequence
is extended accordingly.- Specified by:
toOverwrite
in interfaceSequence
- Parameters:
aSequence
- TheSequence
where to copy the bytes from.- Returns:
- The according
Sequence
.
-
truncateHead
public void truncateHead(int aLength)
Truncates theSequence
by the given number of bytes from the left. If the number of bytes exceeds the actual length of theSequence
, then theSequence
will end up being empty.- Specified by:
truncateHead
in interfaceSequence
- Parameters:
aLength
- The number of bytes to truncate from the left.
-
truncateTail
public void truncateTail(int aLength)
Truncates theSequence
by the given number of bytes from the right. If the number of bytes exceeds the actual length of theSequence
, then theSequence
will end up being empty.- Specified by:
truncateTail
in interfaceSequence
- Parameters:
aLength
- The number of bytes to truncate from the right.
-
withAppend
public ByteArraySequence withAppend(byte... aBytes)
Builder method for theSequence.append(byte...)
method.- Specified by:
withAppend
in interfaceSequence
- Parameters:
aBytes
- The bytes to be appended.- Returns:
- This instance as of the builder pattern.
-
withAppend
public ByteArraySequence withAppend(byte[] aBytes, int aOffset, int aLength)
Builder method for theSequence.append(byte...)
method.- Specified by:
withAppend
in interfaceSequence
- Parameters:
aBytes
- The bytes to be appended.aOffset
- The offset from where to start collecting the bytes.aLength
- The number of bytes to be appended.- Returns:
- This instance as of the builder pattern.
-
withAppend
public ByteArraySequence withAppend(Sequence aSequence)
Builder method for theSequence.append(Sequence)
method.- Specified by:
withAppend
in interfaceSequence
- Parameters:
aSequence
- TheSequence
to be appended.- Returns:
- This instance as of the builder pattern.
-
withConcatenate
public ByteArraySequence withConcatenate(org.refcodes.mixin.ConcatenateMode aConcatenateMode, byte... aBytes)
Builder method for theSequence.concatenate(ConcatenateMode, byte...)
method.- Specified by:
withConcatenate
in interfaceSequence
- Parameters:
aConcatenateMode
- The concatenation mode to be used.aBytes
- The bytes to be concatenated with.- Returns:
- This instance as of the builder pattern.
-
withConcatenate
public ByteArraySequence withConcatenate(Sequence aSequence, org.refcodes.mixin.ConcatenateMode aConcatenateMode)
Builder method for theSequence.concatenate(Sequence, ConcatenateMode)
method.- Specified by:
withConcatenate
in interfaceSequence
- Parameters:
aSequence
- TheSequence
to be concatenated withaConcatenateMode
- The concatenation mode to be used.- Returns:
- This instance as of the builder pattern.
-
withPrepend
public ByteArraySequence withPrepend(byte... aBytes)
Builder method for theSequence.prepend(byte...)
method.- Specified by:
withPrepend
in interfaceSequence
- Parameters:
aBytes
- The bytes to be prepended.- Returns:
- This instance as of the builder pattern.
-
withPrepend
public ByteArraySequence withPrepend(byte[] aBytes, int aOffset, int aLength)
Builder method for theSequence.prepend(byte...)
method.- Specified by:
withPrepend
in interfaceSequence
- Parameters:
aBytes
- The bytes to be prepended.aOffset
- The offset from where to start collecting the bytes.aLength
- The number of bytes to be prepended.- Returns:
- This instance as of the builder pattern.
-
withPrepend
public ByteArraySequence withPrepend(Sequence aSequence)
Builder method for theSequence.prepend(Sequence)
method.- Specified by:
withPrepend
in interfaceSequence
- Parameters:
aSequence
- TheSequence
to be prepended.- Returns:
- This instance as of the builder pattern.
-
withReplace
public ByteArraySequence withReplace(byte[] aBytes)
Builder method for theSequence.replace(byte[])
method.- Specified by:
withReplace
in interfaceSequence
- Parameters:
aBytes
- The byte array where to copy the bytes from.- Returns:
- This instance as of the builder pattern.
-
withReplace
public ByteArraySequence withReplace(byte[] aBytes, int aOffset, int aLength)
Builder method for theSequence.replace(byte[], int, int)
method.- Specified by:
withReplace
in interfaceSequence
- Parameters:
aBytes
- The byte array where to copy the bytes from.aOffset
- The offset in the byte array where to start copying.aLength
- The number of bytes to be copied.- Returns:
- This instance as of the builder pattern.
-
withReplace
public ByteArraySequence withReplace(Sequence aSequence)
Builder method for theSequence.replace(Sequence)
method.- Specified by:
withReplace
in interfaceSequence
- Parameters:
aSequence
- TheSequence
where to copy the bytes from.- Returns:
- This instance as of the builder pattern.
-
withReplace
public ByteArraySequence withReplace(Sequence aSequence, int aOffset, int aLength)
Builder method for theSequence.replace(Sequence, int, int)
method.- Specified by:
withReplace
in interfaceSequence
- Parameters:
aSequence
- TheSequence
where to copy the bytes from.aOffset
- The offset in the byte array where to start copying.aLength
- The number of bytes to be copied.- Returns:
- This instance as of the builder pattern.
-
withTruncate
public ByteArraySequence withTruncate(int aLength, org.refcodes.mixin.TruncateMode aTruncateMode)
Builder method for theSequence.truncate(int, TruncateMode)
method.- Specified by:
withTruncate
in interfaceSequence
- Parameters:
aLength
- The number of bytes to truncate according to theTruncateMode
.aTruncateMode
- TheTruncateMode
to use for truncating theSequence
.- Returns:
- This instance as of the builder pattern.
-
withTruncateHead
public ByteArraySequence withTruncateHead(int aLength)
Builder method for theSequence.truncateHead(int)
method.- Specified by:
withTruncateHead
in interfaceSequence
- Parameters:
aLength
- The number of bytes to truncate.- Returns:
- This instance as of the builder pattern.
-
withTruncateTail
public ByteArraySequence withTruncateTail(int aLength)
Builder method for theSequence.truncateTail(int)
method.- Specified by:
withTruncateTail
in interfaceSequence
- Parameters:
aLength
- The number of bytes to truncate.- Returns:
- This instance as of the builder pattern.
-
withOverwrite
public ByteArraySequence withOverwrite(byte[] aBytes)
Builder method for theSequence.overwrite(byte[])
method.- Specified by:
withOverwrite
in interfaceSequence
- Parameters:
aBytes
- The byte array where to copy the bytes from.- Returns:
- This instance as of the builder pattern.
-
withOverwrite
public ByteArraySequence withOverwrite(int aOffset, byte[] aBytes)
Builder method for theSequence.overwrite(int, byte[])
method.- Specified by:
withOverwrite
in interfaceSequence
- Parameters:
aOffset
- The offset where to start writing the bytes to.aBytes
- The byte array where to copy the bytes from.- Returns:
- This instance as of the builder pattern.
-
withOverwrite
public ByteArraySequence withOverwrite(int aOffset, byte[] aBytes, int aBytesOffset, int aLength)
Builder method for theSequence.overwrite(int, byte[], int, int)
method.- Specified by:
withOverwrite
in interfaceSequence
- Parameters:
aOffset
- The offset where to start writing the bytes to.aBytes
- The byte array where to copy the bytes from.aBytesOffset
- The offset in the byte array where to start copying.aLength
- The number of bytes to be copied.- Returns:
- This instance as of the builder pattern.
-
withOverwrite
public ByteArraySequence withOverwrite(int aOffset, Sequence aSequence)
Builder method for theSequence.overwrite(int, Sequence)
method.- Specified by:
withOverwrite
in interfaceSequence
- Parameters:
aOffset
- The offset where to start writing the bytes to.aSequence
- TheSequence
where to copy the bytes from.- Returns:
- This instance as of the builder pattern.
-
withOverwrite
public ByteArraySequence withOverwrite(int aOffset, Sequence aSequence, int aSequenceOffset, int aLength)
Builder method for theSequence.overwrite(int, Sequence, int, int)
method.- Specified by:
withOverwrite
in interfaceSequence
- Parameters:
aOffset
- The offset where to start writing the bytes to.aSequence
- TheSequence
where to copy the bytes from.aSequenceOffset
- The offset in the byte array where to start copying.aLength
- The number of bytes to be copied.- Returns:
- This instance as of the builder pattern.
-
withOverwrite
public ByteArraySequence withOverwrite(Sequence aSequence)
Builder method for theSequence.overwrite(Sequence)
method.- Specified by:
withOverwrite
in interfaceSequence
- Parameters:
aSequence
- TheSequence
where to copy the bytes from.- Returns:
- This instance as of the builder pattern.
-
writeTo
public void writeTo(OutputStream aOutputStream) throws IOException
Writes the content of the Sequence to the providedOutputStream
.- Specified by:
writeTo
in interfaceSequence
- Parameters:
aOutputStream
- TheOutputStream
where to write to.- Throws:
IOException
- thrown in case of I/O problems.
-
-