/*
* Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package javax.management.openmbean;
// java import
//
import java.io.InvalidObjectException;
import java.io.ObjectStreamException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Date;
import java.util.Map;
import java.util.HashMap;
// jmx import
//
import javax.management.ObjectName;
/**
* The SimpleType
class is the open type class whose instances describe
* all open data values which are neither arrays,
* nor {@link CompositeData CompositeData
} values,
* nor {@link TabularData TabularData
} values.
* It predefines all its possible instances as static fields, and has no public constructor.
*
* Given a This method returns
*
* Two
* As
* The string representation consists of
* the name of this class (ie
* As SimpleType
instance describing values whose Java class name is className,
* the internal fields corresponding to the name and description of this SimpleType
instance
* are also set to className.
* In other words, its methods getClassName
, getTypeName
and getDescription
* all return the same string value className.
*
* @since 1.5
*/
public final class SimpleTypeSimpleType
instance describing values whose
* Java class name is java.lang.Void
.
*/
public static final SimpleTypeSimpleType
instance describing values whose
* Java class name is java.lang.Boolean
.
*/
public static final SimpleTypeSimpleType
instance describing values whose
* Java class name is java.lang.Character
.
*/
public static final SimpleTypeSimpleType
instance describing values whose
* Java class name is java.lang.Byte
.
*/
public static final SimpleTypeSimpleType
instance describing values whose
* Java class name is java.lang.Short
.
*/
public static final SimpleTypeSimpleType
instance describing values whose
* Java class name is java.lang.Integer
.
*/
public static final SimpleTypeSimpleType
instance describing values whose
* Java class name is java.lang.Long
.
*/
public static final SimpleTypeSimpleType
instance describing values whose
* Java class name is java.lang.Float
.
*/
public static final SimpleTypeSimpleType
instance describing values whose
* Java class name is java.lang.Double
.
*/
public static final SimpleTypeSimpleType
instance describing values whose
* Java class name is java.lang.String
.
*/
public static final SimpleTypeSimpleType
instance describing values whose
* Java class name is java.math.BigDecimal
.
*/
public static final SimpleTypeSimpleType
instance describing values whose
* Java class name is java.math.BigInteger
.
*/
public static final SimpleTypeSimpleType
instance describing values whose
* Java class name is java.util.Date
.
*/
public static final SimpleTypeSimpleType
instance describing values whose
* Java class name is javax.management.ObjectName
.
*/
public static final SimpleTypeSimpleType
instance. true
if and only if obj is not null and
* obj's class name is the same as the className field
* defined for this SimpleType
instance (ie the class
* name returned by the {@link OpenType#getClassName()
* getClassName} method).
*
* @param obj the object to be tested.
*
* @return true
if obj is a value for this
* SimpleType
instance.
*/
public boolean isValue(Object obj) {
// if obj is null, return false
//
if (obj == null) {
return false;
}
// Test if obj's class name is the same as for this instance
//
return this.getClassName().equals(obj.getClass().getName());
}
/* *** Methods overriden from class Object *** */
/**
* Compares the specified obj
parameter with this SimpleType
instance for equality.
* SimpleType
instances are equal if and only if their
* {@link OpenType#getClassName() getClassName} methods return the same value.
*
* @param obj the object to be compared for equality with this SimpleType
instance;
* if obj is null
or is not an instance of the class SimpleType
,
* equals
returns false
.
*
* @return true
if the specified object is equal to this SimpleType
instance.
*/
public boolean equals(Object obj) {
/* If it weren't for readReplace(), we could replace this method
with just:
return (this == obj);
*/
if (!(obj instanceof SimpleType>))
return false;
SimpleType> other = (SimpleType>) obj;
// Test if other's className field is the same as for this instance
//
return this.getClassName().equals(other.getClassName());
}
/**
* Returns the hash code value for this SimpleType
instance.
* The hash code of a SimpleType
instance is the the hash code of
* the string value returned by the {@link OpenType#getClassName() getClassName} method.
* SimpleType
instances are immutable, the hash code for this instance is calculated once,
* on the first call to hashCode
, and then the same value is returned for subsequent calls.
*
* @return the hash code value for this SimpleType
instance
*/
public int hashCode() {
// Calculate the hash code value if it has not yet been done (ie 1st call to hashCode())
//
if (myHashCode == null) {
myHashCode = Integer.valueOf(this.getClassName().hashCode());
}
// return always the same hash code for this instance (immutable)
//
return myHashCode.intValue();
}
/**
* Returns a string representation of this SimpleType
instance.
* javax.management.openmbean.SimpleType
) and the type name
* for this instance (which is the java class name of the values this SimpleType
instance represents).
* SimpleType
instances are immutable, the string representation for this instance is calculated once,
* on the first call to toString
, and then the same value is returned for subsequent calls.
*
* @return a string representation of this SimpleType
instance
*/
public String toString() {
// Calculate the string representation if it has not yet been done (ie 1st call to toString())
//
if (myToString == null) {
myToString = this.getClass().getName()+ "(name="+ getTypeName() +")";
}
// return always the same string representation for this instance (immutable)
//
return myToString;
}
private static final Map