- All Implemented Interfaces:
Serializable
,org.refcodes.mixin.AliasAccessor
,org.refcodes.mixin.LengthAccessor
,org.refcodes.mixin.PayloadAccessor<String>
,org.refcodes.mixin.PayloadAccessor.PayloadBuilder<String,
,PayloadTransmission<String>> org.refcodes.mixin.PayloadAccessor.PayloadMutator<String>
,org.refcodes.mixin.PayloadAccessor.PayloadProperty<String>
,org.refcodes.mixin.Schemable
,EndOfStringByteAccessor
,PayloadSegment<String>
,PayloadTransmission<String>
,Segment
,Segment.SegmentMixin
,Transmission
,Transmission.TransmissionMixin
public class AsciizSegment
extends AbstractPayloadSegment<String>
implements EndOfStringByteAccessor
The
AsciizSegment
is an implementation of a Segment
carrying
an ASCII encoded String
as payload, terminated by a 0 ("zero")
indicating its end. A 0 terminated is called ACIIZ or CString. Termination
with 0 is done by the AsciizSegment
and must not be handled by the
programmer, though it is up to the developer to make sure no 0 value is
contained within the provided String
.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.refcodes.mixin.AliasAccessor
org.refcodes.mixin.AliasAccessor.AliasBuilder<B extends org.refcodes.mixin.AliasAccessor.AliasBuilder<B>>, org.refcodes.mixin.AliasAccessor.AliasMutator, org.refcodes.mixin.AliasAccessor.AliasProperty
Nested classes/interfaces inherited from interface org.refcodes.serial.EndOfStringByteAccessor
EndOfStringByteAccessor.EndOfStringByteBuilder<B extends EndOfStringByteAccessor.EndOfStringByteBuilder<B>>, EndOfStringByteAccessor.EndOfStringByteMutator, EndOfStringByteAccessor.EndOfStringByteProperty
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.PayloadAccessor
org.refcodes.mixin.PayloadAccessor.PayloadBuilder<P extends Object,
B extends org.refcodes.mixin.PayloadAccessor.PayloadBuilder<P, B>>, org.refcodes.mixin.PayloadAccessor.PayloadMutator<P extends Object>, org.refcodes.mixin.PayloadAccessor.PayloadProperty<P extends Object> Nested classes/interfaces inherited from interface org.refcodes.serial.Segment
Segment.SegmentMixin
Nested classes/interfaces inherited from interface org.refcodes.serial.Transmission
Transmission.TransmissionMixin
-
Field Summary
Fields inherited from class org.refcodes.serial.AbstractPayloadSegment
_alias, _payload
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs an emptyAsciizSegment
.AsciizSegment
(byte aEndOfStringByte) Constructs an emptyAsciizSegment
.AsciizSegment
(byte[] aValue) Constructs anAsciizSegment
with the given (ASCII encoded) bytes payload.AsciizSegment
(byte[] aValue, byte aEndOfStringByte) Constructs anAsciizSegment
with the given (ASCII encoded) bytes payload.AsciizSegment
(String aValue) Constructs anAsciizSegment
with the givenString
payload.AsciizSegment
(String aValue, byte aEndOfStringByte) Constructs anAsciizSegment
with the givenString
payload.AsciizSegment
(String aAlias, byte[] aValue) Constructs anAsciizSegment
with the given (ASCII encoded) bytes payload.AsciizSegment
(String aAlias, byte[] aValue, byte aEndOfStringByte) Constructs anAsciizSegment
with the given (ASCII encoded) bytes payload.AsciizSegment
(String aAlias, String aValue) Constructs anAsciizSegment
with the givenString
payload.AsciizSegment
(String aAlias, String aValue, byte aEndOfStringByte) Constructs anAsciizSegment
with the givenString
payload.AsciizSegment
(String aAlias, TransmissionMetrics aTransmissionMetrics, byte[] aValue) Constructs anAsciizSegment
with the given (ASCII encoded) bytes payload.AsciizSegment
(String aAlias, TransmissionMetrics aTransmissionMetrics, String aValue) Constructs anAsciizSegment
with the givenString
payload.AsciizSegment
(TransmissionMetrics aTransmissionMetrics) Constructs an emptyAsciizSegment
.AsciizSegment
(TransmissionMetrics aTransmissionMetrics, byte[] aValue) Constructs anAsciizSegment
with the given (ASCII encoded) bytes payload.AsciizSegment
(TransmissionMetrics aTransmissionMetrics, String aValue) Constructs anAsciizSegment
with the givenString
payload. -
Method Summary
Modifier and TypeMethodDescriptionint
fromTransmission
(Sequence aSequence, int aOffset) (Re-)initializes this instance with the the givenSequence
data.byte
Retrieves the end of string byte from the end of string byte property.int
Determines the overall length of thisTransmission
.void
receiveFrom
(InputStream aInputStream, OutputStream aReturnStream) (Re-)initializes this instance by receiving the accordingSequence
from the givenInputStream
.void
setPayload
(byte[] aValue) Sets the given (ASCII encoded) bytes payload.toSchema()
Provides theSequence
representation of thisTransmission
.withPayload
(byte[] aValue) Sets the given (ASCII encoded) bytes payload.withPayload
(String aValue) Methods inherited from class org.refcodes.serial.AbstractPayloadSegment
equals, getAlias, getPayload, hashCode, setPayload, toSimpleTypeMap, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.refcodes.mixin.PayloadAccessor
getPayloadOr
Methods inherited from interface org.refcodes.mixin.PayloadAccessor.PayloadProperty
letPayload
Methods inherited from interface org.refcodes.serial.Segment
fromTransmission, fromTransmission, fromTransmission, receiveFrom, receiveFrom
Methods inherited from interface org.refcodes.serial.Transmission
transmitTo, transmitTo
Methods inherited from interface org.refcodes.serial.Transmission.TransmissionMixin
transmitTo
-
Constructor Details
-
AsciizSegment
public AsciizSegment()Constructs an emptyAsciizSegment
. The serialized content (as oftoSequence()
orTransmission.transmitTo(java.io.OutputStream)
) of anAsciizSegment
represents an an ASCIIZString
(also known as CString). -
AsciizSegment
Constructs an emptyAsciizSegment
. The serialized content (as oftoSequence()
orTransmission.transmitTo(java.io.OutputStream)
) of anAsciizSegment
represents an an ASCIIZString
(also known as CString).- Parameters:
aTransmissionMetrics
- TheTransmissionMetrics
to be used for configuring this instance.
-
AsciizSegment
Constructs anAsciizSegment
with the givenString
payload. The serialized content (as oftoSequence()
orTransmission.transmitTo(java.io.OutputStream)
) of anAsciizSegment
represents an an ASCIIZString
(also known as CString). It is in the responsibility of the programmer to make sure that theString
does not contain any 0 ("zero") values as a value of 0 unintendedly terminates the resultingString
.- Parameters:
aTransmissionMetrics
- TheTransmissionMetrics
to be used for configuring this instance.aValue
- The payload to be contained by thisAsciizSegment
.
-
AsciizSegment
Constructs anAsciizSegment
with the given (ASCII encoded) bytes payload. The serialized content (as oftoSequence()
orTransmission.transmitTo(java.io.OutputStream)
) of anAsciizSegment
represents an an ASCIIZString
(also known as CString). It is in the responsibility of the programmer to make sure that the bytes do not contain any 0 ("zero") values as a value of 0 unintendedly terminates the resultingString
.- Parameters:
aTransmissionMetrics
- TheTransmissionMetrics
to be used for configuring this instance.aValue
- The payload to be contained by thisAsciizSegment
.
-
AsciizSegment
Constructs anAsciizSegment
with the given (ASCII encoded) bytes payload. The serialized content (as oftoSequence()
orTransmission.transmitTo(java.io.OutputStream)
) of anAsciizSegment
represents an an ASCIIZString
(also known as CString). It is in the responsibility of the programmer to make sure that the bytes do not contain any 0 ("zero") values as a value of 0 unintendedly terminates the resultingString
.- Parameters:
aAlias
- The alias which identifies the content of this segment.aTransmissionMetrics
- TheTransmissionMetrics
to be used for configuring this instance.aValue
- The payload to be contained by thisAsciizSegment
.
-
AsciizSegment
Constructs anAsciizSegment
with the givenString
payload. The serialized content (as oftoSequence()
orTransmission.transmitTo(java.io.OutputStream)
) of anAsciizSegment
represents an an ASCIIZString
(also known as CString). It is in the responsibility of the programmer to make sure that theString
does not contain any 0 ("zero") values as a value of 0 unintendedly terminates the resultingString
.- Parameters:
aAlias
- The alias which identifies the content of this segment.aTransmissionMetrics
- TheTransmissionMetrics
to be used for configuring this instance.aValue
- The payload to be contained by thisAsciizSegment
.
-
AsciizSegment
Constructs anAsciizSegment
with the givenString
payload. The serialized content (as oftoSequence()
orTransmission.transmitTo(java.io.OutputStream)
) of anAsciizSegment
represents an an ASCIIZString
(also known as CString). It is in the responsibility of the programmer to make sure that theString
does not contain any 0 ("zero") values as a value of 0 unintendedly terminates the resultingString
.- Parameters:
aValue
- The payload to be contained by thisAsciizSegment
.
-
AsciizSegment
public AsciizSegment(byte[] aValue) Constructs anAsciizSegment
with the given (ASCII encoded) bytes payload. The serialized content (as oftoSequence()
orTransmission.transmitTo(java.io.OutputStream)
) of anAsciizSegment
represents an an ASCIIZString
(also known as CString). It is in the responsibility of the programmer to make sure that the bytes do not contain any 0 ("zero") values as a value of 0 unintendedly terminates the resultingString
.- Parameters:
aValue
- The payload to be contained by thisAsciizSegment
.
-
AsciizSegment
Constructs anAsciizSegment
with the given (ASCII encoded) bytes payload. The serialized content (as oftoSequence()
orTransmission.transmitTo(java.io.OutputStream)
) of anAsciizSegment
represents an an ASCIIZString
(also known as CString). It is in the responsibility of the programmer to make sure that the bytes do not contain any 0 ("zero") values as a value of 0 unintendedly terminates the resultingString
.- Parameters:
aAlias
- The alias which identifies the content of this segment.aValue
- The payload to be contained by thisAsciizSegment
.
-
AsciizSegment
Constructs anAsciizSegment
with the givenString
payload. The serialized content (as oftoSequence()
orTransmission.transmitTo(java.io.OutputStream)
) of anAsciizSegment
represents an an ASCIIZString
(also known as CString). It is in the responsibility of the programmer to make sure that theString
does not contain any 0 ("zero") values as a value of 0 unintendedly terminates the resultingString
.- Parameters:
aAlias
- The alias which identifies the content of this segment.aValue
- The payload to be contained by thisAsciizSegment
.
-
AsciizSegment
public AsciizSegment(byte aEndOfStringByte) Constructs an emptyAsciizSegment
. The serialized content (as oftoSequence()
orTransmission.transmitTo(java.io.OutputStream)
) of anAsciizSegment
represents an an ASCIIZString
(also known as CString).- Parameters:
aEndOfStringByte
- The alternate value instead of 0 "zero" identifying the end of the string.
-
AsciizSegment
Constructs anAsciizSegment
with the givenString
payload. The serialized content (as oftoSequence()
orTransmission.transmitTo(java.io.OutputStream)
) of anAsciizSegment
represents an an ASCIIZString
(also known as CString). It is in the responsibility of the programmer to make sure that theString
does not contain any 0 ("zero") values as a value of 0 unintendedly terminates the resultingString
.- Parameters:
aValue
- The payload to be contained by thisAsciizSegment
.aEndOfStringByte
- The alternate value instead of 0 "zero" identifying the end of the string.
-
AsciizSegment
public AsciizSegment(byte[] aValue, byte aEndOfStringByte) Constructs anAsciizSegment
with the given (ASCII encoded) bytes payload. The serialized content (as oftoSequence()
orTransmission.transmitTo(java.io.OutputStream)
) of anAsciizSegment
represents an an ASCIIZString
(also known as CString). It is in the responsibility of the programmer to make sure that the bytes do not contain any 0 ("zero") values as a value of 0 unintendedly terminates the resultingString
.- Parameters:
aValue
- The payload to be contained by thisAsciizSegment
.aEndOfStringByte
- The alternate value instead of 0 "zero" identifying the end of the string.
-
AsciizSegment
Constructs anAsciizSegment
with the given (ASCII encoded) bytes payload. The serialized content (as oftoSequence()
orTransmission.transmitTo(java.io.OutputStream)
) of anAsciizSegment
represents an an ASCIIZString
(also known as CString). It is in the responsibility of the programmer to make sure that the bytes do not contain any 0 ("zero") values as a value of 0 unintendedly terminates the resultingString
.- Parameters:
aAlias
- The alias which identifies the content of this segment.aValue
- The payload to be contained by thisAsciizSegment
.aEndOfStringByte
- The alternate value instead of 0 "zero" identifying the end of the string.
-
AsciizSegment
Constructs anAsciizSegment
with the givenString
payload. The serialized content (as oftoSequence()
orTransmission.transmitTo(java.io.OutputStream)
) of anAsciizSegment
represents an an ASCIIZString
(also known as CString). It is in the responsibility of the programmer to make sure that theString
does not contain any 0 ("zero") values as a value of 0 unintendedly terminates the resultingString
.- Parameters:
aAlias
- The alias which identifies the content of this segment.aValue
- The payload to be contained by thisAsciizSegment
.aEndOfStringByte
- The alternate value instead of 0 "zero" identifying the end of the string.
-
-
Method Details
-
toSequence
Provides theSequence
representation of thisTransmission
. In case of nestedTransmission
instances, allSequence
representations from all sub-segments are accumulated to the result as well. Caution, the Transmission (or its nestedTransmission
instances) may be backed by the returnedSequence
.- Specified by:
toSequence
in interfaceTransmission
- Returns:
- The according instance's
Sequence
.
-
fromTransmission
(Re-)initializes this instance with the the givenSequence
data.- Specified by:
fromTransmission
in interfaceSegment
- Parameters:
aSequence
- TheSequence
data from which to (re-)initialize this instance.aOffset
- The offset where to start processing the providedSequence
.- Returns:
- The index after the last offset into the given
Sequence
processed by this method. - Throws:
TransmissionException
- thrown in case a givenSequence
cannot be processed.
-
receiveFrom
(Re-)initializes this instance by receiving the accordingSequence
from the givenInputStream
. Implementations providing error correction methods use the provided feedbackOutputStream
to do some sort of "stop-and-wait ARQ" or apply similar methods to ensure correctness of the received data.- Specified by:
receiveFrom
in interfaceSegment
- Specified by:
receiveFrom
in interfaceSegment.SegmentMixin
- Parameters:
aInputStream
- TheInputStream
from which to read the instance's (re-)initializationSequence
from.aReturnStream
- AnOutputStream
being the return channel to handle "stop-and-wait ARQ" or the like in case of a bidirectional connection. Can be null in case we have a unidirectional connection.- Throws:
IOException
- thrown in case reading data from theInputStream
caused problems.TransmissionException
- thrown in case a given transmission cannot be processed.
-
getLength
public int getLength()Determines the overall length of thisTransmission
. In case of nestedTransmission
instances, all length values from all sub-segments are accumulated to the result as well.- Specified by:
getLength
in interfaceorg.refcodes.mixin.LengthAccessor
- Specified by:
getLength
in interfaceTransmission
- Returns:
- The (overall) length of the
Transmission
(including any sub-segments).
-
toSchema
- Specified by:
toSchema
in interfaceorg.refcodes.mixin.Schemable
- Specified by:
toSchema
in interfaceTransmission
-
withPayload
- Specified by:
withPayload
in interfaceorg.refcodes.mixin.PayloadAccessor.PayloadBuilder<String,
PayloadTransmission<String>>
-
setPayload
public void setPayload(byte[] aValue) Sets the given (ASCII encoded) bytes payload.- Parameters:
aValue
- The payload to set.
-
withPayload
Sets the given (ASCII encoded) bytes payload.- Parameters:
aValue
- The payload to set.- Returns:
- THis instance as of the builder pattern.
-
getEndOfStringByte
public byte getEndOfStringByte()Retrieves the end of string byte from the end of string byte property.- Specified by:
getEndOfStringByte
in interfaceEndOfStringByteAccessor
- Returns:
- The end of string byte stored by the end of string byte property.
-