Package org.apache.commons.io
Enum FileSystem.NameLengthStrategy
- All Implemented Interfaces:
Serializable,Comparable<FileSystem.NameLengthStrategy>
- Enclosing class:
- FileSystem
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 ConstantsEnum ConstantDescriptionLength measured as encoded bytes.Length measured as UTF-16 code units (i.e.,CharSequence.length()). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) abstract intgetLength(CharSequence value, Charset charset) Gets the measured length in this strategy’s unit.(package private) final booleanisWithinLimit(CharSequence value, int limit, Charset charset) Tests if the measured length is less or equal thelimit.(package private) abstract CharSequencetruncate(CharSequence value, int limit, Charset charset) Truncates tolimitin this strategy’s unit (no-op if already within limit).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 Details
-
BYTES
Length measured as encoded bytes. -
UTF16_CODE_UNITS
Length measured as UTF-16 code units (i.e.,CharSequence.length()).
-
-
Constructor Details
-
NameLengthStrategy
private NameLengthStrategy()
-
-
Method Details
-
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
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 nameNullPointerException- if the argument is null
-
getLength
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
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
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.
-