Class RegexPathConstraint
- java.lang.Object
-
- edu.wisc.library.ocfl.core.path.constraint.RegexPathConstraint
-
- All Implemented Interfaces:
FileNameConstraint,PathConstraint
public class RegexPathConstraint extends Object implements PathConstraint, FileNameConstraint
Validates that a path or filename does or does not match a regex
-
-
Constructor Summary
Constructors Constructor Description RegexPathConstraint(boolean mustMatch, Pattern pattern)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidapply(String path)Validates that a path meets a defined constraintvoidapply(String fileName, String path)Validates that a filename meets a defined constraintstatic RegexPathConstraintmustContain(Pattern pattern)Creates a new constraint that validates paths do match the regexstatic RegexPathConstraintmustNotContain(Pattern pattern)Creates a new constraint that validates paths do not match the regex
-
-
-
Constructor Detail
-
RegexPathConstraint
public RegexPathConstraint(boolean mustMatch, Pattern pattern)
-
-
Method Detail
-
mustNotContain
public static RegexPathConstraint mustNotContain(Pattern pattern)
Creates a new constraint that validates paths do not match the regex- Parameters:
pattern- the regex that paths must not match- Returns:
- constraint
-
mustContain
public static RegexPathConstraint mustContain(Pattern pattern)
Creates a new constraint that validates paths do match the regex- Parameters:
pattern- the regex that paths must match- Returns:
- constraint
-
apply
public void apply(String path)
Description copied from interface:PathConstraintValidates that a path meets a defined constraint- Specified by:
applyin 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:
applyin interfaceFileNameConstraint- Parameters:
fileName- the filename to validatepath- the path the filename is part of. This is supplied for context and is not validated
-
-