KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > clif > scenario > util > isac > util > tree > Node


1 /*
2 * CLIF is a Load Injection Framework
3 * Copyright (C) 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 * CLIF
20 *
21 * Contact: clif@objectweb.org
22 */

23 package org.objectweb.clif.scenario.util.isac.util.tree;
24
25 import org.apache.log4j.Category;
26
27 /**
28  * This interface defined the differents types allowed for tree nodes
29  *
30  * @author JC Meillaud
31  * @author A Peyrard
32  */

33 public class Node {
34     static Category cat = Category.getInstance(Node.class.getName()) ;
35     /**
36      * This type is used to be an unknow type
37      */

38     public static final String JavaDoc UNKNOW = "unknow";
39     /**
40      * Type for a control scenario
41      */

42     public static final String JavaDoc SCENARIO = "scenario";
43     /**
44      * Type for a control node
45      */

46     public static final String JavaDoc IF = "if";
47     /**
48      * Type for a control node
49      */

50     public static final String JavaDoc THEN = "then";
51     /**
52      * Type for a control node
53      */

54     public static final String JavaDoc ELSE = "else";
55     /**
56      * Type for a control node
57      */

58     public static final String JavaDoc WHILE = "while";
59     /**
60      * Type for a control node
61      */

62     public static final String JavaDoc PREEMPTIVE = "preemptive";
63     /**
64      * Type for a control node
65      */

66     public static final String JavaDoc NCHOICE = "nchoice";
67     /**
68      * Type for separate the different choice for a nchoice controler
69      */

70     public static final String JavaDoc CHOICE = "choice" ;
71     /**
72      *
73      */

74     public static final String JavaDoc BEHAVIORS = "behaviors";
75     /**
76      *
77      */

78     public static final String JavaDoc BEHAVIOR = "behavior";
79     /**
80      *
81      */

82     public static final String JavaDoc PLUGINS = "plugins";
83     /**
84      *
85      */

86     public static final String JavaDoc TEST = "test";
87     /**
88      *
89      */

90     public static final String JavaDoc TIMER = "timer";
91     /**
92      *
93      */

94     public static final String JavaDoc SAMPLE = "sample";
95     /**
96      *
97      */

98     public static final String JavaDoc USE = "use";
99     /**
100      *
101      */

102     public static final String JavaDoc LOAD_PROFILE = "loadprofile";
103
104     
105     public static final String JavaDoc CONDITION = "condition" ;
106     public static final String JavaDoc PARAMS = "params" ;
107     public static final String JavaDoc PARAM = "param" ;
108     /**
109     * type for a definition of a group
110     */

111    public static final String JavaDoc GROUP = "group";
112    /**
113     * type for the definition of a ramp
114     */

115    public static final String JavaDoc RAMP = "ramp";
116     /**
117      * type for the definition of the points of a ramp
118      */

119     public static final String JavaDoc POINTS = "points";
120     /**
121      * type for a point node
122      */

123     public static final String JavaDoc POINT = "point";
124     
125
126     /**
127      * Method which evaluate if the given string is a type of a plugin node
128      * @param type The type which will be evaluate
129      * @return True if it's a plugin node
130      */

131     public static boolean isPluginNode(String JavaDoc type) {
132         cat.debug("-> isPluginNode") ;
133         if (type == null)
134             return false ;
135         if (type.equals(Node.SAMPLE))
136             return true;
137         if (type.equals(Node.TIMER))
138             return true;
139         if (type.equals(Node.TEST))
140             return true;
141         if (type.equals(Node.USE))
142             return true;
143         return false;
144     }
145     
146     /**
147      * Method which evaluate if the given string is a type of a controler node
148      * @param type The type which will be evaluate
149      * @return True if it's a controler type
150      */

151     public static boolean isControllerNode(String JavaDoc type) {
152         cat.debug("-> isControllerNode") ;
153         if (type == null)
154             return false;
155         if (type.equals(Node.IF))
156             return true ;
157         if (type.equals(Node.WHILE))
158             return true ;
159         if (type.equals(Node.PREEMPTIVE))
160             return true ;
161         return false ;
162     }
163
164     /**
165      * This method evaluate if the given type is a behaviors tree node
166      * @param type The type wich will be evaluate
167      * @return True if the type is a behaviors tree node, False in the others cases
168      */

169     public static boolean isBehaviorsNode(String JavaDoc type) {
170         cat.debug("-> isBehaviorsNode") ;
171         if (type == null)
172             return false ;
173         if (type.equals(Node.SAMPLE))
174             return true;
175         if (type.equals(Node.TIMER))
176             return true;
177         if (type.equals(Node.TEST))
178             return true;
179         if (type.equals(Node.USE))
180             return true;
181         if (type.equals(Node.IF))
182             return true ;
183         if (type.equals(Node.THEN))
184             return true ;
185         if (type.equals(Node.ELSE))
186             return true ;
187         if (type.equals(Node.WHILE))
188             return true ;
189         if (type.equals(Node.PREEMPTIVE))
190             return true ;
191         if (type.equals(Node.NCHOICE))
192             return true ;
193         if (type.equals(Node.CHOICE))
194             return true ;
195         if (type.equals(Node.BEHAVIORS))
196             return true ;
197         if (type.equals(Node.BEHAVIOR))
198             return true ;
199         if (type.equals(Node.PLUGINS))
200             return true ;
201         return false;
202     }
203     
204     /**
205      * Method which return if the type is a structure node type
206      * @param type The node type
207      * @return True id the type is structure node type
208      */

209     public static boolean isStructureNode(String JavaDoc type) {
210         cat.debug("-> isStructureNode") ;
211         if (type == null)
212             return false ;
213         if (type.equals(BEHAVIOR))
214             return true ;
215         if (type.equals(PLUGINS))
216             return true ;
217         if (type.equals(BEHAVIORS))
218             return true ;
219         return false ;
220     }
221 }
222
Popular Tags