Coverage Report - org.jaudiotagger.tag.datatype.PairedTextEncodedStringNullTerminated
 
Classes in this File Line Coverage Branch Coverage Complexity
PairedTextEncodedStringNullTerminated
78%
11/14
N/A
1.286
PairedTextEncodedStringNullTerminated$ValuePairs
80%
4/5
50%
1/2
1.286
 
 1  
 package org.jaudiotagger.tag.datatype;
 2  
 
 3  
 import org.jaudiotagger.tag.InvalidDataTypeException;
 4  
 import org.jaudiotagger.tag.id3.AbstractTagFrameBody;
 5  
 
 6  
 /**
 7  
  * Represents a datatype that allow multiple Strings but they should be paired, i.e should be 2,4,6.. Strings
 8  
  * <p/>
 9  
  * TODO Pair restriction not currently implemented
 10  
  */
 11  6
 public class PairedTextEncodedStringNullTerminated extends MultipleTextEncodedStringNullTerminated
 12  
 {
 13  
     public PairedTextEncodedStringNullTerminated(String identifier, AbstractTagFrameBody frameBody)
 14  
     {
 15  18
         super(identifier, frameBody);
 16  18
         value = new PairedTextEncodedStringNullTerminated.ValuePairs();
 17  18
     }
 18  
 
 19  
     public PairedTextEncodedStringNullTerminated(TextEncodedStringSizeTerminated object)
 20  
     {
 21  0
         super(object);
 22  0
         value = new PairedTextEncodedStringNullTerminated.ValuePairs();
 23  0
     }
 24  
 
 25  
     public PairedTextEncodedStringNullTerminated(PairedTextEncodedStringNullTerminated object)
 26  
     {
 27  1
         super(object);        
 28  1
     }
 29  
 
 30  
     /**
 31  
      * Read Null Terminated Strings from the array starting at offset, continue until unable to find any null terminated
 32  
      * Strings or until reached the end of the array. The offset should be set to byte after the last null terminated
 33  
      * String found.
 34  
      *
 35  
      * @param arr    to read the Strings from
 36  
      * @param offset in the array to start reading from
 37  
      * @throws InvalidDataTypeException if unable to find any null terminated Strings or if find odd number of Strings
 38  
      */
 39  
     public void readByteArray(byte[] arr, int offset) throws InvalidDataTypeException
 40  
     {
 41  6
         logger.finer("Reading PairedTextEncodedStringNullTerminated from array from offset:" + offset);
 42  6
         super.readByteArray(arr, offset);
 43  6
         logger.finer("Read PairedTextEncodedStringNullTerminated from array from offset:");
 44  6
     }
 45  
 
 46  
     /**
 47  
      * This holds the values held by this PairedTextEncodedDatatype, always held as pairs of values
 48  
      */
 49  
     public static class ValuePairs extends MultipleTextEncodedStringNullTerminated.Values
 50  
     {
 51  
         public ValuePairs()
 52  
         {
 53  22
             super();
 54  22
         }
 55  
 
 56  
         /**
 57  
          *
 58  
          * @return no of values
 59  
         */
 60  
         public int getNumberOfPairs()
 61  
         {
 62  2
             if(this.getNumberOfValues()>0)
 63  
             {
 64  2
                 return this.getNumberOfValues() / 2;
 65  
             }
 66  0
             return 0;
 67  
         }
 68  
     }
 69  
 
 70  
     public ValuePairs getValue()
 71  
     {
 72  21
         return (ValuePairs)value;
 73  
     }
 74  
 
 75  
 
 76  
 }