jid3lib-0.5.4

16:37:54.668 INFO  jd.cli.Main - Decompiling jid3lib-0.5.4.jar
package org.farng.mp3;

import java.io.IOException;

public abstract class AbstractMP3FileItem
{
  protected AbstractMP3FileItem() {}
  
  protected AbstractMP3FileItem(AbstractMP3FileItem paramAbstractMP3FileItem) {}
  
  public abstract String getIdentifier();
  
  public abstract int getSize();
  
  public abstract void read(RandomAccessFile paramRandomAccessFile)
    throws TagException, IOException;
  
  public abstract void write(RandomAccessFile paramRandomAccessFile)
    throws TagException, IOException;
  
  public boolean isSubsetOf(Object paramObject)
  {
    return paramObject instanceof AbstractMP3FileItem;
  }
  
  public boolean equals(Object paramObject)
  {
    return paramObject instanceof AbstractMP3FileItem;
  }
}

/* Location:
 * Qualified Name:     org.farng.mp3.AbstractMP3FileItem
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.farng.mp3;

public abstract class AbstractMP3Fragment
  extends AbstractMP3FileItem
{
  private AbstractMP3FragmentBody body;
  
  protected AbstractMP3Fragment() {}
  
  protected AbstractMP3Fragment(AbstractMP3FragmentBody paramAbstractMP3FragmentBody)
  {
    body = paramAbstractMP3FragmentBody;
  }
  
  protected AbstractMP3Fragment(AbstractMP3Fragment paramAbstractMP3Fragment)
  {
    super(paramAbstractMP3Fragment);
    AbstractMP3FragmentBody localAbstractMP3FragmentBody = paramAbstractMP3Fragment.getBody();
    body = ((AbstractMP3FragmentBody)TagUtility.copyObject(localAbstractMP3FragmentBody));
  }
  
  public void setBody(AbstractMP3FragmentBody paramAbstractMP3FragmentBody)
  {
    body = paramAbstractMP3FragmentBody;
  }
  
  public AbstractMP3FragmentBody getBody()
  {
    return body;
  }
  
  public boolean isSubsetOf(Object paramObject)
  {
    AbstractMP3FragmentBody localAbstractMP3FragmentBody1 = body;
    boolean bool;
    if (paramObject == null)
    {
      bool = false;
    }
    else if (!(paramObject instanceof AbstractMP3Fragment))
    {
      bool = false;
    }
    else
    {
      AbstractMP3FragmentBody localAbstractMP3FragmentBody2 = ((AbstractMP3Fragment)paramObject).getBody();
      if ((localAbstractMP3FragmentBody1 == null) && (localAbstractMP3FragmentBody2 == null)) {
        bool = true;
      } else {
        bool = (localAbstractMP3FragmentBody1 != null) && (localAbstractMP3FragmentBody2 != null) && (localAbstractMP3FragmentBody1.isSubsetOf(localAbstractMP3FragmentBody2)) && (super.isSubsetOf(paramObject));
      }
    }
    return bool;
  }
  
  public boolean equals(Object paramObject)
  {
    boolean bool;
    if ((paramObject instanceof AbstractMP3Fragment))
    {
      AbstractMP3Fragment localAbstractMP3Fragment = (AbstractMP3Fragment)paramObject;
      String str1 = localAbstractMP3Fragment.getIdentifier();
      String str2 = getIdentifier();
      if (str2.equals(str1))
      {
        AbstractMP3FragmentBody localAbstractMP3FragmentBody1 = localAbstractMP3Fragment.getBody();
        AbstractMP3FragmentBody localAbstractMP3FragmentBody2 = getBody();
        if (localAbstractMP3FragmentBody2.equals(localAbstractMP3FragmentBody1)) {
          bool = super.equals(paramObject);
        } else {
          bool = false;
        }
      }
      else
      {
        bool = false;
      }
    }
    else
    {
      bool = false;
    }
    return bool;
  }
}

/* Location:
 * Qualified Name:     org.farng.mp3.AbstractMP3Fragment
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.farng.mp3;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import org.farng.mp3.id3.ID3v2_2;
import org.farng.mp3.id3.ID3v2_3;
import org.farng.mp3.id3.ID3v2_4;
import org.farng.mp3.object.AbstractMP3Object;

public abstract class AbstractMP3FragmentBody
  extends AbstractMP3FileItem
{
  private static final int SIZE_OBJECT_LIST = 16;
  private static final int SIZE_BRIEF_DESCRIPTION = 64;
  private static final int SIZE_DESCRIPTION = 256;
  private List objectList = new ArrayList(16);
  
  protected AbstractMP3FragmentBody()
  {
    setupObjectList();
  }
  
  protected AbstractMP3FragmentBody(AbstractMP3FragmentBody paramAbstractMP3FragmentBody)
  {
    super(paramAbstractMP3FragmentBody);
    Iterator localIterator = paramAbstractMP3FragmentBody.iterator();
    while (localIterator.hasNext())
    {
      AbstractMP3Object localAbstractMP3Object1 = (AbstractMP3Object)localIterator.next();
      AbstractMP3Object localAbstractMP3Object2 = (AbstractMP3Object)TagUtility.copyObject(localAbstractMP3Object1);
      objectList.add(localAbstractMP3Object2);
    }
  }
  
  public String getBriefDescription()
  {
    StringBuffer localStringBuffer = new StringBuffer(64);
    ListIterator localListIterator = objectList.listIterator();
    while (localListIterator.hasNext())
    {
      AbstractMP3Object localAbstractMP3Object = (AbstractMP3Object)localListIterator.next();
      String str1 = localAbstractMP3Object.toString();
      if ((str1 != null) && (str1.length() > 0))
      {
        String str2 = localAbstractMP3Object.getIdentifier();
        localStringBuffer.append(str2);
        localStringBuffer.append("=\"");
        localStringBuffer.append(str1);
        localStringBuffer.append("\"; ");
      }
    }
    return localStringBuffer.toString();
  }
  
  public String getDescription()
  {
    StringBuffer localStringBuffer = new StringBuffer(256);
    ListIterator localListIterator = objectList.listIterator();
    while (localListIterator.hasNext())
    {
      localObject = (AbstractMP3Object)localListIterator.next();
      String str1 = ((AbstractMP3Object)localObject).getIdentifier();
      localStringBuffer.append(str1);
      localStringBuffer.append(" = ");
      String str2 = ((AbstractMP3Object)localObject).toString();
      localStringBuffer.append(str2);
      localStringBuffer.append(TagConstant.SEPERATOR_LINE);
    }
    Object localObject = localStringBuffer.toString();
    return ((String)localObject).trim();
  }
  
  public Iterator getObjectListIterator()
  {
    return objectList.listIterator();
  }
  
  public void setObject(String paramString, Object paramObject)
  {
    ListIterator localListIterator = objectList.listIterator();
    while (localListIterator.hasNext())
    {
      AbstractMP3Object localAbstractMP3Object = (AbstractMP3Object)localListIterator.next();
      String str = localAbstractMP3Object.getIdentifier();
      if (str.equals(paramString)) {
        localAbstractMP3Object.setValue(paramObject);
      }
    }
  }
  
  public Object getObject(String paramString)
  {
    Object localObject = null;
    ListIterator localListIterator = objectList.listIterator();
    while (localListIterator.hasNext())
    {
      AbstractMP3Object localAbstractMP3Object = (AbstractMP3Object)localListIterator.next();
      String str = localAbstractMP3Object.getIdentifier();
      if (str.equals(paramString)) {
        localObject = localAbstractMP3Object.getValue();
      }
    }
    return localObject;
  }
  
  public int getSize()
  {
    int i = 0;
    ListIterator localListIterator = objectList.listIterator();
    while (localListIterator.hasNext())
    {
      AbstractMP3Object localAbstractMP3Object = (AbstractMP3Object)localListIterator.next();
      i += localAbstractMP3Object.getSize();
    }
    return i;
  }
  
  public boolean isSubsetOf(Object paramObject)
  {
    if (!super.isSubsetOf(paramObject)) {
      return false;
    }
    if (!(paramObject instanceof AbstractMP3FragmentBody)) {
      return false;
    }
    List localList = objectList;
    int i = objectList.size();
    for (int j = 0; j < i; j++)
    {
      AbstractMP3Object localAbstractMP3Object = (AbstractMP3Object)objectList.get(j);
      if ((localAbstractMP3Object.getValue() != null) && (!localList.contains(localAbstractMP3Object))) {
        return false;
      }
    }
    return true;
  }
  
  public boolean equals(Object paramObject)
  {
    if (!(paramObject instanceof AbstractMP3FragmentBody)) {
      return false;
    }
    AbstractMP3FragmentBody localAbstractMP3FragmentBody = (AbstractMP3FragmentBody)paramObject;
    if (!objectList.equals(objectList)) {
      return false;
    }
    return super.equals(paramObject);
  }
  
  public Iterator iterator()
  {
    return objectList.iterator();
  }
  
  protected void appendToObjectList(AbstractMP3Object paramAbstractMP3Object)
  {
    objectList.add(paramAbstractMP3Object);
  }
  
  public void read(RandomAccessFile paramRandomAccessFile)
    throws IOException, InvalidTagException
  {
    int i = readHeader(paramRandomAccessFile);
    byte[] arrayOfByte = new byte[i];
    paramRandomAccessFile.read(arrayOfByte);
    ListIterator localListIterator = objectList.listIterator();
    int j = 0;
    while (localListIterator.hasNext())
    {
      if (j > i - 1) {
        throw new InvalidTagException("Invalid size for Frame Body");
      }
      AbstractMP3Object localAbstractMP3Object = (AbstractMP3Object)localListIterator.next();
      localAbstractMP3Object.readByteArray(arrayOfByte, j);
      j += localAbstractMP3Object.getSize();
    }
  }
  
  public String toString()
  {
    StringBuffer localStringBuffer = new StringBuffer(256);
    String str1 = getIdentifier();
    localStringBuffer.append(str1);
    localStringBuffer.append(TagConstant.SEPERATOR_LINE);
    ListIterator localListIterator = objectList.listIterator();
    while (localListIterator.hasNext())
    {
      AbstractMP3Object localAbstractMP3Object = (AbstractMP3Object)localListIterator.next();
      String str2 = localAbstractMP3Object.getIdentifier();
      localStringBuffer.append(str2);
      localStringBuffer.append(" = ");
      String str3 = localAbstractMP3Object.toString();
      localStringBuffer.append(str3);
      localStringBuffer.append(TagConstant.SEPERATOR_LINE);
    }
    return localStringBuffer.toString();
  }
  
  public void write(RandomAccessFile paramRandomAccessFile)
    throws IOException
  {
    int i = getSize();
    writeHeader(paramRandomAccessFile, i);
    ListIterator localListIterator = objectList.listIterator();
    while (localListIterator.hasNext())
    {
      AbstractMP3Object localAbstractMP3Object = (AbstractMP3Object)localListIterator.next();
      byte[] arrayOfByte = localAbstractMP3Object.writeByteArray();
      paramRandomAccessFile.write(arrayOfByte);
    }
  }
  
  protected abstract int readHeader(RandomAccessFile paramRandomAccessFile)
    throws IOException, InvalidTagException;
  
  protected abstract void setupObjectList();
  
  protected abstract void writeHeader(RandomAccessFile paramRandomAccessFile, int paramInt)
    throws IOException;
  
  protected static boolean has6ByteHeader()
  {
    Exception localException = new Exception();
    StackTraceElement[] arrayOfStackTraceElement = localException.getStackTrace();
    String str1 = ID3v2_2.class.getName();
    String str2 = ID3v2_3.class.getName();
    String str3 = ID3v2_4.class.getName();
    boolean bool = false;
    int i = 0;
    for (int j = arrayOfStackTraceElement.length - 1; j >= 0; j--)
    {
      String str4 = arrayOfStackTraceElement[j].getClassName();
      if (str1.equals(str4))
      {
        bool = true;
        i = 1;
      }
      else if (str2.equals(str4))
      {
        bool = false;
        i = 1;
      }
      else if (str3.equals(str4))
      {
        bool = false;
        i = 1;
      }
    }
    if (i == 0) {
      throw new UnsupportedOperationException("FragmentBody not called within ID3v2 tag.");
    }
    return bool;
  }
}

/* Location:
 * Qualified Name:     org.farng.mp3.AbstractMP3FragmentBody
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.farng.mp3;

import java.io.IOException;
import java.util.Iterator;
import org.farng.mp3.id3.AbstractID3v2;
import org.farng.mp3.id3.AbstractID3v2Frame;
import org.farng.mp3.id3.ID3v2_4;

public abstract class AbstractMP3Tag
  extends AbstractMP3FileItem
{
  protected AbstractMP3Tag() {}
  
  protected AbstractMP3Tag(AbstractMP3Tag paramAbstractMP3Tag)
  {
    super(paramAbstractMP3Tag);
  }
  
  public abstract void append(RandomAccessFile paramRandomAccessFile)
    throws IOException, TagException;
  
  public abstract void delete(RandomAccessFile paramRandomAccessFile)
    throws IOException;
  
  public abstract void overwrite(RandomAccessFile paramRandomAccessFile)
    throws IOException, TagException;
  
  public abstract boolean seek(RandomAccessFile paramRandomAccessFile)
    throws IOException;
  
  public boolean isSubsetOf(AbstractMP3Tag paramAbstractMP3Tag)
  {
    ID3v2_4 localID3v2_41 = new ID3v2_4(this);
    ID3v2_4 localID3v2_42 = new ID3v2_4(paramAbstractMP3Tag);
    Iterator localIterator = localID3v2_41.iterator();
    while (localIterator.hasNext())
    {
      AbstractID3v2Frame localAbstractID3v2Frame1 = (AbstractID3v2Frame)localIterator.next();
      String str = localAbstractID3v2Frame1.getIdentifier();
      AbstractID3v2Frame localAbstractID3v2Frame2 = localID3v2_42.getFrame(str);
      if (localAbstractID3v2Frame2 == null) {
        return false;
      }
      if (!localAbstractID3v2Frame1.isSubsetOf(localAbstractID3v2Frame2)) {
        return false;
      }
    }
    return true;
  }
  
  public abstract void append(AbstractMP3Tag paramAbstractMP3Tag);
  
  public boolean equals(Object paramObject)
  {
    return ((paramObject instanceof AbstractMP3Tag)) && (super.equals(paramObject));
  }
  
  public abstract Iterator iterator();
  
  public abstract void overwrite(AbstractMP3Tag paramAbstractMP3Tag);
  
  public abstract void write(AbstractMP3Tag paramAbstractMP3Tag);
  
  public abstract String getSongTitle();
  
  public abstract String getLeadArtist();
  
  public abstract String getAlbumTitle();
  
  public abstract String getYearReleased();
  
  public abstract String getSongComment();
  
  public abstract String getSongGenre();
  
  public abstract String getTrackNumberOnAlbum();
  
  public abstract String getSongLyric();
  
  public abstract String getAuthorComposer();
  
  public abstract void setSongTitle(String paramString);
  
  public abstract void setLeadArtist(String paramString);
  
  public abstract void setAlbumTitle(String paramString);
  
  public abstract void setYearReleased(String paramString);
  
  public abstract void setSongComment(String paramString);
  
  public abstract void setSongGenre(String paramString);
  
  public abstract void setTrackNumberOnAlbum(String paramString);
  
  public abstract void setSongLyric(String paramString);
  
  public abstract void setAuthorComposer(String paramString);
}

/* Location:
 * Qualified Name:     org.farng.mp3.AbstractMP3Tag
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.farng.mp3;

import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

public class InvalidTagException
  extends TagException
{
  public InvalidTagException() {}
  
  public InvalidTagException(Throwable paramThrowable)
  {
    super(paramThrowable);
  }
  
  public InvalidTagException(String paramString)
  {
    super(paramString);
  }
  
  public InvalidTagException(String paramString, Throwable paramThrowable)
  {
    super(paramString, paramThrowable);
  }
  
  private void writeObject(ObjectOutputStream paramObjectOutputStream)
  {
    throw new UnsupportedOperationException("Cannot write to Output Stream: " + paramObjectOutputStream.toString());
  }
  
  private void readObject(ObjectInputStream paramObjectInputStream)
  {
    throw new UnsupportedOperationException("Cannot read from Input Stream: " + paramObjectInputStream.toString());
  }
}

/* Location:
 * Qualified Name:     org.farng.mp3.InvalidTagException
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.farng.mp3;

import com.wowza.io.IRandomAccessReader;
import java.io.EOFException;
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.farng.mp3.filename.FilenameTag;
import org.farng.mp3.filename.FilenameTagBuilder;
import org.farng.mp3.id3.AbstractID3v2;
import org.farng.mp3.id3.AbstractID3v2Frame;
import org.farng.mp3.id3.ID3v1;
import org.farng.mp3.id3.ID3v1_1;
import org.farng.mp3.id3.ID3v2_2;
import org.farng.mp3.id3.ID3v2_3;
import org.farng.mp3.id3.ID3v2_4;
import org.farng.mp3.lyrics3.AbstractLyrics3;
import org.farng.mp3.lyrics3.Lyrics3v1;
import org.farng.mp3.lyrics3.Lyrics3v2;

public class MP3File
{
  private AbstractID3v2 id3v2tag;
  private AbstractLyrics3 lyrics3tag;
  private File mp3file;
  private FilenameTag filenameTag;
  private ID3v1 id3v1tag;
  private boolean copyProtected;
  private boolean home;
  private boolean padding;
  private boolean privacy;
  private boolean protection;
  private boolean variableBitRate;
  private byte emphasis;
  private byte layer;
  private byte mode;
  private byte modeExtension;
  private byte mpegVersion;
  private double frequency;
  private int bitRate;
  
  public MP3File() {}
  
  public MP3File(MP3File paramMP3File)
  {
    copyProtected = copyProtected;
    home = home;
    padding = padding;
    privacy = privacy;
    protection = protection;
    variableBitRate = variableBitRate;
    emphasis = emphasis;
    layer = layer;
    mode = mode;
    modeExtension = modeExtension;
    mpegVersion = mpegVersion;
    frequency = frequency;
    bitRate = bitRate;
    mp3file = new File(mp3file.getAbsolutePath());
    filenameTag = new FilenameTag(filenameTag);
    id3v2tag = ((AbstractID3v2)TagUtility.copyObject(id3v2tag));
    lyrics3tag = ((AbstractLyrics3)TagUtility.copyObject(lyrics3tag));
    id3v1tag = ((ID3v1)TagUtility.copyObject(id3v1tag));
  }
  
  public MP3File(String paramString)
    throws IOException, TagException
  {
    this(new File(paramString));
  }
  
  public MP3File(File paramFile)
    throws IOException, TagException
  {}
  
  public MP3File(IRandomAccessReader paramIRandomAccessReader, boolean paramBoolean)
    throws IOException, TagException
  {
    RandomAccessFile localRandomAccessFile = new RandomAccessFile(paramIRandomAccessReader);
    try
    {
      id3v1tag = new ID3v1_1(localRandomAccessFile);
    }
    catch (TagNotFoundException localTagNotFoundException1) {}
    try
    {
      if (id3v1tag == null) {
        id3v1tag = new ID3v1(localRandomAccessFile);
      }
    }
    catch (TagNotFoundException localTagNotFoundException2) {}
    try
    {
      id3v2tag = new ID3v2_4(localRandomAccessFile);
    }
    catch (TagNotFoundException localTagNotFoundException3) {}
    try
    {
      if (id3v2tag == null) {
        id3v2tag = new ID3v2_3(localRandomAccessFile);
      }
    }
    catch (TagNotFoundException localTagNotFoundException4) {}
    try
    {
      if (id3v2tag == null) {
        id3v2tag = new ID3v2_2(localRandomAccessFile);
      }
    }
    catch (TagNotFoundException localTagNotFoundException5) {}
    try
    {
      lyrics3tag = new Lyrics3v2(localRandomAccessFile);
    }
    catch (TagNotFoundException localTagNotFoundException6) {}
    try
    {
      if (lyrics3tag == null) {
        lyrics3tag = new Lyrics3v1(localRandomAccessFile);
      }
    }
    catch (TagNotFoundException localTagNotFoundException7) {}
    localRandomAccessFile.close();
    try
    {
      filenameTag = FilenameTagBuilder.createFilenameTagFromMP3File(this);
    }
    catch (Exception localException)
    {
      throw new TagException("Unable to create FilenameTag", localException);
    }
  }
  
  public int getBitRate()
  {
    return bitRate;
  }
  
  public boolean isCopyProtected()
  {
    return copyProtected;
  }
  
  public byte getEmphasis()
  {
    return emphasis;
  }
  
  public void setFilenameTag(FilenameTag paramFilenameTag)
  {
    filenameTag = paramFilenameTag;
  }
  
  public FilenameTag getFilenameTag()
  {
    return filenameTag;
  }
  
  public void setFrameAcrossTags(AbstractID3v2Frame paramAbstractID3v2Frame)
  {
    ID3v2_4 localID3v2_4;
    if (id3v1tag != null)
    {
      localID3v2_4 = new ID3v2_4(id3v1tag);
      localID3v2_4.setFrame(paramAbstractID3v2Frame);
      id3v1tag.overwrite(localID3v2_4);
    }
    if (id3v2tag != null) {
      id3v2tag.setFrame(paramAbstractID3v2Frame);
    }
    if (lyrics3tag != null)
    {
      localID3v2_4 = new ID3v2_4(lyrics3tag);
      localID3v2_4.setFrame(paramAbstractID3v2Frame);
      lyrics3tag = new Lyrics3v2(localID3v2_4);
    }
    if (filenameTag != null) {
      filenameTag.setFrame(paramAbstractID3v2Frame);
    }
  }
  
  public List getFrameAcrossTags(String paramString)
  {
    if ((paramString != null) && (paramString.length() > 0))
    {
      ArrayList localArrayList = new ArrayList(32);
      ID3v2_4 localID3v2_4;
      Iterator localIterator;
      if (id3v1tag != null)
      {
        localID3v2_4 = new ID3v2_4(id3v1tag);
        if (localID3v2_4.hasFrameOfType(paramString))
        {
          localIterator = localID3v2_4.getFrameOfType(paramString);
          while (localIterator.hasNext()) {
            localArrayList.add(localIterator.next());
          }
        }
      }
      if ((id3v2tag != null) && 
        (id3v2tag.hasFrameOfType(paramString)))
      {
        localIterator = id3v2tag.getFrameOfType(paramString);
        while (localIterator.hasNext()) {
          localArrayList.add(localIterator.next());
        }
      }
      if (lyrics3tag != null)
      {
        localID3v2_4 = new ID3v2_4(lyrics3tag);
        if (localID3v2_4.hasFrameOfType(paramString))
        {
          localIterator = localID3v2_4.getFrameOfType(paramString);
          while (localIterator.hasNext()) {
            localArrayList.add(localIterator.next());
          }
        }
      }
      if ((filenameTag != null) && 
        (filenameTag.hasFrameOfType(paramString)))
      {
        localIterator = filenameTag.getFrameOfType(paramString);
        while (localIterator.hasNext()) {
          localArrayList.add(localIterator.next());
        }
      }
      return localArrayList;
    }
    return null;
  }
  
  public double getFrequency()
  {
    return frequency;
  }
  
  public boolean isHome()
  {
    return home;
  }
  
  public void setID3v1Tag(AbstractMP3Tag paramAbstractMP3Tag)
  {
    id3v1tag = new ID3v1_1(paramAbstractMP3Tag);
  }
  
  public void setID3v1Tag(ID3v1 paramID3v1)
  {
    id3v1tag = paramID3v1;
  }
  
  public ID3v1 getID3v1Tag()
  {
    return id3v1tag;
  }
  
  public void setID3v2Tag(AbstractMP3Tag paramAbstractMP3Tag)
  {
    id3v2tag = new ID3v2_4(paramAbstractMP3Tag);
  }
  
  public void setID3v2Tag(AbstractID3v2 paramAbstractID3v2)
  {
    id3v2tag = paramAbstractID3v2;
  }
  
  public AbstractID3v2 getID3v2Tag()
  {
    return id3v2tag;
  }
  
  public byte getLayer()
  {
    return layer;
  }
  
  public void setLyrics3Tag(AbstractMP3Tag paramAbstractMP3Tag)
  {
    lyrics3tag = new Lyrics3v2(paramAbstractMP3Tag);
  }
  
  public void setLyrics3Tag(AbstractLyrics3 paramAbstractLyrics3)
  {
    lyrics3tag = paramAbstractLyrics3;
  }
  
  public AbstractLyrics3 getLyrics3Tag()
  {
    return lyrics3tag;
  }
  
  public byte getMode()
  {
    return mode;
  }
  
  public byte getModeExtension()
  {
    return modeExtension;
  }
  
  public long getMp3StartByte()
    throws IOException, FileNotFoundException
  {
    return getMp3StartByte(mp3file);
  }
  
  public long getMp3StartByte(File paramFile)
    throws IOException, FileNotFoundException
  {
    RandomAccessFile localRandomAccessFile = null;
    long l = 0L;
    try
    {
      localRandomAccessFile = new RandomAccessFile(paramFile, "r");
      seekMP3Frame(localRandomAccessFile);
      l = localRandomAccessFile.getFilePointer();
    }
    finally
    {
      if (localRandomAccessFile != null) {
        localRandomAccessFile.close();
      }
    }
    return l;
  }
  
  public void setMp3file(File paramFile)
  {
    mp3file = paramFile;
  }
  
  public File getMp3file()
  {
    return mp3file;
  }
  
  public byte getMpegVersion()
  {
    return mpegVersion;
  }
  
  public boolean isPadding()
  {
    return padding;
  }
  
  public boolean isPrivacy()
  {
    return privacy;
  }
  
  public boolean isProtection()
  {
    return protection;
  }
  
  public boolean isUnsynchronized()
  {
    return getUnsynchronizedFragments().size() > 0;
  }
  
  public Set getUnsynchronizedFragments()
  {
    ID3v2_4 localID3v2_41 = new ID3v2_4(id3v2tag);
    HashSet localHashSet = new HashSet(32);
    localID3v2_41.append(id3v1tag);
    localID3v2_41.append(lyrics3tag);
    localID3v2_41.append(filenameTag);
    localID3v2_41.append(id3v2tag);
    ID3v2_4 localID3v2_42 = new ID3v2_4(id3v1tag);
    ID3v2_4 localID3v2_43 = new ID3v2_4(lyrics3tag);
    ID3v2_4 localID3v2_44 = new ID3v2_4(filenameTag);
    AbstractID3v2 localAbstractID3v2 = id3v2tag;
    Iterator localIterator = localID3v2_41.iterator();
    while (localIterator.hasNext())
    {
      AbstractID3v2Frame localAbstractID3v2Frame = (AbstractID3v2Frame)localIterator.next();
      String str = localAbstractID3v2Frame.getIdentifier();
      if ((localAbstractID3v2 != null) && 
        (localAbstractID3v2.hasFrame(str)) && 
        (!localAbstractID3v2.getFrame(str).isSubsetOf(localAbstractID3v2Frame))) {
        localHashSet.add(str);
      }
      if ((localID3v2_42.hasFrame(str)) && 
        (!localID3v2_42.getFrame(str).isSubsetOf(localAbstractID3v2Frame))) {
        localHashSet.add(str);
      }
      if ((localID3v2_43.hasFrame(str)) && 
        (!localID3v2_43.getFrame(str).isSubsetOf(localAbstractID3v2Frame))) {
        localHashSet.add(str);
      }
      if ((localID3v2_44.hasFrame(str)) && 
        (!localID3v2_44.getFrame(str).isSubsetOf(localAbstractID3v2Frame))) {
        localHashSet.add(str);
      }
    }
    return localHashSet;
  }
  
  public void setVariableBitRate(boolean paramBoolean)
  {
    variableBitRate = paramBoolean;
  }
  
  public boolean isVariableBitRate()
  {
    return variableBitRate;
  }
  
  public boolean adjustID3v2Padding()
    throws FileNotFoundException, IOException, TagException
  {
    return adjustID3v2Padding(TagOptionSingleton.getInstance().getId3v2PaddingSize(), TagOptionSingleton.getInstance().isId3v2PaddingWillShorten(), TagOptionSingleton.getInstance().isId3v2PaddingCopyTag(), mp3file);
  }
  
  public boolean adjustID3v2Padding(int paramInt, boolean paramBoolean1, boolean paramBoolean2)
    throws FileNotFoundException, IOException, TagException
  {
    return adjustID3v2Padding(paramInt, paramBoolean1, paramBoolean2, mp3file);
  }
  
  public boolean adjustID3v2Padding(int paramInt, boolean paramBoolean1, boolean paramBoolean2, File paramFile)
    throws FileNotFoundException, IOException, TagException
  {
    int i = 0;
    long l1 = getMp3StartByte(paramFile);
    long l2 = paramInt;
    FileOutputStream localFileOutputStream = null;
    FileInputStream localFileInputStream = null;
    File localFile1 = null;
    File localFile2 = null;
    if (l2 < 0L) {
      throw new TagException("Invalid paddingSize: " + l2);
    }
    if (hasID3v2Tag()) {
      i = getID3v2Tag().getSize();
    }
    if (l2 != 0L) {
      while (l2 < i) {
        l2 = ((float)l2 * TagOptionSingleton.getInstance().getId3v2PaddingMultiplier());
      }
    }
    if ((l2 < l1) && (!paramBoolean1)) {
      return false;
    }
    if (l2 == l1) {
      return false;
    }
    try
    {
      localFile2 = File.createTempFile("temp", ".mp3", paramFile.getParentFile());
      localFileOutputStream = new FileOutputStream(localFile2);
      localFileInputStream = new FileInputStream(paramFile);
      if (paramBoolean2 == true)
      {
        if ((l2 < l1) && (paramBoolean1))
        {
          arrayOfByte = new byte[(int)l2];
          localFileInputStream.read(arrayOfByte, 0, arrayOfByte.length);
          localFileOutputStream.write(arrayOfByte, 0, arrayOfByte.length);
          arrayOfByte = new byte[(int)(l1 - l2)];
          
          localFileInputStream.read(arrayOfByte, 0, arrayOfByte.length);
        }
        else
        {
          arrayOfByte = new byte[(int)l1];
          localFileInputStream.read(arrayOfByte, 0, arrayOfByte.length);
          localFileOutputStream.write(arrayOfByte, 0, arrayOfByte.length);
          if (l2 - l1 > 0L)
          {
            arrayOfByte = new byte[(int)(l2 - l1)];
            localFileOutputStream.write(arrayOfByte, 0, arrayOfByte.length);
          }
        }
      }
      else
      {
        arrayOfByte = new byte[(int)l2];
        
        localFileInputStream.skip(l1);
        
        localFileOutputStream.write(arrayOfByte, 0, arrayOfByte.length);
      }
      byte[] arrayOfByte = new byte['?'];
      int j = localFileInputStream.read(arrayOfByte, 0, arrayOfByte.length);
      while (j == 1024)
      {
        localFileOutputStream.write(arrayOfByte, 0, arrayOfByte.length);
        j = localFileInputStream.read(arrayOfByte, 0, arrayOfByte.length);
      }
      if (j != -1) {
        localFileOutputStream.write(arrayOfByte, 0, j);
      }
      localFile1 = new File(paramFile.getParentFile(), TagUtility.appendBeforeExtension(paramFile.getName(), ".original"));
      TagUtility.copyFile(paramFile, localFile1);
      boolean bool;
      if (localFile1.exists()) {
        localFile1.setLastModified(paramFile.lastModified());
      } else {
        return false;
      }
      TagUtility.copyFile(localFile2, paramFile);
      return true;
    }
    finally
    {
      if (localFileInputStream != null)
      {
        localFileInputStream.getFD().sync();
        localFileInputStream.close();
      }
      if (localFileOutputStream != null)
      {
        localFileOutputStream.getFD().sync();
        localFileOutputStream.close();
      }
      if ((localFile1 != null) && (!TagOptionSingleton.getInstance().isOriginalSavedAfterAdjustingID3v2Padding())) {
        localFile1.delete();
      }
      if (localFile2 != null) {
        localFile2.delete();
      }
    }
  }
  
  public void delete(AbstractMP3Tag paramAbstractMP3Tag)
    throws FileNotFoundException, IOException
  {
    paramAbstractMP3Tag.delete(new RandomAccessFile(mp3file, "rw"));
  }
  
  public boolean hasFilenameTag()
  {
    return filenameTag != null;
  }
  
  public boolean hasID3v1Tag()
  {
    return id3v1tag != null;
  }
  
  public boolean hasID3v2Tag()
  {
    return id3v2tag != null;
  }
  
  public boolean hasLyrics3Tag()
  {
    return lyrics3tag != null;
  }
  
  public void save()
    throws IOException, TagException
  {
    save(mp3file, TagOptionSingleton.getInstance().getDefaultSaveMode());
  }
  
  public void save(int paramInt)
    throws IOException, TagException
  {
    save(mp3file, paramInt);
  }
  
  public void save(String paramString)
    throws IOException, TagException
  {
    save(new File(paramString), TagOptionSingleton.getInstance().getDefaultSaveMode());
  }
  
  public void save(File paramFile)
    throws IOException, TagException
  {
    save(paramFile, TagOptionSingleton.getInstance().getDefaultSaveMode());
  }
  
  public void save(String paramString, int paramInt)
    throws IOException, TagException
  {
    save(new File(paramString), paramInt);
  }
  
  public void save(File paramFile, int paramInt)
    throws IOException, TagException
  {
    if ((paramInt < 1) || (paramInt > 3)) {
      throw new TagException("Invalid Save Mode");
    }
    RandomAccessFile localRandomAccessFile = null;
    try
    {
      if (id3v2tag != null) {
        adjustID3v2Padding(TagOptionSingleton.getInstance().getId3v2PaddingSize(), TagOptionSingleton.getInstance().isId3v2PaddingWillShorten(), TagOptionSingleton.getInstance().isId3v2PaddingCopyTag(), paramFile);
      }
      localRandomAccessFile = new RandomAccessFile(paramFile, "rw");
      if (TagOptionSingleton.getInstance().isId3v2Save()) {
        if (id3v2tag == null)
        {
          if (paramInt == 2) {
            new ID3v2_4().delete(localRandomAccessFile);
          }
        }
        else if (paramInt == 1) {
          id3v2tag.write(localRandomAccessFile);
        } else if (paramInt == 3) {
          id3v2tag.append(localRandomAccessFile);
        } else if (paramInt == 2) {
          id3v2tag.overwrite(localRandomAccessFile);
        }
      }
      if (TagOptionSingleton.getInstance().isLyrics3Save()) {
        if (lyrics3tag == null)
        {
          if (paramInt == 2) {
            new Lyrics3v2().delete(localRandomAccessFile);
          }
        }
        else if (paramInt == 1) {
          lyrics3tag.write(localRandomAccessFile);
        } else if (paramInt == 3) {
          lyrics3tag.append(localRandomAccessFile);
        } else if (paramInt == 2) {
          lyrics3tag.overwrite(localRandomAccessFile);
        }
      }
      if (TagOptionSingleton.getInstance().isId3v1Save()) {
        if (id3v1tag == null)
        {
          if (paramInt == 2) {
            new ID3v1().delete(localRandomAccessFile);
          }
        }
        else if (paramInt == 1) {
          id3v1tag.write(localRandomAccessFile);
        } else if (paramInt == 3) {
          id3v1tag.append(localRandomAccessFile);
        } else if (paramInt == 2) {
          id3v1tag.overwrite(localRandomAccessFile);
        }
      }
      if ((TagOptionSingleton.getInstance().isFilenameTagSave()) && 
        (filenameTag != null)) {
        if (paramInt == 1) {
          filenameTag.write(localRandomAccessFile);
        } else if (paramInt == 3) {
          filenameTag.append(localRandomAccessFile);
        } else if (paramInt == 2) {
          filenameTag.overwrite(localRandomAccessFile);
        }
      }
    }
    finally
    {
      if (localRandomAccessFile != null) {
        localRandomAccessFile.close();
      }
    }
  }
  
  public boolean seekMP3Frame()
    throws IOException
  {
    RandomAccessFile localRandomAccessFile = null;
    boolean bool = false;
    try
    {
      localRandomAccessFile = new RandomAccessFile(mp3file, "r");
      bool = seekMP3Frame(localRandomAccessFile);
    }
    finally
    {
      if (localRandomAccessFile != null) {
        localRandomAccessFile.close();
      }
    }
    return bool;
  }
  
  public boolean seekMP3Frame(RandomAccessFile paramRandomAccessFile)
    throws IOException
  {
    boolean bool = false;
    
    long l = 1L;
    variableBitRate = false;
    try
    {
      paramRandomAccessFile.seek(0L);
      do
      {
        int i = paramRandomAccessFile.readByte();
        if (i == -1)
        {
          l = paramRandomAccessFile.getFilePointer();
          int j = (byte)(paramRandomAccessFile.readByte() & 0xFFFFFFE0);
          if (j == -32)
          {
            paramRandomAccessFile.seek(l - 1L);
            
            bool = seekNextMP3Frame(paramRandomAccessFile, TagOptionSingleton.getInstance().getNumberMP3SyncFrame());
          }
          paramRandomAccessFile.seek(l);
        }
      } while (!bool);
      paramRandomAccessFile.seek(l - 1L);
    }
    catch (EOFException localEOFException)
    {
      bool = false;
    }
    catch (IOException localIOException)
    {
      throw localIOException;
    }
    return bool;
  }
  
  private int getFrameSize()
  {
    if (frequency == 0.0D) {
      return 0;
    }
    int j = padding ? 1 : 0;
    int i;
    if (layer == 3) {
      i = (int)((12 * bitRate / frequency + j) * 4.0D);
    } else {
      i = (int)(144 * bitRate / frequency + j);
    }
    return i;
  }
  
  private void readFrameHeader(RandomAccessFile paramRandomAccessFile)
    throws IOException, TagNotFoundException, InvalidTagException
  {
    byte[] arrayOfByte = new byte[4];
    paramRandomAccessFile.read(arrayOfByte);
    if ((arrayOfByte[0] != -1) || ((arrayOfByte[1] & 0xFFFFFFE0) != -32)) {
      throw new TagNotFoundException("MP3 Frame sync bits not found");
    }
    mpegVersion = ((byte)((arrayOfByte[1] & 0x18) >> 3));
    layer = ((byte)((arrayOfByte[1] & 0x6) >> 1));
    protection = ((arrayOfByte[1] & 0x1) != 1);
    int i = arrayOfByte[2] & 0xF0 | arrayOfByte[1] & 0x8 | arrayOfByte[1] & 0x6;
    
    Long localLong = (Long)TagConstant.bitrate.get(new Long(i));
    if (localLong != null)
    {
      if (localLong.longValue() != bitRate) {
        variableBitRate = true;
      }
      bitRate = localLong.intValue();
    }
    else
    {
      throw new InvalidTagException("Invalid bit rate");
    }
    int j = (arrayOfByte[2] & 0xC) >>> 2;
    if (mpegVersion == 3) {
      switch (j)
      {
      case 0: 
        frequency = 44.1D;
        break;
      case 1: 
        frequency = 48.0D;
        break;
      case 2: 
        frequency = 32.0D;
      }
    } else if (mpegVersion == 2) {
      switch (j)
      {
      case 0: 
        frequency = 22.05D;
        break;
      case 1: 
        frequency = 24.0D;
        break;
      case 2: 
        frequency = 16.0D;
      }
    } else if (mpegVersion == 0) {
      switch (j)
      {
      case 0: 
        frequency = 11.025D;
        break;
      case 1: 
        frequency = 12.0D;
        break;
      case 2: 
        frequency = 8.0D;
      }
    } else {
      throw new InvalidTagException("Invalid MPEG version");
    }
    padding = ((arrayOfByte[2] & 0x2) != 0);
    privacy = ((arrayOfByte[2] & 0x1) != 0);
    mode = ((byte)((arrayOfByte[3] & 0xC0) >> 6));
    modeExtension = ((byte)((arrayOfByte[3] & 0x30) >> 4));
    copyProtected = ((arrayOfByte[3] & 0x8) != 0);
    home = ((arrayOfByte[3] & 0x4) != 0);
    emphasis = ((byte)(arrayOfByte[3] & 0x3));
  }
  
  private boolean seekNextMP3Frame(RandomAccessFile paramRandomAccessFile, int paramInt)
    throws IOException
  {
    boolean bool;
    if (paramInt == 0)
    {
      bool = true;
    }
    else
    {
      try
      {
        readFrameHeader(paramRandomAccessFile);
      }
      catch (TagException localTagException)
      {
        return false;
      }
      int k = getFrameSize();
      if ((k <= 0) || (k > paramRandomAccessFile.length())) {
        return false;
      }
      byte[] arrayOfByte = new byte[k - 4];
      paramRandomAccessFile.read(arrayOfByte);
      long l = paramRandomAccessFile.getFilePointer();
      int i = paramRandomAccessFile.readByte();
      if (i == -1)
      {
        int j = (byte)(paramRandomAccessFile.readByte() & 0xFFFFFFE0);
        if (j == -32)
        {
          paramRandomAccessFile.seek(l);
          
          bool = seekNextMP3Frame(paramRandomAccessFile, paramInt - 1);
        }
        else
        {
          bool = false;
        }
      }
      else
      {
        bool = false;
      }
    }
    return bool;
  }
}

/* Location:
 * Qualified Name:     org.farng.mp3.MP3File
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.farng.mp3;

import com.wowza.io.IRandomAccessReader;
import com.wowza.wms.logging.WMSLogger;
import com.wowza.wms.logging.WMSLoggerFactory;
import java.io.Closeable;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

public class RandomAccessFile
  implements Closeable, DataInput, DataOutput
{
  private IRandomAccessReader randomAccessReader = null;
  private byte[] buffer = new byte[16];
  private ByteBuffer tmpBuffer;
  
  public RandomAccessFile(File paramFile, String paramString)
    throws FileNotFoundException
  {}
  
  public RandomAccessFile(String paramString1, String paramString2)
    throws FileNotFoundException
  {}
  
  public RandomAccessFile(IRandomAccessReader paramIRandomAccessReader)
  {
    randomAccessReader = paramIRandomAccessReader;
    tmpBuffer = ByteBuffer.wrap(buf
1 2 3 4 5 6 7 8 9 10 11 12 13 14

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd