public class ERXFileRepository extends Object
UUID
.
It uses a factory to create the folder structure under the root directory. With the default factory there will be directories for the first two characters and under these again directories for the next two characters of the GUID.
Modifier and Type | Class and Description |
---|---|
static class |
ERXFileRepository.DefaultFactory
Default implementation of the Factory interface.
|
static interface |
ERXFileRepository.Factory |
Modifier and Type | Field and Description |
---|---|
protected ERXFileRepository.Factory |
_factory |
protected File |
_root |
Modifier | Constructor and Description |
---|---|
protected |
ERXFileRepository(File root,
ERXFileRepository.Factory factory)
Private constructor, as we use the factory methods to create instances.
|
Modifier and Type | Method and Description |
---|---|
static ERXFileRepository |
addRepository(String name,
ERXFileRepository repository)
Adds an existing repository under the given name.
|
static ERXFileRepository |
addRepository(String name,
File root)
Adds a repository under the given name and the given root directory that uses the default factory.
|
static ERXFileRepository |
addRepository(String name,
File root,
ERXFileRepository.Factory factory)
Adds a repository under the given name and the given root directory that uses the given factory.
|
File |
createFile()
Returns a new file in the repository.
|
File |
getFile(String id)
Returns a file for a given id
|
File |
getRoot()
Returns the root directory for the repository.
|
boolean |
hasFile(String id)
Returns true if the file is present in the repository and also exists.
|
static ERXFileRepository |
repository(String name)
Returns the repository that is registered under the given name.
|
protected File _root
protected final ERXFileRepository.Factory _factory
protected ERXFileRepository(File root, ERXFileRepository.Factory factory)
root
- factory
- public File createFile()
public File getFile(String id)
id
- the id of the filepublic boolean hasFile(String id)
id
- the id of the filepublic File getRoot()
public static ERXFileRepository repository(String name)
name
- the name under which the repository is registeredpublic static ERXFileRepository addRepository(String name, File root)
name
- the name under which the repository should be addedroot
- the root directory of the repositorypublic static ERXFileRepository addRepository(String name, File root, ERXFileRepository.Factory factory)
name
- the name under which the repository should be addedroot
- the root directory of the repositoryfactory
- the factory to determine the directory from the id for this repositorypublic static ERXFileRepository addRepository(String name, ERXFileRepository repository)
name
- the name under which the repository should be addedrepository
- the repository to registerCopyright © 2002 – 2024 Project Wonder.