FileDocCategorySizeDatePackage
GRIDID3V2Frame.javaAPI Docjid3 0.467812Sun Feb 06 18:11:23 GMT 2005org.blinkenlights.jid3.v2

GRIDID3V2Frame

public class GRIDID3V2Frame extends ID3V2Frame
author
paul Frame containing group identification registration.

Fields Summary
private String
m_sOwnerIdentifier
private byte
m_byGroupSymbol
private byte[]
m_abyGroupDependantData
Constructors Summary
public GRIDID3V2Frame(String sOwnerIdentifier, byte byGroupSymbol, byte[] abyGroupDependantData)
Constructor.

param
sOwnerIdentifier an URL or email address where information about this grouping can be found
param
byGroupSymbol a symbol which will be used to identify this group throughout this tag (values lower than $80 are reserved)
param
abyGroupDependantData any data which is required for the correct interpretation of this grouping
throws
ID3Exception if the owner identifier is null or zero-length

    
                                                                             
          
         
    
        if ((sOwnerIdentifier == null) || (sOwnerIdentifier.length() == 0))
        {
            throw new ID3Exception("GRID frame requires owner identifier value.");
        }
        m_sOwnerIdentifier = sOwnerIdentifier;
        m_byGroupSymbol = byGroupSymbol;
        m_abyGroupDependantData = abyGroupDependantData;
        if ((m_abyGroupDependantData != null) && (m_abyGroupDependantData.length == 0))
        {
            m_abyGroupDependantData = null;
        }
    
public GRIDID3V2Frame(InputStream oIS)

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

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

        if ((oOther == null) || (!(oOther instanceof GRIDID3V2Frame)))
        {
            return false;
        }
        
        GRIDID3V2Frame oOtherGRID = (GRIDID3V2Frame)oOther;
        
        return ( (((m_sOwnerIdentifier == null) && (oOtherGRID.m_sOwnerIdentifier == null)) || m_sOwnerIdentifier.equals(oOtherGRID.m_sOwnerIdentifier)) &&
                 (m_byGroupSymbol == oOtherGRID.m_byGroupSymbol) &&
                 Arrays.equals(m_abyGroupDependantData, oOtherGRID.m_abyGroupDependantData));
    
protected byte[]getFrameId()

        return "GRID".getBytes();
    
public byte[]getGroupDependantData()
Get group dependant data.

return
any additional group dependant data, or null if none has been set

        return m_abyGroupDependantData;
    
public bytegetGroupSymbol()
Get the group symbol for this grouping.

return
the byte value used as a symbol for this group

        return m_byGroupSymbol;
    
public java.lang.StringgetOwnerIdentifier()
Get owner identifier information.

return
the owner identifier value, which should be either an URL or an email address

        return m_sOwnerIdentifier;
    
public voidsetGroupIdentificationRegistration(java.lang.String sOwnerIdentifier, byte byGroupSymbol, byte[] abyGroupDependantData)
Set group identification registration data.

param
sOwnerIdentifier an URL or email address where information about this grouping can be found
param
byGroupSymbol a symbol which will be used to identify this group throughout this tag (values lower than $80 are reserved)
param
abyGroupDependantData any data which is required for the correct interpretation of this grouping
throws
ID3Exception if the owner identifier is null or zero-length
throws
ID3Exception if this frame is in a tag with another GRID frame which would have the same group symbol

        String sOrigOwnerIdentifier = m_sOwnerIdentifier;
        byte byOrigGroupSymbol = m_byGroupSymbol;
        byte[] abyOrigGroupDependantData = m_abyGroupDependantData;
        
        if ((sOwnerIdentifier == null) || (sOwnerIdentifier.length() == 0))
        {
            throw new ID3Exception("GRID frame requires owner identifier value.");
        }
        
        m_sOwnerIdentifier = sOwnerIdentifier;
        m_byGroupSymbol = byGroupSymbol;
        m_abyGroupDependantData = abyGroupDependantData;
        if ((m_abyGroupDependantData != null) && (m_abyGroupDependantData.length == 0))
        {
            m_abyGroupDependantData = null;
        }
        
        // try this update, and reverse it if it generates and error
        try
        {
            notifyID3Observers();
        }
        catch (ID3Exception e)
        {
            m_sOwnerIdentifier = sOrigOwnerIdentifier;
            m_byGroupSymbol = byOrigGroupSymbol;
            m_abyGroupDependantData = abyOrigGroupDependantData;

            throw e;
        }
    
public java.lang.StringtoString()

        StringBuffer sbOutput = new StringBuffer();
        sbOutput.append("Group identification registration: Owner identifier=[" + m_sOwnerIdentifier +
                        "], Group symbol=[" + m_byGroupSymbol + "], ");
        if (m_abyGroupDependantData == null)
        {
            sbOutput.append("Group dependant data = none");
        }
        else
        {
            sbOutput.append("Group dependant data length = " + m_abyGroupDependantData.length);
        }
                        
        return sbOutput.toString(); 
    
protected voidwriteBody(ID3DataOutputStream oIDOS)

        // owner identifier
        oIDOS.write(m_sOwnerIdentifier.getBytes());
        oIDOS.writeUnsignedByte(0);
        // group symbol
        oIDOS.writeUnsignedByte(m_byGroupSymbol);
        // optional group dependant data
        if (m_abyGroupDependantData != null)
        {
            oIDOS.write(m_abyGroupDependantData);
        }