KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > fenyo > gnetwatch > targets > TargetInterface


1
2 /*
3  * GNetWatch
4  * Copyright 2006, 2007 Alexandre Fenyo
5  * gnetwatch@fenyo.net
6  *
7  * This file is part of GNetWatch.
8  *
9  * GNetWatch is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * GNetWatch is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with GNetWatch; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22  */

23
24 package net.fenyo.gnetwatch.targets;
25
26 import net.fenyo.gnetwatch.*;
27 import net.fenyo.gnetwatch.GUI.*;
28 import net.fenyo.gnetwatch.actions.*;
29 import net.fenyo.gnetwatch.data.*;
30
31 import org.apache.commons.logging.Log;
32 import org.apache.commons.logging.LogFactory;
33
34 /**
35  * TargetInterface implements an interface of an IP target.
36  * @author Alexandre Fenyo
37  * @version $Id: TargetInterface.java,v 1.6 2007/03/03 00:38:19 fenyo Exp $
38  */

39
40 public class TargetInterface extends Target {
41   private static Log log = LogFactory.getLog(TargetInterface.class);
42
43   private String JavaDoc interface_name; // not null
44

45   /**
46    * Constructor.
47    * @param name target name.
48    * @param interface_name interface name.
49    * @throws AlgorithmException exception.
50    */

51   // GUI thread
52
public TargetInterface(final String JavaDoc name, final String JavaDoc interface_name) throws AlgorithmException {
53     super(name);
54     this.interface_name = interface_name;
55     setItem(interface_name);
56   }
57
58   /**
59    * Initializes this target.
60    * @param gui current GUI instance.
61    * @return void.
62    */

63   // final because called by constructor (by means of setItem())
64
protected final void initialize(final GUI gui) {
65     super.initialize(gui);
66     if (gui != null) setImageInterface();
67   }
68
69   protected String JavaDoc getInterfaceName() {
70     return interface_name;
71   }
72
73   /**
74    * Checks that the parameter can be attached to this target.
75    * @param visual_element parameter to check.
76    * @return true if the parameter can be attached to this target.
77    */

78   public boolean canManageThisChild(final VisualElement visual_element) {
79     if (Target.class.isInstance(visual_element)) return true;
80     return false;
81   }
82
83   // we do not define equals() nor hashCode() since we want name being the discriminant
84
// instead of interface_name
85
}
86
Popular Tags