package org.honours.collection; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; /** * A collection information object is used to * hold information about a collection during runtime * of the system. Replaces the collectionInfo.inf file * which was used originally. * @author Korii 14/11/2012 */ public class CollectionInformation { private List _rows; public CollectionInformation(){ _rows = new ArrayList(); } /** * Add a row containing information about an individual collection * item or layer. * * @param type - Three types: "I" for collection item; * "LT" for text layer and "LI" for image layer. * @param frameName - name of the frame representing a collection item/layer * @param assocfilepath - the assocfilepath value associated with the item. */ public void addRow(String type,String frameName,String assocfilepath){ String[] row = new String[]{type,frameName,assocfilepath}; _rows.add(row); } public List getRows(){ return _rows; } /** * Find a row associated with a particular frame. * @param frameName * @return */ public String[] findRow(String frameName){ String[] result = null; for(String[] s : _rows){ if(s[1].equals(frameName)) result = s; } return result; } /** * Sort the collection information object by * assocfilepath */ public void sort(){ //sort rows by the 3rd index of arrays (assocfilepath) Collections.sort(_rows,new Comparator(){ public int compare(String[] s1, String[] s2){ return s1[2].compareTo(s2[2]); } }); } }