FileDocCategorySizeDatePackage
OpenType.javaAPI DocJava SE 5 API9061Fri Aug 26 14:57:36 BST 2005javax.management.openmbean

OpenType

public abstract class OpenType extends Object implements Serializable
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:

  • the fully qualified Java class name of the open data values this type describes; note that only a limited set of Java classes is allowed for open data values (see {@link #ALLOWED_CLASSNAMES ALLOWED_CLASSNAMES}),
  • its name,
  • its description.
version
3.27 03/12/19
author
Sun Microsystems, Inc.
since
1.5
since.unbundled
JMX 1.1

Fields Summary
static final long
serialVersionUID
public static final String[]
ALLOWED_CLASSNAMES
List of the fully qualified names of the Java classes allowed for open data values. A multidimensional array of any one of these classes is also an allowed for open data values.
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() } ;
private String
className
private String
description
private String
typeName
private transient boolean
isArray
Constructors Summary
protected OpenType(String className, String typeName, String description)
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.
 

param
className The fully qualified Java class name of the open data values this open type describes. The valid Java class names allowed for open data values are listed in {@link #ALLOWED_CLASSNAMES ALLOWED_CLASSNAMES}. A multidimensional array of any one of these classes is also an allowed class, in which case the class name follows the rules defined by the method {@link Class#getName() getName()} of java.lang.Class. For example, a 3-dimensional array of Strings has for class name "[[[Ljava.lang.String;" (without the quotes).
 
param
typeName The name given to the open type this instance represents; cannot be a null or empty string.
 
param
description The human readable description of the open type this instance represents; cannot be a null or empty string.
 
throws
IllegalArgumentException if className, typeName or description is a null or empty string
 
throws
OpenDataException if className is not one of the allowed Java class names for open data

 

    /* *** Constructor *** */

                                                     			              			     			               			              			      			            			                                            			                   					                             
        
		          
		            
	
	// Check parameters that cannot be null or empty
	//
	if ( (className == null) || (className.trim().equals("")) ) {
	    throw new IllegalArgumentException("Argument className cannot be null or empty.");
	}
	if ( (typeName == null) || (typeName.trim().equals("")) ) {
	    throw new IllegalArgumentException("Argument typeName cannot be null or empty.");
	}
	if ( (description == null) || (description.trim().equals("")) ) {
	    throw new IllegalArgumentException("Argument description cannot be null or empty.");
	}

	// remove leading and trailing white spaces, if any
	//
	className   = className.trim();
	typeName    = typeName.trim();
	description = description.trim();

	// Check if className describes an array class, and determines its elements' class name.
	// (eg: a 3-dimensional array of Strings has for class name: "[[[Ljava.lang.String;")
	//
	int n = 0;
	while (className.startsWith("[", n)) {
	    n++;
	}
	String eltClassName; // class name of array elements
	boolean isArray = false;
	if (n > 0) {
	    // removes the n leading '[' + the 'L' characters and the last ';' character
	    eltClassName = className.substring(n+1, className.length()-1); // see javadoc of String.substring(begin,end)
	    isArray = true;
	} else {
	    // not an array
	    eltClassName = className;
	}

	// Check that eltClassName's value is one of the allowed basic data types for open data
	//
	boolean ok = false;
	for (int i=0; i<ALLOWED_CLASSNAMES.length; i++) {
	    if (ALLOWED_CLASSNAMES[i].equals(eltClassName)) {
		ok = true;
		break;
	    }
	}
	if ( ! ok ) {
	    throw new OpenDataException("Argument className=\""+ className +
					"\" is not one of the allowed Java class names for open data.");
	}

	// Now initializes this OpenType instance
	//
	this.className   = className;
	this.typeName    = typeName;
	this.description = description;
	this.isArray     = isArray;
    
Methods Summary
public abstract booleanequals(java.lang.Object obj)
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 java.lang.StringgetClassName()
Returns the fully qualified Java class name of the open data values this open type describes. The only possible Java class names for open data values are listed in {@link #ALLOWED_CLASSNAMES ALLOWED_CLASSNAMES}. A multidimensional array of any one of these classes is also an allowed class, in which case the class name follows the rules defined by the method {@link Class#getName() getName()} of java.lang.Class. For example, a 3-dimensional array of Strings has for class name "[[[Ljava.lang.String;" (without the quotes).

return
the class name.


	return className;
    
public java.lang.StringgetDescription()
Returns the text description of this OpenType instance.

return
the description.


	return description;
    
public java.lang.StringgetTypeName()
Returns the name of this OpenType instance.

return
the type name.


	return typeName;
    
public abstract inthashCode()

public booleanisArray()
Returns true if the open data values this open type describes are arrays, false otherwise.

return
true if this is an array type.


	return isArray;
    
public abstract booleanisValue(java.lang.Object obj)
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.

private voidreadObject(java.io.ObjectInputStream in)
Deserializes an {@link OpenType} from an {@link ObjectInputStream}.

      in.defaultReadObject();
      isArray = (className.startsWith("["));
    
public abstract java.lang.StringtoString()
Returns a string representation of this open type instance.

return
the string representation.