|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.tffenterprises.music.tag.id3v2.Frame
com.tffenterprises.music.tag.id3v2.frame.BaseFrame
com.tffenterprises.music.tag.id3v2.frame.TextBasedFrame
public abstract class TextBasedFrame
This class is the basis for all text-based frame types in ID3v2, including but not exclusive to the text frame type. TextBaseFrame includes a number of String-handling utilities, as well as utilities involving text encoding.
Field Summary | |
---|---|
static char |
BOM_CHAR
A utility char, the byte-order mark (non-breaking space) character. |
static java.lang.String |
BOM_CHAR_STRING
A utility string, containing only the BOM (non-breaking space) character. |
private static java.util.Hashtable |
ENCODING_BYTES
The encoding strings, indexing their bytes; converse of the previous. |
static java.lang.String[] |
ENCODING_STRINGS
The encoding strings, indexed by ID3v2 encoding id. |
static java.lang.String |
ISO_8859_1
The ISO 8859-1 string encoding. |
static java.lang.String |
NULL_BOM_STRING
A utility string, containing a null character followed by a BOM. |
static char |
NULL_CHAR
A utility char, the null character. |
static java.lang.String |
NULL_CHAR_STRING
A utility string, containing only the null character. |
static java.lang.String |
UNICODE
The Unicode string encoding. |
static java.lang.String |
UNICODE_BIG
The Unicode string encoding, with big-endian byte ordering. |
static java.lang.String |
UNICODE_LITTLE
The Unicode string encoding, with little-endian byte ordering. |
static java.lang.String |
UTF8
The UTF-8 string encoding, that the 3-bytes-maximum version of it... |
Constructor Summary | |
---|---|
protected |
TextBasedFrame()
Protected default constructor. |
protected |
TextBasedFrame(FrameHeader header)
Frame subclasses MUST provide a constructor with this parameter list. |
Method Summary | |
---|---|
byte[] |
getNullBytes(java.lang.String encoding)
Returns the ID3v2 string-separator null byte(s), for the named encoding. |
java.lang.String |
getTextEncoding(byte b)
Returns a string representing the text encoding used by this frame, given a byte containing the ID3v2 specification's representation of an encoding. |
java.lang.String |
getTextEncoding(ByteArrayInputStream in)
Returns a string representing the text encoding used by this frame, given a byte containing the ID3v2 specification's representation of an encoding. |
byte[] |
getTextEncoding(java.lang.String encoding)
Returns a byte array containing ID3v2's byte representation of encodings, given a named encoding. |
boolean |
is8859String(java.lang.String string)
Tests a String to see if it can be encoded in ISO-8859-1. |
char[] |
read8859Characters(ByteArrayInputStream in)
Reads an array of characters from a ByteArrayInputStream, using the ISO 8859-1 encoding. |
java.lang.String |
read8859String(ByteArrayInputStream in)
Reads a string from a ByteArrayInputStream, using the ISO 8859-1 encoding. |
protected char[] |
readCharacters(ByteArrayInputStream in,
java.lang.String encoding)
Reads an array of characters from a ByteArrayInputStream, using the named character encoding. |
protected java.lang.String |
readString(ByteArrayInputStream in,
java.lang.String encoding)
Reads a String from a ByteArrayInputStream, using the named character encoding. |
char[] |
readUnicodeCharacters(ByteArrayInputStream in)
Reads an array of characters from a ByteArrayInputStream, using the Unicode encoding. |
java.lang.String |
readUnicodeString(ByteArrayInputStream in)
Reads a String from a ByteArrayInputStream, using the Unicode encoding. |
Methods inherited from class com.tffenterprises.music.tag.id3v2.frame.BaseFrame |
---|
clone, equals, getBytes, getChecksum, getFormatFlags, getFrameID, getHeader, getRawData, getStatusFlags, hashCode, isChanged, isOfRepeatableType, setChanged, setFormatFlags, setRawData, setStatusFlags, toByteArray, toString, updateChecksum, writeTo |
Methods inherited from class com.tffenterprises.music.tag.id3v2.Frame |
---|
FromByteArray, FromByteArray, FromInputStream, GetFrameClassForID, getNewInstance, getNewInstance, getNewInstance, MinimumLength, RegisterFrameClass, UnregisterFrameClass |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String ISO_8859_1
public static final java.lang.String UNICODE
public static final java.lang.String UNICODE_BIG
public static final java.lang.String UNICODE_LITTLE
public static final java.lang.String UTF8
public static final char NULL_CHAR
public static final char BOM_CHAR
public static final java.lang.String NULL_CHAR_STRING
public static final java.lang.String BOM_CHAR_STRING
public static final java.lang.String NULL_BOM_STRING
public static final java.lang.String[] ENCODING_STRINGS
private static final java.util.Hashtable ENCODING_BYTES
Constructor Detail |
---|
protected TextBasedFrame()
protected TextBasedFrame(FrameHeader header) throws java.lang.IllegalArgumentException
header
- The FrameHeader to be used for this Frame instance.
See FrameHeader
for details.
java.lang.IllegalArgumentException
- This is exception is thrown when
the parameter is unacceptable for
use with an object of this
Frame class/subclass.Method Detail |
---|
public boolean is8859String(java.lang.String string)
string
- The String to test.
public java.lang.String getTextEncoding(ByteArrayInputStream in) throws FrameDataFormatException
ByteArrayInputStream
parameter. The returned string will always be the name of an encoding type useable by java.
For the moment, this method returns either "ISO8859_1" or "Unicode". Note that in the case of Unicode, further probing may be necessary in order to determine the byte ordering. The readUnicodeString() method does such additional probing.
in
- stream where to get the encoding, in its ID3v2 representation.
FrameDataFormatException
- if the byte value is not one
supported by ID3v2.public java.lang.String getTextEncoding(byte b) throws FrameDataFormatException
The returned string will always be the name of an encoding type useable by java.
For the moment, this method returns either "ISO8859_1" or "Unicode". Note that in the case of Unicode, further probing may be necessary in order to determine the byte ordering. The readUnicodeString() method does such additional probing.
b
- the encoding, in its ID3v2 representation.
FrameDataFormatException
- if the byte value is not one
supported by ID3v2.public byte[] getTextEncoding(java.lang.String encoding) throws FrameDataFormatException
The named encoding should always be an encoding type useable by java.
encoding
- the name of the encoding.
FrameDataFormatException
- if the named encoding isn't supported
by the ID3v2 specification.public byte[] getNullBytes(java.lang.String encoding) throws FrameDataFormatException
encoding
- the encoding to use for the string terminator.
FrameDataFormatException
- if the named encoding is not
supported.public java.lang.String read8859String(ByteArrayInputStream in) throws FrameDataFormatException
in
- A ByteArrayInputStream to milk for characters.
FrameDataFormatException
- if the requested encoding is not
supported, or if the data is
malformed.public char[] read8859Characters(ByteArrayInputStream in) throws FrameDataFormatException
in
- A ByteArrayInputStream to milk for characters.
FrameDataFormatException
- if the requested encoding is not
supported, or if the data is
malformed.public java.lang.String readUnicodeString(ByteArrayInputStream in) throws FrameDataFormatException
in
- A ByteArrayInputStream to milk for characters.
FrameDataFormatException
- if the requested encoding is not
supported, or if the data is
malformed.public char[] readUnicodeCharacters(ByteArrayInputStream in) throws FrameDataFormatException
in
- A ByteArrayInputStream to milk for characters.
FrameDataFormatException
- if the requested encoding is not
supported, or if the data is
malformed.protected java.lang.String readString(ByteArrayInputStream in, java.lang.String encoding) throws FrameDataFormatException
The encoding string used should be one of the strings defined as public static variables for the TextBasedFrame class. Other character encodings may be unsupported by java VMs.
in
- A ByteArrayInputStream to milk for characters.encoding
- The name of the character encoding to be used.
FrameDataFormatException
- if the requested encoding is not
supported, or if the data is
malformed.protected char[] readCharacters(ByteArrayInputStream in, java.lang.String encoding) throws FrameDataFormatException
The encoding string used should be one of the strings defined as public static variables for the TextBasedFrame class. Other character encodings may be unsupported by java VMs.
in
- A ByteArrayInputStream to milk for characters.encoding
- The name of the character encoding to be used.
FrameDataFormatException
- if the requested encoding is not
supported, or if the data is
malformed.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |