/**
   * If the frame body's values have been modified, then resize the raw binary buffer and store the
   * new values there. When finished, the dirty flag is reset to indicate that the buffer is up to
   * date, and the frame is now ready to be saved to the .mp3 file.
   */
  @Override
  public void setBuffer() {
    if (isDirty()) {
      byte[] languageBytes = language.getCodeBytes();
      byte[] textBytes = stringToBytes(encoding.getCharacterSet(), text);
      int index = 0;

      buffer = new byte[1 + languageBytes.length + textBytes.length];

      buffer[index] = (byte) encoding.ordinal();
      index = 1;
      System.arraycopy(languageBytes, 0, buffer, index, languageBytes.length);
      index += languageBytes.length;
      System.arraycopy(textBytes, 0, buffer, index, textBytes.length);

      dirty = false;
    }
  }
 /**
  * parses the raw bytes of the frame body and stores the parsed values in the frame's fields.
  *
  * @throws IllegalArgumentException if an invalid value is detected while parsing the frame body's
  *     raw bytes.
  */
 @Override
 public void parse() throws IllegalArgumentException {
   try {
     setEncoding(Encoding.getEncoding(buffer[0]));
   } catch (
       IllegalArgumentException
           ex) { // ignore the bad value and set it to ISO-8859-1 so we can continue parsing the
                 // tag
     setEncoding(Encoding.ISO_8859_1);
   }
   try {
     setLanguage(
         Language.getLanguage(new String(buffer, 1, 3, Encoding.ISO_8859_1.getCharacterSet())));
   } catch (
       IllegalArgumentException
           ex) { // ignore the bad value and set it to english so we can continue parsing the tag
     setLanguage(Language.ENG);
   }
   text = new String(buffer, 4, buffer.length - 4, encoding.getCharacterSet()).trim();
   dirty =
       false; // we just read in the frame info, so the frame body's internal byte buffer is up to
              // date
 }