KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > notification > filter > etcl > RuntimeVariableNode


1 package org.jacorb.notification.filter.etcl;
2
3 /*
4  * JacORB - a free Java ORB
5  *
6  * Copyright (C) 1999-2004 Gerald Brose
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the Free
20  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  *
22  */

23
24 import org.jacorb.notification.filter.EvaluationContext;
25 import org.jacorb.notification.filter.EvaluationException;
26 import org.jacorb.notification.filter.EvaluationResult;
27 import org.jacorb.notification.filter.RuntimeVariable;
28
29 import antlr.Token;
30
31 /**
32  * @author Alphonse Bendt
33  * @version $Id: RuntimeVariableNode.java,v 1.6 2004/08/13 11:55:29 alphonse.bendt Exp $
34  */

35
36 public class RuntimeVariableNode
37     extends AbstractTCLNode
38     implements RuntimeVariable
39 {
40     private final String JavaDoc value_;
41     private final AbstractTCLNode strategy_;
42
43     public RuntimeVariableNode( Token token )
44     {
45         super(token);
46
47         value_ = token.getText();
48
49         strategy_ = newStrategy(value_);
50     }
51
52     public EvaluationResult evaluate(EvaluationContext context)
53         throws EvaluationException
54     {
55         return strategy_.evaluate(context);
56     }
57
58     private AbstractTCLNode newStrategy(String JavaDoc variable) {
59         if (DomainNameShorthandNode.SHORT_NAME.equals(variable)) {
60             return new DomainNameShorthandNode();
61         } else if (TypeNameShorthandNode.SHORT_NAME.equals(variable)) {
62             return new TypeNameShorthandNode();
63         } else if (EventNameShorthandNode.SHORT_NAME.equals(variable)) {
64             return new EventNameShorthandNode();
65         } else if (CurrentTimeNode.SHORT_NAME.equals(variable)) {
66             return new CurrentTimeNode();
67         } else {
68             return new PropertyShorthandNode(variable);
69         }
70     }
71
72     public void acceptPostOrder( AbstractTCLVisitor visitor ) throws VisitorException
73     {
74         if (getFirstChild() != null) {
75             ( ( AbstractTCLNode ) getFirstChild() ).acceptPostOrder( visitor );
76         }
77         visitor.visitRuntimeVariable( this );
78     }
79
80     public void acceptPreOrder( AbstractTCLVisitor visitor ) throws VisitorException
81     {
82         visitor.visitRuntimeVariable( this );
83
84         if (getFirstChild() != null) {
85             ( ( AbstractTCLNode ) getFirstChild() ).acceptPreOrder( visitor );
86         }
87     }
88
89     public void acceptInOrder( AbstractTCLVisitor visitor ) throws VisitorException
90     {
91         if (getFirstChild() != null) {
92             ( ( AbstractTCLNode ) getFirstChild() ).acceptInOrder( visitor );
93         }
94
95         visitor.visitRuntimeVariable(this);
96     }
97
98     public String JavaDoc toString() {
99         return value_;
100     }
101
102     public String JavaDoc getIdentifier() {
103         return value_;
104     }
105
106 }
107
Popular Tags