Esempio n. 1
0
 /**
  * Returns the keys for the values in the collection
  *
  * @return The keys (never null)
  * @author Klaus Meffert
  * @since 2.3
  */
 public List getKeys() {
   final List result = new java.util.ArrayList();
   final Iterator iterator = m_data.iterator();
   while (iterator.hasNext()) {
     final KeyedValue kv = (KeyedValue) iterator.next();
     result.add(kv.getKey());
   }
   return result;
 }
Esempio n. 2
0
 /**
  * @param a_key the key to search for
  * @return index for a given key or -1 if the key is not found
  * @author Klaus Meffert
  * @since 2.3
  */
 public int getIndex(final Comparable a_key) {
   int i = 0;
   final Iterator iterator = m_data.iterator();
   while (iterator.hasNext()) {
     final KeyedValue kv = (KeyedValue) iterator.next();
     if (kv.getKey() != null) {
       if (kv.getKey().equals(a_key)) {
         return i;
       }
     } else {
       if (a_key == null) {
         return i;
       }
     }
     i++;
   }
   // key not found
   return -1;
 }
Esempio n. 3
0
 /**
  * @param a_index the item index to retrieve the key for, starting at 0
  * @return the row key for item at given index
  * @author Klaus Meffert
  * @since 2.3
  */
 public Comparable getKey(final int a_index) {
   Comparable result;
   final KeyedValue item = (KeyedValue) m_data.get(a_index);
   if (item != null) {
     result = item.getKey();
   } else {
     result = null;
   }
   return result;
 }