Class RegexNameValidatingRewriter

  • All Implemented Interfaces:

    public final class RegexNameValidatingRewriter
    extends Object
    implements NameRewriter
    A regular expression-based name validation rewriter. Always returns the original name if the name is valid.
    David M. Lloyd
    • Field Detail

      • pattern

        private final Pattern pattern
      • match

        private final boolean match
    • Constructor Detail

      • RegexNameValidatingRewriter

        public RegexNameValidatingRewriter​(Pattern pattern,
                                           boolean match)
        Construct a new instance. The pattern is a partial pattern; if the whole string is to be matched, then the appropriate regex anchors should be used.
        pattern - the pattern that the name must match (or not match) in order to be considered valid
        match - true if the pattern must match, false if the pattern must not match
    • Method Detail

      • rewriteName

        public String rewriteName​(String original)
        Description copied from interface: NameRewriter
        Rewrite a name. Must not return null.
        Specified by:
        rewriteName in interface NameRewriter
        original - the original name (must not be null)
        the rewritten name, or null if the name is invalid
      • getPattern

        public Pattern getPattern()
        Get the pattern.
        the pattern
      • isMatch

        public boolean isMatch()
        Get the match flag. If the flag is true, the pattern must match; if false, the pattern must not match.
        the match flag