public final class MemoryFileSystemBuilder extends Object
The builder takes care of creating the environment and selecting
the correct class loader to pass to FileSystems.newFileSystem(URI, Map, ClassLoader)
.
Modifier and Type | Method | Description |
---|---|---|
MemoryFileSystemBuilder |
addFileAttributeView(Class<? extends FileAttributeView> fileAttributeView) |
Adds support for an attribute view.
|
MemoryFileSystemBuilder |
addFileAttributeView(String fileAttributeViewName) |
Adds support for an attribute view.
|
MemoryFileSystemBuilder |
addForbiddenCharacter(char c) |
Forbids a character to be used in a name.
|
MemoryFileSystemBuilder |
addGroup(String groupName) |
Adds a group to the file systems
UserPrincipalLookupService . |
MemoryFileSystemBuilder |
addRoot(String root) |
Add a file system root.
|
MemoryFileSystemBuilder |
addUser(String userName) |
Adds a user and a group to the file systems
UserPrincipalLookupService . |
FileSystem |
build(String name) |
Creates the new file system instance.
|
Map<String,?> |
buildEnvironment() |
Builds an environment to pass to
FileSystems.newFileSystem(URI, Map) . |
static MemoryFileSystemBuilder |
newEmpty() |
Creates a builder for a very basic file system.
|
static MemoryFileSystemBuilder |
newLinux() |
Creates a builder for a Linux-like file system.
|
static MemoryFileSystemBuilder |
newMacOs() |
Creates a builder for a macOS-like file system.
|
static MemoryFileSystemBuilder |
newMacOsOldJvm() |
Creates a builder for a macOS-like file system for old JVMs.
|
static MemoryFileSystemBuilder |
newWindows() |
Creates a builder for a Windows-like file system.
|
MemoryFileSystemBuilder |
setCaseSensitive(boolean caseSensitive) |
Toggles case sensitivity.
|
MemoryFileSystemBuilder |
setCollator(Collator collator) |
Sets the collator used for name comparisons.
|
MemoryFileSystemBuilder |
setCurrentWorkingDirectory(String currentWorkingDirectory) |
Sets the current working directory used for resolving relative paths.
|
MemoryFileSystemBuilder |
setLocale(Locale locale) |
Sets the locale to be used for case insensitivity.
|
MemoryFileSystemBuilder |
setLookUpTransformer(StringTransformer lookUpTransformer) |
Sets the transformer that controls how a file name is looked up.
|
MemoryFileSystemBuilder |
setSeprator(String separator) |
Sets the the name separator.
|
MemoryFileSystemBuilder |
setStoreTransformer(StringTransformer storeTransformer) |
Sets the transformer that controls how a file name is stored.
|
MemoryFileSystemBuilder |
setUmask(Set<PosixFilePermission> umask) |
Sets the permissions that will be applied to new files.
|
public MemoryFileSystemBuilder addRoot(String root)
This method is intended to be used in Windows mode to add a drive letter eg.:
builder.addRoot("D:\\")
root
- the file system rootpublic MemoryFileSystemBuilder setSeprator(String separator)
separator
- the name separator, not null
FileSystem.getSeparator()
public MemoryFileSystemBuilder addForbiddenCharacter(char c)
c
- the character to forbidpublic MemoryFileSystemBuilder addUser(String userName)
UserPrincipalLookupService
.userName
- the name of the user to addpublic MemoryFileSystemBuilder addGroup(String groupName)
UserPrincipalLookupService
.groupName
- the name of the group to addpublic MemoryFileSystemBuilder setUmask(Set<PosixFilePermission> umask)
umask
- the permissions that will be applied to new filespublic MemoryFileSystemBuilder addFileAttributeView(String fileAttributeViewName)
fileAttributeViewName
- the name of the attribute view to addAttributeView.name()
public MemoryFileSystemBuilder addFileAttributeView(Class<? extends FileAttributeView> fileAttributeView)
fileAttributeView
- the attribute view classpublic MemoryFileSystemBuilder setCurrentWorkingDirectory(String currentWorkingDirectory)
currentWorkingDirectory
- path of the current working directorypublic MemoryFileSystemBuilder setStoreTransformer(StringTransformer storeTransformer)
storeTransformer
- to apply to the file names before storingpublic MemoryFileSystemBuilder setLocale(Locale locale)
locale
- for case insensitivitysetCaseSensitive(boolean)
public MemoryFileSystemBuilder setCaseSensitive(boolean caseSensitive)
caseSensitive
- whether the file names should be case sensitivesetLocale(Locale)
public MemoryFileSystemBuilder setLookUpTransformer(StringTransformer lookUpTransformer)
lookUpTransformer
- to apply to the file names for lookuppublic MemoryFileSystemBuilder setCollator(Collator collator)
collator
- the collator for name comparisonspublic static MemoryFileSystemBuilder newEmpty()
The file system does not support permissions and only supports
BasicFileAttributeView
. It is UNIX-like in the sense that
is uses "/" as a separator, has a single root and is
case sensitive and case preserving.
public static MemoryFileSystemBuilder newLinux()
The file system has the following properties:
"user.name"
system property)
is added as a user"user.name"
system property)
is added as a groupPosixFileAttributeView
is added as an attribute view"/home/${user.name}"
0x00
is not allowed in file namespublic static MemoryFileSystemBuilder newMacOs()
The file system has the following properties:
"user.name"
system property)
is added as a user"user.name"
system property)
is added as a groupPosixFileAttributeView
is added as an attribute view"/Users/${user.name}"
0x00
is not allowed in file namespublic static MemoryFileSystemBuilder newMacOsOldJvm()
The file system has the following properties:
"user.name"
system property)
is added as a user"user.name"
system property)
is added as a groupPosixFileAttributeView
is added as an attribute view"/Users/${user.name}"
0x00
is not allowed in file namespublic static MemoryFileSystemBuilder newWindows()
The file system has the following properties:
"C:\\"
"user.name"
system property)
is added as a user"user.name"
system property)
is added as a groupDosFileAttributeView
is added as an attribute view"C:\\Users\\${user.name}"
'\\'
, '/'
, ':'
, '*'
, '?'
,
'"'
, '<'
, '<'
and '|'
and not allowed
in file namespublic FileSystem build(String name) throws IOException
name
- the name, must be unique otherwise a
FileSystemAlreadyExistsException
will be thrownIOException
- if the file system can't be createdFileSystems.newFileSystem(URI, Map, ClassLoader)
public Map<String,?> buildEnvironment()
FileSystems.newFileSystem(URI, Map)
.Copyright © 2011–2017. All rights reserved.