gt:                 lyric = new Lyrics3v2Field(byteBuffer);
context: /**
   *  @author : Paul Taylor
   *  @author : Eric Farng
   *
   *  Version @version:$Id: Lyrics3v2.java 836 2009-11-12 15:44:07Z paultaylor $
   *
   *  MusicTag Copyright (C)2003,2004
   *
   *  This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser
   *  General Public  License as published by the Free Software Foundation; either version 2.1 of the License,
   *  or (at your option) any later version.
   *
   *  This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
   *  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
   *  See the GNU Lesser General Public License for more details.
   *
   *  You should have received a copy of the GNU Lesser General Public License along with this library; if not,
   *  you can get a copy from http://www.opensource.org/licenses/lgpl-license.php or write to the Free Software
   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
   *
   * Description:
   */
  package org.jaudiotagger.tag.lyrics3;
  
  import org.jaudiotagger.tag.InvalidTagException;
  import org.jaudiotagger.tag.TagException;
  import org.jaudiotagger.tag.TagNotFoundException;
  import org.jaudiotagger.tag.TagOptionSingleton;
  import org.jaudiotagger.tag.id3.AbstractID3v2Frame;
  import org.jaudiotagger.tag.id3.AbstractTag;
  import org.jaudiotagger.tag.id3.ID3v1Tag;
  import org.jaudiotagger.tag.id3.ID3v24Tag;
  
  import java.io.IOException;
  import java.io.RandomAccessFile;
  import java.nio.ByteBuffer;
  import java.util.HashMap;
  import java.util.Iterator;
  
  public class Lyrics3v2 extends AbstractLyrics3 {
      /**
       *
       */
      private HashMap<String, Lyrics3v2Field> fieldMap = new HashMap<String, Lyrics3v2Field>();
  
      /**
       * Creates a new Lyrics3v2 datatype.
       */
      public Lyrics3v2() {
      }
  
      public Lyrics3v2(Lyrics3v2 copyObject) {
          super(copyObject);
  
          Iterator<String> iterator = copyObject.fieldMap.keySet().iterator();
          String oldIdentifier;
          String newIdentifier;
          Lyrics3v2Field newObject;
  
          while (iterator.hasNext()) {
              oldIdentifier = iterator.next();
              newIdentifier = oldIdentifier;
              newObject = new Lyrics3v2Field(copyObject.fieldMap.get(newIdentifier));
              fieldMap.put(newIdentifier, newObject);
          }
      }
  
      /**
       * Creates a new Lyrics3v2 datatype.
       *
       * @param mp3tag
       * @throws UnsupportedOperationException
       */
      public Lyrics3v2(AbstractTag mp3tag) {
          if (mp3tag != null) {
              // upgrade the tag to lyrics3v2
              if (mp3tag instanceof Lyrics3v2) {
                  throw new UnsupportedOperationException("Copy Constructor not called. Please type cast the argument");
              } else if (mp3tag instanceof Lyrics3v1) {
                  Lyrics3v1 lyricOld = (Lyrics3v1) mp3tag;
                  Lyrics3v2Field newField;
                  newField = new Lyrics3v2Field(new FieldFrameBodyLYR(lyricOld.getLyric()));
                  fieldMap.put(newField.getIdentifier(), newField);
              } else {
                  Lyrics3v2Field newField;
                  Iterator<AbstractID3v2Frame> iterator;
                  iterator = (new ID3v24Tag(mp3tag)).iterator();
  
                  while (iterator.hasNext()) {
                      try {
                          newField = new Lyrics3v2Field(iterator.next());
  
                          if (newField != null) {
                              fieldMap.put(newField.getIdentifier(), newField);
                          }
                      } catch (TagException ex) {
                          //invalid frame to createField lyrics3 field. ignore and keep going
                      }
                  }
              }
          }
      }
  
      /**
       * Creates a new Lyrics3v2 datatype.
       *
       * @param file
       * @param byteBuffer
       * @throws TagNotFoundException
       * @throws IOException
       */
      public Lyrics3v2(ByteBuffer byteBuffer) throws TagNotFoundException, IOException {
          try {
              this.read(byteBuffer);
          } catch (TagException e) {
              e.printStackTrace();
          }
      }
  
      /**
       * @param field
       */
      public void setField(Lyrics3v2Field field) {
          fieldMap.put(field.getIdentifier(), field);
      }
  
      /**
       * Gets the value of the frame identified by identifier
       *
       * @param identifier The three letter code
       * @return The value associated with the identifier
       */
      public Lyrics3v2Field getField(String identifier) {
          return fieldMap.get(identifier);
      }
  
      /**
       * @return
       */
      public int getFieldCount() {
          return fieldMap.size();
      }
  
      /**
       * @return
       */
      public String getIdentifier() {
          return "Lyrics3v2.00";
      }
  
      /**
       * @return
       */
      public int getSize() {
          int size = 0;
          Iterator<Lyrics3v2Field> iterator = fieldMap.values().iterator();
          Lyrics3v2Field field;
  
          while (iterator.hasNext()) {
              field = iterator.next();
              size += field.getSize();
          }
  
          // include LYRICSBEGIN, but not 6 char size or LYRICSEND
          return 11 + size;
      }
  
  
      /**
       * @param obj
       * @return
       */
      public boolean equals(Object obj) {
          if (!(obj instanceof Lyrics3v2)) {
              return false;
          }
  
          Lyrics3v2 object = (Lyrics3v2) obj;
  
          return this.fieldMap.equals(object.fieldMap) && super.equals(obj);
  
      }
  
      /**
       * @param identifier
       * @return
       */
      public boolean hasField(String identifier) {
          return fieldMap.containsKey(identifier);
      }
  
      /**
       * @return
       */
      public Iterator<Lyrics3v2Field> iterator() {
          return fieldMap.values().iterator();
      }
  
  
      /**
       * TODO implement
       *
       * @param byteBuffer
       * @return
       * @throws IOException
       */
      public boolean seek(ByteBuffer byteBuffer) {
          return false;
      }
  
  
      public void read(ByteBuffer byteBuffer) throws TagException {
          long filePointer;
          int lyricSize;
  
          if (seek(byteBuffer)) {
              lyricSize = seekSize(byteBuffer);
          } else {
              throw new TagNotFoundException("Lyrics3v2.00 Tag Not Found");
          }
  
          // reset file pointer to the beginning of the tag;
          seek(byteBuffer);
          filePointer = byteBuffer.position();
  
          fieldMap = new HashMap<String, Lyrics3v2Field>();
  
          Lyrics3v2Field lyric;
  
          // read each of the fields
          while ((byteBuffer.position()) < (lyricSize - 11)) {
              try {
  