Enum FileSystem.NameLengthStrategy

java.lang.Object
java.lang.Enum<FileSystem.NameLengthStrategy>
org.apache.commons.io.FileSystem.NameLengthStrategy
All Implemented Interfaces:
Serializable, Comparable<FileSystem.NameLengthStrategy>
Enclosing class:
FileSystem

static enum FileSystem.NameLengthStrategy extends 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 Details

  • Constructor Details

    • NameLengthStrategy

      private NameLengthStrategy()
  • Method Details

    • values

      public static FileSystem.NameLengthStrategy[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static FileSystem.NameLengthStrategy valueOf(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:
      IllegalArgumentException - if this enum type has no constant with the specified name
      NullPointerException - if the argument is null
    • getLength

      abstract int getLength(CharSequence value, 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(CharSequence value, int limit, 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 CharSequence truncate(CharSequence value, int limit, 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.