FileDocCategorySizeDatePackage
TCOPTextInformationID3V2Frame.javaAPI Docjid3 0.465713Sun Feb 06 18:11:18 GMT 2005org.blinkenlights.jid3.v2

TCOPTextInformationID3V2Frame

public class TCOPTextInformationID3V2Frame extends TextInformationID3V2Frame
author
paul Text frame which contains copyright information for the track it is associated with.

Fields Summary
private int
m_iYear
private String
m_sCopyrightMessage
Constructors Summary
public TCOPTextInformationID3V2Frame(int iYear, String sCopyrightMessage)
Constructor.

param
iYear the year in which the track was copyrighted
param
sCopyrightMessage the copyright notice message for the track (ie. the holder)

    
                                
        
         
    
        super(getYearString(iYear) + " " + ((sCopyrightMessage == null) ? "" : sCopyrightMessage)  );
        
        if ((iYear < 0) || (iYear > 9999))
        {
            throw new ID3Exception("Year must be within the range from 1 to 9999.");
        }
        
        m_iYear = iYear;
        m_sCopyrightMessage = sCopyrightMessage;
    
public TCOPTextInformationID3V2Frame(InputStream oIS)

        super(oIS);
        
        // parse copyright message components from frame
        try
        {
            // parse year from copyright notice
            String sYear = m_sInformation.substring(0, 4);
            if (!sYear.matches("(?uis)\\d+"))
            {
                throw new ID3Exception("Missing 4-digit year value.");
            }
            m_iYear = Integer.parseInt(sYear);
            // space between
            if (m_sInformation.charAt(4) != ' ")
            {
                throw new ID3Exception("Missing space after year..");
            }
            // text of copyright notice
            if (m_sInformation.length() > 5)
            {
                m_sCopyrightMessage = m_sInformation.substring(5);
            }
            else
            {
                m_sCopyrightMessage = "";
            }
        }
        catch (Exception e)
        {
            // Tag & Rename It does not enforce the requirement that the first five characters of the copyright
            // notice be the year, so we will just make the whole thing the copyright message if we fail to parse
            // the value correctly, and make the year 0.
            m_iYear = 0;
            m_sCopyrightMessage = m_sInformation;
            
            //throw new ID3Exception("Encountered corrupt TCOP copyright notice frame.", e);
        }
    
Methods Summary
public voidaccept(ID3Visitor oID3Visitor)

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

        if ((oOther == null) || (!(oOther instanceof TCOPTextInformationID3V2Frame)))
        {
            return false;
        }
        
        TCOPTextInformationID3V2Frame oOtherTCOP = (TCOPTextInformationID3V2Frame)oOther;
        
        return ( (m_iYear == oOtherTCOP.m_iYear) &&
                 m_sCopyrightMessage.equals(oOtherTCOP.m_sCopyrightMessage) &&
                 m_oTextEncoding.equals(oOtherTCOP.m_oTextEncoding) &&
                 m_sInformation.equals(oOtherTCOP.m_sInformation) );
    
public java.lang.StringgetCopyrightMessage()
Get the copyright message, not including the year.

return
the copyright message

        return m_sCopyrightMessage;
    
public intgetCopyrightYear()
Get the copyright year.

return
the year of the copyright

        return m_iYear;
    
protected byte[]getFrameId()

        return "TCOP".getBytes();
    
private static java.lang.StringgetYearString(int iYear)
Internal method to return the year value as a four digit string.

        NumberFormat oNF = new DecimalFormat("0000");
        
        return oNF.format(iYear);
    
public voidsetCopyright(int iYear, java.lang.String sCopyrightMessage)
Set the copyright information for the track.

param
iYear the year of the copyright
param
sCopyrightMessage the copyright message itself (ie. the holder)

        m_iYear = iYear;
        m_sCopyrightMessage = sCopyrightMessage;
        
        m_oTextEncoding = TextEncoding.getDefaultTextEncoding();
        m_sInformation = getYearString(iYear) + " " + ((sCopyrightMessage == null) ? "" : sCopyrightMessage);
    
public java.lang.StringtoString()

        return "Copyright message: [" + m_sInformation + "]";