Modifier and Type | Field and Description |
---|---|
protected int |
duplicateBytes |
protected String |
duplicateFrameId |
protected int |
emptyFrameBytes |
HashMap<String,Object> |
encryptedFrameMap
Map of all encrypted frames, these cannot be unencrypted by jaudiotagger
|
static int |
FIELD_TAG_FLAG_LENGTH |
protected static int |
FIELD_TAG_FLAG_POS |
static int |
FIELD_TAG_MAJOR_VERSION_LENGTH |
static int |
FIELD_TAG_MAJOR_VERSION_POS |
static int |
FIELD_TAG_MINOR_VERSION_LENGTH |
protected static int |
FIELD_TAG_MINOR_VERSION_POS |
static int |
FIELD_TAG_SIZE_LENGTH |
protected static int |
FIELD_TAG_SIZE_POS |
static int |
FIELD_TAGID_LENGTH |
protected static int |
FIELD_TAGID_POS |
protected int |
fileReadSize |
HashMap<String,Object> |
frameMap
Map of all frames for this tag
|
protected int |
invalidFrames |
static int |
TAG_HEADER_LENGTH |
static byte[] |
TAG_ID |
protected static int |
TAG_SIZE_INCREMENT |
static String |
TAGID |
protected static String |
TYPE_BODY |
protected static String |
TYPE_DUPLICATEBYTES
Holds count the number of bytes used up by invalid duplicate frames
|
protected static String |
TYPE_DUPLICATEFRAMEID
Holds the ids of invalid duplicate frames
|
protected static String |
TYPE_EMPTYFRAMEBYTES
Holds count the number bytes used up by empty frames
|
protected static String |
TYPE_FILEREADSIZE
Holds the size of the tag as reported by the tag header
|
protected static String |
TYPE_HEADER |
protected static String |
TYPE_INVALIDFRAMES
Holds count of invalid frames, (frames that could not be read)
|
logger, TAG_RELEASE
TYPE_TAG
Modifier | Constructor and Description |
---|---|
|
AbstractID3v2Tag()
Empty Constructor
|
protected |
AbstractID3v2Tag(AbstractID3v2Tag copyObject)
This constructor is used when a tag is created as a duplicate of another
tag of the same type and version.
|
Modifier and Type | Method and Description |
---|---|
void |
addField(Artwork artwork)
Create field and then set within tag itself
|
void |
addField(FieldKey genericKey,
String... value)
Create the field based on the generic key and add it to the tag
This is handled differently by different formats
|
void |
addField(TagField field)
Add new field
There is a special handling if adding another text field of the same type, in this case the value will
be appended to the existing field, separated by the null character.
|
protected abstract void |
addFrame(AbstractID3v2Frame frame)
Add the frame converted to the correct version
|
protected int |
calculateTagSize(int tagSize,
int preferredSize)
This method determines the total tag size taking into account
the preferredSize and the min size required for new tag.
|
protected abstract List<AbstractID3v2Frame> |
convertFrame(AbstractID3v2Frame frame)
Convert the frame to the correct frame(s)
|
protected void |
copyFrameIntoMap(String id,
AbstractID3v2Frame newFrame)
Copy frame into map, whilst accounting for multiple frame of same type which can occur even if there were
not frames of the same type in the original tag
|
protected void |
copyFrames(AbstractID3v2Tag copyObject)
Copy frames from another tag,
|
protected void |
copyPrimitives(AbstractID3v2Tag copyObject)
Copy primitives apply to all tags
|
TagField |
createCompilationField(boolean value)
Creates isCompilation field
It is useful to have this method because it handles ensuring that the correct value to represent a boolean
is stored in the underlying field format.
|
TagField |
createField(FieldKey genericKey,
String... values)
Create a new field
Only MUSICIAN field make use of Varargs values field
|
abstract AbstractID3v2Frame |
createFrame(String id)
Create Frame of correct ID3 version with the specified id
|
TagField |
createLinkedArtworkField(String url)
Create a link to artwork, this is not recommended because the link may be broken if the mp3 or image
file is moved
|
void |
createStructure() |
void |
createStructureBody() |
void |
createStructureHeader() |
void |
delete(RandomAccessFile file)
Delete Tag
|
void |
deleteArtworkField()
Delete all instance of artwork Field
|
void |
deleteField(FieldKey fieldKey)
Delete fields with this generic key
If generic key maps to multiple frames then do special processing here rather doDeleteField()
|
protected TagField |
doCreateTagField(org.jaudiotagger.tag.id3.AbstractID3v2Tag.FrameAndSubId formatKey,
String... values)
Create Frame for Id3 Key
Only textual data supported at the moment, should only be used with frames that
support a simple string argument.
|
protected void |
doDeleteTagField(org.jaudiotagger.tag.id3.AbstractID3v2Tag.FrameAndSubId formatKey)
Internal delete method, for deleting/modifying an individual ID3 frame
|
protected String |
doGetValueAtIndex(org.jaudiotagger.tag.id3.AbstractID3v2Tag.FrameAndSubId formatKey,
int index)
Get the value at the index, we massage the values so that the index as used in the generic interface rather
than simply taking the frame index.
|
protected List<String> |
doGetValues(org.jaudiotagger.tag.id3.AbstractID3v2Tag.FrameAndSubId formatKey)
Create a list of values for this (sub)frame
This method does all the complex stuff of splitting multiple values in one frame into separate values.
|
boolean |
equals(Object obj)
Is this tag equivalent to another
|
List<String> |
getAll(FieldKey genericKey)
Maps the generic key to the id3 key and return the list of values for this field as strings
|
int |
getDuplicateBytes()
Returns the number of bytes which come from duplicate frames
|
String |
getDuplicateFrameId()
Return the string which holds the ids of all
duplicate frames.
|
int |
getEmptyFrameBytes()
Returns the number of bytes which come from empty frames
|
Object |
getEncryptedFrame(String identifier)
Return any encrypted frames with this identifier
|
Long |
getEndLocationInFile() |
int |
getFieldCount()
Count number of frames/fields in this tag
|
int |
getFieldCountIncludingSubValues()
Return count of fields, this considers a text frame with two null separated values as two fields, if you want
a count of frames @see getFrameCount
|
Iterator<TagField> |
getFields()
Iterator over all the fields within the tag, handle multiple fields with the same id
|
List<TagField> |
getFields(FieldKey genericKey)
Get field(s) for this generic key
This will return the number of underlying frames of this type, for example if you have added two TCOM field
values these will be stored within a single frame so only one field will be returned not two.
|
List<TagField> |
getFields(String id)
Retrieve the values that exists for this id3 frame id
|
protected FileLock |
getFileLockForWriting(FileChannel fileChannel,
String filePath)
Get file lock for writing too file
TODO:this appears to have little effect on Windows Vista
|
int |
getFileReadBytes()
Returns the tag size as reported by the tag header
|
String |
getFirst(FieldKey genericKey)
Retrieve the first value that exists for this generic key
|
String |
getFirst(String identifier)
Retrieve the first value that exists for this identifier
If the value is a String it returns that, otherwise returns a summary of the fields information
|
Artwork |
getFirstArtwork() |
TagField |
getFirstField(FieldKey genericKey) |
AbstractID3v2Frame |
getFirstField(String identifier)
Retrieve the first tag field that exists for this identifier
|
Object |
getFrame(String identifier)
For single frames return the frame in this tag with given identifier if it exists, if multiple frames
exist with the same identifier it will return a list containing all the frames with this identifier
Warning the match is only done against the identifier so if a tag contains a frame with an unsupported body
but happens to have an identifier that is valid for another version of the tag it will be returned.
|
protected abstract org.jaudiotagger.tag.id3.AbstractID3v2Tag.FrameAndSubId |
getFrameAndSubIdFromGenericKey(FieldKey genericKey) |
Iterator |
getFrameOfType(String identifier)
Return all frames which start with the identifier, this
can be more than one which is useful if trying to retrieve
similar frames e.g TIT1,TIT2,TIT3 ...
|
protected abstract ID3Frames |
getID3Frames() |
int |
getInvalidFrames()
Return byte count of invalid frames
|
abstract Comparator |
getPreferredFrameOrderComparator() |
int |
getSize()
Return tag size based upon the sizes of the tags rather than the physical
no of bytes between start of ID3Tag and start of Audio Data.Should be extended
by subclasses to include header.
|
Long |
getStartLocationInFile() |
static long |
getV2TagSizeIfExists(File file)
Checks to see if the file contains an ID3tag and if so return its size as reported in
the tag header and return the size of the tag (including header), if no such tag exists return
zero.
|
String |
getValue(FieldKey genericKey,
int index)
Retrieve the value that exists for this generic key and this index
Have to do some special mapping for certain generic keys because they share frame
with another generic key.
|
boolean |
hasCommonFields()
|
boolean |
hasField(FieldKey key)
Does this tag contain a field with the specified key
|
boolean |
hasField(String id)
Does this tag contain a field with the specified id
|
boolean |
hasFrame(String identifier)
Return whether tag has frame with this identifier
Warning the match is only done against the identifier so if a tag contains a frame with an unsupported body
but happens to have an identifier that is valid for another version of the tag it will return true
|
boolean |
hasFrameAndBody(String identifier)
Return whether tag has frame with this identifier and a related body.
|
boolean |
hasFrameOfType(String identifier)
Return whether tag has frame starting with this identifier
Warning the match is only done against the identifier so if a tag contains a frame with an unsupported body
but happens to have an identifier that is valid for another version of the tag it will return true
|
boolean |
isEmpty()
Is this tag empty
|
static boolean |
isId3Tag(FileChannel fc)
Is ID3 tag
|
static boolean |
isId3Tag(RandomAccessFile raf)
Determines if file contain an id3 tag and if so positions the file pointer just after the end
of the tag.
|
Iterator |
iterator()
Return the frames in the order they were added
|
protected void |
loadFrameIntoMap(String frameId,
AbstractID3v2Frame next)
Add frame to the frame map
|
protected void |
loadFrameIntoSpecifiedMap(HashMap map,
String frameId,
AbstractID3v2Frame next)
Decides what to with the frame that has just been read from file.
|
void |
mergeDuplicateFrames(AbstractID3v2Frame newFrame,
List<AbstractID3v2Frame> frames)
Add frame taking into account existing frames of the same type
|
void |
mergeNumberTotalFrames(AbstractID3v2Frame newFrame,
AbstractID3v2Frame nextFrame)
All Number/Count frames are treated the same (TCK, TPOS, MVNM)
|
protected void |
processDuplicateFrame(AbstractID3v2Frame newFrame,
AbstractID3v2Frame existingFrame)
If frame already exists default behaviour is to just add another one, but can be overrridden if
special handling required
|
void |
removeFrame(String identifier)
Remove frame(s) with this identifier from tag
|
void |
removeFrameOfType(String identifier)
Remove any frames starting with this identifier from tag
|
void |
removeUnsupportedFrames()
Remove all frame(s) which have an unsupported body, in other words
remove all frames that are not part of the standard frameSet for
this tag
|
boolean |
seek(ByteBuffer byteBuffer)
Does a tag of the correct version exist in this file.
|
boolean |
setEncoding(Charset enc) |
void |
setEndLocationInFile(long endLocationInFile) |
void |
setField(Artwork artwork)
Create field and then set within tag itself
|
void |
setField(FieldKey genericKey,
String... values)
Create the field based on the generic key and set it in the tag
|
void |
setField(TagField field)
Set Field
|
void |
setFrame(AbstractID3v2Frame frame)
Add a frame to this tag
|
void |
setFrame(String identifier,
List<AbstractID3v2Frame> multiFrame)
Used for setting multiple frames for a single frame Identifier
Warning if frame(s) already exists for this identifier they are overwritten
TODO needs to ensure do not add an invalid frame for this tag
|
void |
setStartLocationInFile(long startLocationInFile) |
String |
toString() |
abstract long |
write(File file,
long audioStartByte)
Write tag to file.
|
void |
write(OutputStream outputStream)
Write tag to output stream
|
void |
write(OutputStream outputStream,
int currentTagSize)
Write tag to output stream
|
void |
write(RandomAccessFile file)
Write tag to file.
|
void |
write(WritableByteChannel channel,
int currentTagSize)
Write tag to channel.
|
protected void |
writeBufferToFile(File file,
ByteBuffer headerBuffer,
byte[] bodyByteBuffer,
int padding,
int sizeIncPadding,
long audioStartLocation)
Write the data from the buffer to the file
|
protected ByteArrayOutputStream |
writeFramesToBuffer()
Write all the frames to the byteArrayOutputStream
|
protected void |
writePadding(WritableByteChannel channel,
int padding)
Write paddings byte to the channel
|
getIdentifier, getLoggingFilename, getMajorVersion, getRelease, getRevision, setLoggingFilename
isSubsetOf, read
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
createField, deleteField, getArtworkList
protected static final String TYPE_HEADER
protected static final String TYPE_BODY
public static final byte[] TAG_ID
public static final String TAGID
public static final int TAG_HEADER_LENGTH
public static final int FIELD_TAGID_LENGTH
public static final int FIELD_TAG_MAJOR_VERSION_LENGTH
public static final int FIELD_TAG_MINOR_VERSION_LENGTH
public static final int FIELD_TAG_FLAG_LENGTH
public static final int FIELD_TAG_SIZE_LENGTH
protected static final int FIELD_TAGID_POS
public static final int FIELD_TAG_MAJOR_VERSION_POS
protected static final int FIELD_TAG_MINOR_VERSION_POS
protected static final int FIELD_TAG_FLAG_POS
protected static final int FIELD_TAG_SIZE_POS
protected static final int TAG_SIZE_INCREMENT
public HashMap<String,Object> encryptedFrameMap
protected static final String TYPE_DUPLICATEFRAMEID
protected String duplicateFrameId
protected static final String TYPE_DUPLICATEBYTES
protected int duplicateBytes
protected static final String TYPE_EMPTYFRAMEBYTES
protected int emptyFrameBytes
protected static final String TYPE_FILEREADSIZE
protected int fileReadSize
protected static final String TYPE_INVALIDFRAMES
protected int invalidFrames
public AbstractID3v2Tag()
protected AbstractID3v2Tag(AbstractID3v2Tag copyObject)
copyObject
- public static boolean isId3Tag(RandomAccessFile raf) throws IOException
raf
- IOException
public static boolean isId3Tag(FileChannel fc) throws IOException
fc
- IOException
protected void copyPrimitives(AbstractID3v2Tag copyObject)
copyObject
- protected void copyFrames(AbstractID3v2Tag copyObject)
copyObject
- protected abstract void addFrame(AbstractID3v2Frame frame)
frame
- protected abstract List<AbstractID3v2Frame> convertFrame(AbstractID3v2Frame frame) throws InvalidFrameException
frame
- InvalidFrameException
public int getDuplicateBytes()
public String getDuplicateFrameId()
public int getEmptyFrameBytes()
public int getInvalidFrames()
public int getFileReadBytes()
public boolean hasFrame(String identifier)
identifier
- frameId to lookuppublic boolean hasFrameAndBody(String identifier)
identifier
- frameId to lookuppublic boolean hasFrameOfType(String identifier)
identifier
- start of frameId to lookuppublic Object getFrame(String identifier)
identifier
- is an ID3Frame identifierpublic Object getEncryptedFrame(String identifier)
For single frames return the frame in this tag with given identifier if it exists, if multiple frames exist with the same identifier it will return a list containing all the frames with this identifier
identifier
- public String getFirst(String identifier)
public TagField getFirstField(FieldKey genericKey) throws KeyNotFoundException
getFirstField
in interface Tag
KeyNotFoundException
public AbstractID3v2Frame getFirstField(String identifier)
getFirstField
in interface Tag
identifier
- public void setFrame(AbstractID3v2Frame frame)
frame
- the frame to add
Warning if frame(s) already exists for this identifier that they are overwrittenprotected abstract ID3Frames getID3Frames()
public void setField(FieldKey genericKey, String... values) throws KeyNotFoundException, FieldDataInvalidException
Tag
setField
in interface Tag
KeyNotFoundException
FieldDataInvalidException
public void addField(FieldKey genericKey, String... value) throws KeyNotFoundException, FieldDataInvalidException
Tag
addField
in interface Tag
KeyNotFoundException
FieldDataInvalidException
public void mergeNumberTotalFrames(AbstractID3v2Frame newFrame, AbstractID3v2Frame nextFrame)
newFrame
- nextFrame
- public void mergeDuplicateFrames(AbstractID3v2Frame newFrame, List<AbstractID3v2Frame> frames)
newFrame
- frames
- public void setField(TagField field) throws FieldDataInvalidException
setField
in interface Tag
field
- FieldDataInvalidException
public void addField(TagField field) throws FieldDataInvalidException
addField
in interface Tag
field
- FieldDataInvalidException
public void setFrame(String identifier, List<AbstractID3v2Frame> multiFrame)
identifier
- multiFrame
- public Iterator getFrameOfType(String identifier)
identifier
- public void delete(RandomAccessFile file) throws IOException
delete
in class AbstractTag
file
- to delete the tag fromIOException
- if problem accessing the filepublic boolean equals(Object obj)
equals
in class AbstractTag
obj
- to test for equivalencepublic Iterator iterator()
iterator
in class AbstractTag
public void removeFrame(String identifier)
identifier
- frameId to look forpublic void removeUnsupportedFrames()
public void removeFrameOfType(String identifier)
identifier
- start of frameId to look forpublic abstract long write(File file, long audioStartByte) throws IOException
file
- audioStartByte
- IOException
protected FileLock getFileLockForWriting(FileChannel fileChannel, String filePath) throws IOException
fileChannel
- filePath
- IOException
- if unable to get lock because already locked by another programOverlappingFileLockException
- if already locked by another thread in the same VM, we dont catch this
because indicates a programming errorpublic void write(RandomAccessFile file) throws IOException
write
in class AbstractTag
file
- IOException
- TODO should be abstractpublic void write(WritableByteChannel channel, int currentTagSize) throws IOException
channel
- IOException
- TODO should be abstractpublic void write(OutputStream outputStream) throws IOException
outputStream
- IOException
public void write(OutputStream outputStream, int currentTagSize) throws IOException
outputStream
- IOException
protected void writePadding(WritableByteChannel channel, int padding) throws IOException
channel
- padding
- IOException
public static long getV2TagSizeIfExists(File file) throws IOException
file
- IOException
public boolean seek(ByteBuffer byteBuffer)
seek
in class AbstractTag
byteBuffer
- to search throughprotected int calculateTagSize(int tagSize, int preferredSize)
tagSize
- preferredSize
- protected void writeBufferToFile(File file, ByteBuffer headerBuffer, byte[] bodyByteBuffer, int padding, int sizeIncPadding, long audioStartLocation) throws IOException
file
- headerBuffer
- bodyByteBuffer
- padding
- sizeIncPadding
- audioStartLocation
- IOException
protected void processDuplicateFrame(AbstractID3v2Frame newFrame, AbstractID3v2Frame existingFrame)
newFrame
- existingFrame
- protected final void copyFrameIntoMap(String id, AbstractID3v2Frame newFrame)
id
- newFrame
- protected void loadFrameIntoMap(String frameId, AbstractID3v2Frame next)
frameId
- next
- protected void loadFrameIntoSpecifiedMap(HashMap map, String frameId, AbstractID3v2Frame next)
frameId
- next
- public int getSize()
getSize
in class AbstractTagItem
protected ByteArrayOutputStream writeFramesToBuffer() throws IOException
Currently Write all frames, defaults to the order in which they were loaded, newly created frames will be at end of tag.
IOException
public abstract Comparator getPreferredFrameOrderComparator()
public void createStructure()
public void createStructureHeader()
public void createStructureBody()
public List<String> getAll(FieldKey genericKey) throws KeyNotFoundException
getAll
in interface Tag
genericKey
- KeyNotFoundException
public List<TagField> getFields(String id) throws KeyNotFoundException
getFields
in interface Tag
id
- The field id.TagField
objects with the given "id".KeyNotFoundException
public abstract AbstractID3v2Frame createFrame(String id)
id
- public boolean hasCommonFields()
Tag
hasCommonFields
in interface Tag
true
if a common
field is present.public boolean hasField(FieldKey key)
public boolean hasField(String id)
hasField
in interface Tag
id
- The field id to look for.true
if tag contains a TagField
with the
given id.Tag.hasField(java.lang.String)
public boolean isEmpty()
isEmpty
in interface Tag
true
if tag contains no field.Tag.isEmpty()
public Iterator<TagField> getFields()
Tag
public int getFieldCount()
getFieldCount
in interface Tag
public int getFieldCountIncludingSubValues()
getFieldCountIncludingSubValues
in interface Tag
public boolean setEncoding(Charset enc) throws FieldDataInvalidException
setEncoding
in interface Tag
FieldDataInvalidException
public String getFirst(FieldKey genericKey) throws KeyNotFoundException
getFirst
in interface Tag
genericKey
- KeyNotFoundException
public String getValue(FieldKey genericKey, int index) throws KeyNotFoundException
getValue
in interface Tag
genericKey
- KeyNotFoundException
public TagField createField(FieldKey genericKey, String... values) throws KeyNotFoundException, FieldDataInvalidException
createField
in interface Tag
genericKey
- is the generic keyvalues
- KeyNotFoundException
FieldDataInvalidException
protected TagField doCreateTagField(org.jaudiotagger.tag.id3.AbstractID3v2Tag.FrameAndSubId formatKey, String... values) throws KeyNotFoundException, FieldDataInvalidException
formatKey
- values
- KeyNotFoundException
FieldDataInvalidException
protected List<String> doGetValues(org.jaudiotagger.tag.id3.AbstractID3v2Tag.FrameAndSubId formatKey) throws KeyNotFoundException
formatKey
- KeyNotFoundException
protected String doGetValueAtIndex(org.jaudiotagger.tag.id3.AbstractID3v2Tag.FrameAndSubId formatKey, int index) throws KeyNotFoundException
formatKey
- index
- the index specified by the userKeyNotFoundException
public TagField createLinkedArtworkField(String url)
url
- specifies the link, it could be a local file or could be a full urlpublic void deleteField(FieldKey fieldKey) throws KeyNotFoundException
deleteField
in interface Tag
fieldKey
- KeyNotFoundException
protected void doDeleteTagField(org.jaudiotagger.tag.id3.AbstractID3v2Tag.FrameAndSubId formatKey) throws KeyNotFoundException
formatKey
- KeyNotFoundException
protected abstract org.jaudiotagger.tag.id3.AbstractID3v2Tag.FrameAndSubId getFrameAndSubIdFromGenericKey(FieldKey genericKey)
public List<TagField> getFields(FieldKey genericKey) throws KeyNotFoundException
getFields
in interface Tag
genericKey
- KeyNotFoundException
public Artwork getFirstArtwork()
getFirstArtwork
in interface Tag
public void setField(Artwork artwork) throws FieldDataInvalidException
setField
in interface Tag
artwork
- FieldDataInvalidException
public void addField(Artwork artwork) throws FieldDataInvalidException
addField
in interface Tag
artwork
- FieldDataInvalidException
public void deleteArtworkField() throws KeyNotFoundException
deleteArtworkField
in interface Tag
KeyNotFoundException
public String toString()
public TagField createCompilationField(boolean value) throws KeyNotFoundException, FieldDataInvalidException
Tag
createCompilationField
in interface Tag
KeyNotFoundException
FieldDataInvalidException
public Long getStartLocationInFile()
public void setStartLocationInFile(long startLocationInFile)
public Long getEndLocationInFile()
public void setEndLocationInFile(long endLocationInFile)
Copyright © 2005–2020 jthink.net. All rights reserved.