Class ModelFileFinderImpl

  • All Implemented Interfaces:
    ModelFileFinder

    public class ModelFileFinderImpl
    extends java.lang.Object
    implements ModelFileFinder
    This is the implementation of a class that finds model-files.
    • Constructor Detail

      • ModelFileFinderImpl

        public ModelFileFinderImpl()
    • Method Detail

      • setModelFilePathOffsets

        public void setModelFilePathOffsets​(ModelPathOffsets modelPathOffsets)
        the setter for the necessary offsets.
        Parameters:
        modelPathOffsets - the offsets to use.
      • getFile

        public java.io.File getFile​(ModelFile modelFile,
                                    JMadKernel kernel)
        Description copied from interface: ModelFileFinder
        returns an accessible file that is searched according to the given ModelFile, but (in case coming from an archive) extracted in a way that it is unique for the given kerne. This avoids potential name conflicts between files coming from different model packages used in kernels that are concurrently running.
        Specified by:
        getFile in interface ModelFileFinder
        Parameters:
        modelFile - the instance of ModelFile which describes where to find the file
        kernel - the jmad kernel relative to whose temp path files should be placed.
        Returns:
        the file
      • getFile

        public java.io.File getFile​(ModelFile modelFile,
                                    java.util.function.Function<java.lang.String,​java.io.File> tmpFileFunction)
      • getStream

        public java.io.InputStream getStream​(ModelFile modelFile)
        Description copied from interface: ModelFileFinder
        returns the content of the model file as input stream. This is useful e.g. for copying the file or for packing it into a zip archive.
        Specified by:
        getStream in interface ModelFileFinder
        Parameters:
        modelFile - the model file for which to get the stream
        Returns:
        the input stream
      • getLocalSourceFile

        public java.util.Optional<java.io.File> getLocalSourceFile​(ModelFile modelFile)
        Description copied from interface: ModelFileFinder
        Returns an optional file that is the source of the given model file. This will return an empty optional in case the source of this model file is not a plain file, but is supposed to be extracted from an archive. In other words, the model definition for which this file finder is responsible is not coming from a file.
        Specified by:
        getLocalSourceFile in interface ModelFileFinder
        Parameters:
        modelFile - the model file for which to retrieve the source file
        Returns:
        an optional of the source file for the given model file, or Optional.empty() if the source of the model definition does not come from a file
      • getRepositoryPath

        public java.lang.String getRepositoryPath​(ModelFile modelFile)
        Description copied from interface: ModelFileFinder
        puts together the path within the repository
        Specified by:
        getRepositoryPath in interface ModelFileFinder
        Parameters:
        modelFile - the model file for which to put together the path
        Returns:
        the absolute path to the file
      • setPreferences

        public void setPreferences​(JMadPreferences preferences)
      • setFileUtil

        public void setFileUtil​(TempFileUtil fileUtil)
      • setSourceInformation

        public void setSourceInformation​(SourceInformation sourceInformation)