FileDocCategorySizeDatePackage
PRIVID3V2Frame.javaAPI Docjid3 0.465927Sun Feb 06 18:11:15 GMT 2005org.blinkenlights.jid3.v2

PRIVID3V2Frame

public class PRIVID3V2Frame extends ID3V2Frame
Frame containing private information.
author
paul

Fields Summary
private String
m_sOwnerIdentifier
private byte[]
m_abyPrivateData
Constructors Summary
public PRIVID3V2Frame(String sOwnerIdentifier, byte[] abyPrivateData)
Creates a new instance of PRIVID3V2Frame

param
sOwnerIdentifier an URL or email address identifier the owner related to the private data
param
abyPrivateData the private data to be stored in this frame
throws
ID3Exception if the owner identifier is null or zero length, or if the private data is null

    
                                                            
      
                           
         
    
        if ((sOwnerIdentifier == null) || (sOwnerIdentifier.length() == 0))
        {
            throw new ID3Exception("Owner identifier required in PRIV frame.");
        }
        m_sOwnerIdentifier = sOwnerIdentifier;
        if (abyPrivateData == null)
        {
            throw new ID3Exception("Private data required in PRIV frame.");
        }
        m_abyPrivateData = abyPrivateData;
    
public PRIVID3V2Frame(InputStream oIS)

        try
        {
            ID3DataInputStream oFrameDataID3DIS = new ID3DataInputStream(oIS);
            
            // owner identifier (read to null)
            m_sOwnerIdentifier = oFrameDataID3DIS.readStringToNull();
            
            // private data (to end)
            m_abyPrivateData = new byte[oFrameDataID3DIS.available()];
            oFrameDataID3DIS.readFully(m_abyPrivateData);
        }
        catch (Exception e)
        {
            throw new InvalidFrameID3Exception(e);
        }
    
Methods Summary
public voidaccept(ID3Visitor oID3Visitor)

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

        if ((oOther == null) || (!(oOther instanceof PRIVID3V2Frame)))
        {
            return false;
        }
        
        PRIVID3V2Frame oOtherPRIV = (PRIVID3V2Frame)oOther;
        
        return (m_sOwnerIdentifier.equals(oOtherPRIV.m_sOwnerIdentifier) &&
                Arrays.equals(m_abyPrivateData, oOtherPRIV.m_abyPrivateData));
    
protected byte[]getFrameId()

        return "PRIV".getBytes();
    
public java.lang.StringgetOwnerIdentifier()
Get the owner identifier.

return
an identification string for the owner associated with the private data in this frame

        return m_sOwnerIdentifier;
    
public byte[]getPrivateData()
Get private data.

return
the private data stored in this frame

        return m_abyPrivateData;
    
public voidsetPrivateInformation(java.lang.String sOwnerIdentifier, byte[] abyPrivateData)
Set private information.

param
sOwnerIdentifier an URL or email address identifier the owner related to the private data
param
abyPrivateData the private data to be stored in this frame
throws
ID3Exception if the owner identifier is null or zero length, or if the private data is null
throws
ID3Exception if this frame is in a tag with another PRIV frame which would have the same contents

        String sOrigOwnerIdentifier = m_sOwnerIdentifier;
        byte[] abyOrigPrivateData = m_abyPrivateData;
        
        if ((sOwnerIdentifier == null) || (sOwnerIdentifier.length() == 0))
        {
            throw new ID3Exception("Owner identifier required in PRIV frame.");
        }
        if (abyPrivateData == null)
        {
            throw new ID3Exception("Private data required in PRIV frame.");
        }

        m_sOwnerIdentifier = sOwnerIdentifier;
        m_abyPrivateData = abyPrivateData;
        
        // try this update, and reverse it if it generates and error
        try
        {
            notifyID3Observers();
        }
        catch (ID3Exception e)
        {
            m_sOwnerIdentifier = sOrigOwnerIdentifier;
            m_abyPrivateData = abyOrigPrivateData;
            
            throw e;
        }
    
public java.lang.StringtoString()

        return "Private information: Ownership identifier=[" + m_sOwnerIdentifier +
               "], Private data length=[" + m_abyPrivateData.length + "]";
    
protected voidwriteBody(ID3DataOutputStream oIDOS)

        // ownership identifier string
        oIDOS.write(m_sOwnerIdentifier.getBytes());
        oIDOS.writeUnsignedByte(0);
        // private data
        oIDOS.write(m_abyPrivateData);