1 26 27 package org.objectweb.util.browser.plugin.java.map; 28 29 import org.objectweb.util.browser.api.Table; 30 import org.objectweb.util.browser.api.TreeView; 31 import org.objectweb.util.browser.core.naming.DefaultEntry; 32 import org.objectweb.util.browser.core.naming.DefaultName; 33 34 42 public class MapTable 43 implements Table 44 { 45 46 47 53 59 65 71 74 public String [] getHeaders(TreeView treeView) 75 { 76 return new String []{"Keys","Values"}; 77 } 78 79 83 public Object [][] getRows(TreeView treeView) 84 { 85 java.util.Map map = (java.util.Map )treeView.getSelectedObject(); 87 88 java.util.Map.Entry[] elements = 90 (java.util.Map.Entry[])map.entrySet().toArray(new java.util.Map.Entry[0]); 91 92 Object [][] mappings = new Object [map.size()][2]; 94 for (int i = 0; i < elements.length; i++) { 95 mappings[i] = 96 new Object []{elements[i].getKey(), 97 new DefaultEntry(elements[i].getValue(), 98 new DefaultName(elements[i].getKey().toString()))}; 99 } 100 return mappings; 101 } 102 103 } | Popular Tags |