/*
* 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;
import com.sun.jmx.mbeanserver.GetPropertyAction;
import java.io.IOException;
import java.io.InvalidObjectException;
import java.io.ObjectInputStream;
import java.io.Serializable;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import javax.management.Descriptor;
import javax.management.ImmutableDescriptor;
/**
* 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_LIST = { "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 List
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).
* java.lang.Class
.
* For example, a 3-dimensional array of Strings has for class name
* "[[[Ljava.lang.String;
" (without the quotes),
* a 3-dimensional array of Integers has for class name
* "[[[Ljava.lang.Integer;
" (without the quotes),
* and a 3-dimensional array of int has for class name
* "[[[I
" (without the quotes)
*
* @return the class name.
*/
public String getClassName() {
return className;
}
// A version of getClassName() that can only be called from within this
// package and that cannot be overridden.
String safeGetClassName() {
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) ;
/**
* Tests whether values of the given type can be assigned to this open type.
* The default implementation of this method returns true only if the
* types are equal.
*
* @param ot the type to be tested.
*
* @return true if {@code ot} is assignable to this open type.
*/
boolean isAssignableFrom(OpenType> ot) {
return this.equals(ot);
}
/* *** 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 java.io.ObjectInputStream}.
*/
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException {
checkClassNameOverride();
ObjectInputStream.GetField fields = in.readFields();
final String classNameField;
final String descriptionField;
final String typeNameField;
try {
classNameField =
validClassName((String) fields.get("className", null));
descriptionField =
valid("description", (String) fields.get("description", null));
typeNameField =
valid("typeName", (String) fields.get("typeName", null));
} catch (Exception e) {
IOException e2 = new InvalidObjectException(e.getMessage());
e2.initCause(e);
throw e2;
}
className = classNameField;
description = descriptionField;
typeName = typeNameField;
isArray = (className.startsWith("["));
}
}