FileDocCategorySizeDatePackage
UFIDID3V2Frame.javaAPI Docjid3 0.466158Sun Feb 06 18:11:22 GMT 2005org.blinkenlights.jid3.v2

UFIDID3V2Frame

public class UFIDID3V2Frame extends ID3V2Frame
Frame containing a unique file identifier.
author
paul

Fields Summary
private String
m_sOwnerIdentifier
private byte[]
m_abyIdentifier
Constructors Summary
public UFIDID3V2Frame(String sOwnerIdentifier, byte[] abyIdentifier)
Creates a new instance of UFIDID3V2Frame.

param
sOwnerIdentifier an URL or email address identifying the owner of this file
param
abyIdentifier up to 64 bytes of data which uniquely identify this file
throws
ID3Exception if sOwnerIdentifier is null or zero length, or if abyIdentifier is null or of length outside the range from 0-64

    
                                                                                    
        
         
    
        if ((sOwnerIdentifier == null) || (sOwnerIdentifier.length() == 0))
        {
            throw new ID3Exception("The owner identifier cannot be null or zero length in UFID frame.");
        }
        m_sOwnerIdentifier = sOwnerIdentifier;
        if ((abyIdentifier == null) || (abyIdentifier.length > 64))
        {
            throw new ID3Exception("The identifier be a non-null byte array of length 0-64 bytes in UFID frame.");
        }
        m_abyIdentifier = abyIdentifier;
    
public UFIDID3V2Frame(InputStream oIS)

        try
        {
            ID3DataInputStream oFrameDataID3DIS = new ID3DataInputStream(oIS);
            
            // owner identifier
            m_sOwnerIdentifier = oFrameDataID3DIS.readStringToNull();
            // identifier
            m_abyIdentifier = new byte[oFrameDataID3DIS.available()];
            if (oFrameDataID3DIS.available() > 0)
            {
                oFrameDataID3DIS.readFully(m_abyIdentifier);
            }
        }
        catch (Exception e)
        {
            throw new InvalidFrameID3Exception(e);
        }
    
Methods Summary
public voidaccept(ID3Visitor oID3Visitor)

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

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

        return "UFID".getBytes();
    
public byte[]getIdentifier()
Get the unique file identifier from this frame

return
the unique file identifier

        return m_abyIdentifier;
    
public java.lang.StringgetOwnerIdentifier()
Get the owner identifier for this frame.

return
the owner identifier

        return m_sOwnerIdentifier;
    
public voidsetUniqueIdentifier(java.lang.String sOwnerIdentifier, byte[] abyIdentifier)
Set unique file identifier.

param
sOwnerIdentifier an URL or email address identifying the owner of this file
param
abyIdentifier up to 64 bytes of data which uniquely identify this file
throws
ID3Exception if sOwnerIdentifier is null or zero length, or if abyIdentifier is null or of length outside the range from 0-64, or if this frame is in a tag with another UFID frame which has the same owner identifier

        String sOrigOwnerIdentifier = m_sOwnerIdentifier;
        byte[] abyOrigIdentifier = m_abyIdentifier;
        
        if ((sOwnerIdentifier == null) || (sOwnerIdentifier.length() == 0))
        {
            throw new ID3Exception("The owner identifier cannot be null or zero length in UFID frame.");
        }
        if ((abyIdentifier == null) || (abyIdentifier.length > 64))
        {
            throw new ID3Exception("The identifier must be a non-null byte array of length 0-64 bytes in UFID frame.");
        }

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

        return "Unique file identifier: Owner identifier=[" + m_sOwnerIdentifier +
               "], Identifier length=[" + m_abyIdentifier.length + "]";
    
protected voidwriteBody(ID3DataOutputStream oIDOS)

        oIDOS.write(m_sOwnerIdentifier.getBytes());
        oIDOS.write(0);
        oIDOS.write(m_abyIdentifier);