1 2 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 30 import org.apache.commons.logging.Log; 31 import org.apache.commons.logging.LogFactory; 32 import java.net.*; 33 34 39 40 public class TargetIPv4Range extends Target { 41 private static Log log = LogFactory.getLog(TargetIPv4Subnet.class); 42 43 private Inet4Address begin; private Inet4Address end; 46 53 public TargetIPv4Range(final String name, final Inet4Address begin, final Inet4Address end) throws AlgorithmException { 55 super(name); 56 if (begin == null || end == null) throw new AlgorithmException("begin or end is null"); 57 this.begin = begin; 58 this.end = end; 59 setItem(begin.getHostAddress() + "-" + end.getHostAddress()); 60 } 61 62 67 public void initialize(final GUI gui) { 68 super.initialize(gui); 69 if (gui != null) setImageNetwork(); 70 } 71 72 77 protected Inet4Address getBegin() { 79 return begin; 80 } 81 82 87 protected Inet4Address getEnd() { 89 return end; 90 } 91 92 97 public boolean canManageThisChild(final VisualElement visual_element) { 98 if (TargetIPv4.class.isInstance(visual_element)) return true; 99 return false; 100 } 101 102 107 public boolean equals(final Object o) { 109 if (this == o) return true; 110 if ((o == null) || (o.getClass() != getClass())) return false; 111 final TargetIPv4Range target = (TargetIPv4Range) o; 112 return getBegin().equals(target.getBegin()) && getEnd().equals(target.getEnd()); 113 } 114 115 120 public int hashCode() { 122 return getBegin().hashCode() ^ getEnd().hashCode(); 123 } 124 } 125 | Popular Tags |