Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.jwall.object
Class ICMPService  view ICMPService download ICMPService.java

java.lang.Object
  extended byorg.jwall.object.Service
      extended byorg.jwall.object.ICMPService
All Implemented Interfaces:
java.lang.Comparable, org.jwall.gui.Enum, FirewallDataEventSource, org.jwall.type.SortedDisplayable

public class ICMPService
extends Service

This class represents an ICMP service.

The Internet Protocol (IP) is not designed to be absolutely reliable. The purpose of these control messages (ICMP) is to provide feedback about problems in the communication environment, not to make IP reliable.

The Internet Control Message Protocol (ICMP) has many messages that are identified by a "type" field, these are defined by RFCs. Many of the types of ICMP message are now obsolete and are no longer seen in the Internet.


Field Summary
private  int code
           
private  javax.swing.Icon icon
           
private static int protocol
           
private  int type
           
 
Fields inherited from class org.jwall.object.Service
AH, ANY, byName, byType, comment, ESP, ICMP, MAX, MAXPRIVILEDGED, MIN, name, TCP, UDP
 
Constructor Summary
  ICMPService()
          Creates a new ICMP service with the null type and null code.
  ICMPService(int type)
          Creates a new ICMP service with the given type and code zero.
  ICMPService(int type, int code)
          Creates a new ICMP service with the given type and code.
protected ICMPService(java.lang.String name, java.lang.String comment)
          Creates a new ICMP service.
 
Method Summary
 boolean equals(java.lang.Object o)
          Determine whether this Object is semantically equal to another Object.
 int getCode()
          Returns the ICMP code.
 java.lang.String getCodeDescription()
          Gets the description that belongs to the code of this ICMP type.
 java.lang.String getName()
          Gets the name of the current ICMP type.
 int getType()
          Returns the ICMP type.
 int hashCode()
          Get a value that represents this Object, as uniquely as possible within the confines of an int.
static boolean isReserved(int type)
          Returns if the type is an unassigned or reserved ICMP type.
 java.lang.String toString()
          Returns a string representation of the object.
static ICMPService valueOf(java.lang.String type, java.lang.String code)
          Creates a new ICMP services from the given strings.
static ICMPService valueOf(java.lang.String name, java.lang.String comment, java.lang.String type, java.lang.String code)
           
 
Methods inherited from class org.jwall.object.Service
addFirewallDataListener, compareTo, contains, getComment, getIcon, getProtocol, hasComment, removeFirewallDataListener, replaceWith, resKey, setComment, setIcon, setName, setProtocol, wasDeleted, wasModified
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

protocol

private static final int protocol
See Also:
Constant Field Values

type

private int type

code

private int code

icon

private final javax.swing.Icon icon
Constructor Detail

ICMPService

protected ICMPService(java.lang.String name,
                      java.lang.String comment)
Creates a new ICMP service.


ICMPService

public ICMPService(int type,
                   int code)
Creates a new ICMP service with the given type and code.


ICMPService

public ICMPService(int type)
Creates a new ICMP service with the given type and code zero.


ICMPService

public ICMPService()
Creates a new ICMP service with the null type and null code.

Method Detail

getType

public int getType()
Returns the ICMP type.


getCode

public int getCode()
Returns the ICMP code.


valueOf

public static final ICMPService valueOf(java.lang.String type,
                                        java.lang.String code)
Creates a new ICMP services from the given strings.


valueOf

public static final ICMPService valueOf(java.lang.String name,
                                        java.lang.String comment,
                                        java.lang.String type,
                                        java.lang.String code)

getName

public java.lang.String getName()
Gets the name of the current ICMP type. The returned value is equal to the name defined in the RFCs for this ICMP type.

Overrides:
getName in class Service

getCodeDescription

public java.lang.String getCodeDescription()
Gets the description that belongs to the code of this ICMP type.


isReserved

public static boolean isReserved(int type)
Returns if the type is an unassigned or reserved ICMP type. This method can be used as a helper method, e.g. for only showing serives that are common


toString

public java.lang.String toString()
Returns a string representation of the object. This is identical to getName().

Overrides:
toString in class Service

equals

public boolean equals(java.lang.Object o)
Description copied from class: java.lang.Object
Determine whether this Object is semantically equal to another Object.

There are some fairly strict requirements on this method which subclasses must follow:

  • It must be transitive. If a.equals(b) and b.equals(c), then a.equals(c) must be true as well.
  • It must be symmetric. a.equals(b) and b.equals(a) must have the same value.
  • It must be reflexive. a.equals(a) must always be true.
  • It must be consistent. Whichever value a.equals(b) returns on the first invocation must be the value returned on all later invocations.
  • a.equals(null) must be false.
  • It must be consistent with hashCode(). That is, a.equals(b) must imply a.hashCode() == b.hashCode(). The reverse is not true; two objects that are not equal may have the same hashcode, but that has the potential to harm hashing performance.

This is typically overridden to throw a java.lang.ClassCastException if the argument is not comparable to the class performing the comparison, but that is not a requirement. It is legal for a.equals(b) to be true even though a.getClass() != b.getClass(). Also, it is typical to never cause a java.lang.NullPointerException.

In general, the Collections API (java.util) use the equals method rather than the == operator to compare objects. However, java.util.IdentityHashMap is an exception to this rule, for its own good reasons.

The default implementation returns this == o.

Overrides:
equals in class Service

hashCode

public int hashCode()
Description copied from class: java.lang.Object
Get a value that represents this Object, as uniquely as possible within the confines of an int.

There are some requirements on this method which subclasses must follow:

  • Semantic equality implies identical hashcodes. In other words, if a.equals(b) is true, then a.hashCode() == b.hashCode() must be as well. However, the reverse is not necessarily true, and two objects may have the same hashcode without being equal.
  • It must be consistent. Whichever value o.hashCode() returns on the first invocation must be the value returned on all later invocations as long as the object exists. Notice, however, that the result of hashCode may change between separate executions of a Virtual Machine, because it is not invoked on the same object.

Notice that since hashCode is used in java.util.Hashtable and other hashing classes, a poor implementation will degrade the performance of hashing (so don't blindly implement it as returning a constant!). Also, if calculating the hash is time-consuming, a class may consider caching the results.

The default implementation returns System.identityHashCode(this)

Overrides:
hashCode in class Service