A class that manages persistence of an associated {@link FileBased} object.
Instances of this class can be used to load and save arbitrary objects implementing the {@code FileBased} interface in a convenient way from and tovarious locations. At construction time the {@code FileBased} object tomanage is passed in. Basically, this object is assigned a location from which it is loaded and to which it can be saved. The following possibilities exist to specify such a location:
An instance stores a location. The {@code load()} and {@code save()} methodsthat do not take an argument make use of this internal location. Alternatively, it is also possible to use overloaded variants of {@code load()} and {@code save()} which expect a location. In these cases thelocation specified takes precedence over the internal one; the internal location is not changed.
The actual position of the file to be loaded is determined by a {@link FileLocationStrategy} based on the location information that has beenprovided. By providing a custom location strategy the algorithm for searching files can be adapted. Save operations require more explicit information. They cannot rely on a location strategy because the file to be written may not yet exist. So there may be some differences in the way location information is interpreted by load and save operations. In order to avoid this, the following approach is recommended:
When loading or saving a {@code FileBased} object some additionalfunctionality is performed if the object implements one of the following interfaces:
This class is thread-safe.
@version $Id: FileHandler.java 1624601 2014-09-12 18:04:36Z oheger $ @since 2.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|