KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.util.Hashtable JavaDoc;
26
27 import org.apache.log4j.Category;
28 import org.objectweb.clif.scenario.util.isac.util.tree.nodes.NonePluginNode;
29 /**
30  * Implementation of an object storing the full description of a tree node
31  *
32  * @author JC Meillaud
33  * @author A Peyrard
34  */

35 public class NodeDescription {
36     static Category cat = Category.getInstance(NodeDescription.class.getName()) ;
37     
38     private String JavaDoc type;
39     private Hashtable JavaDoc params;
40     private String JavaDoc plugin;
41     private String JavaDoc actionName;
42
43     /**
44      * Build a node description element, the type of the node must be defined in
45      * parameter
46      *
47      * @param type
48      * The node type
49      */

50     public NodeDescription(String JavaDoc type) {
51         cat.debug("-> constructor") ;
52         this.type = type;
53         this.params = new Hashtable JavaDoc() ;
54         this.plugin = null;
55         this.actionName = null;
56     }
57
58     /**
59      * Build a new element which is a copy of the given one
60      *
61      * @param node
62      * The node description to be copied
63      */

64     public NodeDescription(NodeDescription node) {
65         cat.debug("-> constructor : copy") ;
66         if (node != null) {
67             this.type = new String JavaDoc(node.getType());
68             this.params = (Hashtable JavaDoc) node.getParams().clone();
69             if (node.getPlugin() != null)
70                 this.plugin = new String JavaDoc(node.getPlugin());
71             if (node.getActionName() != null)
72                 this.actionName = new String JavaDoc(node.getActionName());
73         }
74     }
75
76     /**
77      * Attribute actionName getter
78      *
79      * @return The name of the action representing by this node
80      */

81     public String JavaDoc getActionName() {
82         cat.debug("-> getActionName") ;
83         return actionName;
84     }
85
86     /**
87      * Attribute params getter
88      *
89      * @return The parameters values in a hashtable
90      */

91     public Hashtable JavaDoc getParams() {
92         cat.debug("-> getParams") ;
93         return params;
94     }
95
96     /**
97      * Attribute plugin getter
98      *
99      * @return The plugin name
100      */

101     public String JavaDoc getPlugin() {
102         cat.debug("-> getPlugin") ;
103         return plugin;
104     }
105
106     /**
107      * Attribute type getter
108      *
109      * @return The type of the node
110      */

111     public String JavaDoc getType() {
112         cat.debug("-> getType") ;
113         return type;
114     }
115
116     /**
117      * Attribute actionName setter
118      *
119      * @param string
120      * The name of the action representing by this node
121      */

122     public void setActionName(String JavaDoc string) {
123         cat.debug("-> setActionName") ;
124         actionName = string;
125     }
126
127     /**
128      * Attribute params setter
129      *
130      * @param hashtable
131      * The table containing all parameters values
132      */

133     public void setParams(Hashtable JavaDoc hashtable) {
134         cat.debug("-> setParams") ;
135         params = hashtable;
136     }
137
138     /**
139      * Attribute plugin setter
140      *
141      * @param string
142      * The plugin name
143      */

144     public void setPlugin(String JavaDoc string) {
145         cat.debug("-> setPlugin") ;
146         plugin = string;
147     }
148
149     /**
150      * Create a new node description of the specified type, if this type is
151      * known
152      *
153      * @param type
154      * The type of the node which will be created
155      * @return The node description
156      */

157     public static NodeDescription createNonePluginNode(String JavaDoc type) {
158         cat.debug("-> createNonePluginNode") ;
159         NodeDescription node = NonePluginNode.createNodeDescription(type) ;
160         
161
162         return node;
163     }
164
165     /**
166      * This method serialize the object
167      * @return the object informations representing by a string
168      */

169     public String JavaDoc toString() {
170         return new String JavaDoc("{type:"+type+",params:"+params+",plugin"+plugin+",an:"+actionName+"}") ;
171     }
172 }
Popular Tags