Lyrics3v2Fieldpublic class Lyrics3v2Field extends org.jaudiotagger.tag.id3.AbstractTagFrame
Constructors Summary |
---|
public Lyrics3v2Field()Creates a new Lyrics3v2Field datatype.
| public Lyrics3v2Field(Lyrics3v2Field copyObject)
super(copyObject);
| public Lyrics3v2Field(AbstractLyrics3v2FieldFrameBody body)Creates a new Lyrics3v2Field datatype.
this.frameBody = body;
| public Lyrics3v2Field(org.jaudiotagger.tag.id3.AbstractID3v2Frame frame)Creates a new Lyrics3v2Field datatype.
AbstractFrameBodyTextInfo textFrame;
String text;
String frameIdentifier = frame.getIdentifier();
if (frameIdentifier.startsWith("USLT"))
{
frameBody = new FieldFrameBodyLYR("");
((FieldFrameBodyLYR) frameBody).addLyric((FrameBodyUSLT) frame.getBody());
}
else if (frameIdentifier.startsWith("SYLT"))
{
frameBody = new FieldFrameBodyLYR("");
((FieldFrameBodyLYR) frameBody).addLyric((FrameBodySYLT) frame.getBody());
}
else if (frameIdentifier.startsWith("COMM"))
{
text = ((FrameBodyCOMM) frame.getBody()).getText();
frameBody = new FieldFrameBodyINF(text);
}
else if (frameIdentifier.equals("TCOM"))
{
textFrame = (AbstractFrameBodyTextInfo) frame.getBody();
frameBody = new FieldFrameBodyAUT("");
if ((textFrame != null) && (textFrame.getText().length() > 0))
{
frameBody = new FieldFrameBodyAUT(textFrame.getText());
}
}
else if (frameIdentifier.equals("TALB"))
{
textFrame = (AbstractFrameBodyTextInfo) frame.getBody();
if ((textFrame != null) && (textFrame.getText().length() > 0))
{
frameBody = new FieldFrameBodyEAL(textFrame.getText());
}
}
else if (frameIdentifier.equals("TPE1"))
{
textFrame = (AbstractFrameBodyTextInfo) frame.getBody();
if ((textFrame != null) && (textFrame.getText().length() > 0))
{
frameBody = new FieldFrameBodyEAR(textFrame.getText());
}
}
else if (frameIdentifier.equals("TIT2"))
{
textFrame = (AbstractFrameBodyTextInfo) frame.getBody();
if ((textFrame != null) && (textFrame.getText().length() > 0))
{
frameBody = new FieldFrameBodyETT(textFrame.getText());
}
}
else
{
throw new TagException("Cannot createField Lyrics3v2 field from given ID3v2 frame");
}
| public Lyrics3v2Field(ByteBuffer byteBuffer)Creates a new Lyrics3v2Field datatype.
this.read(byteBuffer);
|
Methods Summary |
---|
public java.lang.String | getIdentifier()
if (frameBody == null)
{
return "";
}
return frameBody.getIdentifier();
| public int | getSize()
return frameBody.getSize() + 5 + getIdentifier().length();
| public void | read(java.nio.ByteBuffer byteBuffer)
byte[] buffer = new byte[6];
// lets scan for a non-zero byte;
long filePointer;
byte b;
do
{
b = byteBuffer.get();
}
while (b == 0);
byteBuffer.position(byteBuffer.position() - 1);
// read the 3 character ID
byteBuffer.get(buffer, 0, 3);
String identifier = new String(buffer, 0, 3);
// is this a valid identifier?
if (!Lyrics3v2Fields.isLyrics3v2FieldIdentifier(identifier))
{
throw new InvalidTagException(identifier + " is not a valid ID3v2.4 frame");
}
frameBody = readBody(identifier, byteBuffer);
| private AbstractLyrics3v2FieldFrameBody | readBody(java.lang.String identifier, java.nio.ByteBuffer byteBuffer)Read a Lyrics3 Field from a file.
AbstractLyrics3v2FieldFrameBody newBody;
if (identifier.equals(Lyrics3v2Fields.FIELD_V2_AUTHOR))
{
newBody = new FieldFrameBodyAUT(byteBuffer);
}
else if (identifier.equals(Lyrics3v2Fields.FIELD_V2_ALBUM))
{
newBody = new FieldFrameBodyEAL(byteBuffer);
}
else if (identifier.equals(Lyrics3v2Fields.FIELD_V2_ARTIST))
{
newBody = new FieldFrameBodyEAR(byteBuffer);
}
else if (identifier.equals(Lyrics3v2Fields.FIELD_V2_TRACK))
{
newBody = new FieldFrameBodyETT(byteBuffer);
}
else if (identifier.equals(Lyrics3v2Fields.FIELD_V2_IMAGE))
{
newBody = new FieldFrameBodyIMG(byteBuffer);
}
else if (identifier.equals(Lyrics3v2Fields.FIELD_V2_INDICATIONS))
{
newBody = new FieldFrameBodyIND(byteBuffer);
}
else if (identifier.equals(Lyrics3v2Fields.FIELD_V2_ADDITIONAL_MULTI_LINE_TEXT))
{
newBody = new FieldFrameBodyINF(byteBuffer);
}
else if (identifier.equals(Lyrics3v2Fields.FIELD_V2_LYRICS_MULTI_LINE_TEXT))
{
newBody = new FieldFrameBodyLYR(byteBuffer);
}
else
{
newBody = new FieldFrameBodyUnsupported(byteBuffer);
}
return newBody;
| public java.lang.String | toString()
if (frameBody == null)
{
return "";
}
return frameBody.toString();
| public void | write(java.io.RandomAccessFile file)
if ((frameBody.getSize() > 0) || TagOptionSingleton.getInstance().isLyrics3SaveEmptyField())
{
byte[] buffer = new byte[3];
String str = getIdentifier();
for (int i = 0; i < str.length(); i++)
{
buffer[i] = (byte) str.charAt(i);
}
file.write(buffer, 0, str.length());
//body.write(file);
}
|
|