KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > dream > multiplexer > Attachment


1 /**
2  * Dream
3  * Copyright (C) 2003-2004 INRIA Rhone-Alpes
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 : dream@objectweb.org
20  *
21  * Initial developer(s): Vivien Quema
22  * Contributor(s):
23  */

24
25 package org.objectweb.dream.multiplexer;
26
27 import java.io.Serializable JavaDoc;
28 import java.util.Map JavaDoc;
29
30 import org.objectweb.dream.Pull;
31 import org.objectweb.dream.Push;
32
33 /**
34  * This class defines an Attachement.
35  *
36  * @author <a HREF="mailto:Vivien.Quema@inrialpes.fr">Vivien Quema </a>
37  * @version 1.0
38  */

39 public class Attachment implements Serializable JavaDoc, Cloneable JavaDoc
40 {
41
42   /** The id of the attachment. */
43   protected int id;
44
45   /** The name of attached inputs. */
46   protected String JavaDoc[] inputNames;
47
48   /** The attached inputs. */
49   protected Pull[] inputs;
50
51   /** The context to be passed to inputs when they are used. */
52   protected Map JavaDoc[] inputContexts;
53
54   /** The name of the outputs to which inputs are attached. */
55   protected String JavaDoc[] outputNames;
56
57   /** The outputs to which inputs are attached. */
58   protected Push[] outputs;
59
60   /** The context to be passed to outputs when they are used. */
61   protected Map JavaDoc[] outputContexts;
62
63   /**
64    * Creates a new <code>Attachment</code> object
65    *
66    * @param id the id of the attachment.
67    * @param inputNames the names of the attached inputs.
68    * @param inputs the attached inputs.
69    * @param inputContexts the context associated with attached inputs.
70    * @param outputNames the names of the attached outputs.
71    * @param outputs the attached outputs.
72    * @param outputContexts the context associated with attached outputs.
73    */

74   public Attachment(int id, String JavaDoc[] inputNames, Pull[] inputs,
75       Map JavaDoc[] inputContexts, String JavaDoc[] outputNames, Push[] outputs,
76       Map JavaDoc[] outputContexts)
77   {
78     this.id = id;
79     this.inputNames = inputNames;
80     this.inputs = inputs;
81     this.inputContexts = inputContexts;
82     this.outputNames = outputNames;
83     this.outputs = outputs;
84     this.outputContexts = outputContexts;
85   }
86
87   /**
88    * @return the id.
89    */

90   public int getId()
91   {
92     return id;
93   }
94
95   /**
96    * @return the inputContexts.
97    */

98   public Map JavaDoc[] getInputContexts()
99   {
100     return inputContexts;
101   }
102
103   /**
104    * @param inputContexts the inputContexts to set.
105    */

106   public void setInputContexts(Map JavaDoc[] inputContexts)
107   {
108     this.inputContexts = inputContexts;
109   }
110
111   /**
112    * @return the inputNames.
113    */

114   public String JavaDoc[] getInputNames()
115   {
116     return inputNames;
117   }
118
119   /**
120    * @param inputNames the inputNames to set.
121    */

122   public void setInputNames(String JavaDoc[] inputNames)
123   {
124     this.inputNames = inputNames;
125   }
126
127   /**
128    * @return the outputContexts.
129    */

130   public Map JavaDoc[] getOutputContexts()
131   {
132     return outputContexts;
133   }
134
135   /**
136    * @param outputContexts the outputContexts to set.
137    */

138   public void setOutputContexts(Map JavaDoc[] outputContexts)
139   {
140     this.outputContexts = outputContexts;
141   }
142
143   /**
144    * @return the outputNames.
145    */

146   public String JavaDoc[] getOutputNames()
147   {
148     return outputNames;
149   }
150
151   /**
152    * @param outputNames the outputNames to set.
153    */

154   public void setOutputNames(String JavaDoc[] outputNames)
155   {
156     this.outputNames = outputNames;
157   }
158
159   /**
160    * @return the inputs.
161    */

162   public Pull[] getInputs()
163   {
164     return inputs;
165   }
166
167   /**
168    * @param inputs the inputs to set.
169    */

170   public void setInputs(Pull[] inputs)
171   {
172     this.inputs = inputs;
173   }
174
175   /**
176    * @return the outputs.
177    */

178   public Push[] getOutputs()
179   {
180     return outputs;
181   }
182
183   /**
184    * @param outputs the outputs to set.
185    */

186   public void setOutputs(Push[] outputs)
187   {
188     this.outputs = outputs;
189   }
190
191   /**
192    * @see java.lang.Object#hashCode()
193    */

194   public int hashCode()
195   {
196     return id;
197   }
198
199   /**
200    * Returns <code>true</code> iff the specified object is an Attachment with
201    * the same id.
202    *
203    * @see java.lang.Object#equals(java.lang.Object)
204    */

205   public boolean equals(Object JavaDoc obj)
206   {
207     if (obj instanceof Attachment)
208     {
209       return (id == ((Attachment) obj).id);
210     }
211     return false;
212   }
213
214   /**
215    * Returns a clone of this attachment.
216    * <p>
217    * <i>Notes: </i> inputs, inputContexts, outputs, and outputs are set to
218    * <code>null</code>.
219    *
220    * @return a clone of this attachment.
221    */

222   public Object JavaDoc clone()
223   {
224     try
225     {
226       Attachment obj = (Attachment) super.clone();
227       // the inputs and outputs
228
obj.inputs = null;
229       obj.outputs = null;
230       obj.inputContexts = null;
231       obj.outputContexts = null;
232       // the inputNames
233
obj.inputNames = new String JavaDoc[inputNames.length];
234       for (int i = 0; i < inputNames.length; i++)
235       {
236         obj.inputNames[i] = inputNames[i];
237       }
238       // the outputNames
239
obj.outputNames = new String JavaDoc[outputNames.length];
240       for (int i = 0; i < outputNames.length; i++)
241       {
242         obj.outputNames[i] = outputNames[i];
243       }
244       return obj;
245     }
246     catch (CloneNotSupportedException JavaDoc e)
247     {
248       // this shouldn't happen, since we are Cloneable
249
throw new InternalError JavaDoc();
250     }
251   }
252 }
Popular Tags