/*
* @(#)OpenType.java 3.27 03/12/19
*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package javax.management.openmbean;
// java import
//
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.Serializable;
// jmx import
//
/**
* The OpenType class is the parent abstract class of all classes which describe the actual open type
* of open data values.
*
* An open type is defined by: *
ALLOWED_CLASSNAMES = {
"java.lang.Void",
"java.lang.Boolean",
"java.lang.Character",
"java.lang.Byte",
"java.lang.Short",
"java.lang.Integer",
"java.lang.Long",
"java.lang.Float",
"java.lang.Double",
"java.lang.String",
"java.math.BigDecimal",
"java.math.BigInteger",
"java.util.Date",
"javax.management.ObjectName",
CompositeData.class.getName(),
TabularData.class.getName() } ;
*
*/
public static final String[] ALLOWED_CLASSNAMES = {
"java.lang.Void",
"java.lang.Boolean",
"java.lang.Character",
"java.lang.Byte",
"java.lang.Short",
"java.lang.Integer",
"java.lang.Long",
"java.lang.Float",
"java.lang.Double",
"java.lang.String",
"java.math.BigDecimal",
"java.math.BigInteger",
"java.util.Date",
"javax.management.ObjectName",
CompositeData.class.getName(), // better refer to these two class names like this, rather than hardcoding a string,
TabularData.class.getName() } ; // in case the package of these classes should change (who knows...)
/**
* @serial The fully qualified Java class name of open data values this type describes.
*/
private String className;
/**
* @serial The type description (should not be null or empty).
*/
private String description;
/**
* @serial The name given to this type (should not be null or empty).
*/
private String typeName;
/**
* @serial Tells if this type describes an array (checked in constructor).
*/
private transient boolean isArray = false;
/* *** Constructor *** */
/**
* Constructs an OpenType instance (actually a subclass instance as OpenType is abstract),
* checking for the validity of the given parameters.
* The validity constraints are described below for each parameter.
* java.lang.Class.
* For example, a 3-dimensional array of Strings has for class name
* "[[[Ljava.lang.String;" (without the quotes).
* [[[Ljava.lang.String;" (without the quotes).
*
* @return the class name.
*/
public String getClassName() {
return className;
}
/**
* Returns the name of this OpenType instance.
*
* @return the type name.
*/
public String getTypeName() {
return typeName;
}
/**
* Returns the text description of this OpenType instance.
*
* @return the description.
*/
public String getDescription() {
return description;
}
/**
* Returns true if the open data values this open
* type describes are arrays, false otherwise.
*
* @return true if this is an array type.
*/
public boolean isArray() {
return isArray;
}
/**
* Tests whether obj is a value for this open type.
*
* @param obj the object to be tested for validity.
*
* @return true if obj is a value for this
* open type, false otherwise.
*/
public abstract boolean isValue(Object obj) ;
/* *** Methods overriden from class Object *** */
/**
* Compares the specified obj parameter with this
* open type instance for equality.
*
* @param obj the object to compare to.
*
* @return true if this object and obj are equal.
*/
public abstract boolean equals(Object obj) ;
public abstract int hashCode() ;
/**
* Returns a string representation of this open type instance.
*
* @return the string representation.
*/
public abstract String toString() ;
/**
* Deserializes an {@link OpenType} from an {@link ObjectInputStream}.
*/
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException {
in.defaultReadObject();
isArray = (className.startsWith("["));
}
}