Top Description Inners Fields Constructors Methods
org.springframework.expression.spel.ast

public Class OperatorMatches

extends Operator
Class Inheritance
Imports
java.util.concurrent.ConcurrentHashMap, .ConcurrentMap, java.util.regex.Matcher, .Pattern, .PatternSyntaxException, org.springframework.expression.EvaluationException, org.springframework.expression.spel.ExpressionState, .SpelEvaluationException, .SpelMessage, org.springframework.expression.spel.support.BooleanTypedValue

Implements the matches operator. Matches takes two operands: The first is a String and the second is a Java regex. It will return true when getValue is called if the first operand matches the regex.
Authors
Andy Clement, Juergen Hoeller, Sam Brannen
Since
3.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class

Field Summary

Modifier and TypeField and Description
private static final int
MAX_REGEX_LENGTH

Maximum number of characters permitted in a regular expression.

private static final int
private final ConcurrentMap<String, Pattern>
Inherited from org.springframework.expression.spel.ast.Operator:
leftActualDescriptorrightActualDescriptor

Constructor Summary

AccessConstructor and Description
public
OperatorMatches(int startPos, int endPos, SpelNodeImpl... operands)

Deprecated since 5.2.23. as of Spring Framework 5.2.23 in favor of invoking OperatorMatches(ConcurrentMap, int, int, SpelNodeImpl...) with a shared pattern cache instead
Create a new OperatorMatches instance.
public
OperatorMatches(ConcurrentMap<String, Pattern> patternCache, int startPos, int endPos, SpelNodeImpl... operands)

Create a new OperatorMatches instance with a shared pattern cache.

Method Summary

Modifier and TypeMethod and Description
private void
public BooleanTypedValue

Returns:

true if the first operand matches the regex specified as the second operand, otherwise false
getValueInternal
(ExpressionState
the expression state
state
)

Implements abstract org.springframework.expression.spel.ast.SpelNodeImpl.getValueInternal.

Check the first operand matches the regex specified as the second operand.
Inherited from org.springframework.expression.spel.ast.Operator:
equalityCheckgenerateComparisonCodegetLeftOperandgetOperatorNamegetRightOperandisCompilableOperatorUsingNumericstoStringAST

Field Detail

MAX_REGEX_LENGTHback to summary
private static final int MAX_REGEX_LENGTH

Maximum number of characters permitted in a regular expression.

Since
5.2.23
PATTERN_ACCESS_THRESHOLDback to summary
private static final int PATTERN_ACCESS_THRESHOLD
patternCacheback to summary
private final ConcurrentMap<String, Pattern> patternCache

Constructor Detail

OperatorMatchesback to summary
public OperatorMatches(int startPos, int endPos, SpelNodeImpl... operands)

Deprecated

since 5.2.23.

as of Spring Framework 5.2.23 in favor of invoking OperatorMatches(ConcurrentMap, int, int, SpelNodeImpl...) with a shared pattern cache instead

Create a new OperatorMatches instance.

Annotations
@Deprecated
since:5.2.23
OperatorMatchesback to summary
public OperatorMatches(ConcurrentMap<String, Pattern> patternCache, int startPos, int endPos, SpelNodeImpl... operands)

Create a new OperatorMatches instance with a shared pattern cache.

Since
5.2.23

Method Detail

checkRegexLengthback to summary
private void checkRegexLength(String regex)
getValueInternalback to summary
public BooleanTypedValue getValueInternal(ExpressionState state) throws EvaluationException

Implements abstract org.springframework.expression.spel.ast.SpelNodeImpl.getValueInternal.

Check the first operand matches the regex specified as the second operand.

Parameters
state:ExpressionState

the expression state

Returns:BooleanTypedValue

true if the first operand matches the regex specified as the second operand, otherwise false

Annotations
@Override
Exceptions
EvaluationException:
if there is a problem evaluating the expression (e.g. the regex is invalid)
org.springframework.expression.spel.ast back to summary

private Class OperatorMatches.AccessCount

extends Object
Class Inheritance
  • java.lang.Object
  • org.springframework.expression.spel.ast.OperatorMatches.AccessCount

Field Summary

Modifier and TypeField and Description
private int

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

countback to summary
private int count

Constructor Detail

AccessCountback to summary
private AccessCount()

Method Detail

checkback to summary
public void check() throws IllegalStateException
org.springframework.expression.spel.ast back to summary

private Class OperatorMatches.MatcherInput

extends Object
implements CharSequence
Class Inheritance
  • java.lang.Object
  • org.springframework.expression.spel.ast.OperatorMatches.MatcherInput
All Implemented Interfaces
java.lang.CharSequence

Field Summary

Modifier and TypeField and Description
private final OperatorMatches.AccessCount
private final CharSequence

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public char
charAt(int
the index of the char value to be returned
index
)

Implements java.lang.CharSequence.charAt.

Returns the char value at the specified index.
public int
length()

Implements java.lang.CharSequence.length.

Returns the length of this character sequence.
public CharSequence
subSequence(int
the start index, inclusive
start
,
int
the end index, exclusive
end
)

Implements java.lang.CharSequence.subSequence.

Returns a CharSequence that is a subsequence of this sequence.
public String
toString()

Overrides java.lang.Object.toString.

Implements java.lang.CharSequence.toString.

Returns a string containing the characters in this sequence in the same order as this sequence.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

accessback to summary
private final OperatorMatches.AccessCount access
valueback to summary
private final CharSequence value

Constructor Detail

MatcherInputback to summary
public MatcherInput(CharSequence value, OperatorMatches.AccessCount access)

Method Detail

charAtback to summary
public char charAt(int index)

Implements java.lang.CharSequence.charAt.

Doc from java.lang.CharSequence.charAt.

Returns the char value at the specified index. An index ranges from zero to length() - 1. The first char value of the sequence is at index zero, the next at index one, and so on, as for array indexing.

If the char value specified by the index is a surrogate, the surrogate value is returned.

Parameters
index:int

the index of the char value to be returned

Returns:char

the specified char value

Annotations
@Override
lengthback to summary
public int length()

Implements java.lang.CharSequence.length.

Doc from java.lang.CharSequence.length.

Returns the length of this character sequence. The length is the number of 16-bit chars in the sequence.

Returns:int

the number of chars in this sequence

Annotations
@Override
subSequenceback to summary
public CharSequence subSequence(int start, int end)

Implements java.lang.CharSequence.subSequence.

Doc from java.lang.CharSequence.subSequence.

Returns a CharSequence that is a subsequence of this sequence. The subsequence starts with the char value at the specified index and ends with the char value at index end - 1. The length (in chars) of the returned sequence is end - start, so if start == end then an empty sequence is returned.

Parameters
start:int

the start index, inclusive

end:int

the end index, exclusive

Returns:CharSequence

the specified subsequence

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Implements java.lang.CharSequence.toString.

Doc from java.lang.CharSequence.toString.

Returns a string containing the characters in this sequence in the same order as this sequence. The length of the string will be the length of this sequence.

Returns:String

a string consisting of exactly this sequence of characters

Annotations
@Override