| 1 |  |   | 
  | 2 |  |   | 
  | 3 |  |   | 
  | 4 |  |   | 
  | 5 |  |   | 
  | 6 |  |   | 
  | 7 |  |   | 
  | 8 |  |   | 
  | 9 |  |   | 
  | 10 |  |   | 
  | 11 |  |   | 
  | 12 |  |   | 
  | 13 |  |   | 
  | 14 |  |   | 
  | 15 |  |   | 
  | 16 |  |  package org.kuali.student.common.ui.client.widgets.list.impl; | 
  | 17 |  |   | 
  | 18 |  |  import java.util.ArrayList; | 
  | 19 |  |  import java.util.HashMap; | 
  | 20 |  |  import java.util.List; | 
  | 21 |  |  import java.util.Map; | 
  | 22 |  |   | 
  | 23 |  |  import org.kuali.student.common.ui.client.widgets.list.ListItems; | 
  | 24 |  |   | 
  | 25 | 0 |  public class SimpleListItems implements ListItems { | 
  | 26 | 0 |          HashMap<String,String> items = new HashMap<String,String>(); | 
  | 27 | 0 |          HashMap<String,HashMap<String,String>> attributes = new HashMap<String,HashMap<String,String>>(); | 
  | 28 |  |           | 
  | 29 |  |          public void addItem(String id, String value){ | 
  | 30 | 0 |                  items.put(id, value); | 
  | 31 | 0 |          } | 
  | 32 |  |   | 
  | 33 |  |          public void addAttribute(String itemId, String attrKey, String value){ | 
  | 34 | 0 |                  HashMap<String,String> attributeMap = attributes.get(itemId); | 
  | 35 | 0 |                  if(attributeMap==null){ | 
  | 36 | 0 |                          attributeMap = new HashMap<String,String>(); | 
  | 37 | 0 |                          attributes.put(itemId, attributeMap); | 
  | 38 |  |                  } | 
  | 39 | 0 |                  attributeMap.put(attrKey, value); | 
  | 40 | 0 |          } | 
  | 41 |  |   | 
  | 42 |  |           | 
  | 43 |  |          @Override | 
  | 44 |  |          public List<String> getAttrKeys() { | 
  | 45 | 0 |                  ArrayList<String> attrKeys = new ArrayList<String>(); | 
  | 46 | 0 |                  for(Map.Entry<String,HashMap<String,String>> attributeEntry:attributes.entrySet()){ | 
  | 47 | 0 |                          attrKeys.addAll(attributeEntry.getValue().keySet()); | 
  | 48 |  |                  } | 
  | 49 | 0 |                  return attrKeys; | 
  | 50 |  |          } | 
  | 51 |  |   | 
  | 52 |  |          @Override | 
  | 53 |  |          public String getItemAttribute(String id, String attrkey) { | 
  | 54 | 0 |                  return attributes.get("id").get("attrkey"); | 
  | 55 |  |          } | 
  | 56 |  |   | 
  | 57 |  |          @Override | 
  | 58 |  |          public int getItemCount() { | 
  | 59 | 0 |                  return items.size(); | 
  | 60 |  |          } | 
  | 61 |  |   | 
  | 62 |  |          @Override | 
  | 63 |  |          public List<String> getItemIds() { | 
  | 64 | 0 |                  return new ArrayList<String>(items.keySet()); | 
  | 65 |  |          } | 
  | 66 |  |   | 
  | 67 |  |          @Override | 
  | 68 |  |          public String getItemText(String id) { | 
  | 69 | 0 |                  return items.get(id); | 
  | 70 |  |          } | 
  | 71 |  |   | 
  | 72 |  |          public void clear(){ | 
  | 73 | 0 |                  items.clear(); | 
  | 74 | 0 |                  attributes.clear(); | 
  | 75 | 0 |          } | 
  | 76 |  |  } |