Coverage Report - org.jaudiotagger.tag.datatype.AbstractIntStringValuePair
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractIntStringValuePair
100%
9/9
100%
2/2
1.333
 
 1  
 /**
 2  
  * @author : Paul Taylor
 3  
  * <p/>
 4  
  * Version @version:$Id: AbstractIntStringValuePair.java 836 2009-11-12 15:44:07Z paultaylor $
 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  20
 public class AbstractIntStringValuePair extends AbstractValuePair<Integer, String>
 31  
 {
 32  20
     protected Integer key = null;
 33  
 
 34  
     /**
 35  
      * Get Id for Value
 36  
      * @param value
 37  
      * @return
 38  
      */
 39  
     public Integer getIdForValue(String value)
 40  
     {
 41  110
         return valueToId.get(value);
 42  
     }
 43  
 
 44  
     /**
 45  
      * Get value for Id
 46  
      * @param id
 47  
      * @return
 48  
      */
 49  
     public String getValueForId(int id)
 50  
     {
 51  18818
         return idToValue.get(id);
 52  
     }
 53  
 
 54  
     protected void createMaps()
 55  
     {
 56  
         //Create the reverse the map
 57  20
         for (Map.Entry<Integer, String> entry : idToValue.entrySet())
 58  
         {
 59  736
             valueToId.put(entry.getValue(), entry.getKey());
 60  
         }
 61  
 
 62  
         //Value List sort alphabetically
 63  20
         valueList.addAll(idToValue.values());
 64  20
         Collections.sort(valueList);
 65  20
     }
 66  
 }