- All Superinterfaces:
org.refcodes.mixin.Clearable
,org.refcodes.mixin.InputStreamAccessor
,Iterable<Byte>
,org.refcodes.mixin.LengthAccessor
,org.refcodes.mixin.OutputStreamAccessor
- All Known Implementing Classes:
BoundedSequenceDecorator
,ByteArraySequence
public interface Sequence
extends org.refcodes.mixin.LengthAccessor, Iterable<Byte>, org.refcodes.mixin.InputStreamAccessor, org.refcodes.mixin.OutputStreamAccessor, org.refcodes.mixin.Clearable
A
Sequence
abstracts a byte field providing means to applying complex
operations on that byte field.-
Nested Class Summary
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
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
append
(byte... aBytes) Appends the given bytes to the end of thisSequence
.void
append
(byte[] aBytes, int aOffset, int aLength) Appends the given bytes to the end of thisSequence
.void
default void
clear()
Sets all bytes in theSequence
to zero.default void
clear
(byte aValue) Sets all bytes in theSequence
to the provided value.default void
concatenate
(org.refcodes.mixin.ConcatenateMode aConcatenateMode, byte... aBytes) Concatenates the given bytes with thisSequence
according to the providedConcatenateMode
.default void
concatenate
(org.refcodes.mixin.ConcatenateMode aConcatenateMode, byte[] aBytes, int aOffset, int aLength) Concatenates the given bytes with thisSequence
according to the providedConcatenateMode
.default void
concatenate
(Sequence aSequence, org.refcodes.mixin.ConcatenateMode aConcatenateMode) void
empty()
Empties theSequence
to end up being of length 0.byte
getByteAt
(int aIndex) Returns the byte at the given index in theSequence
.default InputStream
Creates anInputStream
backed by thisSequence
.default OutputStream
Creates anOutputStream
backed by thisSequence
.default void
overwrite
(byte[] aBytes) Writes the given bytes into thisSequence
.default void
overwrite
(byte[] aBytes, int aLength) Writes the given bytes into thisSequence
.default void
overwrite
(int aOffset, byte[] aBytes) Writes the given bytes into thisSequence
.default void
overwrite
(int aOffset, byte[] aBytes, int aBytesOffset, int aLength) Writes the given bytes into thisSequence
.default void
default void
Writes the given bytes into thisSequence
.default void
default void
Writes the given bytes into thisSequence
.default void
prepend
(byte... aBytes) Prepends the given bytes the beginning of thisSequence
.void
prepend
(byte[] aBytes, int aOffset, int aLength) Prepends the given bytes to the beginning of thisSequence
.void
default void
replace
(byte[] aBytes) Replaces the given bytes with this byte array.default void
replace
(byte[] aBytes, int aLength) Replaces the given bytes with this byte array.void
replace
(byte[] aBytes, int aOffset, int aLength) Replaces the given bytes with this byte array.default void
default void
Replaces the given bytes with thisSequence
.void
Replaces the given bytes with thisSequence
.void
setByteAt
(int aIndex, byte aByte) Sets the byte at the given index in theSequence
.default Sequence
toAppend
(byte... aBytes) Appends the given bytes to the end of thisSequence
.toAppend
(byte[] aBytes, int aOffset, int aLength) Appends the given bytes to the end of thisSequence
.default byte[]
toBytes()
Retrieves a continuous array of bytes from theSequence
.default byte[]
toBytes
(int aOffset, int aLength) Retrieves a continuous array of bytes from theSequence
, starting with the byte at the given offset and containing the given number of bytes.default void
toBytes
(int aOffset, int aLength, byte[] aBytes, int aBytesOffset) Retrieves a continuous array of bytes from theSequence
, starting with the byte at the given offset and containing the given number of bytes.toClone()
Creates a deep clone of thisSequence
.default Sequence
toConcatenate
(org.refcodes.mixin.ConcatenateMode aConcatenateMode, byte... aBytes) Concatenates the given bytes with thisSequence
according to the providedConcatenateMode
.default Sequence
toConcatenate
(org.refcodes.mixin.ConcatenateMode aConcatenateMode, byte[] aBytes, int aOffset, int aLength) Concatenates the given bytes with thisSequence
according to the providedConcatenateMode
.default Sequence
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
.default String
default String
toHexString
(String aSeparator) default InputStream
Creates anInputStream
form thisSequence
without being backed by thisSequence
, e.g. reading from the returnedInputStream
does not affect thisSequence
(in contrast to theInputStream
returned by the methodgetInputStream()
).default Sequence
toOverwrite
(byte[] aBytes) Writes the given bytes into a copy of thisSequence
.default Sequence
toOverwrite
(byte[] aBytes, int aLength) Writes the given bytes into a copy of thisSequence
.default Sequence
toOverwrite
(int aOffset, byte[] aBytes) Writes the given bytes into a copy of thisSequence
.toOverwrite
(int aOffset, byte[] aBytes, int aBytesOffset, int aLength) Writes the given bytes into a copy of thisSequence
.default Sequence
toOverwrite
(int aOffset, Sequence aSequence) Writes the given bytes into a copy of thisSequence
.toOverwrite
(int aOffset, Sequence aSequence, int aBytesOffset, int aLength) default Sequence
toOverwrite
(Sequence aSequence) Writes the given bytes into a copy of thisSequence
.default Sequence
toOverwrite
(Sequence aSequence, int aLength) Writes the given bytes into a copy of thisSequence
.default Sequence
toPrepend
(byte... aBytes) Prepends the given bytes to the beginning of thisSequence
.toPrepend
(byte[] aBytes, int aOffset, int aLength) Prepends the given bytes to the beginning of thisSequence
.toSequence
(int aOffset, int aLength) default Sequence
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
.toTruncateHead
(int aLength) Returns a newSequence
truncated by the given number of bytes from the left.toTruncateTail
(int aLength) Returns a newSequence
truncated by the given number of bytes from the right.default void
truncate
(int aLength, org.refcodes.mixin.TruncateMode aTruncateMode) Truncates theSequence
by the given number of bytes from the right or from the left of both, according to the givenTruncateMode
.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.default Sequence
withAppend
(byte... aBytes) Builder method for theappend(byte...)
method.default Sequence
withAppend
(byte[] aBytes, int aOffset, int aLength) Builder method for theappend(byte...)
method.default Sequence
withAppend
(Sequence aSequence) Builder method for theappend(Sequence)
method.default Sequence
withConcatenate
(org.refcodes.mixin.ConcatenateMode aConcatenateMode, byte... aBytes) Builder method for theconcatenate(ConcatenateMode, byte...)
method.default Sequence
withConcatenate
(Sequence aSequence, org.refcodes.mixin.ConcatenateMode aConcatenateMode) Builder method for theconcatenate(Sequence, ConcatenateMode)
method.default Sequence
withOverwrite
(byte[] aBytes) Builder method for theoverwrite(byte[])
method.default Sequence
withOverwrite
(byte[] aBytes, int aLength) Builder method for theoverwrite(Sequence, int)
method.default Sequence
withOverwrite
(int aOffset, byte[] aBytes) Builder method for theoverwrite(int, byte[])
method.default Sequence
withOverwrite
(int aOffset, byte[] aBytes, int aBytesOffset, int aLength) Builder method for theoverwrite(int, byte[], int, int)
method.default Sequence
withOverwrite
(int aOffset, Sequence aSequence) Builder method for theoverwrite(int, Sequence)
method.default Sequence
withOverwrite
(int aOffset, Sequence aSequence, int aSequenceOffset, int aLength) Builder method for theoverwrite(int, Sequence, int, int)
method.default Sequence
withOverwrite
(Sequence aSequence) Builder method for theoverwrite(Sequence)
method.default Sequence
withOverwrite
(Sequence aSequence, int aLength) Builder method for theoverwrite(Sequence, int)
method.default Sequence
withPrepend
(byte... aBytes) Builder method for theprepend(byte...)
method.default Sequence
withPrepend
(byte[] aBytes, int aOffset, int aLength) Builder method for theprepend(byte...)
method.default Sequence
withPrepend
(Sequence aSequence) Builder method for theprepend(Sequence)
method.default Sequence
withReplace
(byte[] aBytes) Builder method for thereplace(byte[])
method.default Sequence
withReplace
(byte[] aBytes, int aLength) Builder method for thereplace(byte[], int, int)
method.default Sequence
withReplace
(byte[] aBytes, int aOffset, int aLength) Builder method for thereplace(byte[], int, int)
method.default Sequence
withReplace
(Sequence aSequence) Builder method for thereplace(Sequence)
method.default Sequence
withReplace
(Sequence aSequence, int aLength) Builder method for thereplace(Sequence, int, int)
method.default Sequence
withReplace
(Sequence aSequence, int aOffset, int aLength) Builder method for thereplace(Sequence, int, int)
method.default Sequence
withTruncate
(int aLength, org.refcodes.mixin.TruncateMode aTruncateMode) Builder method for thetruncate(int, TruncateMode)
method.default Sequence
withTruncateHead
(int aLength) Builder method for thetruncateHead(int)
method.default Sequence
withTruncateTail
(int aLength) Builder method for thetruncateTail(int)
method.void
writeTo
(OutputStream aOutputStream) Writes the content of the Sequence to the providedOutputStream
.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
Methods inherited from interface org.refcodes.mixin.LengthAccessor
getLength
-
Method Details
-
append
default void append(byte... aBytes) Appends the given bytes to the end of thisSequence
. Beware: ThisSequence
is modified! If you do not wish to modify thisSequence
, please usetoAppend(byte...)
.- Parameters:
aBytes
- The bytes to be appended.
-
append
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 usetoAppend(byte[], int, int)
.- 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.
-
append
Appends the givenSequence
to the end of thisSequence
. Beware: ThisSequence
is modified! If you do not wish to modify thisSequence
, please usetoAppend(Sequence)
.- Parameters:
aSequence
- TheSequence
to be appended.
-
clear
default void clear()Sets all bytes in theSequence
to zero.- Specified by:
clear
in interfaceorg.refcodes.mixin.Clearable
-
clear
default void clear(byte aValue) Sets all bytes in theSequence
to the provided value.- Parameters:
aValue
- The value with which to zero out thisSequence
.
-
concatenate
default void concatenate(org.refcodes.mixin.ConcatenateMode aConcatenateMode, byte... aBytes) Concatenates the given bytes with thisSequence
according to the providedConcatenateMode
. Beware: ThisSequence
is modified! If you do not wish to modify thisSequence
, please usetoConcatenate(ConcatenateMode, byte...)
.- Parameters:
aConcatenateMode
- The concatenation mode to be used.aBytes
- The bytes to be concatenated with.
-
concatenate
default void concatenate(org.refcodes.mixin.ConcatenateMode aConcatenateMode, byte[] aBytes, int aOffset, int aLength) Concatenates the given bytes with thisSequence
according to the providedConcatenateMode
. Beware: ThisSequence
is modified! If you do not wish to modify thisSequence
, please usetoConcatenate(ConcatenateMode, byte[], int, int)
.- Parameters:
aConcatenateMode
- The concatenation mode to be used.aBytes
- The bytes to be concatenated with.aOffset
- The offset from where to start collecting the bytes.aLength
- The number of bytes to be concatenated.
-
concatenate
Concatenates the givenSequence
with thisSequence
according to the providedConcatenateMode
. Beware: ThisSequence
is modified! If you do not wish to modify thisSequence
, please usetoConcatenate(Sequence, ConcatenateMode)
.- Parameters:
aSequence
- TheSequence
to be concatenated with.aConcatenateMode
- The concatenation mode to be used.
-
empty
void empty()Empties theSequence
to end up being of length 0. -
getByteAt
Returns the byte at the given index in theSequence
.- 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.
-
getInputStream
Creates anInputStream
backed by thisSequence
.- Specified by:
getInputStream
in interfaceorg.refcodes.mixin.InputStreamAccessor
-
getOutputStream
Creates anOutputStream
backed by thisSequence
.- Specified by:
getOutputStream
in interfaceorg.refcodes.mixin.OutputStreamAccessor
-
overwrite
default void overwrite(byte[] aBytes) Writes the given bytes into thisSequence
. If theSequence
is too small for the bytes to fit into, then theSequence
is extended accordingly.- Parameters:
aBytes
- The byte array where to copy the bytes from.
-
overwrite
default void overwrite(byte[] aBytes, int aLength) Writes the given bytes into thisSequence
. If theSequence
is too small for the bytes to fit into, then theSequence
is extended accordingly.- Parameters:
aBytes
- The byte array where to copy the bytes from.aLength
- The number of bytes to be copied starting at offset 0.
-
overwrite
default void overwrite(int aOffset, byte[] aBytes) Writes the given bytes into thisSequence
. If theSequence
is too small for the bytes to fit into, then theSequence
is extended accordingly.- Parameters:
aOffset
- The offset where to start writing the bytes to.aBytes
- The byte array where to copy the bytes from.
-
overwrite
default void overwrite(int aOffset, byte[] aBytes, int aBytesOffset, int aLength) Writes the given bytes into thisSequence
. If theSequence
is too small for the bytes to fit into, then theSequence
is extended accordingly.- 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.
-
overwrite
-
overwrite
Writes the given bytes into thisSequence
. If theSequence
is too small for the bytes to fit into, then theSequence
is extended accordingly.- Parameters:
aOffset
- The offset where to start writing the bytes to.aSequence
- The givenSequence
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.
-
overwrite
Writes the givenSequence
into thisSequence
. If theSequence
is too small for the givenSequence
's bytes to fit into, then thisSequence
is extended accordingly.- Parameters:
aSequence
- The givenSequence
where to copy the bytes from.
-
overwrite
Writes the given bytes into thisSequence
. If theSequence
is too small for the bytes to fit into, then theSequence
is extended accordingly.- Parameters:
aSequence
- TheSequence
where to copy the bytes from.aLength
- The number of bytes to be copied starting at offset 0.
-
prepend
default void prepend(byte... aBytes) Prepends the given bytes the beginning of thisSequence
. Beware: ThisSequence
is modified! If you do not wish to modify thisSequence
, please usetoPrepend(byte...)
.- Parameters:
aBytes
- The bytes to be prepended.
-
prepend
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 usetoPrepend(byte[], int, int)
.- 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.
-
prepend
Prepends the givenSequence
to the beginning of thisSequence
. Beware: ThisSequence
is modified! If you do not wish to modify thisSequence
, please usetoPrepend(Sequence)
.- Parameters:
aSequence
- TheSequence
to be prepended.
-
replace
default void replace(byte[] aBytes) Replaces the given bytes with this byte array.- Parameters:
aBytes
- The byte array where to copy the bytes from.
-
replace
default void replace(byte[] aBytes, int aLength) Replaces the given bytes with this byte array.- Parameters:
aBytes
- The byte array where to copy the bytes from.aLength
- The number of bytes to be copied starting with offset 0.
-
replace
void replace(byte[] aBytes, int aOffset, int aLength) Replaces the given bytes with this byte array.- 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.
-
replace
- Parameters:
aSequence
- The givenSequence
where to copy the bytes from.
-
replace
Replaces the given bytes with thisSequence
.- Parameters:
aSequence
- The givenSequence
where to copy the bytes from.aLength
- The number of bytes to be copied starting with offset 0.
-
replace
Replaces the given bytes with thisSequence
.- Parameters:
aSequence
- The givenSequence
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.
-
setByteAt
void setByteAt(int aIndex, byte aByte) Sets the byte at the given index in theSequence
.- 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
Appends the given bytes to the end of thisSequence
. ThisSequence
is not modified and a newSequence
is returned.- Parameters:
aBytes
- The bytes to be appended.- Returns:
- The according
Sequence
.
-
toAppend
Appends the given bytes to the end of thisSequence
. ThisSequence
is not modified and a newSequence
is returned.- 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:
- The according
Sequence
.
-
toAppend
-
toBytes
default byte[] toBytes()Retrieves a continuous array of bytes from theSequence
.- Returns:
- The according byte array.
-
toBytes
default byte[] toBytes(int aOffset, int aLength) Retrieves a continuous array of bytes from theSequence
, starting with the byte at the given offset and containing the given number of bytes.- Parameters:
aOffset
- The offset from where to start collecting the bytes.aLength
- The length of the byte array to be returned.- Returns:
- The according bytes.
- Throws:
IndexOutOfBoundsException
- thrown in case the length overshot the available bytes.
-
toBytes
default void toBytes(int aOffset, int aLength, byte[] aBytes, int aBytesOffset) Retrieves a continuous array of bytes from theSequence
, starting with the byte at the given offset and containing the given number of bytes. The bytes are stored in the provided bytes starting at the given bytes' offset.- Parameters:
aOffset
- The offset from where to start collecting the bytes.aLength
- The number of bytes to be copied.aBytes
- The byte array where to copy the bytes to.aBytesOffset
- The offset in the byte array where to start copying.
-
toClone
Sequence toClone()Creates a deep clone of thisSequence
.- Returns:
- The deep clone.
-
toConcatenate
Concatenates the given bytes with thisSequence
according to the providedConcatenateMode
. ThisSequence
is not modified and a newSequence
is returned.- Parameters:
aConcatenateMode
- The concatenation mode to be used.aBytes
- The bytes to be concatenated with.- Returns:
- The according
Sequence
.
-
toConcatenate
default Sequence toConcatenate(org.refcodes.mixin.ConcatenateMode aConcatenateMode, byte[] aBytes, int aOffset, int aLength) Concatenates the given bytes with thisSequence
according to the providedConcatenateMode
. ThisSequence
is not modified and a newSequence
is returned.- Parameters:
aConcatenateMode
- The concatenation mode to be used.aBytes
- The bytes to be concatenated.aOffset
- The offset from where to start collecting the bytes.aLength
- The number of bytes to be concatenated with.- Returns:
- The according
Sequence
.
-
toConcatenate
default Sequence toConcatenate(Sequence aSequence, org.refcodes.mixin.ConcatenateMode aConcatenateMode) -
toCrcBytes
byte[] toCrcBytes(org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.numerical.Endianess aEndianess) Calculates the CRC checksum as byte array for thisSequence
.- 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
byte[] toCrcBytes(long aCrcChecksum, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.numerical.Endianess aEndianess) Calculates the CRC checksum as byte array for thisSequence
.- 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
long toCrcChecksum(org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm) Calculates the CRC checksum for thisSequence
.- Parameters:
aCrcAlgorithm
- TheCrcAlgorithm
to be used when calculating the CRC checksum.- Returns:
- The CRC checksum of the
Sequence
.
-
toCrcChecksum
long toCrcChecksum(long aCrcChecksum, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm) Calculates the CRC checksum for thisSequence
.- 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
.
-
toHexString
- Returns:
- The according
String
.
-
toHexString
- Parameters:
aSeparator
- The separator to separate two hex bytes from each other or null if no separator is to be used.- Returns:
- The according
String
.
-
toInputStream
Creates anInputStream
form thisSequence
without being backed by thisSequence
, e.g. reading from the returnedInputStream
does not affect thisSequence
(in contrast to theInputStream
returned by the methodgetInputStream()
).- Returns:
- The according
InputStream
not affecting thisSequence
.
-
toOverwrite
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.- Parameters:
aBytes
- The byte array where to copy the bytes from.- Returns:
- The according
Sequence
.
-
toOverwrite
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.- Parameters:
aBytes
- The byte array where to copy the bytes from.aLength
- The number of bytes to be copied starting with offset 0.- Returns:
- The according
Sequence
.
-
toOverwrite
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.- Parameters:
aOffset
- The offset where to start writing the bytes to.aBytes
- The byte array where to copy the bytes from.- Returns:
- The according
Sequence
.
-
toOverwrite
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.- 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
-
toOverwrite
-
toOverwrite
-
toOverwrite
-
toPrepend
Prepends the given bytes to the beginning of thisSequence
. ThisSequence
is not modified and a newSequence
is returned.- Parameters:
aBytes
- The bytes to be prepended.- Returns:
- The according
Sequence
.
-
toPrepend
Prepends the given bytes to the beginning of thisSequence
. ThisSequence
is not modified and a newSequence
is returned.- 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:
- The according
Sequence
.
-
toPrepend
-
toSequence
Retrieves a newSequence
from thisSequence
, starting with the byte at the given offset and containing the given number of bytes.- 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
. - Throws:
IndexOutOfBoundsException
- thrown in case the length overshot the available bytes.
-
toTruncate
-
toTruncateHead
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.- Parameters:
aLength
- The number of bytes to truncate from the left.- Returns:
- The newly created truncated
Sequence
.
-
toTruncateTail
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.- Parameters:
aLength
- The number of bytes to truncate from the right.- Returns:
- The newly created truncated
Sequence
.
-
truncate
default void truncate(int aLength, org.refcodes.mixin.TruncateMode aTruncateMode) Truncates theSequence
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 theSequence
will end up being empty.- Parameters:
aLength
- The number of bytes to truncate according to theTruncateMode
.aTruncateMode
- TheTruncateMode
to use for truncating theSequence
.
-
truncateHead
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.- Parameters:
aLength
- The number of bytes to truncate from the left.
-
truncateTail
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.- Parameters:
aLength
- The number of bytes to truncate from the right.
-
withAppend
Builder method for theappend(byte...)
method.- Parameters:
aBytes
- The bytes to be appended.- Returns:
- This instance as of the builder pattern.
-
withAppend
Builder method for theappend(byte...)
method.- 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
Builder method for theappend(Sequence)
method.- Parameters:
aSequence
- TheSequence
to be appended.- Returns:
- This instance as of the builder pattern.
-
withConcatenate
default Sequence withConcatenate(org.refcodes.mixin.ConcatenateMode aConcatenateMode, byte... aBytes) Builder method for theconcatenate(ConcatenateMode, byte...)
method.- Parameters:
aConcatenateMode
- The concatenation mode to be used.aBytes
- The bytes to be concatenated with.- Returns:
- This instance as of the builder pattern.
-
withConcatenate
default Sequence withConcatenate(Sequence aSequence, org.refcodes.mixin.ConcatenateMode aConcatenateMode) Builder method for theconcatenate(Sequence, ConcatenateMode)
method.- Parameters:
aSequence
- TheSequence
to be concatenated withaConcatenateMode
- The concatenation mode to be used.- Returns:
- This instance as of the builder pattern.
-
withOverwrite
Builder method for theoverwrite(byte[])
method.- Parameters:
aBytes
- The byte array where to copy the bytes from.- Returns:
- This instance as of the builder pattern.
-
withOverwrite
Builder method for theoverwrite(Sequence, int)
method.- Parameters:
aBytes
- The bytes where to copy the bytes from.aLength
- The number of bytes to be copied starting at offset 0.- Returns:
- This instance as of the builder pattern.
-
withOverwrite
Builder method for theoverwrite(int, byte[])
method.- 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
Builder method for theoverwrite(int, byte[], int, int)
method.- 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
Builder method for theoverwrite(int, Sequence)
method.- 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
Builder method for theoverwrite(int, Sequence, int, int)
method.- 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
Builder method for theoverwrite(Sequence)
method.- Parameters:
aSequence
- TheSequence
where to copy the bytes from.- Returns:
- This instance as of the builder pattern.
-
withOverwrite
Builder method for theoverwrite(Sequence, int)
method.- Parameters:
aSequence
- TheSequence
where to copy the bytes from.aLength
- The number of bytes to be copied starting at offset 0.- Returns:
- This instance as of the builder pattern.
-
withPrepend
Builder method for theprepend(byte...)
method.- Parameters:
aBytes
- The bytes to be prepended.- Returns:
- This instance as of the builder pattern.
-
withPrepend
Builder method for theprepend(byte...)
method.- 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
Builder method for theprepend(Sequence)
method.- Parameters:
aSequence
- TheSequence
to be prepended.- Returns:
- This instance as of the builder pattern.
-
withReplace
Builder method for thereplace(byte[])
method.- Parameters:
aBytes
- The byte array where to copy the bytes from.- Returns:
- This instance as of the builder pattern.
-
withReplace
Builder method for thereplace(byte[], int, int)
method.- Parameters:
aBytes
- The byte array where to copy the bytes from.aLength
- The number of bytes to be copied starting at offset 0.- Returns:
- This instance as of the builder pattern.
-
withReplace
Builder method for thereplace(Sequence, int, int)
method.- Parameters:
aSequence
- The byteSequence
where to copy the bytes from.aLength
- The number of bytes to be copied starting at offset 0.- Returns:
- This instance as of the builder pattern.
-
withReplace
Builder method for thereplace(byte[], int, int)
method.- 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
Builder method for thereplace(Sequence)
method.- Parameters:
aSequence
- TheSequence
where to copy the bytes from.- Returns:
- This instance as of the builder pattern.
-
withReplace
Builder method for thereplace(Sequence, int, int)
method.- 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
Builder method for thetruncate(int, TruncateMode)
method.- 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
Builder method for thetruncateHead(int)
method.- Parameters:
aLength
- The number of bytes to truncate.- Returns:
- This instance as of the builder pattern.
-
withTruncateTail
Builder method for thetruncateTail(int)
method.- Parameters:
aLength
- The number of bytes to truncate.- Returns:
- This instance as of the builder pattern.
-
writeTo
Writes the content of the Sequence to the providedOutputStream
.- Parameters:
aOutputStream
- TheOutputStream
where to write to.- Throws:
IOException
- thrown in case of I/O problems.
-