Package org.apache.commons.io
Enum FileSystem.NameLengthStrategy
- java.lang.Object
-
- java.lang.Enum<FileSystem.NameLengthStrategy>
-
- org.apache.commons.io.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 BYTESLength measured as encoded bytes.UTF16_CODE_UNITSLength measured as UTF-16 code units (i.e.,CharSequence.length()).
-
Constructor Summary
Constructors Modifier Constructor Description privateNameLengthStrategy()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description (package private) abstract intgetLength(java.lang.CharSequence value, java.nio.charset.Charset charset)Gets the measured length in this strategy’s unit.(package private) booleanisWithinLimit(java.lang.CharSequence value, int limit, java.nio.charset.Charset charset)Tests if the measured length is less or equal thelimit.(package private) abstract java.lang.CharSequencetruncate(java.lang.CharSequence value, int limit, java.nio.charset.Charset charset)Truncates tolimitin this strategy’s unit (no-op if already within limit).static FileSystem.NameLengthStrategyvalueOf(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.
-
-
-
Enum Constant Detail
-
BYTES
public static final FileSystem.NameLengthStrategy BYTES
Length measured as encoded bytes.
-
UTF16_CODE_UNITS
public static final FileSystem.NameLengthStrategy UTF16_CODE_UNITS
Length measured as UTF-16 code units (i.e.,CharSequence.length()).
-
-
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 namejava.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 thelimit.- Parameters:
value- The value to measure, not null.limit- The limit to compare to.charset- The charset to use when measuring in bytes.- Returns:
trueif the measured length is less or equal thelimit,falseotherwise.
-
truncate
abstract java.lang.CharSequence truncate(java.lang.CharSequence value, int limit, java.nio.charset.Charset charset)Truncates tolimitin 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.
-
-