|
Java example source code file (TabularType.java)
The TabularType.java Java example source code/*
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.management.openmbean;
// java import
//
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
// jmx import
//
/**
* The <code>TabularType class is the open type class
* whose instances describe the types of {@link TabularData TabularData} values.
*
* @since 1.5
*/
public class TabularType extends OpenType<TabularData> {
/* Serial version */
static final long serialVersionUID = 6554071860220659261L;
/**
* @serial The composite type of rows
*/
private CompositeType rowType;
/**
* @serial The items used to index each row element, kept in the order the user gave
* This is an unmodifiable {@link ArrayList}
*/
private List<String> indexNames;
private transient Integer myHashCode = null; // As this instance is immutable, these two values
private transient String myToString = null; // need only be calculated once.
/* *** Constructor *** */
/**
* Constructs a <code>TabularType instance, checking for the validity of the given parameters.
* The validity constraints are described below for each parameter.
* <p>
* The Java class name of tabular data values this tabular type represents
* (ie the class name returned by the {@link OpenType#getClassName() getClassName} method)
* is set to the string value returned by <code>TabularData.class.getName().
* <p>
* @param typeName The name given to the tabular type this instance represents; cannot be a null or empty string.
* <br>
* @param description The human readable description of the tabular type this instance represents;
* cannot be a null or empty string.
* <br>
* @param rowType The type of the row elements of tabular data values described by this tabular type instance;
* cannot be null.
* <br>
* @param indexNames The names of the items the values of which are used to uniquely index each row element in the
* tabular data values described by this tabular type instance;
* cannot be null or empty. Each element should be an item name defined in <var>rowType
* (no null or empty string allowed).
* It is important to note that the <b>order of the item names in indexNames
* is used by the methods {@link TabularData#get(java.lang.Object[]) get} and
* {@link TabularData#remove(java.lang.Object[]) remove} of class
* <code>TabularData to match their array of values parameter to items.
* <br>
* @throws IllegalArgumentException if <var>rowType is null,
* or <var>indexNames is a null or empty array,
* or an element in <var>indexNames is a null or empty string,
* or <var>typeName or description is a null or empty string.
* <br>
* @throws OpenDataException if an element's value of <var>indexNames
* is not an item name defined in <var>rowType.
*/
public TabularType(String typeName,
String description,
CompositeType rowType,
String[] indexNames) throws OpenDataException {
// Check and initialize state defined by parent.
//
super(TabularData.class.getName(), typeName, description, false);
// Check rowType is not null
//
if (rowType == null) {
throw new IllegalArgumentException("Argument rowType cannot be null.");
}
// Check indexNames is neither null nor empty and does not contain any null element or empty string
//
checkForNullElement(indexNames, "indexNames");
checkForEmptyString(indexNames, "indexNames");
// Check all indexNames values are valid item names for rowType
//
for (int i=0; i<indexNames.length; i++) {
if ( ! rowType.containsKey(indexNames[i]) ) {
throw new OpenDataException("Argument's element value indexNames["+ i +"]=\""+ indexNames[i] +
"\" is not a valid item name for rowType.");
}
}
// initialize rowType
//
this.rowType = rowType;
// initialize indexNames (copy content so that subsequent
// modifs to the array referenced by the indexNames parameter
// have no impact)
//
List<String> tmpList = new ArrayList
Other Java examples (source code examples)Here is a short list of links related to this Java TabularType.java source code file: |
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.