Example usage for org.apache.commons.lang3.text StrMatcher isMatch

List of usage examples for org.apache.commons.lang3.text StrMatcher isMatch

Introduction

In this page you can find the example usage for org.apache.commons.lang3.text StrMatcher isMatch.

Prototype

public int isMatch(final char[] buffer, final int pos) 

Source Link

Document

Returns the number of matching characters, zero for no match.

Usage

From source file:dk.dbc.RequireSubstitution.java

@Override
protected String resolveVariable(String variableName, StrBuilder buf, int startPos, int endPos) {
    String resolved = getVariableResolver().lookup(variableName);
    if (resolved == null) {
        StrMatcher variablePrefixMatcher = getVariablePrefixMatcher();
        StrMatcher valueDelimiterMatcher = getValueDelimiterMatcher();
        char[] buffer = buf.toCharArray();
        int start = startPos;
        start += variablePrefixMatcher.isMatch(buffer, start);
        start += variableName.length();/*from w w  w .j  ava2s.  c  om*/
        int matchLength = valueDelimiterMatcher.isMatch(buffer, start);
        if (matchLength == 0) {
            throw new UndefinedEnvironmentVariableException("The environment variable '" + variableName
                    + "' is not defined; could not substitute the expression '"
                    + buf.substring(startPos, endPos) + "'.");
        }
    }
    return resolved;
}