FileDocCategorySizeDatePackage
TextInformationID3V2Frame.javaAPI Docjid3 0.464790Sun Feb 06 18:11:18 GMT 2005org.blinkenlights.jid3.v2

TextInformationID3V2Frame

public abstract class TextInformationID3V2Frame extends ID3V2Frame
author
paul The base class for all text frames.

Fields Summary
protected TextEncoding
m_oTextEncoding
The text encoding of the strings in this frame.
protected String
m_sInformation
The text content of this frame. Based on the type of frame, there will be different meanings, and potentailly unique restrictions, for this value.
Constructors Summary
protected TextInformationID3V2Frame()

        m_oTextEncoding = TextEncoding.getDefaultTextEncoding();
    
protected TextInformationID3V2Frame(TextEncoding oTextEncoding, String sInformation)
Constructor for user created frames.

param
oTextEncoding the text encoding
param
sInformation the raw text to be stored in this frame when it is written

        // set the text and its encoding type for this text information frame
        m_oTextEncoding = oTextEncoding;
        m_sInformation = sInformation;
    
protected TextInformationID3V2Frame(String sInformation)
Constructor for user created frames. Uses the current default text encoding.

param
sInformation the raw text to be stored in this frame when it is written

        // set the text and its encoding type for this text information frame
        m_oTextEncoding = TextEncoding.getDefaultTextEncoding();
        m_sInformation = sInformation;
    
public TextInformationID3V2Frame(InputStream oIS)
Constructor to be used internally when reading frames from a file.

param
oIS input stream from which to read the raw data in the frame, to be parsed into a text frame object
throws
ID3Exception if there is any error parsing the text frame data

        // Parse out the text encoding and text string from the raw data
        try
        {
            ID3DataInputStream oFrameDataID3DIS = new ID3DataInputStream(oIS);
            
            m_oTextEncoding = TextEncoding.getTextEncoding(oFrameDataID3DIS.readUnsignedByte());
            byte[] abyInformation = new byte[oFrameDataID3DIS.available()];
            oFrameDataID3DIS.readFully(abyInformation);
            m_sInformation = new String(abyInformation, m_oTextEncoding.getEncodingString());
        }
        catch (Exception e)
        {
            throw new InvalidFrameID3Exception(e);
        }
    
Methods Summary
public TextEncodinggetTextEncoding()
Get the text encoding used for the text information in this frame.

return
the text encoding to be used for this frame

        return m_oTextEncoding;
    
public voidsetTextEncoding(TextEncoding oTextEncoding)
Set the text encoding to be used for the text information 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;
    
protected voidwriteBody(ID3DataOutputStream oIDOS)
Write the body of this frame to an output stream.

param
oIDOS the ID3 output stream to which the frame body is to be written
throws
ID3Exception if there is any error writing the frame body data

        oIDOS.writeUnsignedByte(m_oTextEncoding.getEncodingValue());
        oIDOS.write(m_sInformation.getBytes(m_oTextEncoding.getEncodingString()));