All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.swisspush.gateleen.validation.RegexpValidator Maven / Gradle / Ivy

The newest version!
package org.swisspush.gateleen.validation;

import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;


public class RegexpValidator {

    /**
     * 

Tries to compile the passed regular expression pattern.

* *

This method will throw specified exception if passed pattern fails to compile.

* * @param pattern * The pattern to validate. * @throws ValidationException * Thrown in case there was a problem compiling passed pattern. */ public static Pattern throwIfPatternInvalid( String pattern ) throws ValidationException { try{ return Pattern.compile( pattern ); }catch( PatternSyntaxException e ){ throw new ValidationException( "Failed to parse regex pattern '"+pattern+"'." , e ); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy