summaryrefslogtreecommitdiffstats
path: root/libjava/classpath/javax/management/openmbean
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/javax/management/openmbean')
-rw-r--r--libjava/classpath/javax/management/openmbean/ArrayType.java23
-rw-r--r--libjava/classpath/javax/management/openmbean/CompositeDataSupport.java11
-rw-r--r--libjava/classpath/javax/management/openmbean/CompositeType.java6
-rw-r--r--libjava/classpath/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java23
-rw-r--r--libjava/classpath/javax/management/openmbean/OpenMBeanInfoSupport.java8
-rw-r--r--libjava/classpath/javax/management/openmbean/OpenMBeanParameterInfoSupport.java23
-rw-r--r--libjava/classpath/javax/management/openmbean/SimpleType.java2
-rw-r--r--libjava/classpath/javax/management/openmbean/TabularDataSupport.java31
-rw-r--r--libjava/classpath/javax/management/openmbean/TabularType.java5
9 files changed, 63 insertions, 69 deletions
diff --git a/libjava/classpath/javax/management/openmbean/ArrayType.java b/libjava/classpath/javax/management/openmbean/ArrayType.java
index e6cf5261aaa..1a23f666f10 100644
--- a/libjava/classpath/javax/management/openmbean/ArrayType.java
+++ b/libjava/classpath/javax/management/openmbean/ArrayType.java
@@ -152,7 +152,7 @@ public class ArrayType<T>
throw new IllegalArgumentException("Dimensions must be greater " +
"than or equal to 1.");
if (elementType instanceof ArrayType)
- return dim + ((ArrayType) elementType).getDimension();
+ return dim + ((ArrayType<?>) elementType).getDimension();
return dim;
}
@@ -236,7 +236,7 @@ public class ArrayType<T>
private static final OpenType<?> getElementType(OpenType<?> elemType)
{
if (elemType instanceof ArrayType)
- return ((ArrayType) elemType).getElementOpenType();
+ return ((ArrayType<?>) elemType).getElementOpenType();
return elemType;
}
@@ -257,7 +257,7 @@ public class ArrayType<T>
{
OpenType<?> trueElemType = getElementType(elemType);
if (elemType instanceof ArrayType &&
- ((ArrayType) elemType).isPrimitiveArray())
+ ((ArrayType<?>) elemType).isPrimitiveArray())
return getPrimitiveTypeClass((SimpleType<?>) trueElemType).getName();
return trueElemType.getClassName();
}
@@ -323,7 +323,7 @@ public class ArrayType<T>
dimension = getDimensions(elementType, dim);
this.elementType = getElementType(elementType);
primitiveArray = (elementType instanceof ArrayType &&
- ((ArrayType) elementType).isPrimitiveArray());
+ ((ArrayType<?>) elementType).isPrimitiveArray());
}
/**
@@ -408,7 +408,7 @@ public class ArrayType<T>
{
if (!(obj instanceof ArrayType))
return false;
- ArrayType atype = (ArrayType) obj;
+ ArrayType<?> atype = (ArrayType<?>) obj;
return (atype.getDimension() == dimension &&
atype.getElementOpenType().equals(elementType) &&
atype.isPrimitiveArray() == primitiveArray);
@@ -439,13 +439,14 @@ public class ArrayType<T>
* is not in {@link OpenType#ALLOWED_CLASSNAMES_LIST}.
* @since 1.6
*/
+ @SuppressWarnings("unchecked")
public static <E> ArrayType<E[]> getArrayType(OpenType<E> elementType)
throws OpenDataException
{
ArrayType<E[]> arr = (ArrayType<E[]>) cache.get(elementType);
if (arr != null)
return arr;
- arr = new ArrayType(1, elementType);
+ arr = new ArrayType<E[]>(1, elementType);
cache.put(elementType, arr);
return arr;
}
@@ -484,6 +485,7 @@ public class ArrayType<T>
* array.
* @since 1.6
*/
+ @SuppressWarnings("unchecked")
public static <T> ArrayType<T> getPrimitiveArrayType(Class<T> type)
{
ArrayType<T> arr = (ArrayType<T>) primCache.get(type);
@@ -499,10 +501,9 @@ public class ArrayType<T>
throw new IllegalArgumentException("The given class is " +
"not an array.");
} while (comType.isArray());
- String className = type.getName();
try
{
- arr = new ArrayType(getPrimitiveType(comType), true);
+ arr = new ArrayType<T>(getPrimitiveType(comType), true);
}
catch (OpenDataException e)
{
@@ -512,7 +513,7 @@ public class ArrayType<T>
while (dim > 1)
try
{
- arr = new ArrayType(1, arr);
+ arr = new ArrayType<T>(1, arr);
--dim;
}
catch (OpenDataException e)
@@ -610,12 +611,12 @@ public class ArrayType<T>
{
if (obj == null)
return false;
- Class objClass = obj.getClass();
+ Class<?> objClass = obj.getClass();
if (!(objClass.isArray()))
return false;
if (elementType instanceof SimpleType)
return getClassName().equals(objClass.getName());
- Class elementClass = null;
+ Class<?> elementClass = null;
try
{
elementClass = Class.forName(getClassName());
diff --git a/libjava/classpath/javax/management/openmbean/CompositeDataSupport.java b/libjava/classpath/javax/management/openmbean/CompositeDataSupport.java
index d4c9d450c38..6bce2672d4f 100644
--- a/libjava/classpath/javax/management/openmbean/CompositeDataSupport.java
+++ b/libjava/classpath/javax/management/openmbean/CompositeDataSupport.java
@@ -154,7 +154,7 @@ public class CompositeDataSupport
throw new IllegalArgumentException("The values array is null.");
if (names.length != values.length)
throw new IllegalArgumentException("The sizes of the arrays differ.");
- Set typeKeys = type.keySet();
+ Set<String> typeKeys = type.keySet();
if (typeKeys.size() != names.length)
throw new OpenDataException("The number of field names does not match " +
"the type description.");
@@ -227,10 +227,8 @@ public class CompositeDataSupport
CompositeData data = (CompositeData) obj;
if (!(data.getCompositeType().equals(compositeType)))
return false;
- Iterator it = contents.keySet().iterator();
- while (it.hasNext())
+ for (String key : contents.keySet())
{
- String key = (String) it.next();
if (!(data.containsKey(key)))
return false;
if (!(data.get(key).equals(contents.get(key))))
@@ -308,9 +306,8 @@ public class CompositeDataSupport
public int hashCode()
{
int code = compositeType.hashCode();
- Iterator it = values().iterator();
- while (it.hasNext())
- code += it.next().hashCode();
+ for (Object o : contents.values())
+ code += o.hashCode();
return code;
}
diff --git a/libjava/classpath/javax/management/openmbean/CompositeType.java b/libjava/classpath/javax/management/openmbean/CompositeType.java
index 1a213f607c9..3244c6457c1 100644
--- a/libjava/classpath/javax/management/openmbean/CompositeType.java
+++ b/libjava/classpath/javax/management/openmbean/CompositeType.java
@@ -118,7 +118,7 @@ public class CompositeType
|| names.length != types.length)
throw new IllegalArgumentException("Arrays must be non-empty " +
"and of equal size.");
- nameToDescription = new TreeMap();
+ nameToDescription = new TreeMap<String,String>();
for (int a = 0; a < names.length; ++a)
{
if (names[a] == null)
@@ -243,10 +243,8 @@ public class CompositeType
if (hashCode == null)
{
int elementTotal = 0;
- Iterator it = nameToType.entrySet().iterator();
- while (it.hasNext())
+ for (Map.Entry<String,OpenType<?>> entry : nameToType.entrySet())
{
- Map.Entry entry = (Map.Entry) it.next();
elementTotal += (entry.getKey().hashCode() +
entry.getValue().hashCode());
}
diff --git a/libjava/classpath/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java b/libjava/classpath/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java
index 22667aadf7d..6da2e95e689 100644
--- a/libjava/classpath/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java
+++ b/libjava/classpath/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java
@@ -77,12 +77,12 @@ public class OpenMBeanAttributeInfoSupport
/**
* The minimum value of the attribute (may be <code>null</code>).
*/
- private Comparable<Object> minValue;
+ private Comparable<?> minValue;
/**
* The maximum value of the attribute (may be <code>null</code>).
*/
- private Comparable<Object> maxValue;
+ private Comparable<?> maxValue;
/**
* The hash code of this instance.
@@ -203,6 +203,7 @@ public class OpenMBeanAttributeInfoSupport
* the empty string.
* @throws OpenDataException if any condition in the list above is broken.
*/
+ @SuppressWarnings("unchecked")
public <T> OpenMBeanAttributeInfoSupport(String name, String desc, OpenType<T> type,
boolean isReadable, boolean isWritable,
boolean isIs, T defaultValue,
@@ -224,23 +225,23 @@ public class OpenMBeanAttributeInfoSupport
type instanceof TabularType))
throw new OpenDataException("Default values are not applicable for " +
"array or tabular types.");
- if (minValue != null && maxValue != null
- && minValue.compareTo(maxValue) > 0)
+ if (minimumValue != null && maximumValue != null
+ && minimumValue.compareTo((T) maximumValue) > 0)
throw new OpenDataException("The minimum value is greater than the " +
"maximum.");
- if (minValue != null && defaultValue != null
- && minValue.compareTo(defaultValue) > 0)
+ if (minimumValue != null && defaultValue != null
+ && minimumValue.compareTo(defaultValue) > 0)
throw new OpenDataException("The minimum value is greater than the " +
"default.");
- if (defaultValue != null && maxValue != null
- && maxValue.compareTo(defaultValue) < 0)
+ if (defaultValue != null && maximumValue != null
+ && maximumValue.compareTo(defaultValue) < 0)
throw new OpenDataException("The default value is greater than the " +
"maximum.");
openType = type;
this.defaultValue = defaultValue;
- minValue = (Comparable<Object>) minimumValue;
- maxValue = (Comparable<Object>) maximumValue;
+ minValue = minimumValue;
+ maxValue = maximumValue;
}
/**
@@ -300,7 +301,7 @@ public class OpenMBeanAttributeInfoSupport
"array or tabular types.");
if (legalValues != null && legalValues.length > 0)
{
- Set lv = new HashSet(legalValues.length);
+ Set<T> lv = new HashSet<T>(legalValues.length);
for (int a = 0; a < legalValues.length; ++a)
{
if (legalValues[a] != null &&
diff --git a/libjava/classpath/javax/management/openmbean/OpenMBeanInfoSupport.java b/libjava/classpath/javax/management/openmbean/OpenMBeanInfoSupport.java
index 5f8d55b8377..d67ff76a0f3 100644
--- a/libjava/classpath/javax/management/openmbean/OpenMBeanInfoSupport.java
+++ b/libjava/classpath/javax/management/openmbean/OpenMBeanInfoSupport.java
@@ -151,10 +151,10 @@ public class OpenMBeanInfoSupport
if (hashCode == null)
hashCode =
Integer.valueOf(getClassName().hashCode() +
- new HashSet(Arrays.asList(getAttributes())).hashCode() +
- new HashSet(Arrays.asList(getConstructors())).hashCode() +
- new HashSet(Arrays.asList(getNotifications())).hashCode() +
- new HashSet(Arrays.asList(getOperations())).hashCode());
+ new HashSet<MBeanAttributeInfo>(Arrays.asList(getAttributes())).hashCode() +
+ new HashSet<MBeanConstructorInfo>(Arrays.asList(getConstructors())).hashCode() +
+ new HashSet<MBeanNotificationInfo>(Arrays.asList(getNotifications())).hashCode() +
+ new HashSet<MBeanOperationInfo>(Arrays.asList(getOperations())).hashCode());
return hashCode.intValue();
}
diff --git a/libjava/classpath/javax/management/openmbean/OpenMBeanParameterInfoSupport.java b/libjava/classpath/javax/management/openmbean/OpenMBeanParameterInfoSupport.java
index 7fad2a13161..5f86bf4af96 100644
--- a/libjava/classpath/javax/management/openmbean/OpenMBeanParameterInfoSupport.java
+++ b/libjava/classpath/javax/management/openmbean/OpenMBeanParameterInfoSupport.java
@@ -78,12 +78,12 @@ public class OpenMBeanParameterInfoSupport
/**
* The minimum value of the parameter (may be <code>null</code>).
*/
- private Comparable<Object> minValue;
+ private Comparable<?> minValue;
/**
* The maximum value of the parameter (may be <code>null</code>).
*/
- private Comparable<Object> maxValue;
+ private Comparable<?> maxValue;
/**
* The hash code of this instance.
@@ -190,6 +190,7 @@ public class OpenMBeanParameterInfoSupport
* the empty string.
* @throws OpenDataException if any condition in the list above is broken.
*/
+ @SuppressWarnings("unchecked")
public <T> OpenMBeanParameterInfoSupport(String name, String desc, OpenType<T> type,
T defaultValue, Comparable<T> minimumValue,
Comparable<T> maximumValue)
@@ -209,22 +210,22 @@ public class OpenMBeanParameterInfoSupport
type instanceof TabularType))
throw new OpenDataException("Default values are not applicable for " +
"array or tabular types.");
- if (minValue != null && maxValue != null
- && minValue.compareTo(maxValue) > 0)
+ if (minimumValue != null && maximumValue != null
+ && minimumValue.compareTo((T) maximumValue) > 0)
throw new OpenDataException("The minimum value is greater than the " +
"maximum.");
- if (minValue != null && defaultValue != null
- && minValue.compareTo(defaultValue) > 0)
+ if (minimumValue != null && defaultValue != null
+ && minimumValue.compareTo(defaultValue) > 0)
throw new OpenDataException("The minimum value is greater than the " +
"default.");
- if (defaultValue != null && maxValue != null
- && maxValue.compareTo(defaultValue) < 0)
+ if (defaultValue != null && maximumValue != null
+ && maximumValue.compareTo(defaultValue) < 0)
throw new OpenDataException("The default value is greater than the " +
"maximum.");
this.defaultValue = defaultValue;
- minValue = (Comparable<Object>) minimumValue;
- maxValue = (Comparable<Object>) maximumValue;
+ minValue = minimumValue;
+ maxValue = maximumValue;
}
/**
@@ -279,7 +280,7 @@ public class OpenMBeanParameterInfoSupport
"array or tabular types.");
if (legalValues != null && legalValues.length > 0)
{
- Set lv = new HashSet(legalValues.length);
+ Set<T> lv = new HashSet<T>(legalValues.length);
for (int a = 0; a < legalValues.length; ++a)
{
if (legalValues[a] != null &&
diff --git a/libjava/classpath/javax/management/openmbean/SimpleType.java b/libjava/classpath/javax/management/openmbean/SimpleType.java
index fb3b1bc28b7..ef05e9dfe4f 100644
--- a/libjava/classpath/javax/management/openmbean/SimpleType.java
+++ b/libjava/classpath/javax/management/openmbean/SimpleType.java
@@ -232,7 +232,7 @@ public final class SimpleType<T>
{
if (!(obj instanceof SimpleType))
return false;
- SimpleType sType = (SimpleType) obj;
+ SimpleType<?> sType = (SimpleType<?>) obj;
return sType.getClassName().equals(getClassName());
}
diff --git a/libjava/classpath/javax/management/openmbean/TabularDataSupport.java b/libjava/classpath/javax/management/openmbean/TabularDataSupport.java
index 1d340e86f59..8557f5f2464 100644
--- a/libjava/classpath/javax/management/openmbean/TabularDataSupport.java
+++ b/libjava/classpath/javax/management/openmbean/TabularDataSupport.java
@@ -68,7 +68,7 @@ public class TabularDataSupport
*
* @serial the map of rows to column values.
*/
- private Map<Object,Object> dataMap;
+ private HashMap<Object,Object> dataMap;
/**
* The tabular type which represents this tabular data instance.
@@ -141,14 +141,10 @@ public class TabularDataSupport
throw new InvalidOpenTypeException("The type of the given value " +
"does not match the row type " +
"of this instance.");
- List indexNames = tabularType.getIndexNames();
- List matchingIndicies = new ArrayList(indexNames.size());
- Iterator it = indexNames.iterator();
- while (it.hasNext())
- {
- String name = (String) it.next();
- matchingIndicies.add(val.get(name));
- }
+ List<String> indexNames = tabularType.getIndexNames();
+ List<String> matchingIndicies = new ArrayList<String>(indexNames.size());
+ for (String name : indexNames)
+ matchingIndicies.add(val.get(name).toString());
return matchingIndicies.toArray();
}
@@ -167,13 +163,14 @@ public class TabularDataSupport
*
* @return a shallow clone of this {@link TabularDataSupport}.
*/
+ @SuppressWarnings("unchecked")
public Object clone()
{
TabularDataSupport clone = null;
try
{
clone = (TabularDataSupport) super.clone();
- clone.setMap((HashMap) ((HashMap) dataMap).clone());
+ clone.setMap((HashMap<Object,Object>) dataMap.clone());
}
catch (CloneNotSupportedException e)
{
@@ -390,11 +387,11 @@ public class TabularDataSupport
*/
private boolean isKeyValid(Object[] key)
{
- Iterator it = tabularType.getIndexNames().iterator();
+ Iterator<String> it = tabularType.getIndexNames().iterator();
CompositeType rowType = tabularType.getRowType();
for (int a = 0; it.hasNext(); ++a)
{
- OpenType type = rowType.getType((String) it.next());
+ OpenType<?> type = rowType.getType(it.next());
if (!(type.isValue(key[a])))
return false;
}
@@ -496,7 +493,7 @@ public class TabularDataSupport
{
if (vals == null || vals.length == 0)
return;
- Map mapToAdd = new HashMap(vals.length);
+ Map<Object,Object> mapToAdd = new HashMap<Object,Object>(vals.length);
for (int a = 0; a < vals.length; ++a)
{
Object[] key = calculateIndex(vals[a]);
@@ -539,9 +536,9 @@ public class TabularDataSupport
{
if (m == null || m.size() == 0)
return;
- Collection vals = m.values();
+ Collection<?> vals = m.values();
CompositeData[] data = new CompositeData[vals.size()];
- Iterator it = vals.iterator();
+ Iterator<?> it = vals.iterator();
for (int a = 0; it.hasNext(); ++a)
{
data[a] = (CompositeData) it.next();
@@ -591,12 +588,12 @@ public class TabularDataSupport
}
/**
- * Package-private method to set the internal {@link java.util.Map}
+ * Private method to set the internal {@link java.util.Map}
* instance (used in cloning).
*
* @param map the new map used.
*/
- void setMap(Map map)
+ private void setMap(HashMap<Object,Object> map)
{
dataMap = map;
}
diff --git a/libjava/classpath/javax/management/openmbean/TabularType.java b/libjava/classpath/javax/management/openmbean/TabularType.java
index 9a0881e0f92..5a861d061bd 100644
--- a/libjava/classpath/javax/management/openmbean/TabularType.java
+++ b/libjava/classpath/javax/management/openmbean/TabularType.java
@@ -206,9 +206,8 @@ public class TabularType
if (hashCode == null)
{
int elementTotal = 0;
- Iterator it = indexNames.iterator();
- while (it.hasNext())
- elementTotal += it.next().hashCode();
+ for (String s : indexNames)
+ elementTotal += s.hashCode();
hashCode = Integer.valueOf(elementTotal
+ getTypeName().hashCode()
+ rowType.hashCode());
OpenPOWER on IntegriCloud