KickJava   Java API By Example, From Geeks To Geeks.

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


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.GUI;
28 import net.fenyo.gnetwatch.GUI.VisualElement;
29 import net.fenyo.gnetwatch.actions.ActionPing;
30 import net.fenyo.gnetwatch.data.EventReachable;
31
32 import org.apache.commons.logging.Log;
33 import org.apache.commons.logging.LogFactory;
34
35 /**
36  * TargetGroup implements a target that can contain other targets.
37  * @author Alexandre Fenyo
38  * @version $Id: TargetGroup.java,v 1.8 2007/03/03 00:38:19 fenyo Exp $
39  */

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

46   /**
47    * Constructor.
48    * @param name target name.
49    * @param group_name group name.
50    * @throws AlgorithmException exception.
51    */

52   // GUI thread
53
public TargetGroup(final String JavaDoc name, final String JavaDoc group_name) throws AlgorithmException {
54     super(name);
55     this.group_name = group_name;
56     setItem(group_name);
57   }
58
59   /**
60    * Returns the group name.
61    * @param none.
62    * @return String group name.
63    */

64   protected String JavaDoc getGroupName() {
65     return group_name;
66   }
67
68   /**
69    * Checks that the parameter can be attached to this target.
70    * @param visual_element parameter to check.
71    * @return true if the parameter can be attached to this target.
72    */

73   public boolean canManageThisChild(final VisualElement visual_element) {
74     if (Target.class.isInstance(visual_element)) return true;
75     return false;
76   }
77
78   /**
79    * Compares two targets.
80    * @param o target to compare to.
81    * @return true if the targets are equal.
82    */

83   // any thread
84
public boolean equals(final Object JavaDoc o) {
85     if (this == o) return true;
86     if ((o == null) || (o.getClass() != getClass())) return false;
87     final TargetGroup target = (TargetGroup) o;
88     return getGroupName().equals(target.getGroupName());
89   }
90
91   /**
92    * Returns the hashcode for this target.
93    * @param none.
94    * @return int hashcode.
95    */

96   // any thread
97
public int hashCode() {
98     return getGroupName().hashCode();
99   }
100 }
101
Popular Tags