Methods Summary |
---|
public void | copyContent(TagField field)
|
public void | createStructure()Return String Representation of frame
MP3File.getStructureFormatter().openHeadingElement(TYPE_FRAME, getIdentifier());
MP3File.getStructureFormatter().closeHeadingElement(TYPE_FRAME);
|
public boolean | equals(java.lang.Object obj)
if ( this == obj ) return true;
if (!(obj instanceof AbstractID3v2Frame))
{
return false;
}
AbstractID3v2Frame that = (AbstractID3v2Frame) obj;
return super.equals(that);
|
public java.lang.String | getContent()Returns the content of the field.
For frames consisting of different fields, this will return the value deemed to be most
likely to be required
return getBody().getUserFriendlyValue();
|
public java.lang.String | getEncoding()Returns the current used charset encoding.
return TextEncoding.getInstanceOf().getValueForId(this.getBody().getTextEncoding());
|
public org.jaudiotagger.tag.id3.AbstractID3v2Frame$EncodingFlags | getEncodingFlags()
return encodingFlags;
|
protected abstract int | getFrameHeaderSize()
|
protected abstract int | getFrameIdSize()
|
protected abstract int | getFrameSizeSize()
|
public java.lang.String | getId()Return the frame identifier, this only identifies the frame it does not provide a unique
key, when using frames such as TXXX which are used by many fields *
return getIdentifier();
|
public java.lang.String | getIdentifier()Return the frame identifier
return identifier;
|
protected java.lang.String | getLoggingFilename()Retrieve the logging filename to be used in debugging
return loggingFilename;
|
public byte[] | getRawContent()
ByteArrayOutputStream baos = new ByteArrayOutputStream();
write(baos);
return baos.toByteArray();
|
public org.jaudiotagger.tag.id3.AbstractID3v2Frame$StatusFlags | getStatusFlags()
return statusFlags;
|
public void | isBinary(boolean b)
//do nothing because whether or not a field is binary is defined by its id and is immutable
|
public boolean | isEmpty()
AbstractTagFrameBody body = this.getBody();
if (body == null)
{
return true;
}
//TODO depends on the body
return false;
|
protected boolean | isPadding(byte[] buffer)
if(
(buffer[0]=='\0")&&
(buffer[1]=='\0")&&
(buffer[2]=='\0")&&
(buffer[3]=='\0")
)
{
return true;
}
return false;
|
protected org.jaudiotagger.tag.id3.framebody.AbstractID3v2FrameBody | readBody(java.lang.String identifier, java.nio.ByteBuffer byteBuffer, int frameSize)Read the frame body from the specified file via the buffer
//Use reflection to map id to frame body, which makes things much easier
//to keep things up to date,although slight performance hit.
logger.finest("Creating framebody:start");
AbstractID3v2FrameBody frameBody;
try
{
Class<AbstractID3v2FrameBody> c = (Class<AbstractID3v2FrameBody>) Class.forName("org.jaudiotagger.tag.id3.framebody.FrameBody" + identifier);
Class<?>[] constructorParameterTypes = {Class.forName("java.nio.ByteBuffer"), Integer.TYPE};
Object[] constructorParameterValues = {byteBuffer, frameSize};
Constructor<AbstractID3v2FrameBody> construct = c.getConstructor(constructorParameterTypes);
frameBody = (construct.newInstance(constructorParameterValues));
}
//No class defined for this frame type,use FrameUnsupported
catch (ClassNotFoundException cex)
{
logger.config(getLoggingFilename() + ":" + "Identifier not recognised:" + identifier + " using FrameBodyUnsupported");
try
{
frameBody = new FrameBodyUnsupported(byteBuffer, frameSize);
}
//Should only throw InvalidFrameException but unfortunately legacy hierachy forces
//read method to declare it can throw InvalidtagException
catch (InvalidFrameException ife)
{
throw ife;
}
catch (InvalidTagException te)
{
throw new InvalidFrameException(te.getMessage());
}
}
//An error has occurred during frame instantiation, if underlying cause is an unchecked exception or error
//propagate it up otherwise mark this frame as invalid
catch (InvocationTargetException ite)
{
logger.severe(getLoggingFilename() + ":" + "An error occurred within abstractID3v2FrameBody for identifier:" + identifier + ":" + ite.getCause().getMessage());
if (ite.getCause() instanceof Error)
{
throw (Error) ite.getCause();
}
else if (ite.getCause() instanceof RuntimeException)
{
throw (RuntimeException) ite.getCause();
}
else if(ite.getCause() instanceof InvalidFrameException )
{
throw (InvalidFrameException)ite.getCause();
}
else if(ite.getCause() instanceof InvalidDataTypeException )
{
throw (InvalidDataTypeException)ite.getCause();
}
else
{
throw new InvalidFrameException(ite.getCause().getMessage());
}
}
//No Such Method should not happen
catch (NoSuchMethodException sme)
{
logger.log(Level.SEVERE, getLoggingFilename() + ":" + "No such method:" + sme.getMessage(), sme);
throw new RuntimeException(sme.getMessage());
}
//Instantiate Interface/Abstract should not happen
catch (InstantiationException ie)
{
logger.log(Level.SEVERE, getLoggingFilename() + ":" + "Instantiation exception:" + ie.getMessage(), ie);
throw new RuntimeException(ie.getMessage());
}
//Private Constructor shouild not happen
catch (IllegalAccessException iae)
{
logger.log(Level.SEVERE, getLoggingFilename() + ":" + "Illegal access exception :" + iae.getMessage(), iae);
throw new RuntimeException(iae.getMessage());
}
logger.finest(getLoggingFilename() + ":" + "Created framebody:end" + frameBody.getIdentifier());
frameBody.setHeader(this);
return frameBody;
|
protected org.jaudiotagger.tag.id3.framebody.AbstractID3v2FrameBody | readBody(java.lang.String identifier, org.jaudiotagger.tag.id3.framebody.AbstractID3v2FrameBody body)This creates a new body based of type identifier but populated by the data
in the body. This is a different type to the body being created which is why
TagUtility.copyObject() can't be used. This is used when converting between
different versions of a tag for frames that have a non-trivial mapping such
as TYER in v3 to TDRC in v4. This will only work where appropriate constructors
exist in the frame body to be created, for example a FrameBodyTYER requires a constructor
consisting of a FrameBodyTDRC.
If this method is called and a suitable constructor does not exist then an InvalidFrameException
will be thrown
/* Use reflection to map id to frame body, which makes things much easier
* to keep things up to date, although slight performance hit.
*/
AbstractID3v2FrameBody frameBody;
try
{
Class<AbstractID3v2FrameBody> c = (Class<AbstractID3v2FrameBody>) Class.forName("org.jaudiotagger.tag.id3.framebody.FrameBody" + identifier);
Class<?>[] constructorParameterTypes = {body.getClass()};
Object[] constructorParameterValues = {body};
Constructor<AbstractID3v2FrameBody> construct = c.getConstructor(constructorParameterTypes);
frameBody = (construct.newInstance(constructorParameterValues));
}
catch (ClassNotFoundException cex)
{
logger.config("Identifier not recognised:" + identifier + " unable to create framebody");
throw new InvalidFrameException("FrameBody" + identifier + " does not exist");
}
//If suitable constructor does not exist
catch (NoSuchMethodException sme)
{
logger.log(Level.SEVERE, "No such method:" + sme.getMessage(), sme);
throw new InvalidFrameException("FrameBody" + identifier + " does not have a constructor that takes:" + body.getClass().getName());
}
catch (InvocationTargetException ite)
{
logger.severe("An error occurred within abstractID3v2FrameBody");
logger.log(Level.SEVERE, "Invocation target exception:" + ite.getCause().getMessage(), ite.getCause());
if (ite.getCause() instanceof Error)
{
throw (Error) ite.getCause();
}
else if (ite.getCause() instanceof RuntimeException)
{
throw (RuntimeException) ite.getCause();
}
else
{
throw new InvalidFrameException(ite.getCause().getMessage());
}
}
//Instantiate Interface/Abstract should not happen
catch (InstantiationException ie)
{
logger.log(Level.SEVERE, "Instantiation exception:" + ie.getMessage(), ie);
throw new RuntimeException(ie.getMessage());
}
//Private Constructor shouild not happen
catch (IllegalAccessException iae)
{
logger.log(Level.SEVERE, "Illegal access exception :" + iae.getMessage(), iae);
throw new RuntimeException(iae.getMessage());
}
logger.finer("frame Body created" + frameBody.getIdentifier());
frameBody.setHeader(this);
return frameBody;
|
protected org.jaudiotagger.tag.id3.framebody.AbstractID3v2FrameBody | readEncryptedBody(java.lang.String identifier, java.nio.ByteBuffer byteBuffer, int frameSize)Read the frameBody when frame marked as encrypted
try
{
AbstractID3v2FrameBody frameBody = new FrameBodyEncrypted(identifier,byteBuffer, frameSize);
frameBody.setHeader(this);
return frameBody;
}
catch(InvalidTagException ite)
{
throw new InvalidDataTypeException(ite);
}
|
protected java.lang.String | readIdentifier(java.nio.ByteBuffer byteBuffer)Get the next frame id, throwing an exception if unable to do this and check against just having padded data
byte[] buffer = new byte[getFrameIdSize()];
if (byteBuffer.position() + getFrameHeaderSize() >= byteBuffer.limit())
{
logger.warning(getLoggingFilename() + ":" + "No space to find another frame:");
throw new InvalidFrameException(getLoggingFilename() + ":" + "No space to find another frame");
}
//Read the Frame Identifier
byteBuffer.get(buffer, 0, getFrameIdSize());
if(isPadding(buffer))
{
throw new PaddingException(getLoggingFilename() + ":only padding found");
}
identifier = new String(buffer);
logger.fine(getLoggingFilename() + ":" + "Identifier is" + identifier);
return identifier;
|
public void | setContent(java.lang.String content)Sets the content of the field.
throw new UnsupportedOperationException("Not implemeneted please use the generic tag methods for setting content");
|
protected void | setLoggingFilename(java.lang.String loggingFilename)Set logging filename when construct tag for read from file
this.loggingFilename = loggingFilename;
|
public abstract void | write(java.io.ByteArrayOutputStream tagBuffer)
|