- All Implemented Interfaces:
Serializable
,org.refcodes.mixin.AliasAccessor
,org.refcodes.mixin.LengthAccessor
,org.refcodes.mixin.PayloadAccessor<File>
,org.refcodes.mixin.PayloadAccessor.PayloadBuilder<File,
,PayloadTransmission<File>> org.refcodes.mixin.PayloadAccessor.PayloadMutator<File>
,org.refcodes.mixin.PayloadAccessor.PayloadProperty<File>
,org.refcodes.mixin.Schemable
,PayloadSection<File>
,PayloadTransmission<File>
,Section
,Section.SectionMixin
,Transmission
,Transmission.TransmissionMixin
A
FileSection
represents a File
on the file system and can be
used to receive or to transmit a File
. Using a Supplier
, one
can use for example a StringSection
's value (as of
AbstractPayloadSection.getPayload()
) to determine the underlying File
name dynamically. Whenever the underlying File
is to be accessed,
then the Supplier
is called (if provided) to construct the according
File dynamically. This way, a file name provided by a StringSection
can be used for the FileSection
within the same transmission.- 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.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.Section
Section.SectionMixin
Nested classes/interfaces inherited from interface org.refcodes.serial.Transmission
Transmission.TransmissionMixin
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
Fields inherited from class org.refcodes.serial.AbstractPayloadSection
_alias, _payload
-
Constructor Summary
ConstructorDescriptionFileSection
(File aFile) Constructs aFileSection
.FileSection
(File aBasePath, Supplier<String> aFilePathSupplier) Constructs aFileSection
, the underlyingFile
is created on demand dynamically using the providedSupplier
.FileSection
(String aFilePath) Constructs aFileSection
.FileSection
(String aAlias, File aFile) Constructs aFileSection
.FileSection
(String aAlias, File aBasePath, Supplier<String> aFilePathSupplier) Constructs aFileSection
, the underlyingFile
is created on demand dynamically using the providedSupplier
.FileSection
(String aAlias, String aFilePath) Constructs aFileSection
.FileSection
(String aAlias, String aBasePath, Supplier<String> aFilePathSupplier) Constructs aFileSection
, the underlyingFile
is created on demand dynamically using the providedSupplier
.FileSection
(String aBasePath, Supplier<String> aFilePathSupplier) Constructs aFileSection
, the underlyingFile
is created on demand dynamically using the providedSupplier
.FileSection
(Supplier<String> aFilePathSupplier) Constructs aFileSection
, the underlyingFile
is created on demand dynamically using the providedSupplier
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
fromTransmission
(Sequence aSequence, int aOffset, int aLength) (Re-)initializes this instance with the the givenSequence
data.int
Determines the overall length of thisTransmission
.void
receiveFrom
(InputStream aInputStream, int aLength, OutputStream aReturnStream) (Re-)initializes this instance by receiving the accordingSequence
from the givenInputStream
.toSchema()
Retrieves theSerialSchema
representing theTransmission
.Provides theSequence
representation of thisTransmission
.void
transmitTo
(OutputStream aOutputStream, InputStream aReturnStream) Transmits theSequence
representing the implementing type's instance to the givenOutputStream
.withPayload
(File aPayload) Methods inherited from class org.refcodes.serial.AbstractPayloadSection
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.AliasAccessor
getAlias
Methods inherited from interface org.refcodes.mixin.PayloadAccessor
getPayload, getPayloadOr
Methods inherited from interface org.refcodes.mixin.PayloadAccessor.PayloadMutator
setPayload
Methods inherited from interface org.refcodes.mixin.PayloadAccessor.PayloadProperty
letPayload
Methods inherited from interface org.refcodes.serial.Section
fromTransmission, fromTransmission, fromTransmission, receiveFrom, receiveFrom
Methods inherited from interface org.refcodes.serial.Transmission
toSimpleTypeMap, transmitTo, transmitTo
-
Field Details
-
FILE_PATH
- See Also:
-
FILE_SIZE
- See Also:
-
FILE_EXISTS
- See Also:
-
FILE
- See Also:
-
-
Constructor Details
-
FileSection
Constructs aFileSection
.- Parameters:
aAlias
- TheFileSection
'S alias.aFile
- TheFile
representing theFileSection
.
-
FileSection
Constructs aFileSection
.- Parameters:
aFile
- TheFile
representing theFileSection
.
-
FileSection
Constructs aFileSection
.- Parameters:
aAlias
- TheFileSection
'S alias.aFilePath
- The file path ofFile
representing theFileSection
.
-
FileSection
Constructs aFileSection
.- Parameters:
aFilePath
- The file path ofFile
representing theFileSection
.
-
FileSection
Constructs aFileSection
, the underlyingFile
is created on demand dynamically using the providedSupplier
.- Parameters:
aFilePathSupplier
- TheSupplier
of the file path ofFile
representing theFileSection
. Whenever the underlying file is to be accessed, then theSupplier
is called to construct the accordingFile
.
-
FileSection
Constructs aFileSection
, the underlyingFile
is created on demand dynamically using the providedSupplier
.- Parameters:
aAlias
- TheFileSection
'S alias.aBasePath
- The base path for the path provided by theSupplier
.aFilePathSupplier
- TheSupplier
of the file path ofFile
representing theFileSection
. Whenever the underlying file is to be accessed, then theSupplier
is called to construct the accordingFile
.
-
FileSection
Constructs aFileSection
, the underlyingFile
is created on demand dynamically using the providedSupplier
. -
FileSection
Constructs aFileSection
, the underlyingFile
is created on demand dynamically using the providedSupplier
.- Parameters:
aAlias
- TheFileSection
'S alias.aBasePath
- TheFile
representing the base path for the path provided by theSupplier
.aFilePathSupplier
- TheSupplier
of the file path ofFile
representing theFileSection
. Whenever the underlying file is to be accessed, then theSupplier
is called to construct the accordingFile
.
-
FileSection
Constructs aFileSection
, the underlyingFile
is created on demand dynamically using the providedSupplier
.
-
-
Method Details
-
toSchema
Retrieves theSerialSchema
representing theTransmission
. Retrieving aSerialSchema
is useful when analyzing and debugging data structures such as aAllocSectionDecoratorSegment
instance to help document, learn and verify on the structure (as well as the content) of that veryAllocSectionDecoratorSegment
.- Specified by:
toSchema
in interfaceorg.refcodes.mixin.Schemable
- Specified by:
toSchema
in interfaceTransmission
- Returns:
- The
SerialSchema
representation of the implementing type for debugging and verification (or documentation) purposes.
-
fromTransmission
public void fromTransmission(Sequence aSequence, int aOffset, int aLength) throws TransmissionException (Re-)initializes this instance with the the givenSequence
data.- Specified by:
fromTransmission
in interfaceSection
- Parameters:
aSequence
- TheSequence
data from which to (re-)initialize this instance.aOffset
- The offset where to start processing the providedSequence
.aLength
- The length of data assigned by theSequence
.- Throws:
TransmissionException
- thrown in case a givenSequence
cannot be processed.
-
receiveFrom
public void receiveFrom(InputStream aInputStream, int aLength, OutputStream aReturnStream) throws IOException, TransmissionException (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 interfaceSection
- Specified by:
receiveFrom
in interfaceSection.SectionMixin
- Parameters:
aInputStream
- TheInputStream
from which to read the instance's (re-)initializationSequence
from.aLength
- The length of data assigned by the byte array.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 givenInputStream
bytes 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).
-
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
. ATTENTION: Use this method with care as all of theFile
's content is loaded into theSequence
(and therewith into memory) as a byte array!- Specified by:
toSequence
in interfaceTransmission
- Returns:
- The according instance's
Sequence
.
-
transmitTo
Transmits theSequence
representing the implementing type's instance to the givenOutputStream
. Implementations providing error correction methods use the provided feedbackInputStream
to do some sort of "stop-and-wait ARQ" or apply similar methods to ensure correctness of the transmitted data.- Specified by:
transmitTo
in interfaceTransmission
- Specified by:
transmitTo
in interfaceTransmission.TransmissionMixin
- Parameters:
aOutputStream
- TheOutputStream
where to write this instance'sSequence
to.aReturnStream
- AnInputStream
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 writing data to theOutputStream
caused problems.
-
withPayload
- Specified by:
withPayload
in interfaceorg.refcodes.mixin.PayloadAccessor.PayloadBuilder<File,
PayloadTransmission<File>>
-
toPayloadFile
Determines whether we have a "dynamic"File
as of aSupplier
being or a "static"File
(or a file path).- Returns:
- The according
File
.
-