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

POSSID3V2Frame

public class POSSID3V2Frame extends ID3V2Frame
Frame containing position synchronization information.
author
paul

Fields Summary
private TimestampFormat
m_oTimestampFormat
private int
m_iPosition
Constructors Summary
public POSSID3V2Frame(TimestampFormat oTimestampFormat, int iPosition)
Creates a new instance of POSSID3V2Frame.

param
oTimestampFormat the format for timestamps, whether by millisecond or frame count
param
iPosition the position in the full recording/broadcast, of the first frame in this stream
throws
ID3Exception if oTimestampFormat is null, or if the position value is negative

        if (oTimestampFormat == null)
        {
            throw new ID3Exception("Timestamp format required in POSS frame.");
        }
        m_oTimestampFormat = oTimestampFormat;
        if (iPosition < 0)
        {
            throw new ID3Exception("Position cannot be negative in POSS frame.");
        }
        m_iPosition = iPosition;
    
public POSSID3V2Frame(InputStream oIS)

        // Parse out the text encoding and the position value
        try
        {
            ID3DataInputStream oFrameDataID3DIS = new ID3DataInputStream(oIS);
            
            // timestamp format
            m_oTimestampFormat = new TimestampFormat((byte)oFrameDataID3DIS.readUnsignedByte());
            
            // position value
            if ((oFrameDataID3DIS.available() >=1) && (oFrameDataID3DIS.available() <= 4))
            {
                byte[] abyPosition = new byte[4];
                int i;
                for (i=0; i < (4 - oFrameDataID3DIS.available()); i++)
                {
                    abyPosition[i] = 0;
                }
                while (oFrameDataID3DIS.available() > 0)
                {
                    abyPosition[i] = (byte)oFrameDataID3DIS.readUnsignedByte();
                    i++;
                }
                ByteArrayInputStream oBAIS = new ByteArrayInputStream(abyPosition);
                ID3DataInputStream oID3DIS = new ID3DataInputStream(oBAIS);
                m_iPosition = oID3DIS.readBE32();
            }
            else
            {
                throw new ID3Exception("Position value of " + oFrameDataID3DIS.available() + " bytes not supported in POSS frame.");
            }
        }
        catch (Exception e)
        {
            throw new InvalidFrameID3Exception(e);
        }
    
Methods Summary
public voidaccept(ID3Visitor oID3Visitor)

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

        if ((oOther == null) || (!(oOther instanceof POSSID3V2Frame)))
        {
            return false;
        }
        
        POSSID3V2Frame oOtherPOSS = (POSSID3V2Frame)oOther;
        
        return (m_oTimestampFormat.equals(oOtherPOSS.m_oTimestampFormat) &&
                (m_iPosition == oOtherPOSS.m_iPosition));
    
protected byte[]getFrameId()

        return "POSS".getBytes();
    
public intgetPosition()
Get the position of the start of this track.

return
the position in the specified format, of the start of this track

        return m_iPosition;
    
public org.blinkenlights.jid3.v2.POSSID3V2Frame$TimestampFormatgetTimestampFormat()
Get the timestamp format.

return
the timestamp format

        return m_oTimestampFormat;
    
public voidsetPositionSynchronizationValue(org.blinkenlights.jid3.v2.POSSID3V2Frame$TimestampFormat oTimestampFormat, int iPosition)
Set position synchronization values for this frame.

param
oTimestampFormat the format for timestamps, whether by millisecond or frame count
param
iPosition the position in the full recording/broadcast, of the first frame in this stream
throws
ID3Exception if oTimestampFormat is null, or if the position value is negative

        if (oTimestampFormat == null)
        {
            throw new ID3Exception("Timestamp format required in POSS frame.");
        }
        m_oTimestampFormat = oTimestampFormat;
        if (iPosition < 0)
        {
            throw new ID3Exception("Position cannot be negative in POSS frame.");
        }
        m_iPosition = iPosition;
    
public java.lang.StringtoString()

        return "Position Synchronization: Timestamp format=[" + m_oTimestampFormat.getValue() +
               "], Position=[" + m_iPosition + "]";
    
protected voidwriteBody(ID3DataOutputStream oIDOS)

        // timestamp format
        oIDOS.writeUnsignedByte(m_oTimestampFormat.getValue());
        
        // position (always four bytes)
        oIDOS.writeBE32(m_iPosition);