- java.lang.Object
-
- javax.management.openmbean.OpenType<T>
-
- javax.management.openmbean.ArrayType<T>
-
- All Implemented Interfaces:
- Serializable
public class ArrayType<T> extends OpenType<T>
TheArrayType
class is the open type class whose instances describe all open data values which are n-dimensional arrays of open data values.Examples of valid
ArrayType
instances are:// 2-dimension array of java.lang.String ArrayType
a1 = new ArrayType (2, SimpleType.STRING); // 1-dimension array of int ArrayType a2 = new ArrayType (SimpleType.INTEGER, true); // 1-dimension array of java.lang.Integer ArrayType a3 = new ArrayType (SimpleType.INTEGER, false); // 4-dimension array of int ArrayType a4 = new ArrayType (3, a2); // 4-dimension array of java.lang.Integer ArrayType a5 = new ArrayType (3, a3); // 1-dimension array of java.lang.String ArrayType a6 = new ArrayType (SimpleType.STRING, false); // 1-dimension array of long ArrayType a7 = new ArrayType (SimpleType.LONG, true); // 1-dimension array of java.lang.Integer ArrayType a8 = ArrayType.getArrayType(SimpleType.INTEGER); // 2-dimension array of java.lang.Integer ArrayType a9 = ArrayType.getArrayType(a8); // 2-dimension array of int ArrayType a10 = ArrayType.getPrimitiveArrayType(int[][].class); // 3-dimension array of int ArrayType a11 = ArrayType.getArrayType(a10); // 1-dimension array of float ArrayType a12 = ArrayType.getPrimitiveArrayType(float[].class); // 2-dimension array of float ArrayType a13 = ArrayType.getArrayType(a12); // 1-dimension array of javax.management.ObjectName ArrayType a14 = ArrayType.getArrayType(SimpleType.OBJECTNAME); // 2-dimension array of javax.management.ObjectName ArrayType a15 = ArrayType.getArrayType(a14); // 3-dimension array of java.lang.String ArrayType a16 = new ArrayType (3, SimpleType.STRING); // 1-dimension array of java.lang.String ArrayType a17 = new ArrayType (1, SimpleType.STRING); // 2-dimension array of java.lang.String ArrayType a18 = new ArrayType (1, a17); // 3-dimension array of java.lang.String ArrayType a19 = new ArrayType (1, a18); - Since:
- 1.5
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class javax.management.openmbean.OpenType
ALLOWED_CLASSNAMES, ALLOWED_CLASSNAMES_LIST
-
-
Constructor Summary
Constructors Constructor and Description ArrayType(int dimension, OpenType<?> elementType)
Constructs an ArrayType instance describing open data values which are arrays with dimension dimension of elements whose open type is elementType.ArrayType(SimpleType<?> elementType, boolean primitiveArray)
Constructs a unidimensionalArrayType
instance for the suppliedSimpleType
.
-
Method Summary
Methods Modifier and Type Method and Description boolean
equals(Object obj)
Compares the specifiedobj
parameter with thisArrayType
instance for equality.static <E> ArrayType<E[]>
getArrayType(OpenType<E> elementType)
Create anArrayType
instance in a type-safe manner.int
getDimension()
Returns the dimension of arrays described by this ArrayType instance.OpenType<?>
getElementOpenType()
Returns the open type of element values contained in the arrays described by this ArrayType instance.static <T> ArrayType<T>
getPrimitiveArrayType(Class<T> arrayClass)
Create anArrayType
instance in a type-safe manner.int
hashCode()
Returns the hash code value for thisArrayType
instance.boolean
isPrimitiveArray()
Returnstrue
if the open data values this open type describes are primitive arrays,false
otherwise.boolean
isValue(Object obj)
Tests whether obj is a value for thisArrayType
instance.String
toString()
Returns a string representation of thisArrayType
instance.-
Methods inherited from class javax.management.openmbean.OpenType
getClassName, getDescription, getTypeName, isArray
-
-
-
-
Constructor Detail
-
ArrayType
public ArrayType(int dimension, OpenType<?> elementType) throws OpenDataException
Constructs an ArrayType instance describing open data values which are arrays with dimension dimension of elements whose open type is elementType.When invoked on an ArrayType instance, the
getClassName
method returns the class name of the array instances it describes (following the rules defined by thegetName
method ofjava.lang.Class
), not the class name of the array elements (which is returned by a call to getElementOpenType().getClassName()).The internal field corresponding to the type name of this
ArrayType
instance is also set to the class name of the array instances it describes. In other words, the methodsgetClassName
andgetTypeName
return the same string value. The internal field corresponding to the description of thisArrayType
instance is set to a string value which follows the following template:- if non-primitive array: <dimension>-dimension array of <element_class_name>
- if primitive array: <dimension>-dimension array of <primitive_type_of_the_element_class_name>
As an example, the following piece of code:
ArrayType
would produce the following output:t = new ArrayType (3, SimpleType.STRING); System.out.println("array class name = " + t.getClassName()); System.out.println("element class name = " + t.getElementOpenType().getClassName()); System.out.println("array type name = " + t.getTypeName()); System.out.println("array type description = " + t.getDescription()); array class name = [[[Ljava.lang.String; element class name = java.lang.String array type name = [[[Ljava.lang.String; array type description = 3-dimension array of java.lang.String
And the following piece of code which is equivalent to the one listed above would also produce the same output:ArrayType
t1 = new ArrayType (1, SimpleType.STRING); ArrayType t2 = new ArrayType (1, t1); ArrayType t3 = new ArrayType (1, t2); System.out.println("array class name = " + t3.getClassName()); System.out.println("element class name = " + t3.getElementOpenType().getClassName()); System.out.println("array type name = " + t3.getTypeName()); System.out.println("array type description = " + t3.getDescription()); - Parameters:
dimension
- the dimension of arrays described by this ArrayType instance; must be greater than or equal to 1.elementType
- the open type of element values contained in the arrays described by this ArrayType instance; must be an instance of either SimpleType, CompositeType, TabularType or another ArrayType with a SimpleType, CompositeType or TabularType as its elementType.- Throws:
IllegalArgumentException
- ifdimension
is not a positive integer.OpenDataException
- if elementType's className is not one of the allowed Java class names for open data.
-
ArrayType
public ArrayType(SimpleType<?> elementType, boolean primitiveArray) throws OpenDataException
Constructs a unidimensionalArrayType
instance for the suppliedSimpleType
.This constructor supports the creation of arrays of primitive types when
primitiveArray
istrue
.For primitive arrays the
getElementOpenType()
method returns theSimpleType
corresponding to the wrapper type of the primitive type of the array.When invoked on an ArrayType instance, the
getClassName
method returns the class name of the array instances it describes (following the rules defined by thegetName
method ofjava.lang.Class
), not the class name of the array elements (which is returned by a call to getElementOpenType().getClassName()).The internal field corresponding to the type name of this
ArrayType
instance is also set to the class name of the array instances it describes. In other words, the methodsgetClassName
andgetTypeName
return the same string value. The internal field corresponding to the description of thisArrayType
instance is set to a string value which follows the following template:- if non-primitive array: 1-dimension array of <element_class_name>
- if primitive array: 1-dimension array of <primitive_type_of_the_element_class_name>
As an example, the following piece of code:
ArrayType
would produce the following output:t = new ArrayType (SimpleType.INTEGER, true); System.out.println("array class name = " + t.getClassName()); System.out.println("element class name = " + t.getElementOpenType().getClassName()); System.out.println("array type name = " + t.getTypeName()); System.out.println("array type description = " + t.getDescription()); array class name = [I element class name = java.lang.Integer array type name = [I array type description = 1-dimension array of int
- Parameters:
elementType
- theSimpleType
of the element values contained in the arrays described by thisArrayType
instance.primitiveArray
-true
when this array describes primitive arrays.- Throws:
IllegalArgumentException
- ifdimension
is not a positive integer.OpenDataException
- ifprimitiveArray
istrue
andelementType
is not a validSimpleType
for a primitive type.- Since:
- 1.6
-
-
Method Detail
-
getDimension
public int getDimension()
Returns the dimension of arrays described by this ArrayType instance.- Returns:
- the dimension.
-
getElementOpenType
public OpenType<?> getElementOpenType()
Returns the open type of element values contained in the arrays described by this ArrayType instance.- Returns:
- the element type.
-
isPrimitiveArray
public boolean isPrimitiveArray()
Returnstrue
if the open data values this open type describes are primitive arrays,false
otherwise.- Returns:
- true if this is a primitive array type.
- Since:
- 1.6
-
isValue
public boolean isValue(Object obj)
Tests whether obj is a value for thisArrayType
instance.This method returns
true
if and only if obj is not null, obj is an array and any one of the following is true:- if this
ArrayType
instance describes an array of SimpleType elements or their corresponding primitive types, obj's class name is the same as the className field defined for thisArrayType
instance (i.e. the class name returned by thegetClassName
method, which includes the dimension information),
- if this
ArrayType
instance describes an array of classes implementing theTabularData
interface or theCompositeData
interface, obj is assignable to such a declared array, and each element contained in obj is either null or a valid value for the element's open type specified by thisArrayType
instance.
- if this
-
equals
public boolean equals(Object obj)
Compares the specifiedobj
parameter with thisArrayType
instance for equality.Two
ArrayType
instances are equal if and only if they describe array instances which have the same dimension, elements' open type and primitive array flag.- Specified by:
equals
in classOpenType<T>
- Parameters:
obj
- the object to be compared for equality with thisArrayType
instance; if obj isnull
or is not an instance of the classArrayType
this method returnsfalse
.- Returns:
true
if the specified object is equal to thisArrayType
instance.- See Also:
Object.hashCode()
,HashMap
-
hashCode
public int hashCode()
Returns the hash code value for thisArrayType
instance.The hash code of an
ArrayType
instance is the sum of the hash codes of all the elements of information used inequals
comparisons (i.e. dimension, elements' open type and primitive array flag). The hashcode for a primitive value is the hashcode of the corresponding boxed object (e.g. the hashcode for true is Boolean.TRUE.hashCode()). This ensures thatt1.equals(t2)
implies thatt1.hashCode()==t2.hashCode()
for any twoArrayType
instancest1
andt2
, as required by the general contract of the methodObject.hashCode()
.As
ArrayType
instances are immutable, the hash code for this instance is calculated once, on the first call tohashCode
, and then the same value is returned for subsequent calls.- Specified by:
hashCode
in classOpenType<T>
- Returns:
- the hash code value for this
ArrayType
instance - See Also:
Object.equals(java.lang.Object)
,System.identityHashCode(java.lang.Object)
-
toString
public String toString()
Returns a string representation of thisArrayType
instance.The string representation consists of the name of this class (i.e.
javax.management.openmbean.ArrayType
), the type name, the dimension, the elements' open type and the primitive array flag defined for this instance.As
ArrayType
instances are immutable, the string representation for this instance is calculated once, on the first call totoString
, and then the same value is returned for subsequent calls.
-
getArrayType
public static <E> ArrayType<E[]> getArrayType(OpenType<E> elementType) throws OpenDataException
Create anArrayType
instance in a type-safe manner.Multidimensional arrays can be built up by calling this method as many times as necessary.
Calling this method twice with the same parameters may return the same object or two equal but not identical objects.
As an example, the following piece of code:
ArrayType
would produce the following output:t1 = ArrayType.getArrayType(SimpleType.STRING); ArrayType t2 = ArrayType.getArrayType(t1); ArrayType t3 = ArrayType.getArrayType(t2); System.out.println("array class name = " + t3.getClassName()); System.out.println("element class name = " + t3.getElementOpenType().getClassName()); System.out.println("array type name = " + t3.getTypeName()); System.out.println("array type description = " + t3.getDescription()); array class name = [[[Ljava.lang.String; element class name = java.lang.String array type name = [[[Ljava.lang.String; array type description = 3-dimension array of java.lang.String
- Parameters:
elementType
- the open type of element values contained in the arrays described by this ArrayType instance; must be an instance of either SimpleType, CompositeType, TabularType or another ArrayType with a SimpleType, CompositeType or TabularType as its elementType.- Throws:
OpenDataException
- if elementType's className is not one of the allowed Java class names for open data.- Since:
- 1.6
-
getPrimitiveArrayType
public static <T> ArrayType<T> getPrimitiveArrayType(Class<T> arrayClass)
Create anArrayType
instance in a type-safe manner.Calling this method twice with the same parameters may return the same object or two equal but not identical objects.
As an example, the following piece of code:
ArrayType
would produce the following output:t = ArrayType.getPrimitiveArrayType(int[][][].class); System.out.println("array class name = " + t.getClassName()); System.out.println("element class name = " + t.getElementOpenType().getClassName()); System.out.println("array type name = " + t.getTypeName()); System.out.println("array type description = " + t.getDescription()); array class name = [[[I element class name = java.lang.Integer array type name = [[[I array type description = 3-dimension array of int
- Parameters:
arrayClass
- a primitive array class such asint[].class
,boolean[][].class
, etc. ThegetElementOpenType()
method of the returnedArrayType
returns theSimpleType
corresponding to the wrapper type of the primitive type of the array.- Throws:
IllegalArgumentException
- if arrayClass is not a primitive array.- Since:
- 1.6
-
-
Traduction non disponible
Les API Java ne sont pas encore traduites en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.
Version en cache
21/11/2024 22:01:06 Cette version de la page est en cache (à la date du 21/11/2024 22:01:06) afin d'accélérer le traitement. Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la dernère version de la page.Document créé le 30/08/2006, dernière modification le 04/03/2020
Source du document imprimé : https://www.gaudry.be/java-api-rf-javax/management/openmbean/arraytype.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.
Références
Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.