Exemple #1
0
 /**
  * Returns index of the object a <code>List</code> object of <code>PersistentObject</code>s that
  * contains an encoded key (<code>getEncodedKey()</code>).
  *
  * @param list <code>List</code> of objects to search.
  * @param encodedKey key obtained via <code>getEncodedKey()</code>.
  * @return index of object on list or <code>-1</code> if not found.
  * @see net.sf.jrf.domain.PersistentObject#getEncodedKey()
  * @see #findByKey(List,String)
  */
 public static int findIndexByKey(List list, String encodedKey) {
   for (int i = 0; i < list.size(); i++) {
     PersistentObject p = (PersistentObject) list.get(i);
     if (p.getEncodedKey().equals(encodedKey)) {
       return i;
     }
   }
   return -1;
 }
Exemple #2
0
 /**
  * Scans a list of <code>PersistentObject</code>s and return the object that matches the key or
  * <code>null</code> if not found.
  *
  * @param list list of <code>PersistentObject</code>s to scan.
  * @param encodedKey key to locate correct record on the list.
  * @return key-matching record of <code>null</code> if not found.
  */
 public static PersistentObject getPoInList(List list, String encodedKey) {
   Iterator iter = list.iterator();
   while (iter.hasNext()) {
     PersistentObject p = (PersistentObject) iter.next();
     if (p.getEncodedKey().equals(encodedKey)) {
       return p;
     }
   }
   return null;
 }