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 super( id );
35 }
36
37 public ASTRootVarRef( OgnlParser p, int id )
38 {
39 super( p, id );
40 }
41
42 protected Object getValueBody( OgnlContext context, Object source )
43 throws OgnlException
44 {
45 return context.getRoot();
46 }
47
48 protected void setValueBody( OgnlContext context, Object target, Object value )
49 throws OgnlException
50 {
51 context.setRoot( value );
52 }
53
54 public String toGetSourceString( OgnlContext context, Object target )
55 {
56 if ( target != null )
57 {
58 getterClass = target.getClass();
59 }
60
61 if ( getterClass != null )
62 {
63
64 context.setCurrentType( getterClass );
65 }
66
67 if ( parent == null || ( getterClass != null && getterClass.isArray() ) )
68 {
69 return "";
70 }
71 else
72 {
73 return ExpressionCompiler.getRootExpression( this, target, context );
74 }
75 }
76
77 public String toSetSourceString( OgnlContext context, Object target )
78 {
79 if ( parent == null || ( getterClass != null && getterClass.isArray() ) )
80 {
81 return "";
82 }
83 else
84 {
85 return "$3";
86 }
87 }
88
89 public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
90 throws OgnlException
91 {
92 return visitor.visit( this, data );
93 }
94 }