1 | |
package org.apache.commons.ognl; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
import org.apache.commons.ognl.enhance.ExpressionCompiler; |
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
public class ASTRootVarRef |
30 | |
extends ASTVarRef |
31 | |
{ |
32 | |
public ASTRootVarRef( int id ) |
33 | |
{ |
34 | 31 | super( id ); |
35 | 31 | } |
36 | |
|
37 | |
public ASTRootVarRef( OgnlParser p, int id ) |
38 | |
{ |
39 | 0 | super( p, id ); |
40 | 0 | } |
41 | |
|
42 | |
protected Object getValueBody( OgnlContext context, Object source ) |
43 | |
throws OgnlException |
44 | |
{ |
45 | 17 | return context.getRoot(); |
46 | |
} |
47 | |
|
48 | |
protected void setValueBody( OgnlContext context, Object target, Object value ) |
49 | |
throws OgnlException |
50 | |
{ |
51 | 0 | context.setRoot( value ); |
52 | 0 | } |
53 | |
|
54 | |
public String toGetSourceString( OgnlContext context, Object target ) |
55 | |
{ |
56 | 8 | if ( target != null ) |
57 | |
{ |
58 | 8 | getterClass = target.getClass(); |
59 | |
} |
60 | |
|
61 | 8 | if ( getterClass != null ) |
62 | |
{ |
63 | |
|
64 | 8 | context.setCurrentType( getterClass ); |
65 | |
} |
66 | |
|
67 | 8 | if ( parent == null || ( getterClass != null && getterClass.isArray() ) ) |
68 | |
{ |
69 | 5 | return ""; |
70 | |
} |
71 | |
else |
72 | |
{ |
73 | 3 | return ExpressionCompiler.getRootExpression( this, target, context ); |
74 | |
} |
75 | |
} |
76 | |
|
77 | |
public String toSetSourceString( OgnlContext context, Object target ) |
78 | |
{ |
79 | 5 | if ( parent == null || ( getterClass != null && getterClass.isArray() ) ) |
80 | |
{ |
81 | 5 | return ""; |
82 | |
} |
83 | |
else |
84 | |
{ |
85 | 0 | return "$3"; |
86 | |
} |
87 | |
} |
88 | |
|
89 | |
public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data ) |
90 | |
throws OgnlException |
91 | |
{ |
92 | 0 | return visitor.visit( this, data ); |
93 | |
} |
94 | |
} |