- All Superinterfaces:
org.refcodes.mixin.Bytes,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, org.refcodes.mixin.Bytes
A
Sequence represents a bytes container providing means to apply
complex operations on that container's 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.InputStreamPropertyNested 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.LengthPropertyNested 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 voidappend(byte... aBytes) Appends the given bytes to the end of thisSequence.voidappend(byte[] aBytes, int aOffset, int aLength) Appends the given bytes to the end of thisSequence.voiddefault voidclear()Sets all bytes in theSequenceto zero.default voidclear(byte aValue) Sets all bytes in theSequenceto the provided value.default voidconcatenate(org.refcodes.mixin.ConcatenateMode aConcatenateMode, byte... aBytes) Concatenates the given bytes with thisSequenceaccording to the providedConcatenateMode.default voidconcatenate(org.refcodes.mixin.ConcatenateMode aConcatenateMode, byte[] aBytes, int aOffset, int aLength) Concatenates the given bytes with thisSequenceaccording to the providedConcatenateMode.default voidconcatenate(Sequence aSequence, org.refcodes.mixin.ConcatenateMode aConcatenateMode) voidempty()Empties theSequenceto end up being of length 0.bytegetByteAt(int aIndex) Returns the byte at the given index in theSequence.default InputStreamCreates anInputStreambacked by thisSequence.default OutputStreamCreates anOutputStreambacked by thisSequence.default voidoverwrite(byte[] aBytes) Writes the given bytes into thisSequence.default voidoverwrite(byte[] aBytes, int aLength) Writes the given bytes into thisSequence.default voidoverwrite(int aOffset, byte[] aBytes) Writes the given bytes into thisSequence.default voidoverwrite(int aOffset, byte[] aBytes, int aBytesOffset, int aLength) Writes the given bytes into thisSequence.default voiddefault voidWrites the given bytes into thisSequence.default voiddefault voidWrites the given bytes into thisSequence.default voidprepend(byte... aBytes) Prepends the given bytes the beginning of thisSequence.voidprepend(byte[] aBytes, int aOffset, int aLength) Prepends the given bytes to the beginning of thisSequence.voiddefault voidreplace(byte[] aBytes) Replaces the given bytes with this byte array.default voidreplace(byte[] aBytes, int aLength) Replaces the given bytes with this byte array.voidreplace(byte[] aBytes, int aOffset, int aLength) Replaces the given bytes with this byte array.default voiddefault voidReplaces the given bytes with thisSequence.voidReplaces the given bytes with thisSequence.voidsetByteAt(int aIndex, byte aByte) Sets the byte at the given index in theSequence.default SequencetoAppend(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 voidtoBytes(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 covering the given number of bytes.toClone()Creates a deep clone of thisSequence.default SequencetoConcatenate(org.refcodes.mixin.ConcatenateMode aConcatenateMode, byte... aBytes) Concatenates the given bytes with thisSequenceaccording to the providedConcatenateMode.default SequencetoConcatenate(org.refcodes.mixin.ConcatenateMode aConcatenateMode, byte[] aBytes, int aOffset, int aLength) Concatenates the given bytes with thisSequenceaccording to the providedConcatenateMode.default SequencetoConcatenate(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.longtoCrcChecksum(long aCrcChecksum, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm) Calculates the CRC checksum for thisSequence.longtoCrcChecksum(org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm) Calculates the CRC checksum for thisSequence.default Stringdefault StringtoHexString(String aSeparator) default InputStreamCreates anInputStreamform thisSequencewithout being backed by thisSequence, e.g. reading from the returnedInputStreamdoes not affect thisSequence(in contrast to theInputStreamreturned by the methodgetInputStream()).default SequencetoOverwrite(byte[] aBytes) Writes the given bytes into a copy of thisSequence.default SequencetoOverwrite(byte[] aBytes, int aLength) Writes the given bytes into a copy of thisSequence.default SequencetoOverwrite(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 SequencetoOverwrite(int aOffset, Sequence aSequence) Writes the given bytes into a copy of thisSequence.toOverwrite(int aOffset, Sequence aSequence, int aBytesOffset, int aLength) default SequencetoOverwrite(Sequence aSequence) Writes the given bytes into a copy of thisSequence.default SequencetoOverwrite(Sequence aSequence, int aLength) Writes the given bytes into a copy of thisSequence.default SequencetoPrepend(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 SequencetoTruncate(int aLength, org.refcodes.mixin.TruncateMode aTruncateMode) Returns a newSequencetruncated by the given number of bytes from the right or from the left of both, according to the givenTruncateMode.toTruncateHead(int aLength) Returns a newSequencetruncated by the given number of bytes from the left.toTruncateTail(int aLength) Returns a newSequencetruncated by the given number of bytes from the right.default voidtruncate(int aLength, org.refcodes.mixin.TruncateMode aTruncateMode) Truncates theSequenceby the given number of bytes from the right or from the left of both, according to the givenTruncateMode.voidtruncateHead(int aLength) Truncates theSequenceby the given number of bytes from the left.voidtruncateTail(int aLength) Truncates theSequenceby the given number of bytes from the right.default SequencewithAppend(byte... aBytes) Builder method for theappend(byte...)method.default SequencewithAppend(byte[] aBytes, int aOffset, int aLength) Builder method for theappend(byte...)method.default SequencewithAppend(Sequence aSequence) Builder method for theappend(Sequence)method.default SequencewithConcatenate(org.refcodes.mixin.ConcatenateMode aConcatenateMode, byte... aBytes) Builder method for theconcatenate(ConcatenateMode, byte...)method.default SequencewithConcatenate(Sequence aSequence, org.refcodes.mixin.ConcatenateMode aConcatenateMode) Builder method for theconcatenate(Sequence, ConcatenateMode)method.default SequencewithOverwrite(byte[] aBytes) Builder method for theoverwrite(byte[])method.default SequencewithOverwrite(byte[] aBytes, int aLength) Builder method for theoverwrite(Sequence, int)method.default SequencewithOverwrite(int aOffset, byte[] aBytes) Builder method for theoverwrite(int, byte[])method.default SequencewithOverwrite(int aOffset, byte[] aBytes, int aBytesOffset, int aLength) Builder method for theoverwrite(int, byte[], int, int)method.default SequencewithOverwrite(int aOffset, Sequence aSequence) Builder method for theoverwrite(int, Sequence)method.default SequencewithOverwrite(int aOffset, Sequence aSequence, int aSequenceOffset, int aLength) Builder method for theoverwrite(int, Sequence, int, int)method.default SequencewithOverwrite(Sequence aSequence) Builder method for theoverwrite(Sequence)method.default SequencewithOverwrite(Sequence aSequence, int aLength) Builder method for theoverwrite(Sequence, int)method.default SequencewithPrepend(byte... aBytes) Builder method for theprepend(byte...)method.default SequencewithPrepend(byte[] aBytes, int aOffset, int aLength) Builder method for theprepend(byte...)method.default SequencewithPrepend(Sequence aSequence) Builder method for theprepend(Sequence)method.default SequencewithReplace(byte[] aBytes) Builder method for thereplace(byte[])method.default SequencewithReplace(byte[] aBytes, int aLength) Builder method for thereplace(byte[], int, int)method.default SequencewithReplace(byte[] aBytes, int aOffset, int aLength) Builder method for thereplace(byte[], int, int)method.default SequencewithReplace(Sequence aSequence) Builder method for thereplace(Sequence)method.default SequencewithReplace(Sequence aSequence, int aLength) Builder method for thereplace(Sequence, int, int)method.default SequencewithReplace(Sequence aSequence, int aOffset, int aLength) Builder method for thereplace(Sequence, int, int)method.default SequencewithTruncate(int aLength, org.refcodes.mixin.TruncateMode aTruncateMode) Builder method for thetruncate(int, TruncateMode)method.default SequencewithTruncateHead(int aLength) Builder method for thetruncateHead(int)method.default SequencewithTruncateTail(int aLength) Builder method for thetruncateTail(int)method.voidwriteTo(OutputStream aOutputStream) Writes the content of the Sequence to the providedOutputStream.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliteratorMethods 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: ThisSequenceis 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: ThisSequenceis 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 givenSequenceto the end of thisSequence. Beware: ThisSequenceis modified! If you do not wish to modify thisSequence, please usetoAppend(Sequence).- Parameters:
aSequence- TheSequenceto be appended.
-
clear
default void clear()Sets all bytes in theSequenceto zero.- Specified by:
clearin interfaceorg.refcodes.mixin.Clearable
-
clear
default void clear(byte aValue) Sets all bytes in theSequenceto 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 thisSequenceaccording to the providedConcatenateMode. Beware: ThisSequenceis 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 thisSequenceaccording to the providedConcatenateMode. Beware: ThisSequenceis 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 givenSequencewith thisSequenceaccording to the providedConcatenateMode. Beware: ThisSequenceis modified! If you do not wish to modify thisSequence, please usetoConcatenate(Sequence, ConcatenateMode).- Parameters:
aSequence- TheSequenceto be concatenated with.aConcatenateMode- The concatenation mode to be used.
-
empty
void empty()Empties theSequenceto end up being of length 0. -
getByteAt
byte getByteAt(int aIndex) 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 anInputStreambacked by thisSequence.- Specified by:
getInputStreamin interfaceorg.refcodes.mixin.InputStreamAccessor
-
getOutputStream
Creates anOutputStreambacked by thisSequence.- Specified by:
getOutputStreamin interfaceorg.refcodes.mixin.OutputStreamAccessor
-
overwrite
default void overwrite(byte[] aBytes) Writes the given bytes into thisSequence. If theSequenceis too small for the bytes to fit into, then theSequenceis 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 theSequenceis too small for the bytes to fit into, then theSequenceis 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 theSequenceis too small for the bytes to fit into, then theSequenceis 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 theSequenceis too small for the bytes to fit into, then theSequenceis 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 theSequenceis too small for the bytes to fit into, then theSequenceis extended accordingly.- Parameters:
aOffset- The offset where to start writing the bytes to.aSequence- The givenSequencewhere 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 givenSequenceinto thisSequence. If theSequenceis too small for the givenSequence's bytes to fit into, then thisSequenceis extended accordingly.- Parameters:
aSequence- The givenSequencewhere to copy the bytes from.
-
overwrite
Writes the given bytes into thisSequence. If theSequenceis too small for the bytes to fit into, then theSequenceis extended accordingly.- Parameters:
aSequence- TheSequencewhere 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: ThisSequenceis 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: ThisSequenceis 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 givenSequenceto the beginning of thisSequence. Beware: ThisSequenceis modified! If you do not wish to modify thisSequence, please usetoPrepend(Sequence).- Parameters:
aSequence- TheSequenceto 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 givenSequencewhere to copy the bytes from.
-
replace
Replaces the given bytes with thisSequence.- Parameters:
aSequence- The givenSequencewhere 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 givenSequencewhere 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. ThisSequenceis not modified and a newSequenceis returned.- Parameters:
aBytes- The bytes to be appended.- Returns:
- The according
Sequence.
-
toAppend
Appends the given bytes to the end of thisSequence. ThisSequenceis not modified and a newSequenceis 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.- Specified by:
toBytesin interfaceorg.refcodes.mixin.Bytes- 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 covering the given number of bytes. The bytes are stored in the provided bytes array 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 thisSequenceaccording to the providedConcatenateMode. ThisSequenceis not modified and a newSequenceis 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 thisSequenceaccording to the providedConcatenateMode. ThisSequenceis not modified and a newSequenceis 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- TheCrcAlgorithmto 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- TheCrcAlgorithmto 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- TheCrcAlgorithmto 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- TheCrcAlgorithmto 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 anInputStreamform thisSequencewithout being backed by thisSequence, e.g. reading from the returnedInputStreamdoes not affect thisSequence(in contrast to theInputStreamreturned by the methodgetInputStream()).- Returns:
- The according
InputStreamnot affecting thisSequence.
-
toOverwrite
Writes the given bytes into a copy of thisSequence. If theSequenceis too small for the bytes to fit into, then theSequenceis 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 theSequenceis too small for the bytes to fit into, then theSequenceis 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 theSequenceis too small for the bytes to fit into, then theSequenceis 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 theSequenceis too small for the bytes to fit into, then theSequenceis 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. ThisSequenceis not modified and a newSequenceis returned.- Parameters:
aBytes- The bytes to be prepended.- Returns:
- The according
Sequence.
-
toPrepend
Prepends the given bytes to the beginning of thisSequence. ThisSequenceis not modified and a newSequenceis 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 newSequencefrom 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 newSequencetruncated by the given number of bytes from the left. If the number of bytes exceeds the actual length of theSequence, then the newSequencewill end up being empty.- Parameters:
aLength- The number of bytes to truncate from the left.- Returns:
- The newly created truncated
Sequence.
-
toTruncateTail
Returns a newSequencetruncated by the given number of bytes from the right. If the number of bytes exceeds the actual length of theSequence, then the newSequencewill 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 theSequenceby 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 theSequencewill end up being empty.- Parameters:
aLength- The number of bytes to truncate according to theTruncateMode.aTruncateMode- TheTruncateModeto use for truncating theSequence.
-
truncateHead
void truncateHead(int aLength) Truncates theSequenceby the given number of bytes from the left. If the number of bytes exceeds the actual length of theSequence, then theSequencewill end up being empty.- Parameters:
aLength- The number of bytes to truncate from the left.
-
truncateTail
void truncateTail(int aLength) Truncates theSequenceby the given number of bytes from the right. If the number of bytes exceeds the actual length of theSequence, then theSequencewill 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- TheSequenceto 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- TheSequenceto 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- TheSequencewhere 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- TheSequencewhere 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- TheSequencewhere to copy the bytes from.- Returns:
- This instance as of the builder pattern.
-
withOverwrite
Builder method for theoverwrite(Sequence, int)method.- Parameters:
aSequence- TheSequencewhere 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- TheSequenceto 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 byteSequencewhere 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- TheSequencewhere to copy the bytes from.- Returns:
- This instance as of the builder pattern.
-
withReplace
Builder method for thereplace(Sequence, int, int)method.- Parameters:
aSequence- TheSequencewhere 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- TheTruncateModeto 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- TheOutputStreamwhere to write to.- Throws:
IOException- thrown in case of I/O problems.
-