Class ModelDefinitionUtil
- java.lang.Object
-
- cern.accsoft.steering.jmad.modeldefs.io.impl.ModelDefinitionUtil
-
public final class ModelDefinitionUtil extends java.lang.Object
This class contains some utility methods for model definitions
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.Class<?>
BASE_CLASS
this is the class relative to which the model-definitions and files will be searched.static java.lang.String
JSON_FILE_EXTENSION
the default file extension for json filesstatic java.lang.String
PACKAGE_OFFSET
the package name relative to the base class where to search for model-definitions and filesstatic java.lang.String
XML_FILE_EXTENSION
the default file extension for xml filesstatic java.lang.String
ZIP_FILE_EXTENSION
The extension used for jmad zip files
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.io.File
ensureZipFileExtension(java.io.File file)
adds the correct file extension for jmad zip files if necessarystatic java.lang.String
getDefaultFileExtension()
static java.lang.String
getProposedDefaultFileName(JMadModelDefinition modelDefinition)
static java.lang.String
getProposedIdStringFromName(JMadModelDefinition modelDefinition)
creates an Id for the given model definition from its name.static java.lang.String
getProposedJsonFileName(JMadModelDefinition modelDefinition)
creates a json-filename for the given model definitionstatic java.lang.String
getProposedXmlFileName(JMadModelDefinition modelDefinition)
creates a file name for the given model definitionstatic java.util.Collection<ModelFile>
getRequiredModelFiles(JMadModelDefinition modelDefinition)
collects all the model files which are required by a model definition and its partsstatic boolean
isXmlFileName(java.lang.String fileName)
determines if the given name is a model definition xml filestatic boolean
isZipFileName(java.lang.String fileName)
determines if the given name is a model definition zip filestatic java.util.Set<java.io.File>
modelDefinitionFilesBelow(java.nio.file.Path root)
static java.util.Set<java.io.File>
nonIgnoredFilesBelow(java.nio.file.Path root)
-
-
-
Field Detail
-
BASE_CLASS
public static final java.lang.Class<?> BASE_CLASS
this is the class relative to which the model-definitions and files will be searched.
-
PACKAGE_OFFSET
public static final java.lang.String PACKAGE_OFFSET
the package name relative to the base class where to search for model-definitions and files- See Also:
- Constant Field Values
-
XML_FILE_EXTENSION
public static final java.lang.String XML_FILE_EXTENSION
the default file extension for xml files- See Also:
- Constant Field Values
-
JSON_FILE_EXTENSION
public static final java.lang.String JSON_FILE_EXTENSION
the default file extension for json files- See Also:
- Constant Field Values
-
ZIP_FILE_EXTENSION
public static final java.lang.String ZIP_FILE_EXTENSION
The extension used for jmad zip files- See Also:
- Constant Field Values
-
-
Method Detail
-
getProposedDefaultFileName
public static java.lang.String getProposedDefaultFileName(JMadModelDefinition modelDefinition)
-
getDefaultFileExtension
public static java.lang.String getDefaultFileExtension()
-
getProposedXmlFileName
public static java.lang.String getProposedXmlFileName(JMadModelDefinition modelDefinition)
creates a file name for the given model definition- Parameters:
modelDefinition
- the model definition for which to create the filename- Returns:
- the filename
-
getProposedJsonFileName
public static java.lang.String getProposedJsonFileName(JMadModelDefinition modelDefinition)
creates a json-filename for the given model definition- Parameters:
modelDefinition
- the model definition for which to create the filename- Returns:
- the filename
-
getProposedIdStringFromName
public static java.lang.String getProposedIdStringFromName(JMadModelDefinition modelDefinition)
creates an Id for the given model definition from its name. This is done by replacing all '(' and ')' by empty strings and all spaces by '-'. Note: Neither uniquenes is guaranteed nor that it will be a valid filename for example.- Parameters:
modelDefinition
- the model definition for which to create the id- Returns:
- the proposed Id as string
-
isXmlFileName
public static boolean isXmlFileName(java.lang.String fileName)
determines if the given name is a model definition xml file- Parameters:
fileName
- the file name to check- Returns:
- true if it is an xml file name, false if not
-
ensureZipFileExtension
public static java.io.File ensureZipFileExtension(java.io.File file)
adds the correct file extension for jmad zip files if necessary- Parameters:
file
- the file which shall be a correct jmad zip file- Returns:
- the corrected file
-
isZipFileName
public static boolean isZipFileName(java.lang.String fileName)
determines if the given name is a model definition zip file- Parameters:
fileName
- the file name to check- Returns:
- true if it is a jmad zip file name, false if not
-
getRequiredModelFiles
public static final java.util.Collection<ModelFile> getRequiredModelFiles(JMadModelDefinition modelDefinition)
collects all the model files which are required by a model definition and its parts- Parameters:
modelDefinition
- theJMadModelDefinition
for which to collect the model files- Returns:
- all the required model files
-
modelDefinitionFilesBelow
public static final java.util.Set<java.io.File> modelDefinitionFilesBelow(java.nio.file.Path root)
-
nonIgnoredFilesBelow
public static final java.util.Set<java.io.File> nonIgnoredFilesBelow(java.nio.file.Path root)
-
-