Class Configuration.Builder

  • Enclosing class:
    Configuration

    public static final class Configuration.Builder
    extends java.lang.Object
    Mutable builder for Configuration objects.
    • Field Detail

      • DEFAULT_MAX_CACHE_SIZE

        public static final long DEFAULT_MAX_CACHE_SIZE
        Equal to the configured max size.
        See Also:
        Constant Field Values
    • Method Detail

      • setNameDisplayNormalization

        public Configuration.Builder setNameDisplayNormalization​(PathNormalization first,
                                                                 PathNormalization... more)
        Sets the normalizations that will be applied to the display form of filenames. The display form is used in the toString() of Path objects.
      • setNameCanonicalNormalization

        public Configuration.Builder setNameCanonicalNormalization​(PathNormalization first,
                                                                   PathNormalization... more)
        Returns the normalizations that will be applied to the canonical form of filenames in the file system. The canonical form is used to determine the equality of two filenames when performing a file lookup.
      • setPathEqualityUsesCanonicalForm

        public Configuration.Builder setPathEqualityUsesCanonicalForm​(boolean useCanonicalForm)
        Sets whether Path objects in the file system use the canonical form (true) or the display form (false) of filenames for determining equality of two paths.

        The default is false.

      • setBlockSize

        public Configuration.Builder setBlockSize​(int blockSize)
        Sets the block size (in bytes) for the file system to use. All regular files will be allocated blocks of the given size, so this is the minimum granularity for file size.

        The default is 8192 bytes (8 KB).

      • setMaxSize

        public Configuration.Builder setMaxSize​(long maxSize)
        Sets the maximum size (in bytes) for the file system's in-memory file storage. This maximum size determines the maximum number of blocks that can be allocated to regular files, so it should generally be a multiple of the block size. The actual maximum size will be the nearest multiple of the block size that is less than or equal to the given size.

        Note: The in-memory file storage will not be eagerly initialized to this size, so it won't use more memory than is needed for the files you create. Also note that in addition to this limit, you will of course be limited by the amount of heap space available to the JVM and the amount of heap used by other objects, both in the file system and elsewhere.

        The default is 4 GB.

      • setMaxCacheSize

        public Configuration.Builder setMaxCacheSize​(long maxCacheSize)
        Sets the maximum amount of unused space (in bytes) in the file system's in-memory file storage that should be cached for reuse. By default, this will be equal to the maximum size of the storage, meaning that all space that is freed when files are truncated or deleted is cached for reuse. This helps to avoid lots of garbage collection when creating and deleting many files quickly. This can be set to 0 to disable caching entirely (all freed blocks become available for garbage collection) or to some other number to put an upper bound on the maximum amount of unused space the file system will keep around.

        Like the maximum size, the actual value will be the closest multiple of the block size that is less than or equal to the given size.

      • setAttributeViews

        public Configuration.Builder setAttributeViews​(java.lang.String first,
                                                       java.lang.String... more)
        Sets the attribute views the file system should support. By default, the following views may be specified:
        Name View Interface Attributes Interface
        "basic" BasicFileAttributeView BasicFileAttributes
        "owner" FileOwnerAttributeView --
        "posix" PosixFileAttributeView PosixFileAttributes
        "unix" -- --
        "dos" DosFileAttributeView DosFileAttributes
        "acl" AclFileAttributeView --
        "user" UserDefinedFileAttributeView --

        If any other views should be supported, attribute providers for those views must be added.

      • setDefaultAttributeValue

        public Configuration.Builder setDefaultAttributeValue​(java.lang.String attribute,
                                                              java.lang.Object value)
        Sets the default value to use for the given file attribute when creating new files. The attribute must be in the form "view:attribute". The value must be of a type that the provider for the view accepts.

        For the included attribute views, default values can be set for the following attributes:

        Attribute Legal Types
        "owner:owner" String (user name)
        "posix:group" String (group name)
        "posix:permissions" String (format "rwxrw-r--"), Set<PosixFilePermission>
        "dos:readonly" Boolean
        "dos:hidden" Boolean
        "dos:archive" Boolean
        "dos:system" Boolean
        "acl:acl" List<AclEntry>
      • setRoots

        public Configuration.Builder setRoots​(java.lang.String first,
                                              java.lang.String... more)
        Sets the roots for the file system.
        Throws:
        java.nio.file.InvalidPathException - if any of the given roots is not a valid path for this builder's path type
        java.lang.IllegalArgumentException - if any of the given roots is a valid path for this builder's path type but is not a root path with no name elements
      • setWorkingDirectory

        public Configuration.Builder setWorkingDirectory​(java.lang.String workingDirectory)
        Sets the path to the working directory for the file system. The working directory must be an absolute path starting with one of the configured roots.
        Throws:
        java.nio.file.InvalidPathException - if the given path is not valid for this builder's path type
        java.lang.IllegalArgumentException - if the given path is valid for this builder's path type but is not an absolute path
      • setSupportedFeatures

        public Configuration.Builder setSupportedFeatures​(Feature... features)
        Sets the given features to be supported by the file system. Any features not provided here will not be supported.
      • setWatchServiceConfiguration

        public Configuration.Builder setWatchServiceConfiguration​(WatchServiceConfiguration config)
        Sets the configuration that WatchService instances created by the file system should use. The default configuration polls watched directories for changes every 5 seconds.
        Since:
        1.1
      • build

        public Configuration build()
        Creates a new immutable configuration object from this builder.