Coverage Report - org.jaudiotagger.tag.lyrics3.Lyrics3v1Iterator
 
Classes in this File Line Coverage Branch Coverage Complexity
Lyrics3v1Iterator
0%
0/20
0%
0/8
2
 
 1  
 /**
 2  
  *  @author : Paul Taylor
 3  
  *  @author : Eric Farng
 4  
  *
 5  
  *  Version @version:$Id: Lyrics3v1Iterator.java 836 2009-11-12 15:44:07Z paultaylor $
 6  
  *
 7  
  *  MusicTag Copyright (C)2003,2004
 8  
  *
 9  
  *  This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser
 10  
  *  General Public  License as published by the Free Software Foundation; either version 2.1 of the License,
 11  
  *  or (at your option) any later version.
 12  
  *
 13  
  *  This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
 14  
  *  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 15  
  *  See the GNU Lesser General Public License for more details.
 16  
  *
 17  
  *  You should have received a copy of the GNU Lesser General Public License along with this library; if not,
 18  
  *  you can get a copy from http://www.opensource.org/licenses/lgpl-license.php or write to the Free Software
 19  
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 20  
  *
 21  
  * Description:
 22  
  */
 23  
 package org.jaudiotagger.tag.lyrics3;
 24  
 
 25  
 import java.util.Iterator;
 26  
 import java.util.NoSuchElementException;
 27  
 
 28  0
 public class Lyrics3v1Iterator implements Iterator<String>
 29  
 {
 30  
     /**
 31  
      *
 32  
      */
 33  0
     private Lyrics3v1 tag = null;
 34  
 
 35  
     /**
 36  
      *
 37  
      */
 38  0
     private int lastIndex = 0;
 39  
 
 40  
     /**
 41  
      *
 42  
      */
 43  0
     private int removeIndex = 0;
 44  
 
 45  
     /**
 46  
      * Creates a new Lyrics3v1Iterator datatype.
 47  
      *
 48  
      * @param lyrics3v1Tag
 49  
      */
 50  
     public Lyrics3v1Iterator(Lyrics3v1 lyrics3v1Tag)
 51  0
     {
 52  0
         tag = lyrics3v1Tag;
 53  0
     }
 54  
 
 55  
     /**
 56  
      * @return
 57  
      */
 58  
     public boolean hasNext()
 59  
     {
 60  0
         return !((tag.getLyric().indexOf('\n', lastIndex) < 0) && (lastIndex > tag.getLyric().length()));
 61  
     }
 62  
 
 63  
     /**
 64  
      * @return
 65  
      * @throws NoSuchElementException
 66  
      */
 67  
     public String next()
 68  
     {
 69  0
         int nextIndex = tag.getLyric().indexOf('\n', lastIndex);
 70  
 
 71  0
         removeIndex = lastIndex;
 72  
 
 73  
         String line;
 74  
 
 75  0
         if (lastIndex >= 0)
 76  
         {
 77  0
             if (nextIndex >= 0)
 78  
             {
 79  0
                 line = tag.getLyric().substring(lastIndex, nextIndex);
 80  
             }
 81  
             else
 82  
             {
 83  0
                 line = tag.getLyric().substring(lastIndex);
 84  
             }
 85  
 
 86  0
             lastIndex = nextIndex;
 87  
         }
 88  
         else
 89  
         {
 90  0
             throw new NoSuchElementException("Iteration has no more elements.");
 91  
         }
 92  
 
 93  0
         return line;
 94  
     }
 95  
 
 96  
     /**
 97  
      *
 98  
      */
 99  
     public void remove()
 100  
     {
 101  0
         String lyric = tag.getLyric().substring(0, removeIndex) + tag.getLyric().substring(lastIndex);
 102  0
         tag.setLyric(lyric);
 103  0
     }
 104  
 }