fixing TODOs
This commit is contained in:
parent
80075f18ce
commit
88c370ad5d
|
|
@ -20,12 +20,12 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.antlr.runtime.Token;
|
import org.antlr.runtime.Token;
|
||||||
import org.springframework.expression.EvaluationException;
|
import org.springframework.expression.EvaluationException;
|
||||||
|
import org.springframework.expression.spel.ExpressionState;
|
||||||
import org.springframework.expression.spel.SpelException;
|
import org.springframework.expression.spel.SpelException;
|
||||||
import org.springframework.expression.spel.SpelMessages;
|
import org.springframework.expression.spel.SpelMessages;
|
||||||
import org.springframework.expression.spel.ExpressionState;
|
|
||||||
|
|
||||||
// TODO 2 support multidimensional arrays
|
// TODO support multidimensional arrays
|
||||||
// TODO 3 support correct syntax for multidimensional [][][] and not [,,,]
|
// TODO support correct syntax for multidimensional [][][] and not [,,,]
|
||||||
/**
|
/**
|
||||||
* An Indexer can index into some proceeding structure to access a particular piece of it. Supported structures are:
|
* An Indexer can index into some proceeding structure to access a particular piece of it. Supported structures are:
|
||||||
* strings/collections (lists/sets)/arrays
|
* strings/collections (lists/sets)/arrays
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,9 @@ package org.springframework.expression.spel.ast;
|
||||||
|
|
||||||
import org.antlr.runtime.Token;
|
import org.antlr.runtime.Token;
|
||||||
import org.springframework.expression.EvaluationException;
|
import org.springframework.expression.EvaluationException;
|
||||||
|
import org.springframework.expression.spel.ExpressionState;
|
||||||
import org.springframework.expression.spel.SpelException;
|
import org.springframework.expression.spel.SpelException;
|
||||||
import org.springframework.expression.spel.SpelMessages;
|
import org.springframework.expression.spel.SpelMessages;
|
||||||
import org.springframework.expression.spel.ExpressionState;
|
|
||||||
|
|
||||||
public class OperatorSoundsLike extends Operator {
|
public class OperatorSoundsLike extends Operator {
|
||||||
|
|
||||||
|
|
@ -32,19 +32,19 @@ public class OperatorSoundsLike extends Operator {
|
||||||
Object left = getLeftOperand().getValue(state);
|
Object left = getLeftOperand().getValue(state);
|
||||||
Object right = getRightOperand().getValue(state);
|
Object right = getRightOperand().getValue(state);
|
||||||
if (!(left instanceof String)) {
|
if (!(left instanceof String)) {
|
||||||
throw new SpelException(getCharPositionInLine(), SpelMessages.SOUNDSLIKE_NEEDS_STRING_OPERAND, left.getClass()
|
throw new SpelException(getCharPositionInLine(), SpelMessages.SOUNDSLIKE_NEEDS_STRING_OPERAND, left
|
||||||
.getName());
|
.getClass().getName());
|
||||||
}
|
}
|
||||||
if (!(right instanceof String)) {
|
if (!(right instanceof String)) {
|
||||||
throw new SpelException(getCharPositionInLine(), SpelMessages.SOUNDSLIKE_NEEDS_STRING_OPERAND, right.getClass()
|
throw new SpelException(getCharPositionInLine(), SpelMessages.SOUNDSLIKE_NEEDS_STRING_OPERAND, right
|
||||||
.getName());
|
.getClass().getName());
|
||||||
}
|
}
|
||||||
String leftSoundex = computeSoundex((String) left);
|
String leftSoundex = computeSoundex((String) left);
|
||||||
String rightSoundex = computeSoundex((String) right);
|
String rightSoundex = computeSoundex((String) right);
|
||||||
return state.getTypeComparator().compare(leftSoundex, rightSoundex) == 0;
|
return state.getTypeComparator().compare(leftSoundex, rightSoundex) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO OPTIMIZE better algorithm implementation is possible for soundex
|
// TODO if we keep soundslike, improve upon this basic implementation
|
||||||
private String computeSoundex(String input) {
|
private String computeSoundex(String input) {
|
||||||
if (input == null || input.length() == 0)
|
if (input == null || input.length() == 0)
|
||||||
return "0000";
|
return "0000";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue