Interface ModelFileFinder
-
- All Known Implementing Classes:
ModelFileFinderImpl
public interface ModelFileFinder
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
ModelFileFinder.RepositoryFilePriority
This enum defines what shall take priority if dealing with repository files.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.String
getArchivePath(ModelFile modelFile)
puts together the resource path for the filejava.io.File
getFile(ModelFile modelFile, JMadKernel kernel)
returns an accessible file that is searched according to the givenModelFile
, but (in case coming from an archive) extracted in a way that it is unique for the given kerne.java.util.Optional<java.io.File>
getLocalSourceFile(ModelFile modelFile)
Returns an optional file that is the source of the given model file.ModelFileFinder.RepositoryFilePriority
getRepositoryFilePriority()
java.lang.String
getRepositoryPath(ModelFile modelFile)
puts together the path within the repositoryjava.io.InputStream
getStream(ModelFile modelFile)
returns the content of the model file as input stream.void
setRepositoryFilePriority(ModelFileFinder.RepositoryFilePriority priority)
set the priority mode for searching repository files.
-
-
-
Method Detail
-
getFile
java.io.File getFile(ModelFile modelFile, JMadKernel kernel)
returns an accessible file that is searched according to the givenModelFile
, 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.- Parameters:
modelFile
- the instance ofModelFile
which describes where to find the filekernel
- the jmad kernel relative to whose temp path files should be placed.- Returns:
- the file
-
getStream
java.io.InputStream getStream(ModelFile modelFile)
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.- Parameters:
modelFile
- the model file for which to get the stream- Returns:
- the input stream
-
getLocalSourceFile
java.util.Optional<java.io.File> getLocalSourceFile(ModelFile modelFile)
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.- 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
java.lang.String getRepositoryPath(ModelFile modelFile)
puts together the path within the repository- Parameters:
modelFile
- the model file for which to put together the path- Returns:
- the absolute path to the file
-
getArchivePath
java.lang.String getArchivePath(ModelFile modelFile)
puts together the resource path for the file- Parameters:
modelFile
- theModelFile
for which to put together the resource path- Returns:
- the relative path used in jars below
ModelDefinitionUtil.PACKAGE_OFFSET
and in zip archives.
-
setRepositoryFilePriority
void setRepositoryFilePriority(ModelFileFinder.RepositoryFilePriority priority)
set the priority mode for searching repository files.- Parameters:
priority
- the new priority
-
getRepositoryFilePriority
ModelFileFinder.RepositoryFilePriority getRepositoryFilePriority()
- Returns:
- the actual priority mode for searching repository files.
-
-