Package com.nomagic.magicdraw.core
Class EnvironmentSpecificFileLocations
- java.lang.Object
-
- com.nomagic.magicdraw.core.EnvironmentSpecificFileLocations
-
- All Implemented Interfaces:
FileLocationRegister
@OpenApi public final class EnvironmentSpecificFileLocations extends java.lang.Object implements FileLocationRegister
This class is for saving environment specific file locations.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.String,java.io.File>
fileLocations
private static EnvironmentSpecificFileLocations
instance
private static java.lang.String
SEPERATOR
-
Constructor Summary
Constructors Modifier Constructor Description private
EnvironmentSpecificFileLocations()
Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.io.File
getFileLocation(java.lang.String locationNameID)
This method should be used to get file object by locationNameID.static EnvironmentSpecificFileLocations
getInstance()
Get instance.private java.lang.String
getUserDocumentDirectory()
Method to get user documents directory as string.private void
readFileLocation()
Reads file locations/locationNameID from generalOptions and stores them to fileLocations map.private void
saveFileLocations()
Saves all file locations/locationNameID from fileLocations map by putting them to generalOptionsGroup.void
setFileLocation(java.lang.String locationNameID, java.io.File file)
Before saving file locations file is checked if it still exist.
-
-
-
Field Detail
-
instance
private static EnvironmentSpecificFileLocations instance
-
SEPERATOR
private static final java.lang.String SEPERATOR
- See Also:
- Constant Field Values
-
fileLocations
private final java.util.Map<java.lang.String,java.io.File> fileLocations
-
-
Method Detail
-
getInstance
@OpenApi public static EnvironmentSpecificFileLocations getInstance()
Get instance.- Returns:
- EnvironmentSpecificFileLocations type object.
-
readFileLocation
private void readFileLocation()
Reads file locations/locationNameID from generalOptions and stores them to fileLocations map. If read file location don`t exist any more it is changed to users documents directory.
-
saveFileLocations
private void saveFileLocations()
Saves all file locations/locationNameID from fileLocations map by putting them to generalOptionsGroup.
-
getFileLocation
public java.io.File getFileLocation(java.lang.String locationNameID)
Description copied from interface:FileLocationRegister
This method should be used to get file object by locationNameID.- Specified by:
getFileLocation
in interfaceFileLocationRegister
- Parameters:
locationNameID
- a unique id for storing/getting file locations.- Returns:
- File type object.
-
setFileLocation
@OpenApi public void setFileLocation(java.lang.String locationNameID, java.io.File file)
Before saving file locations file is checked if it still exist. It is done because user may delete directory, rename it, move it... If file location does not exist anymore default(User document directory) location is used.- Specified by:
setFileLocation
in interfaceFileLocationRegister
- Parameters:
locationNameID
- a unique id for storing/getting file locations.file
- type object
-
getUserDocumentDirectory
private java.lang.String getUserDocumentDirectory()
Method to get user documents directory as string.- Returns:
- user documents directory as string type object.
-
-