Search in sources :

Example 1 with Pattern

use of org.whole.lang.grammars.model.Pattern in project whole by wholeplatform.

the class GrammarsDefaultDataTypeParser method matches.

protected String matches(EntityDescriptor<?> ed, String value) {
    Pattern pattern = grammarBasedDataTypeParser.getDataTerminal(ed).getPattern();
    java.util.regex.Pattern compiledPattern = Matcher.matchImpl(GrammarsEntityDescriptorEnum.CompiledPattern, pattern) ? ((CompiledPattern) pattern).getValue() : java.util.regex.Pattern.compile(((RegExp) pattern).getValue());
    if (!compiledPattern.matcher(value).matches())
        throw new WholeIllegalArgumentException(WholeMessages.no_data_type);
    return value;
}
Also used : CompiledPattern(org.whole.lang.grammars.model.CompiledPattern) Pattern(org.whole.lang.grammars.model.Pattern) RegExp(org.whole.lang.grammars.model.RegExp) WholeIllegalArgumentException(org.whole.lang.exceptions.WholeIllegalArgumentException)

Aggregations

WholeIllegalArgumentException (org.whole.lang.exceptions.WholeIllegalArgumentException)1 CompiledPattern (org.whole.lang.grammars.model.CompiledPattern)1 Pattern (org.whole.lang.grammars.model.Pattern)1 RegExp (org.whole.lang.grammars.model.RegExp)1