本文整理汇总了Java中org.springframework.expression.spel.SpelNode类的典型用法代码示例。如果您正苦于以下问题:Java SpelNode类的具体用法?Java SpelNode怎么用?Java SpelNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SpelNode类属于org.springframework.expression.spel包,在下文中一共展示了SpelNode类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getValueInternal
import org.springframework.expression.spel.SpelNode; //导入依赖的package包/类
@Override
public TypedValue getValueInternal(ExpressionState expressionState) throws EvaluationException {
if (this.constant != null) {
return this.constant;
}
else {
Map<Object, Object> returnValue = new LinkedHashMap<Object, Object>();
int childcount = getChildCount();
for (int c = 0; c < childcount; c++) {
// TODO allow for key being PropertyOrFieldReference like Indexer on maps
SpelNode keyChild = getChild(c++);
Object key = null;
if (keyChild instanceof PropertyOrFieldReference) {
PropertyOrFieldReference reference = (PropertyOrFieldReference) keyChild;
key = reference.getName();
}
else {
key = keyChild.getValue(expressionState);
}
Object value = getChild(c).getValue(expressionState);
returnValue.put(key, value);
}
return new TypedValue(returnValue);
}
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:26,代码来源:InlineMap.java
示例2: handle
import org.springframework.expression.spel.SpelNode; //导入依赖的package包/类
private void handle(SpelNode node, Class<?> expressionRoot) throws ExpressionValidationException{
if (node instanceof MethodReference) {
verify((MethodReference) node, expressionRoot);
} else if (node instanceof Operator) {
Operator operator = (Operator) node;
handle(operator.getLeftOperand(), expressionRoot);
handle(operator.getRightOperand(), expressionRoot);
} else if (node != null) {
for(int i=0; i<node.getChildCount(); i++) {
SpelNode child = node.getChild(i);
if (child instanceof VariableReference ||
child instanceof TypeReference ||
child instanceof BeanReference) {
// stop inspecting if it's a variable or type reference.
// We can handle this later if we get smart about resolving these
break;
}
handle(child, expressionRoot);
}
}
}
开发者ID:massfords,项目名称:spel-maven-plugin,代码行数:22,代码来源:ExpressionValidator.java
示例3: findPermissions
import org.springframework.expression.spel.SpelNode; //导入依赖的package包/类
/**
* Looks for permissions in given node and all its children
*
* @param node node that will be searched for permissions
* @return list of permissions
*/
private List<String> findPermissions(SpelNode node) {
List<String> list = new ArrayList<>(node.getChildCount());
if (startsWithIgnoreCase(node.toStringAST(), "hasRole") || startsWithIgnoreCase(node.toStringAST(), "hasAnyRole")) {
for (int i = 0; i < node.getChildCount(); ++i) {
list.add(remove(node.getChild(i).toStringAST(), '\''));
}
} else {
for (int i = 0; i < node.getChildCount(); ++i) {
list.addAll(findPermissions(node.getChild(i)));
}
}
LOGGER.debug("Found permissions: {}", list);
return list;
}
开发者ID:motech,项目名称:motech,代码行数:24,代码来源:SecurityAnnotationBeanPostProcessor.java
示例4: populateReferenceTypeArray
import org.springframework.expression.spel.SpelNode; //导入依赖的package包/类
private void populateReferenceTypeArray(ExpressionState state, Object newArray, TypeConverter typeConverter,
InlineList initializer, Class<?> componentType) {
TypeDescriptor toTypeDescriptor = TypeDescriptor.valueOf(componentType);
Object[] newObjectArray = (Object[]) newArray;
for (int i = 0; i < newObjectArray.length; i++) {
SpelNode elementNode = initializer.getChild(i);
Object arrayEntry = elementNode.getValue(state);
newObjectArray[i] = typeConverter.convertValue(arrayEntry, TypeDescriptor.forObject(arrayEntry), toTypeDescriptor);
}
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:ConstructorReference.java
示例5: populateReferenceTypeArray
import org.springframework.expression.spel.SpelNode; //导入依赖的package包/类
private void populateReferenceTypeArray(ExpressionState state, Object newArray, TypeConverter typeConverter,
InlineList initializer, Class<?> componentType) {
TypeDescriptor toTypeDescriptor = TypeDescriptor.valueOf(componentType);
Object[] newObjectArray = (Object[]) newArray;
for (int i = 0; i < newObjectArray.length; i++) {
SpelNode elementNode = initializer.getChild(i);
Object arrayEntry = elementNode.getValue(state);
newObjectArray[i] = typeConverter.convertValue(arrayEntry,
TypeDescriptor.forObject(arrayEntry), toTypeDescriptor);
}
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:13,代码来源:ConstructorReference.java
示例6: positionalInformation
import org.springframework.expression.spel.SpelNode; //导入依赖的package包/类
@Test
public void positionalInformation() throws EvaluationException, ParseException {
SpelExpression expr = new SpelExpressionParser().parseRaw("true and true or false");
SpelNode rootAst = expr.getAST();
OpOr operatorOr = (OpOr) rootAst;
OpAnd operatorAnd = (OpAnd) operatorOr.getLeftOperand();
SpelNode rightOrOperand = operatorOr.getRightOperand();
// check position for final 'false'
assertEquals(17, rightOrOperand.getStartPosition());
assertEquals(22, rightOrOperand.getEndPosition());
// check position for first 'true'
assertEquals(0, operatorAnd.getLeftOperand().getStartPosition());
assertEquals(4, operatorAnd.getLeftOperand().getEndPosition());
// check position for second 'true'
assertEquals(9, operatorAnd.getRightOperand().getStartPosition());
assertEquals(13, operatorAnd.getRightOperand().getEndPosition());
// check position for OperatorAnd
assertEquals(5, operatorAnd.getStartPosition());
assertEquals(8, operatorAnd.getEndPosition());
// check position for OperatorOr
assertEquals(14, operatorOr.getStartPosition());
assertEquals(16, operatorOr.getEndPosition());
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:29,代码来源:SpelParserTests.java
示例7: validate
import org.springframework.expression.spel.SpelNode; //导入依赖的package包/类
public void validate(String expression, Class<?> expressionRoot) throws ExpressionValidationException, ParseException {
SpelExpression exp = (SpelExpression) parser.parseExpression(expression);
if (expressionRoot != null) {
SpelNode node = exp.getAST();
handle(node, expressionRoot);
}
}
开发者ID:massfords,项目名称:spel-maven-plugin,代码行数:8,代码来源:ExpressionValidator.java
示例8: printAST
import org.springframework.expression.spel.SpelNode; //导入依赖的package包/类
private static void printAST(PrintStream out, SpelNode t, String indent) {
if (t != null) {
StringBuilder sb = new StringBuilder();
sb.append(indent).append(t.getClass().getSimpleName());
sb.append(" value:").append(t.toStringAST());
sb.append(t.getChildCount() < 2 ? "" : " #children:" + t.getChildCount());
out.println(sb.toString());
for (int i = 0; i < t.getChildCount(); i++) {
printAST(out, t.getChild(i), indent + " ");
}
}
}
开发者ID:leopardoooo,项目名称:cambodia,代码行数:13,代码来源:SpelUtilities.java
示例9: getChild
import org.springframework.expression.spel.SpelNode; //导入依赖的package包/类
@Override
public SpelNode getChild(int index) {
return this.children[index];
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:SpelNodeImpl.java
示例10: getAST
import org.springframework.expression.spel.SpelNode; //导入依赖的package包/类
/**
* @return return the Abstract Syntax Tree for the expression
*/
public SpelNode getAST() {
return this.ast;
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:7,代码来源:SpelExpression.java
示例11: checkIfConstant
import org.springframework.expression.spel.SpelNode; //导入依赖的package包/类
/**
* If all the components of the list are constants, or lists/maps that themselves
* contain constants, then a constant list can be built to represent this node.
* This will speed up later getValue calls and reduce the amount of garbage created.
*/
private void checkIfConstant() {
boolean isConstant = true;
for (int c = 0, max = getChildCount(); c < max; c++) {
SpelNode child = getChild(c);
if (!(child instanceof Literal)) {
if (child instanceof InlineList) {
InlineList inlineList = (InlineList) child;
if (!inlineList.isConstant()) {
isConstant = false;
break;
}
}
else if (child instanceof InlineMap) {
InlineMap inlineMap = (InlineMap) child;
if (!inlineMap.isConstant()) {
isConstant = false;
break;
}
}
else if (!((c%2)==0 && (child instanceof PropertyOrFieldReference))) {
isConstant = false;
break;
}
}
}
if (isConstant) {
Map<Object,Object> constantMap = new LinkedHashMap<Object,Object>();
int childCount = getChildCount();
for (int c = 0; c < childCount; c++) {
SpelNode keyChild = getChild(c++);
SpelNode valueChild = getChild(c);
Object key = null;
Object value = null;
if (keyChild instanceof Literal) {
key = ((Literal) keyChild).getLiteralValue().getValue();
}
else if (keyChild instanceof PropertyOrFieldReference) {
key = ((PropertyOrFieldReference) keyChild).getName();
}
else {
return;
}
if (valueChild instanceof Literal) {
value = ((Literal) valueChild).getLiteralValue().getValue();
}
else if (valueChild instanceof InlineList) {
value = ((InlineList) valueChild).getConstantValue();
}
else if (valueChild instanceof InlineMap) {
value = ((InlineMap) valueChild).getConstantValue();
}
constantMap.put(key, value);
}
this.constant = new TypedValue(Collections.unmodifiableMap(constantMap));
}
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:62,代码来源:InlineMap.java
示例12: getAST
import org.springframework.expression.spel.SpelNode; //导入依赖的package包/类
/**
* Return the Abstract Syntax Tree for the expression.
*/
public SpelNode getAST() {
return this.ast;
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:7,代码来源:SpelExpression.java
示例13: getChild
import org.springframework.expression.spel.SpelNode; //导入依赖的package包/类
public SpelNode getChild(int index) {
return children[index];
}
开发者ID:deathspeeder,项目名称:class-guard,代码行数:4,代码来源:SpelNodeImpl.java
示例14: getAST
import org.springframework.expression.spel.SpelNode; //导入依赖的package包/类
/**
* @return return the Abstract Syntax Tree for the expression
*/
public SpelNode getAST() {
return ast;
}
开发者ID:deathspeeder,项目名称:class-guard,代码行数:7,代码来源:SpelExpression.java
注:本文中的org.springframework.expression.spel.SpelNode类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论