OpenTypepublic abstract class OpenType extends Object implements SerializableThe 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.
|
Fields Summary |
---|
static final long | serialVersionUID | public static final String[] | ALLOWED_CLASSNAMESList 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.
/* *** 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 boolean | equals(java.lang.Object obj)Compares the specified obj parameter with this
open type instance for equality.
| public java.lang.String | getClassName()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 className;
| public java.lang.String | getDescription()Returns the text description of this OpenType instance.
return description;
| public java.lang.String | getTypeName()Returns the name of this OpenType instance.
return typeName;
| public abstract int | hashCode()
| public boolean | isArray()Returns true if the open data values this open
type describes are arrays, false otherwise.
return isArray;
| public abstract boolean | isValue(java.lang.Object obj)Tests whether obj is a value for this open type.
| private void | readObject(java.io.ObjectInputStream in)Deserializes an {@link OpenType} from an {@link ObjectInputStream}.
in.defaultReadObject();
isArray = (className.startsWith("["));
| public abstract java.lang.String | toString()Returns a string representation of this open type instance.
|
|