KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > fractal > adl > Node


1 /***
2  * Fractal ADL Parser
3  * Copyright (C) 2002-2004 France Telecom R&D
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Contact: Eric.Bruneton@rd.francetelecom.com
20  *
21  * Author: Eric Bruneton
22  */

23
24 package org.objectweb.fractal.adl;
25
26 import java.util.Map JavaDoc;
27
28 /**
29  * An Abstract Syntax Tree (AST) node. Each node has a type (which can be
30  * though of as the tag of an XML element), and can have attributes as well as
31  * sub nodes (which can be though of as XML attributes and XML sub elements).
32  */

33
34 public interface Node {
35
36   /**
37    * Returns the type of this node.
38    *
39    * @return the type of this node.
40    */

41   
42   String JavaDoc astGetType ();
43
44   /**
45    * Returns the source of this node.
46    *
47    * @return the source of this node (such as a file name).
48    */

49   
50   String JavaDoc astGetSource ();
51
52   /**
53    * Sets the source of this node.
54    *
55    * @param source the source of this node (such as a file name).
56    */

57   
58   void astSetSource (String JavaDoc source);
59
60   /**
61    * Returns the attributes of this node.
62    *
63    * @return the attributes of this node.
64    */

65   
66   Map JavaDoc astGetAttributes ();
67
68   /**
69    * Sets the attributes of this node.
70    *
71    * @param attributes the attributes of this node that must be changed
72    * (attributes that are not defined in this argument are left unchanged).
73    */

74   
75   void astSetAttributes (Map JavaDoc attributes);
76
77   /**
78    * Returns a decoration of this node.
79    *
80    * @param name the decoration's name.
81    * @return a decoration of this node. May be <code>null</code> if this node
82    * does not have a decoration with the specified name.
83    */

84   
85   Object JavaDoc astGetDecoration (String JavaDoc name);
86   
87   /**
88    * Sets a decoration of this node.
89    *
90    * @param name the decoration's name.
91    * @param decoration a decoration.
92    */

93   
94   void astSetDecoration (String JavaDoc name, Object JavaDoc decoration);
95  
96   /**
97    * Returns the decorations of this node.
98    *
99    * @return the decorations of this node.
100    */

101   
102   Map JavaDoc astGetDecorations ();
103   
104   /**
105    * Sets the decorations of this node.
106    *
107    * @param decorations the decorations of this node that must be changed
108    * (decorations that are not defined in this argument are left unchanged).
109    */

110   
111   void astSetDecorations (Map JavaDoc decorations);
112   
113   /**
114    * Returns the types of the sub nodes that this node can have.
115    *
116    * @return the types of the sub nodes that this node can have.
117    */

118   
119   String JavaDoc[] astGetNodeTypes ();
120
121   /**
122    * Returns the sub nodes of this node that are of the given type.
123    *
124    * @param type a node type.
125    * @return the sub nodes of this node that are of the given type.
126    */

127   
128   Node[] astGetNodes (String JavaDoc type);
129
130   /**
131    * Adds a sub node to this node.
132    *
133    * @param type the type of the sub node to be added.
134    * @param node the sub node to be added to this node.
135    */

136   
137   void astAddNode (Node node);
138
139   /**
140    * Removes a sub node from this node.
141    *
142    * @param type the type of the sub node to be added.
143    * @param node the sub node to be removed from this node.
144    */

145   
146   void astRemoveNode (Node node);
147   
148   /**
149    * Creates a new, empty AST node of the same type as this node.
150    *
151    * @return a new, empty AST node of the same type as this node.
152    */

153   
154   Node astNewInstance ();
155 }
156
Popular Tags