Coverage Report - org.jaudiotagger.tag.datatype.AbstractIntStringValuePair
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractIntStringValuePair
100%
9/9
100%
2/2
0
 
 1  
 /**
 2  
  * @author : Paul Taylor
 3  
  * <p/>
 4  
  * Version @version:$Id: AbstractIntStringValuePair.java,v 1.8 2008/07/21 10:45:40 paultaylor Exp $
 5  
  * <p/>
 6  
  * Jaudiotagger Copyright (C)2004,2005
 7  
  * <p/>
 8  
  * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser
 9  
  * General Public  License as published by the Free Software Foundation; either version 2.1 of the License,
 10  
  * or (at your option) any later version.
 11  
  * <p/>
 12  
  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
 13  
  * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 14  
  * See the GNU Lesser General Public License for more details.
 15  
  * <p/>
 16  
  * You should have received a copy of the GNU Lesser General Public License along with this library; if not,
 17  
  * you can get a copy from http://www.opensource.org/licenses/lgpl-license.php or write to the Free Software
 18  
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 19  
  * <p/>
 20  
  * Description:
 21  
  */
 22  
 package org.jaudiotagger.tag.datatype;
 23  
 
 24  
 import java.util.Collections;
 25  
 import java.util.Map;
 26  
 
 27  
 /**
 28  
  * A two way mapping between an Integral Id and a String value
 29  
  */
 30  137
 public class AbstractIntStringValuePair extends AbstractValuePair<Integer, String>
 31  
 {
 32  137
     protected Integer key = null;
 33  
 
 34  
     /**
 35  
      * Get Id for Value
 36  
      */
 37  
     public Integer getIdForValue(String value)
 38  
     {
 39  29
         return valueToId.get(value);
 40  
     }
 41  
 
 42  
     /**
 43  
      * Get value for Id
 44  
      */
 45  
     public String getValueForId(int id)
 46  
     {
 47  4283
         return idToValue.get(new Integer(id));
 48  
     }
 49  
 
 50  
     protected void createMaps()
 51  
     {
 52  
         //Create the reverse the map
 53  137
         for (Map.Entry<Integer, String> entry : idToValue.entrySet())
 54  
         {
 55  8972
             valueToId.put(entry.getValue(), entry.getKey());
 56  
         }
 57  
 
 58  
         //Value List sort alphabetically
 59  137
         valueList.addAll(idToValue.values());
 60  137
         Collections.sort(valueList);
 61  137
     }
 62  
 }