FileDocCategorySizeDatePackage
OWNEID3V2Frame.javaAPI Docjid3 0.468509Sun Feb 06 18:11:24 GMT 2005org.blinkenlights.jid3.v2

OWNEID3V2Frame

public class OWNEID3V2Frame extends ID3V2Frame
Frame containing ownership information.
author
paul

Fields Summary
private TextEncoding
m_oTextEncoding
private String
m_sPricePaid
private String
m_sDateOfPurchase
private String
m_sSeller
Constructors Summary
public OWNEID3V2Frame(String sPricePaid, String sDateOfPurchase, String sSeller)
Creates a new instance of OWNEID3V2Frame

param
sPricePaid a price(s) string (a price string consists of a three letter ISO-4217 currency code, followed by an amount, where "." is used as the decimal separator). Multiple prices may be separated by a "/" characters
param
sDateOfPurchase the date of the purchase, in the format YYYYMMDD
param
sSeller the name of the seller of this file
throws
ID3Exception if sPricePaid is null or not in a valid format, if sDateOfPurchase is null or not in the correct format, or if sSeller is null

    
                                                                                                                                         
      
                           
                           
         
    
        m_oTextEncoding = TextEncoding.getDefaultTextEncoding();
        if (sPricePaid == null)
        {
            throw new ID3Exception("Price paid required in OWNE frame.");
        }
        if ( ! sPricePaid.matches("(?uis)(\\w{3}\\d*\\.?\\d+/?)+"))
        {
            throw new ID3Exception("Invalid OWNE frame price string.");
        }
        m_sPricePaid = sPricePaid;
        if (sDateOfPurchase == null)
        {
            throw new ID3Exception("Date of purchase required in OWNE frame.");
        }
        if ( ! sDateOfPurchase.matches("(?uis)\\d{8}"))
        {
            throw new ID3Exception("Invalid date of purchase format in OWNE frame.");
        }
        m_sDateOfPurchase = sDateOfPurchase;
        if (sSeller == null)
        {
            throw new ID3Exception("Seller required in OWNE frame.");
        }
        m_sSeller = sSeller;
    
public OWNEID3V2Frame(InputStream oIS)

        try
        {
            ID3DataInputStream oFrameDataID3DIS = new ID3DataInputStream(oIS);
            
            // text encoding
            m_oTextEncoding = TextEncoding.getTextEncoding(oFrameDataID3DIS.readUnsignedByte());
            
            // price paid (read to null)
            m_sPricePaid = oFrameDataID3DIS.readStringToNull();
            
            // date of purchase (eight digits)
            byte[] abyDateOfPurchase = new byte[8];
            oFrameDataID3DIS.readFully(abyDateOfPurchase);
            m_sDateOfPurchase = new String(abyDateOfPurchase);

            // seller (to end)
            byte[] abySeller = new byte[oFrameDataID3DIS.available()];
            oFrameDataID3DIS.readFully(abySeller);
            m_sSeller = new String(abySeller, m_oTextEncoding.getEncodingString());
        }
        catch (Exception e)
        {
            throw new InvalidFrameID3Exception(e);
        }
    
Methods Summary
public voidaccept(ID3Visitor oID3Visitor)

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

        if ((oOther == null) || (!(oOther instanceof OWNEID3V2Frame)))
        {
            return false;
        }
        
        OWNEID3V2Frame oOtherOWNE = (OWNEID3V2Frame)oOther;
        
        return (m_oTextEncoding.equals(oOtherOWNE.m_oTextEncoding) &&
                m_sPricePaid.equals(oOtherOWNE.m_sPricePaid) &&
                m_sDateOfPurchase.equals(oOtherOWNE.m_sDateOfPurchase) &&
                m_sSeller.equals(oOtherOWNE.m_sSeller));
    
public java.lang.StringgetDateOfPurchase()
Get the date of purchase.

return
the date of purchase

        return m_sDateOfPurchase;
    
protected byte[]getFrameId()

        return "OWNE".getBytes();
    
public java.lang.StringgetPricePaid()
Get price paid.

return
the price paid

        return m_sPricePaid;
    
public java.lang.StringgetSeller()
Get the name of the seller.

return
the name of the seller

        return m_sSeller;
    
public TextEncodinggetTextEncoding()
Get the text encoding used for the seller in this frame.

return
the text encoding to be used for this frame

        return m_oTextEncoding;
    
public voidsetOwnershipInformation(java.lang.String sPricePaid, java.lang.String sDateOfPurchase, java.lang.String sSeller)
Set ownership information.

param
sPricePaid a price(s) string (a price string consists of a three letter ISO-4217 currency code, followed by an amount, where "." is used as the decimal separator). Multiple prices may be separated by a "/" characters
param
sDateOfPurchase the date of the purchase, in the format YYYYMMDD
param
sSeller the name of the seller of this file
throws
ID3Exception if sPricePaid is null or not in a valid format, if sDateOfPurchase is null or not in the correct format, or if sSeller is null

        m_oTextEncoding = TextEncoding.getDefaultTextEncoding();
        if (sPricePaid == null)
        {
            throw new ID3Exception("Price paid required in OWNE frame.");
        }
        if ( ! sPricePaid.matches("(?uis)(\\w{3}\\d*\\.?\\d+/?)+"))
        {
            throw new ID3Exception("Invalid OWNE frame price paid string.");
        }
        m_sPricePaid = sPricePaid;
        if (sDateOfPurchase == null)
        {
            throw new ID3Exception("Date of purchase required in OWNE frame.");
        }
        if ( ! sDateOfPurchase.matches("(?uis)\\d{8}"))
        {
            throw new ID3Exception("Invalid OWNE frame date of purchase.");
        }
        m_sDateOfPurchase = sDateOfPurchase;
        if (sSeller == null)
        {
            throw new ID3Exception("Seller required in OWNE frame.");
        }
        m_sSeller = sSeller;
    
public voidsetTextEncoding(TextEncoding oTextEncoding)
Set the text encoding to be used for the seller in this frame.

param
oTextEncoding the text encoding to be used for this frame

        if (oTextEncoding == null)
        {
            throw new NullPointerException("Text encoding cannot be null.");
        }
        m_oTextEncoding = oTextEncoding;
    
public java.lang.StringtoString()

        return "Ownership Frame: Price paid=[" + m_sPricePaid + "], Date of purchase=[" + m_sDateOfPurchase +
               "], Seller=[" + m_sSeller + "]";
    
protected voidwriteBody(ID3DataOutputStream oIDOS)

        // text encoding
        oIDOS.writeUnsignedByte(m_oTextEncoding.getEncodingValue());
        // price paid string
        oIDOS.write(m_sPricePaid.getBytes());
        oIDOS.writeUnsignedByte(0);
        // date of purchase until
        oIDOS.write(m_sDateOfPurchase.getBytes());
        // seller
        oIDOS.write(m_sSeller.getBytes(m_oTextEncoding.getEncodingString()));