public abstract class AbstractTag extends Object implements Tag
Tag
and introduces some more useful
functionality to be implemented.Modifier and Type | Field and Description |
---|---|
protected int |
commonNumber
|
protected Map<String,List<TagField>> |
fields
|
Constructor and Description |
---|
AbstractTag() |
Modifier and Type | Method and Description |
---|---|
void |
addField(Artwork artwork)
Create field and then add within tag itself
|
void |
addField(FieldKey genericKey,
String... value)
Create new field and add it to the tag
|
void |
addField(TagField field)
Add field
|
abstract TagField |
createField(FieldKey genericKey,
String... value)
Create a new field based on generic key, used internally by the library
|
void |
deleteArtworkField()
Delete all instance of artwork Field
|
abstract void |
deleteField(FieldKey fieldKey)
Delete any fields with this key
|
void |
deleteField(String key)
Delete all occurrences of field with this id.
|
List<TagField> |
getAll() |
List<String> |
getAll(String id) |
int |
getFieldCount()
Return field count
TODO:There must be a more efficient way to do this.
|
int |
getFieldCountIncludingSubValues()
Return the number of fields taking multiple value fields into consideration
Fields that actually contain multiple values are counted seperately
i.e.
|
Iterator<TagField> |
getFields()
Iterator over all the fields within the tag, handle multiple fields with the same id
|
List<TagField> |
getFields(String id)
Get list of fields within this tag with the specified id
|
String |
getFirst(FieldKey genericKey)
Retrieve the first value that exists for this generic key
|
String |
getFirst(String id)
Retrieve String value of the first value that exists for this format specific key
|
Artwork |
getFirstArtwork() |
abstract TagField |
getFirstField(FieldKey genericKey) |
TagField |
getFirstField(String id)
Retrieve the first field that exists for this format specific key
|
String |
getItem(String id,
int index) |
boolean |
hasCommonFields()
Does this tag contain any comon fields
|
boolean |
hasField(FieldKey fieldKey)
Determines whether the tag has at least one field with the specified field key.
|
boolean |
hasField(String id)
Does this tag contain a field with the specified id
|
protected abstract boolean |
isAllowedEncoding(Charset enc)
Determines whether the given charset encoding may be used for the
represented tagging system.
|
boolean |
isEmpty()
Is this tag empty
|
boolean |
setEncoding(Charset enc)
Set or add encoding
|
void |
setField(Artwork artwork)
Create field and then set within tag itself
|
void |
setField(FieldKey genericKey,
String... value)
Create new field and set it in the tag
|
void |
setField(TagField field)
Set field
Changed:Just because field is empty it doesn't mean it should be deleted.
|
String |
toString()
(overridden)
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
createCompilationField, createField, getAll, getArtworkList, getFields, getValue
protected int commonNumber
protected Map<String,List<TagField>> fields
public void addField(TagField field)
addField
in interface Tag
field
- The field to add.Changed so add empty fields
public List<TagField> getFields(String id)
getFields
in interface Tag
id
- The field id.TagField
objects with the given "id".Tag.getFields(java.lang.String)
public List<String> getAll(String id) throws KeyNotFoundException
KeyNotFoundException
public String getFirst(FieldKey genericKey) throws KeyNotFoundException
getFirst
in interface Tag
genericKey
- KeyNotFoundException
public String getFirst(String id)
Tag
Can be used to retrieve fields with any identifier, useful if the identifier is not within FieldKey
public TagField getFirstField(String id)
Tag
Can be used to retrieve fields with any identifier, useful if the identifier is not within FieldKey
getFirstField
in interface Tag
id
- audio specific keypublic Iterator<TagField> getFields()
Tag
public int getFieldCount()
getFieldCount
in interface Tag
public int getFieldCountIncludingSubValues()
Tag
getFieldCountIncludingSubValues
in interface Tag
public boolean hasCommonFields()
hasCommonFields
in interface Tag
true
if a common
field is present.Tag.hasCommonFields()
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 hasField(FieldKey fieldKey)
Tag
protected abstract boolean isAllowedEncoding(Charset enc)
enc
- charset encoding.true
if the given encoding can be used.public boolean isEmpty()
isEmpty
in interface Tag
true
if tag contains no field.Tag.isEmpty()
public void setField(FieldKey genericKey, String... value) throws KeyNotFoundException, FieldDataInvalidException
setField
in interface Tag
genericKey
- value
- KeyNotFoundException
FieldDataInvalidException
public void addField(FieldKey genericKey, String... value) throws KeyNotFoundException, FieldDataInvalidException
addField
in interface Tag
genericKey
- value
- KeyNotFoundException
FieldDataInvalidException
public void setField(TagField field)
setField
in interface Tag
field
- The field to add.Tag.setField(org.jaudiotagger.tag.TagField)
public boolean setEncoding(Charset enc)
setEncoding
in interface Tag
org.jaudiotagger.tag.Tag#setEncoding(java.lang.String)
public String toString()
toString
in interface Tag
toString
in class Object
Object.toString()
public abstract TagField createField(FieldKey genericKey, String... value) throws KeyNotFoundException, FieldDataInvalidException
Tag
Only textual data supported at the moment. The genericKey will be mapped to the correct implementation key and return a TagField. Usually the value field should only be one value, but certain fields may require more than one value currently the only field to require this is the MUSICIAN field, it should contain instrument and then performer name
createField
in interface Tag
genericKey
- value
- KeyNotFoundException
FieldDataInvalidException
public abstract TagField getFirstField(FieldKey genericKey) throws KeyNotFoundException
getFirstField
in interface Tag
genericKey
- KeyNotFoundException
public abstract void deleteField(FieldKey fieldKey) throws KeyNotFoundException
Tag
deleteField
in interface Tag
fieldKey
- KeyNotFoundException
public void deleteField(String key)
deleteField
in interface Tag
key
- 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
Copyright © 2005–2020 jthink.net. All rights reserved.