- 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.Resetable,org.refcodes.schema.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.AliasPropertyNested classes/interfaces inherited from interface org.refcodes.serial.EndOfStringByteAccessor
EndOfStringByteAccessor.EndOfStringByteBuilder<B extends EndOfStringByteAccessor.EndOfStringByteBuilder<B>>, EndOfStringByteAccessor.EndOfStringByteMutator, EndOfStringByteAccessor.EndOfStringBytePropertyNested 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.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.SegmentMixinNested 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 anAsciizSegmentwith the given (ASCII encoded) bytes payload.AsciizSegment(byte[] aValue, byte aEndOfStringByte) Constructs anAsciizSegmentwith the given (ASCII encoded) bytes payload.AsciizSegment(String aValue) Constructs anAsciizSegmentwith the givenStringpayload.AsciizSegment(String aValue, byte aEndOfStringByte) Constructs anAsciizSegmentwith the givenStringpayload.AsciizSegment(String aAlias, byte[] aValue) Constructs anAsciizSegmentwith the given (ASCII encoded) bytes payload.AsciizSegment(String aAlias, byte[] aValue, byte aEndOfStringByte) Constructs anAsciizSegmentwith the given (ASCII encoded) bytes payload.AsciizSegment(String aAlias, String aValue) Constructs anAsciizSegmentwith the givenStringpayload.AsciizSegment(String aAlias, String aValue, byte aEndOfStringByte) Constructs anAsciizSegmentwith the givenStringpayload.AsciizSegment(String aAlias, TransmissionMetrics aTransmissionMetrics, byte[] aValue) Constructs anAsciizSegmentwith the given (ASCII encoded) bytes payload.AsciizSegment(String aAlias, TransmissionMetrics aTransmissionMetrics, String aValue) Constructs anAsciizSegmentwith the givenStringpayload.AsciizSegment(TransmissionMetrics aTransmissionMetrics) Constructs an emptyAsciizSegment.AsciizSegment(TransmissionMetrics aTransmissionMetrics, byte[] aValue) Constructs anAsciizSegmentwith the given (ASCII encoded) bytes payload.AsciizSegment(TransmissionMetrics aTransmissionMetrics, String aValue) Constructs anAsciizSegmentwith the givenStringpayload. -
Method Summary
Modifier and TypeMethodDescriptionintfromTransmission(Sequence aSequence, int aOffset) (Re-)initializes this instance with the the givenSequencedata.byteRetrieves the end of string byte from the end of string byte property.intDetermines the overall length of thisTransmission.voidreceiveFrom(InputStream aInputStream, OutputStream aReturnStream) (Re-)initializes this instance by receiving the accordingSequencefrom the givenInputStream.voidsetPayload(byte[] aValue) Sets the given (ASCII encoded) bytes payload.toSchema()Provides theSequencerepresentation 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, reset, setPayload, toSimpleTypeMap, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.refcodes.mixin.PayloadAccessor
getPayloadOrMethods inherited from interface org.refcodes.mixin.PayloadAccessor.PayloadProperty
letPayloadMethods inherited from interface org.refcodes.serial.Segment
fromTransmission, fromTransmission, fromTransmission, receiveFrom, receiveFromMethods inherited from interface org.refcodes.serial.Transmission
transmitTo, transmitToMethods 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 anAsciizSegmentrepresents an an ASCIIZString(also known as CString). -
AsciizSegment
Constructs an emptyAsciizSegment. The serialized content (as oftoSequence()orTransmission.transmitTo(java.io.OutputStream)) of anAsciizSegmentrepresents an an ASCIIZString(also known as CString).- Parameters:
aTransmissionMetrics- TheTransmissionMetricsto be used for configuring this instance.
-
AsciizSegment
Constructs anAsciizSegmentwith the givenStringpayload. The serialized content (as oftoSequence()orTransmission.transmitTo(java.io.OutputStream)) of anAsciizSegmentrepresents an an ASCIIZString(also known as CString). It is in the responsibility of the programmer to make sure that theStringdoes not contain any 0 ("zero") values as a value of 0 unintendedly terminates the resultingString.- Parameters:
aTransmissionMetrics- TheTransmissionMetricsto be used for configuring this instance.aValue- The payload to be contained by thisAsciizSegment.
-
AsciizSegment
Constructs anAsciizSegmentwith the given (ASCII encoded) bytes payload. The serialized content (as oftoSequence()orTransmission.transmitTo(java.io.OutputStream)) of anAsciizSegmentrepresents 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- TheTransmissionMetricsto be used for configuring this instance.aValue- The payload to be contained by thisAsciizSegment.
-
AsciizSegment
Constructs anAsciizSegmentwith the given (ASCII encoded) bytes payload. The serialized content (as oftoSequence()orTransmission.transmitTo(java.io.OutputStream)) of anAsciizSegmentrepresents 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- TheTransmissionMetricsto be used for configuring this instance.aValue- The payload to be contained by thisAsciizSegment.
-
AsciizSegment
Constructs anAsciizSegmentwith the givenStringpayload. The serialized content (as oftoSequence()orTransmission.transmitTo(java.io.OutputStream)) of anAsciizSegmentrepresents an an ASCIIZString(also known as CString). It is in the responsibility of the programmer to make sure that theStringdoes 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- TheTransmissionMetricsto be used for configuring this instance.aValue- The payload to be contained by thisAsciizSegment.
-
AsciizSegment
Constructs anAsciizSegmentwith the givenStringpayload. The serialized content (as oftoSequence()orTransmission.transmitTo(java.io.OutputStream)) of anAsciizSegmentrepresents an an ASCIIZString(also known as CString). It is in the responsibility of the programmer to make sure that theStringdoes 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 anAsciizSegmentwith the given (ASCII encoded) bytes payload. The serialized content (as oftoSequence()orTransmission.transmitTo(java.io.OutputStream)) of anAsciizSegmentrepresents 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 anAsciizSegmentwith the given (ASCII encoded) bytes payload. The serialized content (as oftoSequence()orTransmission.transmitTo(java.io.OutputStream)) of anAsciizSegmentrepresents 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 anAsciizSegmentwith the givenStringpayload. The serialized content (as oftoSequence()orTransmission.transmitTo(java.io.OutputStream)) of anAsciizSegmentrepresents an an ASCIIZString(also known as CString). It is in the responsibility of the programmer to make sure that theStringdoes 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 anAsciizSegmentrepresents an an ASCIIZString(also known as CString).- Parameters:
aEndOfStringByte- The alternate value instead of 0 "zero" identifying the end of the string.
-
AsciizSegment
Constructs anAsciizSegmentwith the givenStringpayload. The serialized content (as oftoSequence()orTransmission.transmitTo(java.io.OutputStream)) of anAsciizSegmentrepresents an an ASCIIZString(also known as CString). It is in the responsibility of the programmer to make sure that theStringdoes 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 anAsciizSegmentwith the given (ASCII encoded) bytes payload. The serialized content (as oftoSequence()orTransmission.transmitTo(java.io.OutputStream)) of anAsciizSegmentrepresents 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 anAsciizSegmentwith the given (ASCII encoded) bytes payload. The serialized content (as oftoSequence()orTransmission.transmitTo(java.io.OutputStream)) of anAsciizSegmentrepresents 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 anAsciizSegmentwith the givenStringpayload. The serialized content (as oftoSequence()orTransmission.transmitTo(java.io.OutputStream)) of anAsciizSegmentrepresents an an ASCIIZString(also known as CString). It is in the responsibility of the programmer to make sure that theStringdoes 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 theSequencerepresentation of thisTransmission. In case of nestedTransmissioninstances, allSequencerepresentations from all sub-segments are accumulated to the result as well. Caution, the Transmission (or its nestedTransmissioninstances) may be backed by the returnedSequence.- Specified by:
toSequencein interfaceTransmission- Returns:
- The according instance's
Sequence.
-
fromTransmission
(Re-)initializes this instance with the the givenSequencedata.- Specified by:
fromTransmissionin interfaceSegment- Parameters:
aSequence- TheSequencedata 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
Sequenceprocessed by this method. - Throws:
TransmissionException- thrown in case a givenSequencecannot be processed.
-
receiveFrom
(Re-)initializes this instance by receiving the accordingSequencefrom the givenInputStream. Implementations providing error correction methods use the provided feedbackOutputStreamto do some sort of "stop-and-wait ARQ" or apply similar methods to ensure correctness of the received data.- Specified by:
receiveFromin interfaceSegment- Specified by:
receiveFromin interfaceSegment.SegmentMixin- Parameters:
aInputStream- TheInputStreamfrom which to read the instance's (re-)initializationSequencefrom.aReturnStream- AnOutputStreambeing 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 theInputStreamcaused problems.TransmissionException- thrown in case a given transmission cannot be processed.
-
getLength
public int getLength()Determines the overall length of thisTransmission. In case of nestedTransmissioninstances, all length values from all sub-segments are accumulated to the result as well.- Specified by:
getLengthin interfaceorg.refcodes.mixin.LengthAccessor- Specified by:
getLengthin interfaceTransmission- Returns:
- The (overall) length of the
Transmission(including any sub-segments).
-
toSchema
- Specified by:
toSchemain interfaceorg.refcodes.schema.Schemable- Specified by:
toSchemain interfaceTransmission
-
withPayload
- Specified by:
withPayloadin 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:
getEndOfStringBytein interfaceEndOfStringByteAccessor- Returns:
- The end of string byte stored by the end of string byte property.
-