KickJava   Java API By Example, From Geeks To Geeks.

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


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.interfaces.Message;
28
29 /**
30  * @author Alphonse Bendt
31  * @version $Id: TypeNameShorthandNode.java,v 1.5 2005/02/14 00:07:08 alphonse.bendt Exp $
32  */

33
34 public class TypeNameShorthandNode extends ETCLComponentName
35 {
36     private static final AbstractTCLNode expandedPath_;
37     private static final String JavaDoc COMP_NAME = "$.header.fixed_header.event_type.type_name";
38     public static final String JavaDoc SHORT_NAME = "type_name";
39
40     static {
41         try
42         {
43             expandedPath_ = TCLParser.parse( COMP_NAME );
44             expandedPath_.acceptInOrder( new TCLCleanUp() );
45         }
46         catch ( Exception JavaDoc e )
47         {
48             // should never happen
49
throw new RuntimeException JavaDoc(e.getMessage());
50         }
51     }
52
53     public TypeNameShorthandNode()
54     {
55         setName( "TypeNameShorthandNode" );
56     }
57
58     public String JavaDoc getComponentName()
59     {
60         return COMP_NAME;
61     }
62
63     public void acceptInOrder( AbstractTCLVisitor v )
64     {}
65
66     public void acceptPostOrder( AbstractTCLVisitor v )
67     {}
68
69     public void acceptPreOrder( AbstractTCLVisitor v )
70     {}
71
72     public EvaluationResult evaluate( EvaluationContext context )
73         throws EvaluationException
74     {
75         Message _event = context.getCurrentMessage();
76
77         EvaluationResult _result;
78
79         switch ( _event.getType() )
80         {
81             case Message.TYPE_ANY:
82                 _result = expandedPath_.evaluate( context );
83                 break;
84
85             case Message.TYPE_STRUCTURED:
86                 String JavaDoc _domainName =
87                     _event.toStructuredEvent().header.fixed_header.event_type.type_name;
88
89                 _result = new EvaluationResult();
90                 _result.setString( _domainName );
91                 break;
92
93             default:
94                 throw new RuntimeException JavaDoc();
95         }
96
97         return _result;
98     }
99
100     public String JavaDoc toString()
101     {
102         return COMP_NAME;
103     }
104
105 }
106
Popular Tags