home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-tomcat-addon-1.4.9-installer.exe / jmx.jar / javax / management / ObjectInstance.class (.txt) < prev    next >
Encoding:
Java Class File  |  2002-10-28  |  2.1 KB  |  58 lines

  1. package javax.management;
  2.  
  3. import java.io.Serializable;
  4.  
  5. public class ObjectInstance implements Serializable {
  6.    private static final long serialVersionUID = -4099952623687795850L;
  7.    private String className;
  8.    private ObjectName name;
  9.  
  10.    public ObjectInstance(String objectName, String className) throws MalformedObjectNameException {
  11.       this(new ObjectName(objectName), className);
  12.    }
  13.  
  14.    public ObjectInstance(ObjectName objectName, String className) {
  15.       if (objectName != null && !objectName.isPattern()) {
  16.          if (className != null && className.trim().length() != 0) {
  17.             this.name = objectName;
  18.             this.className = className;
  19.          } else {
  20.             throw new RuntimeOperationsException(new IllegalArgumentException("Class name cannot be null or empty"));
  21.          }
  22.       } else {
  23.          throw new RuntimeOperationsException(new IllegalArgumentException("Invalid object name"));
  24.       }
  25.    }
  26.  
  27.    public boolean equals(Object object) {
  28.       if (object == null) {
  29.          return false;
  30.       } else if (object == this) {
  31.          return true;
  32.       } else {
  33.          try {
  34.             ObjectInstance other = (ObjectInstance)object;
  35.             return this.name.equals(other.name) && this.className.equals(other.className);
  36.          } catch (ClassCastException var3) {
  37.             return false;
  38.          }
  39.       }
  40.    }
  41.  
  42.    public int hashCode() {
  43.       return this.name.hashCode() ^ this.className.hashCode();
  44.    }
  45.  
  46.    public ObjectName getObjectName() {
  47.       return this.name;
  48.    }
  49.  
  50.    public String getClassName() {
  51.       return this.className;
  52.    }
  53.  
  54.    public String toString() {
  55.       return this.getClassName() + "@" + this.getObjectName();
  56.    }
  57. }
  58.