- 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.Resetable,org.refcodes.schema.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.AliasPropertyNested 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.Section
Section.SectionMixinNested classes/interfaces inherited from interface org.refcodes.serial.Transmission
Transmission.TransmissionMixin -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from class org.refcodes.serial.AbstractPayloadSection
_alias, _payload -
Constructor Summary
ConstructorsConstructorDescriptionFileSection(File aFile) Constructs aFileSection.FileSection(File aBasePath, Supplier<String> aFilePathSupplier) Constructs aFileSection, the underlyingFileis 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 underlyingFileis 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 underlyingFileis created on demand dynamically using the providedSupplier.FileSection(String aBasePath, Supplier<String> aFilePathSupplier) Constructs aFileSection, the underlyingFileis created on demand dynamically using the providedSupplier.FileSection(Supplier<String> aFilePathSupplier) Constructs aFileSection, the underlyingFileis created on demand dynamically using the providedSupplier. -
Method Summary
Modifier and TypeMethodDescriptionvoidfromTransmission(Sequence aSequence, int aOffset, int aLength) (Re-)initializes this instance with the the givenSequencedata.intDetermines the overall length of thisTransmission.voidreceiveFrom(InputStream aInputStream, int aLength, OutputStream aReturnStream) (Re-)initializes this instance by receiving the accordingSequencefrom the givenInputStream.toSchema()Provides theSequencerepresentation of thisTransmission.voidtransmitTo(OutputStream aOutputStream, InputStream aReturnStream) Transmits theSequencerepresenting the implementing type's instance to the givenOutputStream.withPayload(File aPayload) Methods inherited from class org.refcodes.serial.AbstractPayloadSection
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.Section
fromTransmission, fromTransmission, fromTransmission, receiveFrom, receiveFromMethods inherited from interface org.refcodes.serial.Transmission
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- TheFilerepresenting theFileSection.
-
FileSection
Constructs aFileSection.- Parameters:
aFile- TheFilerepresenting theFileSection.
-
FileSection
Constructs aFileSection.- Parameters:
aAlias- TheFileSection'S alias.aFilePath- The file path ofFilerepresenting theFileSection.
-
FileSection
Constructs aFileSection.- Parameters:
aFilePath- The file path ofFilerepresenting theFileSection.
-
FileSection
Constructs aFileSection, the underlyingFileis created on demand dynamically using the providedSupplier.- Parameters:
aFilePathSupplier- TheSupplierof the file path ofFilerepresenting theFileSection. Whenever the underlying file is to be accessed, then theSupplieris called to construct the accordingFile.
-
FileSection
Constructs aFileSection, the underlyingFileis created on demand dynamically using the providedSupplier.- Parameters:
aAlias- TheFileSection'S alias.aBasePath- The base path for the path provided by theSupplier.aFilePathSupplier- TheSupplierof the file path ofFilerepresenting theFileSection. Whenever the underlying file is to be accessed, then theSupplieris called to construct the accordingFile.
-
FileSection
Constructs aFileSection, the underlyingFileis created on demand dynamically using the providedSupplier. -
FileSection
Constructs aFileSection, the underlyingFileis created on demand dynamically using the providedSupplier.- Parameters:
aAlias- TheFileSection'S alias.aBasePath- TheFilerepresenting the base path for the path provided by theSupplier.aFilePathSupplier- TheSupplierof the file path ofFilerepresenting theFileSection. Whenever the underlying file is to be accessed, then theSupplieris called to construct the accordingFile.
-
FileSection
Constructs aFileSection, the underlyingFileis created on demand dynamically using the providedSupplier.
-
-
Method Details
-
toSchema
-
fromTransmission
public void fromTransmission(Sequence aSequence, int aOffset, int aLength) throws TransmissionException (Re-)initializes this instance with the the givenSequencedata.- Parameters:
aSequence- TheSequencedata 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 givenSequencecannot be processed.
-
receiveFrom
public void receiveFrom(InputStream aInputStream, int aLength, OutputStream aReturnStream) throws IOException (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.- Parameters:
aInputStream- TheInputStreamfrom which to read the instance's (re-)initializationSequencefrom.aLength- The length of data assigned by the byte array.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 givenInputStreambytes 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.- Returns:
- The (overall) length of the
Transmission(including any sub-segments).
-
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. ATTENTION: Use this method with care as all of theFile's content is loaded into theSequence(and therewith into memory) as a byte array!- Returns:
- The according instance's
Sequence.
-
transmitTo
Transmits theSequencerepresenting the implementing type's instance to the givenOutputStream. Implementations providing error correction methods use the provided feedbackInputStreamto do some sort of "stop-and-wait ARQ" or apply similar methods to ensure correctness of the transmitted data.- Parameters:
aOutputStream- TheOutputStreamwhere to write this instance'sSequenceto.aReturnStream- AnInputStreambeing 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 theOutputStreamcaused problems.
-
withPayload
-
toPayloadFile
Determines whether we have a "dynamic"Fileas of aSupplierbeing or a "static"File(or a file path).- Returns:
- The according
File.
-