Class FilePool
java.lang.Object
net.simplace.sim.io.FilePool
Pool of the files of a file interface. The file name may contain
${...} tokens, so each simulation or
project may use another file; registerFile(FWSimVarMap) returns the FileData for the current
values. For reading, up to pool size files are kept open (and their data cached); for writing, only the
current file is open. Files already opened by another session are shared via the FilePoolManager. Instead
of a file name the data can be given as content.
The pool has to be finalized at the end to close the files.
- Author:
- Andreas Enders
-
Constructor Summary
ConstructorsConstructorDescriptionFilePool(String aFileName, String aContent, FWSimSession aCurrentSession, String aDivider, int aPoolSize, FWSimVariable.CONTENT_TYPE aContent_Type) Creates the pool. -
Method Summary
Modifier and TypeMethodDescriptionvoidfinalize()Closes all open files (for output files an info message is logged).booleanregisterFile(FWSimVarMap aVarMap) Returns the file for the current token values.toString()Returns the file name (with tokens).
-
Constructor Details
-
FilePool
public FilePool(String aFileName, String aContent, FWSimSession aCurrentSession, String aDivider, int aPoolSize, FWSimVariable.CONTENT_TYPE aContent_Type) Creates the pool.- Parameters:
aFileName- file name, may contain tokens;nullif the content is givenaContent- data as string instead of a file, may benullaCurrentSession- the sessionaDivider- column divider for CSV files, may benullaPoolSize- maximum number of open files for readingaContent_Type-resfor reading,outfor writing
-
-
Method Details
-
registerFile
Returns the file for the current token values. An already open file is reused; otherwise, for reading, the oldest file is dropped when the pool is full, and for writing the current file is closed. The data of an equal file registered by another session is shared. For content, a new file object with the tokens replaced is created.- Parameters:
aVarMap- variable map for replacing the tokens, may benull(tokens are not replaced, the pool's session is used)- Returns:
- the file, or
nullif neither file name nor content is given
-
getContentType
- Returns:
resfor reading,outfor writing
-
finalize
-
toString
-
getRegisteredFiles
-
isInitialized
public boolean isInitialized()- Returns:
trueif at least one file has been registered
-