Package org.jgrapes.io
Class FileStorage
java.lang.Object
org.jgrapes.core.internal.ComponentVertex
org.jgrapes.core.Component
org.jgrapes.io.FileStorage
- All Implemented Interfaces:
Iterable<ComponentType>,Channel,ComponentType,Eligible,Manager
A component that reads from or writes to a file.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jgrapes.core.Channel
Channel.Default -
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionFileStorage(Channel channel) Create a new instance using the default buffer size of 8192.FileStorage(Channel channel, int bufferSize) Create a new instance using the given size for the read buffers. -
Method Summary
Modifier and TypeMethodDescriptionvoidHandle close by closing the file associated with the channel.voidonInput(Input<ByteBuffer> event, Channel channel) Handle input by writing it to the file, if a channel exists.voidonOutput(Output<ByteBuffer> event, Channel channel) HandleOutputevents by writing them to the file, if a channel exists.voidonSaveInput(SaveInput event) Opens a file for writing using the properties of the event.voidonSaveOutput(SaveOutput event) Opens a file for writing using the properties of the event.voidHandle stop by closing all files.voidonStreamFile(StreamFile event) Opens a file for reading using the properties of the event and streams its content as a sequence ofOutputevents with the end of record flag set in the last event.toString()If a name has been set for this component (seeManager.setName(String)), return the name, else return the object name provided byComponents.objectName(Object), usingComponentVertex.component()as argument.Methods inherited from class org.jgrapes.core.Component
channel, component, defaultCriterion, isEligibleFor, setNameMethods inherited from class org.jgrapes.core.internal.ComponentVertex
activeEventPipeline, addHandler, attach, channelReplacements, children, componentPath, componentVertex, detach, fire, initComponentsHandlers, iterator, name, newEventPipeline, newEventPipeline, parent, registerAsGenerator, root, unregisterAsGeneratorMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
FileStorage
Create a new instance using the given size for the read buffers. -
FileStorage
Create a new instance using the default buffer size of 8192.
-
-
Method Details
-
onStreamFile
Opens a file for reading using the properties of the event and streams its content as a sequence ofOutputevents with the end of record flag set in the last event.All generated events are considered responses to this event and therefore fired using the event processor from the event’s I/O subchannel.
- Parameters:
event- the event- Throws:
InterruptedException- if the execution was interrupted
-
onSaveInput
Opens a file for writing using the properties of the event.All data from subsequent
Inputevents is written to the file. The end of record flag is ignored.- Parameters:
event- the event- Throws:
InterruptedException- if the execution was interrupted
-
onInput
Handle input by writing it to the file, if a channel exists.- Parameters:
event- the eventchannel- the channel
-
onSaveOutput
Opens a file for writing using the properties of the event.All data from subsequent
Outputevents is written to the file. The end of record flag is ignored.- Parameters:
event- the event- Throws:
InterruptedException- if the execution was interrupted
-
onOutput
HandleOutputevents by writing them to the file, if a channel exists.- Parameters:
event- the eventchannel- the channel
-
onClose
Handle close by closing the file associated with the channel.- Parameters:
event- the eventchannel- the channel- Throws:
InterruptedException- the interrupted exception
-
onStop
Handle stop by closing all files.- Parameters:
event- the event- Throws:
InterruptedException- the interrupted exception
-
toString
Description copied from class:ComponentVertexIf a name has been set for this component (seeManager.setName(String)), return the name, else return the object name provided byComponents.objectName(Object), usingComponentVertex.component()as argument.- Overrides:
toStringin classComponentVertex
-