KickJava   Java API By Example, From Geeks To Geeks.

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


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.ComponentName;
25 import org.jacorb.notification.filter.EvaluationContext;
26 import org.jacorb.notification.filter.EvaluationException;
27 import org.jacorb.notification.filter.EvaluationResult;
28 import org.jacorb.notification.interfaces.Message;
29
30 import antlr.Token;
31
32 /**
33  * node that represents a COMPONENT Name
34  *
35  * @author Alphonse Bendt
36  * @version $Id: ETCLComponentName.java,v 1.7 2005/02/14 00:07:08 alphonse.bendt Exp $
37  */

38
39 public class ETCLComponentName extends AbstractTCLNode implements ComponentName
40 {
41     private final String JavaDoc value_;
42
43     private String JavaDoc componentName_;
44     
45     ////////////////////////////////////////
46

47     protected ETCLComponentName() {
48         super();
49         
50         value_ = null;
51     }
52
53     public ETCLComponentName( Token tok )
54     {
55         super( tok );
56
57         setName( "ComponentName" );
58         value_ = tok.getText();
59     }
60
61     ////////////////////////////////////////
62

63     public EvaluationResult evaluate( EvaluationContext context )
64         throws EvaluationException
65     {
66         EvaluationResult _ret;
67
68         Message _event = context.getCurrentMessage();
69
70         AbstractTCLNode _left = left();
71
72         if (_left == null) {
73             // this is the case when the expression just consists of
74
// '$'. $ denotes the current Message.
75

76             return EvaluationResult.fromAny( _event.toAny() );
77         }
78
79         switch (_left.getType()) {
80
81         case AbstractTCLNode.RUNTIME_VAR:
82             RuntimeVariableNode _var = ( RuntimeVariableNode ) _left;
83
84             _ret = _event.extractValue( context,
85                                         this,
86                                         _var );
87
88             break;
89
90         case AbstractTCLNode.DOT:
91             // fallthrough
92
case AbstractTCLNode.ASSOC:
93             _ret = _event.extractValue(context,
94                                        this );
95
96             break;
97         default:
98             // coming here means, we've hit a bug
99
throw new RuntimeException JavaDoc("Unexpected Nodetype: "
100                                        + getNameForType(_left.getType()));
101         }
102
103         return _ret;
104     }
105
106
107     public String JavaDoc toString()
108     {
109         return value_;
110     }
111
112
113     public void setComponentName( String JavaDoc name )
114     {
115         componentName_ = name;
116     }
117
118
119     public String JavaDoc getComponentName()
120     {
121         return componentName_;
122     }
123
124
125     public void acceptPostOrder( AbstractTCLVisitor visitor ) throws VisitorException
126     {
127         if (getFirstChild() != null) {
128             ( ( AbstractTCLNode ) getFirstChild() ).acceptPostOrder( visitor );
129         }
130         visitor.visitComponent( this );
131     }
132
133
134     public void acceptPreOrder( AbstractTCLVisitor visitor ) throws VisitorException
135     {
136         visitor.visitComponent( this );
137         ( ( AbstractTCLNode ) getFirstChild() ).acceptPreOrder( visitor );
138     }
139
140
141     public void acceptInOrder( AbstractTCLVisitor visitor ) throws VisitorException
142     {
143         ( ( AbstractTCLNode ) getFirstChild() ).acceptInOrder( visitor );
144         visitor.visitComponent( this );
145     }
146 }
147
Popular Tags