jdk/src/share/classes/javax/management/openmbean/TabularDataSupport.java
changeset 1510 e747d3193ef2
parent 1247 b4c26443dee5
child 5506 202f599c92aa
equal deleted inserted replaced
1509:89e3d8869c94 1510:e747d3193ef2
    28 
    28 
    29 
    29 
    30 // java import
    30 // java import
    31 //
    31 //
    32 import com.sun.jmx.mbeanserver.GetPropertyAction;
    32 import com.sun.jmx.mbeanserver.GetPropertyAction;
       
    33 import com.sun.jmx.mbeanserver.Util;
    33 import java.io.IOException;
    34 import java.io.IOException;
    34 import java.io.ObjectInputStream;
    35 import java.io.ObjectInputStream;
    35 import java.io.Serializable;
    36 import java.io.Serializable;
    36 import java.security.AccessController;
    37 import java.security.AccessController;
    37 import java.util.ArrayList;
    38 import java.util.ArrayList;
   609      * the values contained in this {@code TabularDataSupport} instance.
   610      * the values contained in this {@code TabularDataSupport} instance.
   610      */
   611      */
   611     @SuppressWarnings("unchecked")  // historical confusion about the return type
   612     @SuppressWarnings("unchecked")  // historical confusion about the return type
   612     public Collection<Object> values() {
   613     public Collection<Object> values() {
   613 
   614 
   614         return (Collection) dataMap.values() ;
   615         return Util.cast(dataMap.values());
   615     }
   616     }
   616 
   617 
   617 
   618 
   618     /**
   619     /**
   619      * Returns a collection view of the index to row mappings
   620      * Returns a collection view of the index to row mappings
   645      * @see java.util.Map.Entry
   646      * @see java.util.Map.Entry
   646      */
   647      */
   647     @SuppressWarnings("unchecked")  // historical confusion about the return type
   648     @SuppressWarnings("unchecked")  // historical confusion about the return type
   648     public Set<Map.Entry<Object,Object>> entrySet() {
   649     public Set<Map.Entry<Object,Object>> entrySet() {
   649 
   650 
   650         return (Set) dataMap.entrySet();
   651         return Util.cast(dataMap.entrySet());
   651     }
   652     }
   652 
   653 
   653 
   654 
   654     /* ***  Commodity methods from java.lang.Object  *** */
   655     /* ***  Commodity methods from java.lang.Object  *** */
   655 
   656 
   723         // (row values comparison is enough, because keys are calculated according to tabularType)
   724         // (row values comparison is enough, because keys are calculated according to tabularType)
   724 
   725 
   725         if (this.size() != other.size()) {
   726         if (this.size() != other.size()) {
   726             return false;
   727             return false;
   727         }
   728         }
   728         for (Iterator iter = this.values().iterator(); iter.hasNext();  ) {
   729         for (CompositeData value : dataMap.values()) {
   729             CompositeData value = (CompositeData) iter.next();
       
   730             if ( ! other.containsValue(value) ) {
   730             if ( ! other.containsValue(value) ) {
   731                 return false;
   731                 return false;
   732             }
   732             }
   733         }
   733         }
   734 
   734 
   758    public int hashCode() {
   758    public int hashCode() {
   759 
   759 
   760         int result = 0;
   760         int result = 0;
   761 
   761 
   762         result += this.tabularType.hashCode();
   762         result += this.tabularType.hashCode();
   763         for (Iterator iter = this.values().iterator(); iter.hasNext();  ) {
   763         for (Object value : values())
   764             result += ((CompositeData)iter.next()).hashCode();
   764             result += value.hashCode();
   765         }
       
   766 
   765 
   767         return result;
   766         return result;
   768 
   767 
   769     }
   768     }
   770 
   769