Class FILEInterface

java.lang.Object
net.simplace.sim.io.interfaces.FWSimInterface<FilePool>
net.simplace.sim.io.interfaces.FILEInterface
Direct Known Subclasses:
CSVInterface, NetCDFInterface, XMLInterface

public abstract class FILEInterface extends FWSimInterface<FilePool>
Base class of the file based interfaces. The access object is a FilePool, which manages the files (the file name may contain tokens and therefore differ between simulations). Instead of a file name the data can be given directly as content.
Author:
Andreas Enders
  • Field Details

    • iFilename

      protected String iFilename
      the file name (child filename), may contain ${...} tokens
    • iContent

      protected String iContent
      the data as string instead of a file (child content)
    • iFileinfo

      protected FilePool iFileinfo
      the file pool, created on the first call of getInterface(FWSimVarMap, CONTENT_TYPE)
  • Constructor Details

    • FILEInterface

      protected FILEInterface(String aName, FWSimInterface.INTERFACE_TYPE aType, org.jdom2.Element aInterfaceElement)
      Creates the interface from its element (children filename and content).
      Parameters:
      aName - name of the interface
      aType - type of the interface
      aInterfaceElement - the interface element
    • FILEInterface

      public FILEInterface(String aName, int aPoolSize, FWSimInterface.INTERFACE_TYPE aType, String aFileName, String aContent)
      Creates the interface without element.
      Parameters:
      aName - name of the interface
      aPoolSize - number of pooled files
      aType - type of the interface
      aFileName - the file name, may contain tokens
      aContent - the data as string instead of a file, may be null
  • Method Details

    • getInterface

      public FilePool getInterface(FWSimVarMap aVarMap, FWSimVariable.CONTENT_TYPE aContentType)
      Returns the file pool; it is created on the first call if a file name or content is given.
      Specified by:
      getInterface in class FWSimInterface<FilePool>
      Parameters:
      aVarMap - variable map used for replacing tokens (e.g. in file names), may be null
      aContentType - res for reading, out for writing
      Returns:
      the file pool, or null without file name and content
      See Also:
    • getRegisteredOutputFiles

      public List<String> getRegisteredOutputFiles()
      Returns:
      the output files registered in the file pool of this interface (absolute paths; empty if the interface was not used for writing), see FilePool.getRegisteredFiles()
    • getFilename

      public String getFilename()
      Returns:
      the file name (with tokens)
    • setFilename

      public void setFilename(String aFilename)
      Parameters:
      aFilename - the file name; an already created file pool is closed and created again on the next use
    • resetFilePool

      protected void resetFilePool()
      Closes and discards the file pool, so it is created again with the current settings on the next use (e.g. after the settings were changed in the GUI).
    • toXML

      public org.jdom2.Element toXML()
      Adds the filename and content elements (if set) to the element of the base class.
      Overrides:
      toXML in class FWSimInterface<FilePool>
      Returns:
      the interface element
    • finalize

      public void finalize() throws Exception
      Closes the files of the file pool.
      Specified by:
      finalize in class FWSimInterface<FilePool>
      Throws:
      Exception - if releasing fails
      See Also: