jdk/src/share/classes/javax/management/openmbean/ArrayType.java
changeset 21656 d4c777ccb1db
parent 5506 202f599c92aa
child 23010 6dadb192ad81
equal deleted inserted replaced
21655:55f32ae4f920 21656:d4c777ccb1db
    31 /**
    31 /**
    32  * The <code>ArrayType</code> class is the <i>open type</i> class whose instances describe
    32  * The <code>ArrayType</code> class is the <i>open type</i> class whose instances describe
    33  * all <i>open data</i> values which are n-dimensional arrays of <i>open data</i> values.
    33  * all <i>open data</i> values which are n-dimensional arrays of <i>open data</i> values.
    34  * <p>
    34  * <p>
    35  * Examples of valid {@code ArrayType} instances are:
    35  * Examples of valid {@code ArrayType} instances are:
    36  * <pre>
    36  * <pre>{@code
    37  * // 2-dimension array of java.lang.String
    37  * // 2-dimension array of java.lang.String
    38  * ArrayType<String[][]> a1 = new ArrayType<String[][]>(2, SimpleType.STRING);
    38  * ArrayType<String[][]> a1 = new ArrayType<String[][]>(2, SimpleType.STRING);
    39  *
    39  *
    40  * // 1-dimension array of int
    40  * // 1-dimension array of int
    41  * ArrayType<int[]> a2 = new ArrayType<int[]>(SimpleType.INTEGER, true);
    41  * ArrayType<int[]> a2 = new ArrayType<int[]>(SimpleType.INTEGER, true);
    88  * // 2-dimension array of java.lang.String
    88  * // 2-dimension array of java.lang.String
    89  * ArrayType<String[][]> a18 = new ArrayType<String[][]>(1, a17);
    89  * ArrayType<String[][]> a18 = new ArrayType<String[][]>(1, a17);
    90  *
    90  *
    91  * // 3-dimension array of java.lang.String
    91  * // 3-dimension array of java.lang.String
    92  * ArrayType<String[][][]> a19 = new ArrayType<String[][][]>(1, a18);
    92  * ArrayType<String[][][]> a19 = new ArrayType<String[][][]>(1, a18);
    93  * </pre>
    93  * }</pre>
    94  *
    94  *
    95  *
    95  *
    96  * @since 1.5
    96  * @since 1.5
    97  */
    97  */
    98 /*
    98 /*
   239      * <li>if non-primitive array: <tt><i>&lt;dimension&gt;</i>-dimension array of <i>&lt;element_class_name&gt;</i></tt></li>
   239      * <li>if non-primitive array: <tt><i>&lt;dimension&gt;</i>-dimension array of <i>&lt;element_class_name&gt;</i></tt></li>
   240      * <li>if primitive array: <tt><i>&lt;dimension&gt;</i>-dimension array of <i>&lt;primitive_type_of_the_element_class_name&gt;</i></tt></li>
   240      * <li>if primitive array: <tt><i>&lt;dimension&gt;</i>-dimension array of <i>&lt;primitive_type_of_the_element_class_name&gt;</i></tt></li>
   241      * </ul>
   241      * </ul>
   242      * <p>
   242      * <p>
   243      * As an example, the following piece of code:
   243      * As an example, the following piece of code:
   244      * <pre>
   244      * <pre>{@code
   245      * ArrayType<String[][][]> t = new ArrayType<String[][][]>(3, SimpleType.STRING);
   245      * ArrayType<String[][][]> t = new ArrayType<String[][][]>(3, SimpleType.STRING);
   246      * System.out.println("array class name       = " + t.getClassName());
   246      * System.out.println("array class name       = " + t.getClassName());
   247      * System.out.println("element class name     = " + t.getElementOpenType().getClassName());
   247      * System.out.println("element class name     = " + t.getElementOpenType().getClassName());
   248      * System.out.println("array type name        = " + t.getTypeName());
   248      * System.out.println("array type name        = " + t.getTypeName());
   249      * System.out.println("array type description = " + t.getDescription());
   249      * System.out.println("array type description = " + t.getDescription());
   250      * </pre>
   250      * }</pre>
   251      * would produce the following output:
   251      * would produce the following output:
   252      * <pre>
   252      * <pre>{@code
   253      * array class name       = [[[Ljava.lang.String;
   253      * array class name       = [[[Ljava.lang.String;
   254      * element class name     = java.lang.String
   254      * element class name     = java.lang.String
   255      * array type name        = [[[Ljava.lang.String;
   255      * array type name        = [[[Ljava.lang.String;
   256      * array type description = 3-dimension array of java.lang.String
   256      * array type description = 3-dimension array of java.lang.String
   257      * </pre>
   257      * }</pre>
   258      * And the following piece of code which is equivalent to the one listed
   258      * And the following piece of code which is equivalent to the one listed
   259      * above would also produce the same output:
   259      * above would also produce the same output:
   260      * <pre>
   260      * <pre>{@code
   261      * ArrayType<String[]> t1 = new ArrayType<String[]>(1, SimpleType.STRING);
   261      * ArrayType<String[]> t1 = new ArrayType<String[]>(1, SimpleType.STRING);
   262      * ArrayType<String[][]> t2 = new ArrayType<String[][]>(1, t1);
   262      * ArrayType<String[][]> t2 = new ArrayType<String[][]>(1, t1);
   263      * ArrayType<String[][][]> t3 = new ArrayType<String[][][]>(1, t2);
   263      * ArrayType<String[][][]> t3 = new ArrayType<String[][][]>(1, t2);
   264      * System.out.println("array class name       = " + t3.getClassName());
   264      * System.out.println("array class name       = " + t3.getClassName());
   265      * System.out.println("element class name     = " + t3.getElementOpenType().getClassName());
   265      * System.out.println("element class name     = " + t3.getElementOpenType().getClassName());
   266      * System.out.println("array type name        = " + t3.getTypeName());
   266      * System.out.println("array type name        = " + t3.getTypeName());
   267      * System.out.println("array type description = " + t3.getDescription());
   267      * System.out.println("array type description = " + t3.getDescription());
   268      * </pre>
   268      * }</pre>
   269      *
   269      *
   270      * @param  dimension  the dimension of arrays described by this <tt>ArrayType</tt> instance;
   270      * @param  dimension  the dimension of arrays described by this <tt>ArrayType</tt> instance;
   271      *                    must be greater than or equal to 1.
   271      *                    must be greater than or equal to 1.
   272      *
   272      *
   273      * @param  elementType  the <i>open type</i> of element values contained
   273      * @param  elementType  the <i>open type</i> of element values contained
   332      * <li>if non-primitive array: <tt>1-dimension array of <i>&lt;element_class_name&gt;</i></tt></li>
   332      * <li>if non-primitive array: <tt>1-dimension array of <i>&lt;element_class_name&gt;</i></tt></li>
   333      * <li>if primitive array: <tt>1-dimension array of <i>&lt;primitive_type_of_the_element_class_name&gt;</i></tt></li>
   333      * <li>if primitive array: <tt>1-dimension array of <i>&lt;primitive_type_of_the_element_class_name&gt;</i></tt></li>
   334      * </ul>
   334      * </ul>
   335      * <p>
   335      * <p>
   336      * As an example, the following piece of code:
   336      * As an example, the following piece of code:
   337      * <pre>
   337      * <pre>{@code
   338      * ArrayType<int[]> t = new ArrayType<int[]>(SimpleType.INTEGER, true);
   338      * ArrayType<int[]> t = new ArrayType<int[]>(SimpleType.INTEGER, true);
   339      * System.out.println("array class name       = " + t.getClassName());
   339      * System.out.println("array class name       = " + t.getClassName());
   340      * System.out.println("element class name     = " + t.getElementOpenType().getClassName());
   340      * System.out.println("element class name     = " + t.getElementOpenType().getClassName());
   341      * System.out.println("array type name        = " + t.getTypeName());
   341      * System.out.println("array type name        = " + t.getTypeName());
   342      * System.out.println("array type description = " + t.getDescription());
   342      * System.out.println("array type description = " + t.getDescription());
   343      * </pre>
   343      * }</pre>
   344      * would produce the following output:
   344      * would produce the following output:
   345      * <pre>
   345      * <pre>{@code
   346      * array class name       = [I
   346      * array class name       = [I
   347      * element class name     = java.lang.Integer
   347      * element class name     = java.lang.Integer
   348      * array type name        = [I
   348      * array type name        = [I
   349      * array type description = 1-dimension array of int
   349      * array type description = 1-dimension array of int
   350      * </pre>
   350      * }</pre>
   351      *
   351      *
   352      * @param elementType the {@code SimpleType} of the element values
   352      * @param elementType the {@code SimpleType} of the element values
   353      *                    contained in the arrays described by this
   353      *                    contained in the arrays described by this
   354      *                    {@code ArrayType} instance.
   354      *                    {@code ArrayType} instance.
   355      *
   355      *
   531      * by the {@link OpenType#getClassName() getClassName} method, which
   531      * by the {@link OpenType#getClassName() getClassName} method, which
   532      * includes the dimension information),<br>&nbsp;</li>
   532      * includes the dimension information),<br>&nbsp;</li>
   533      * <li>if this <code>ArrayType</code> instance describes an array of
   533      * <li>if this <code>ArrayType</code> instance describes an array of
   534      * classes implementing the {@code TabularData} interface or the
   534      * classes implementing the {@code TabularData} interface or the
   535      * {@code CompositeData} interface, <var>obj</var> is assignable to
   535      * {@code CompositeData} interface, <var>obj</var> is assignable to
   536      * such a declared array, and each element contained in <var>obj</var>
   536      * such a declared array, and each element contained in {<var>obj</var>
   537      * is either null or a valid value for the element's open type specified
   537      * is either null or a valid value for the element's open type specified
   538      * by this <code>ArrayType</code> instance.</li>
   538      * by this <code>ArrayType</code> instance.</li>
   539      * </ul>
   539      * </ul>
   540      *
   540      *
   541      * @param obj the object to be tested.
   541      * @param obj the object to be tested.
   774      * <p>
   774      * <p>
   775      * Calling this method twice with the same parameters may return the same
   775      * Calling this method twice with the same parameters may return the same
   776      * object or two equal but not identical objects.
   776      * object or two equal but not identical objects.
   777      * <p>
   777      * <p>
   778      * As an example, the following piece of code:
   778      * As an example, the following piece of code:
   779      * <pre>
   779      * <pre>{@code
   780      * ArrayType<String[]> t1 = ArrayType.getArrayType(SimpleType.STRING);
   780      * ArrayType<String[]> t1 = ArrayType.getArrayType(SimpleType.STRING);
   781      * ArrayType<String[][]> t2 = ArrayType.getArrayType(t1);
   781      * ArrayType<String[][]> t2 = ArrayType.getArrayType(t1);
   782      * ArrayType<String[][][]> t3 = ArrayType.getArrayType(t2);
   782      * ArrayType<String[][][]> t3 = ArrayType.getArrayType(t2);
   783      * System.out.println("array class name       = " + t3.getClassName());
   783      * System.out.println("array class name       = " + t3.getClassName());
   784      * System.out.println("element class name     = " + t3.getElementOpenType().getClassName());
   784      * System.out.println("element class name     = " + t3.getElementOpenType().getClassName());
   785      * System.out.println("array type name        = " + t3.getTypeName());
   785      * System.out.println("array type name        = " + t3.getTypeName());
   786      * System.out.println("array type description = " + t3.getDescription());
   786      * System.out.println("array type description = " + t3.getDescription());
   787      * </pre>
   787      * }</pre>
   788      * would produce the following output:
   788      * would produce the following output:
   789      * <pre>
   789      * <pre>{@code
   790      * array class name       = [[[Ljava.lang.String;
   790      * array class name       = [[[Ljava.lang.String;
   791      * element class name     = java.lang.String
   791      * element class name     = java.lang.String
   792      * array type name        = [[[Ljava.lang.String;
   792      * array type name        = [[[Ljava.lang.String;
   793      * array type description = 3-dimension array of java.lang.String
   793      * array type description = 3-dimension array of java.lang.String
   794      * </pre>
   794      * }</pre>
   795      *
   795      *
   796      * @param  elementType  the <i>open type</i> of element values contained
   796      * @param  elementType  the <i>open type</i> of element values contained
   797      *                      in the arrays described by this <tt>ArrayType</tt>
   797      *                      in the arrays described by this <tt>ArrayType</tt>
   798      *                      instance; must be an instance of either
   798      *                      instance; must be an instance of either
   799      *                      <tt>SimpleType</tt>, <tt>CompositeType</tt>,
   799      *                      <tt>SimpleType</tt>, <tt>CompositeType</tt>,
   817      * <p>
   817      * <p>
   818      * Calling this method twice with the same parameters may return the
   818      * Calling this method twice with the same parameters may return the
   819      * same object or two equal but not identical objects.
   819      * same object or two equal but not identical objects.
   820      * <p>
   820      * <p>
   821      * As an example, the following piece of code:
   821      * As an example, the following piece of code:
   822      * <pre>
   822      * <pre>{@code
   823      * ArrayType<int[][][]> t = ArrayType.getPrimitiveArrayType(int[][][].class);
   823      * ArrayType<int[][][]> t = ArrayType.getPrimitiveArrayType(int[][][].class);
   824      * System.out.println("array class name       = " + t.getClassName());
   824      * System.out.println("array class name       = " + t.getClassName());
   825      * System.out.println("element class name     = " + t.getElementOpenType().getClassName());
   825      * System.out.println("element class name     = " + t.getElementOpenType().getClassName());
   826      * System.out.println("array type name        = " + t.getTypeName());
   826      * System.out.println("array type name        = " + t.getTypeName());
   827      * System.out.println("array type description = " + t.getDescription());
   827      * System.out.println("array type description = " + t.getDescription());
   828      * </pre>
   828      * }</pre>
   829      * would produce the following output:
   829      * would produce the following output:
   830      * <pre>
   830      * <pre>{@code
   831      * array class name       = [[[I
   831      * array class name       = [[[I
   832      * element class name     = java.lang.Integer
   832      * element class name     = java.lang.Integer
   833      * array type name        = [[[I
   833      * array type name        = [[[I
   834      * array type description = 3-dimension array of int
   834      * array type description = 3-dimension array of int
   835      * </pre>
   835      * }</pre>
   836      *
   836      *
   837      * @param arrayClass a primitive array class such as {@code int[].class},
   837      * @param arrayClass a primitive array class such as {@code int[].class},
   838      *                   {@code boolean[][].class}, etc. The {@link
   838      *                   {@code boolean[][].class}, etc. The {@link
   839      *                   #getElementOpenType()} method of the returned
   839      *                   #getElementOpenType()} method of the returned
   840      *                   {@code ArrayType} returns the {@link SimpleType}
   840      *                   {@code ArrayType} returns the {@link SimpleType}