M - the specific model typepublic class ModelLocations<M extends IModel>
extends java.lang.Object
ModelManagement. Please not that each individual location is considered
recursively, i.e., nested folders will be considered automatically and do not need to be added
separately.| Modifier and Type | Class and Description |
|---|---|
static class |
ModelLocations.Location
Represents a location with dependent locations (to be considered while loading a model).
|
| Modifier and Type | Field and Description |
|---|---|
private java.util.Set<java.io.File> |
excludedLocations |
private java.util.Map<java.lang.String,ModelLocations.Location> |
knownLocations |
private java.util.List<ModelLocations.Location> |
locations |
private IModelManagementRepository<M> |
repository |
| Constructor and Description |
|---|
ModelLocations(IModelManagementRepository<M> repository)
Prevents this class from being instantiated from outside this package.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addExcludedLocation(java.io.File location)
Adds an excluded model location.
|
private ModelLocations.Location |
addLocation(java.io.File file,
boolean front,
ProgressObserver observer)
Adds a file location, i.e., a location from where models can be loaded.
|
ModelLocations.Location |
addLocation(java.io.File file,
ProgressObserver observer)
Adds a file location to the end of the list of locations, i.e., a location from where models can be loaded.
|
ModelLocations.Location |
addLocationToFront(java.io.File file,
ProgressObserver observer)
Adds a file location, i.e., a location from where models can be loaded.
|
(package private) void |
clear()
Removes all known model locations.
|
private static int |
count(java.io.File location,
java.util.Set<java.io.File> excludedLocations)
Returns the number of files in the given location.
|
(package private) int |
countFilesInLocations()
Returns the number of files in all locations.
|
ModelLocations.Location |
getLocation(int index)
Returns the specified location.
|
int |
getLocationCount()
Returns the number of locations configured.
|
private ModelLocations.Location |
getLocationFor(java.io.File file)
Returns the location for
file. |
private ModelLocations.Location |
getLocationFor(java.io.File file,
boolean create)
Returns the location for
file. |
ModelLocations.Location |
getLocationFor(java.net.URI uri)
Returns the location for
uri. |
boolean |
isLocationKnown(java.io.File file)
Returns whether the specified location is already known.
|
void |
removeExcludedLocation(java.io.File location)
Removes an excluded model location.
|
void |
removeLocation(java.io.File file,
ProgressObserver observer)
Removes a file location, i.e. a location from where models can be loaded.
|
(package private) void |
removeLocation(ModelLocations.Location location)
Removes the given location from the set of model locations of this instance as well as from all
dependent locations.
|
void |
removeLocation(ModelLocations.Location location,
ProgressObserver observer)
Removes a location, i.e. a location from where models can be loaded.
|
(package private) void |
removeLocationFor(java.io.File file)
Removes the location for
file from the set of model locations of this instance as well as from all
dependent locations. |
(package private) void |
scan(java.io.File location,
ModelInfoHolder<M> holder,
IModelLoader<M> loader,
ObservableTask task,
java.util.Set<java.io.File> done)
Scans the given location for model information objects.
|
void |
updateLocation(java.io.File file,
ProgressObserver observer)
Updates a file location, i.e., a location from where models can be loaded.
|
void |
updateModelInformation()
Updates all model information for all locations.
|
private java.util.Map<java.lang.String,ModelLocations.Location> knownLocations
private IModelManagementRepository<M extends IModel> repository
private java.util.List<ModelLocations.Location> locations
private java.util.Set<java.io.File> excludedLocations
ModelLocations(IModelManagementRepository<M> repository)
repository - the model management repository for callbacksvoid clear()
public void addExcludedLocation(java.io.File location)
location - the location to be excludedpublic void removeExcludedLocation(java.io.File location)
location - the location to be discardedpublic ModelLocations.Location getLocationFor(java.net.URI uri)
uri.uri - the URI to search forprivate ModelLocations.Location getLocationFor(java.io.File file) throws ModelManagementException
file.file - the file to return the location forModelManagementException - in case that file cannot be accessed / resolved#getLocationFor(File, boolean)}private ModelLocations.Location getLocationFor(java.io.File file, boolean create) throws ModelManagementException
file.file - the file to return the location forcreate - true if a location shall be created for file if no location is known,
false if no new location shall be createdfile, may be null depending on createModelManagementException - in case that file cannot be accessed / resolvedpublic ModelLocations.Location addLocation(java.io.File file, ProgressObserver observer) throws ModelManagementException
file is considered recursively, i.e., nested folders will be considered
automatically and do not need to be added separately.file - the file location (null is ignored)observer - an optional progress observer (use ProgressObserver.NO_OBSERVER but
not null in case that no observation is intended)fileModelManagementException - in case that the available information
may be come inconsistent due to the new location or that file cannot be accessed / resolvedpublic ModelLocations.Location addLocationToFront(java.io.File file, ProgressObserver observer) throws ModelManagementException
file
is considered recursively, i.e., nested folders will be considered automatically and do not need to be added
separately.file - the file location (null is ignored)observer - an optional progress observer (use ProgressObserver.NO_OBSERVER but
not null in case that no observation is intended)fileModelManagementException - in case that the available information
may be come inconsistent due to the new location or that file cannot be accessed / resolvedprivate ModelLocations.Location addLocation(java.io.File file, boolean front, ProgressObserver observer) throws ModelManagementException
file
is considered recursively, i.e., nested folders will be considered automatically and do not need to be added
separately.file - the file location (null is ignored)front - add to the front or the end of the list of locationsobserver - an optional progress observer (use ProgressObserver.NO_OBSERVER but
not null in case that no observation is intended)fileModelManagementException - in case that the available information
may be come inconsistent due to the new location or that file cannot be accessed / resolvedpublic void removeLocation(ModelLocations.Location location, ProgressObserver observer) throws ModelManagementException
location - the location (null is ignored)observer - an optional progress observer (use ProgressObserver.NO_OBSERVER but
not null in case that no observation is intended)ModelManagementException - in case that file cannot be accessedpublic void removeLocation(java.io.File file,
ProgressObserver observer)
throws ModelManagementException
file - the file location (null is ignored)observer - an optional progress observer (use ProgressObserver.NO_OBSERVER but
not null in case that no observation is intended)ModelManagementException - in case that file cannot be accessedpublic void updateLocation(java.io.File file,
ProgressObserver observer)
throws ModelManagementException
addLocation(File, ProgressObserver).file - the file location (null is ignored)observer - an optional progress observer (use ProgressObserver.NO_OBSERVER but
not null in case that no observation is intended)ModelManagementException - in case that the available information
may be come inconsistent due to the new location or file cannot be accessedpublic boolean isLocationKnown(java.io.File file)
file - the location to search fortrue if it is known, false elseprivate static int count(java.io.File location,
java.util.Set<java.io.File> excludedLocations)
location - the location to scanexcludedLocations - explicitly excluded locations (may be null if no locations shall be excluded)int countFilesInLocations()
public int getLocationCount()
public ModelLocations.Location getLocation(int index)
index - the index pointing to the desired locationjava.lang.IndexOutOfBoundsException - if index < 0 || index >=getLocationCount()void scan(java.io.File location,
ModelInfoHolder<M> holder,
IModelLoader<M> loader,
ObservableTask task,
java.util.Set<java.io.File> done)
location - the location to scanholder - the combined information and result collection instanceloader - the specific loader to consider (may be null)task - the task to be informeddone - records visited directories in order to avoid unintended loopingvoid removeLocationFor(java.io.File file)
throws ModelManagementException
file from the set of model locations of this instance as well as from all
dependent locations.file - the file pointing to the locationModelManagementException - in case that file cannot be resolvedvoid removeLocation(ModelLocations.Location location)
location - the location to be removedpublic void updateModelInformation()
throws ModelManagementException
ModelManagementException - in case that updating fails for some reasonCopyright © 2009 - 2018 SSE. All Rights Reserved.