Enum FileSystem.NameLengthStrategy

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<FileSystem.NameLengthStrategy>
    Enclosing class:
    FileSystem

    static enum FileSystem.NameLengthStrategy
    extends java.lang.Enum<FileSystem.NameLengthStrategy>
    Strategy for measuring and truncating file or path names in different units. Implementations measure length and can truncate to a specified limit.
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      BYTES
      Length measured as encoded bytes.
      UTF16_CODE_UNITS
      Length measured as UTF-16 code units (i.e., CharSequence.length()).
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private NameLengthStrategy()  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) abstract int getLength​(java.lang.CharSequence value, java.nio.charset.Charset charset)
      Gets the measured length in this strategy’s unit.
      (package private) boolean isWithinLimit​(java.lang.CharSequence value, int limit, java.nio.charset.Charset charset)
      Tests if the measured length is less or equal the limit.
      (package private) abstract java.lang.CharSequence truncate​(java.lang.CharSequence value, int limit, java.nio.charset.Charset charset)
      Truncates to limit in this strategy’s unit (no-op if already within limit).
      static FileSystem.NameLengthStrategy valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static FileSystem.NameLengthStrategy[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • NameLengthStrategy

        private NameLengthStrategy()
    • Method Detail

      • values

        public static FileSystem.NameLengthStrategy[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (FileSystem.NameLengthStrategy c : FileSystem.NameLengthStrategy.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static FileSystem.NameLengthStrategy valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • getLength

        abstract int getLength​(java.lang.CharSequence value,
                               java.nio.charset.Charset charset)
        Gets the measured length in this strategy’s unit.
        Parameters:
        value - The value to measure, not null.
        charset - The charset to use when measuring in bytes.
        Returns:
        The length in this strategy’s unit.
      • isWithinLimit

        final boolean isWithinLimit​(java.lang.CharSequence value,
                                    int limit,
                                    java.nio.charset.Charset charset)
        Tests if the measured length is less or equal the limit.
        Parameters:
        value - The value to measure, not null.
        limit - The limit to compare to.
        charset - The charset to use when measuring in bytes.
        Returns:
        true if the measured length is less or equal the limit, false otherwise.
      • truncate

        abstract java.lang.CharSequence truncate​(java.lang.CharSequence value,
                                                 int limit,
                                                 java.nio.charset.Charset charset)
        Truncates to limit in this strategy’s unit (no-op if already within limit).
        Parameters:
        value - The value to truncate, not null.
        limit - The limit to truncate to.
        charset - The charset to use when measuring in bytes.
        Returns:
        The truncated value, not null.