Package io.ocfl.core.path.constraint
Class PathLengthConstraint
- java.lang.Object
-
- io.ocfl.core.path.constraint.PathLengthConstraint
-
- All Implemented Interfaces:
FileNameConstraint
,PathConstraint
public class PathLengthConstraint extends Object implements PathConstraint, FileNameConstraint
Validates that a path or filename are not longer than a fixed number of characters or bytes
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PathLengthConstraint.Type
-
Constructor Summary
Constructors Constructor Description PathLengthConstraint(int maxLength, PathLengthConstraint.Type type)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
apply(String path)
Validates that a path meets a defined constraintvoid
apply(String fileName, String path)
Validates that a filename meets a defined constraintstatic PathLengthConstraint
maxBytes(int maxLength)
Creates a new constraint that limits the number of bytes in a pathstatic PathLengthConstraint
maxChars(int maxLength)
Creates a new constraint that limits the number of characters in a path
-
-
-
Constructor Detail
-
PathLengthConstraint
public PathLengthConstraint(int maxLength, PathLengthConstraint.Type type)
-
-
Method Detail
-
maxChars
public static PathLengthConstraint maxChars(int maxLength)
Creates a new constraint that limits the number of characters in a path- Parameters:
maxLength
- maximum number of characters- Returns:
- constraint
-
maxBytes
public static PathLengthConstraint maxBytes(int maxLength)
Creates a new constraint that limits the number of bytes in a path- Parameters:
maxLength
- maximum number of bytes- Returns:
- constraint
-
apply
public void apply(String path)
Validates that a path meets a defined constraint- Specified by:
apply
in interfacePathConstraint
- Parameters:
path
- the path to validate
-
apply
public void apply(String fileName, String path)
Validates that a filename meets a defined constraint- Specified by:
apply
in interfaceFileNameConstraint
- Parameters:
fileName
- the filename to validatepath
- the path the filename is part of. This is supplied for context and is not validated
-
-