FileDocCategorySizeDatePackage
TPOSTextInformationID3V2Frame.javaAPI Docjid3 0.466928Sun Feb 06 18:11:19 GMT 2005org.blinkenlights.jid3.v2

TPOSTextInformationID3V2Frame

public class TPOSTextInformationID3V2Frame extends TextInformationID3V2Frame
author
paul Text frame containing a reference to the part number of a set to which this recording belongs.

Fields Summary
private int
m_iPartNumber
private int
m_iTotalParts
Constructors Summary
public TPOSTextInformationID3V2Frame(int iPartNumber)
Constructor.

param
iPartNumber the part number in the set to which this recording belongs
throws
ID3Exception if the part number is negative

        super(Integer.toString(iPartNumber));
        
        if (iPartNumber < 0)
        {
            throw new ID3Exception("Part number cannot be negative.");
        }
        
        m_iPartNumber = iPartNumber;
        m_iTotalParts = -1;
    
public TPOSTextInformationID3V2Frame(int iPartNumber, int iTotalParts)
Constructor.

param
iPartNumber the part number in the set to which this recording belongs
param
iTotalParts the total number of parts in the complete set
throws
ID3Exception if the part number is negative, or the total number of parts is less than the part number

        super(Integer.toString(iPartNumber) + "/" + Integer.toString(iTotalParts));
        
        if (iPartNumber < 0)
        {
            throw new ID3Exception("Part number cannot be negative.");
        }
        if (iTotalParts < iPartNumber)
        {
            throw new ID3Exception("Total number of parts must be at least as great as the part number.");
        }
        
        m_iPartNumber = iPartNumber;
        m_iTotalParts = iTotalParts;
    
public TPOSTextInformationID3V2Frame(InputStream oIS)

        super(oIS);
        
        try
        {
            if (m_sInformation.indexOf('/") == -1)
            {
                // no slash, just the part number
                m_iPartNumber = Integer.parseInt(m_sInformation);
                m_iTotalParts = -1;
            }
            else
            {
                String[] asPart = m_sInformation.split("/", 2);
                m_iPartNumber = Integer.parseInt(asPart[0]);
                m_iTotalParts = Integer.parseInt(asPart[1]);
            }
        }
        catch (Exception e)
        {
            throw new InvalidFrameID3Exception("Encountered a corrupt TPOS part number frame.", e);
        }
    
Methods Summary
public voidaccept(ID3Visitor oID3Visitor)

        oID3Visitor.visitTPOSTextInformationID3V2Frame(this);
    
public booleanequals(java.lang.Object oOther)

        if ((oOther == null) || (!(oOther instanceof TPOSTextInformationID3V2Frame)))
        {
            return false;
        }
        
        TPOSTextInformationID3V2Frame oOtherTPOS = (TPOSTextInformationID3V2Frame)oOther;
        
        return ((m_iPartNumber == oOtherTPOS.m_iPartNumber) &&
                (m_iTotalParts == oOtherTPOS.m_iTotalParts) &&
                m_oTextEncoding.equals(oOtherTPOS.m_oTextEncoding) &&
                m_sInformation.equals(oOtherTPOS.m_sInformation));
    
protected byte[]getFrameId()

        return "TPOS".getBytes();
    
public intgetPartNumber()
Get the part number in the set to which this recording belongs.

return
the part number in the set to which this recording belongs

        return m_iPartNumber;
    
public intgetTotalParts()
Get the total number of parts in the complete set to which this recording belongs.

return
the total number of parts in the complete set to which this recording belongs, or -1 if the total number of parts has not been specified

        return m_iTotalParts;
    
public voidsetPartNumber(int iPartNumber)
Set the part number in the set to which this recording belongs.

param
iPartNumber the part number in the set to which this recording belongs
throws
ID3Exception if the part number is negative

        if (iPartNumber < 0)
        {
            throw new ID3Exception("Part number cannot be negative.");
        }

        m_iPartNumber = iPartNumber;
        m_iTotalParts = -1;
        m_oTextEncoding = TextEncoding.getDefaultTextEncoding();
        m_sInformation = Integer.toString(iPartNumber);
    
public voidsetPartNumberAndTotalParts(int iPartNumber, int iTotalParts)
Set the part number in the set to which this recording belongs, and the total number of parts in the complete set.

param
iPartNumber the part number in the set to which this recording belongs
param
iTotalParts the total number of parts in a complete set
throws
ID3Exception if the part number is negative, or the total number of parts is less than the part number

        if (iPartNumber < 0)
        {
            throw new ID3Exception("Part number cannot be negative.");
        }
        if (iTotalParts < iPartNumber)
        {
            throw new ID3Exception("Total number of parts must be at least as great as the part number.");
        }

        m_iPartNumber = iPartNumber;
        m_iTotalParts = iTotalParts;
        
        m_oTextEncoding = TextEncoding.getDefaultTextEncoding();
        m_sInformation = iPartNumber + "/" + iTotalParts;
    
public java.lang.StringtoString()

        return "Part of a set: [" + m_sInformation + "]";