Methods Summary |
---|
public void | addField(TagField field)Add field
if (field == null)
{
return;
}
List<TagField> list = fields.get(field.getId());
// There was no previous item
if (list == null)
{
list = new ArrayList<TagField>();
list.add(field);
fields.put(field.getId(), list);
if (field.isCommon())
{
commonNumber++;
}
}
else
{
// We append to existing list
list.add(field);
}
|
public void | addField(FieldKey genericKey, java.lang.String value)Create new field and add it to the tag
TagField tagfield = createField(genericKey,value);
addField(tagfield);
|
public void | addField(org.jaudiotagger.tag.images.Artwork artwork)Create field and then add within tag itself
this.addField(createField(artwork));
|
public abstract TagField | createField(FieldKey genericKey, java.lang.String value)
|
public void | deleteArtworkField()Delete all instance of artwork Field
this.deleteField(FieldKey.COVER_ART);
|
public abstract void | deleteField(FieldKey fieldKey)
|
public void | deleteField(java.lang.String key)Delete all occurrences of field with this id.
fields.remove(key);
|
public int | getFieldCount()Return field count
TODO:There must be a more efficient way to do this.
Iterator it = getFields();
int count = 0;
while (it.hasNext())
{
count++;
it.next();
}
return count;
|
public int | getFieldCountIncludingSubValues()
return getFieldCount();
|
public java.util.List | getFields(java.lang.String id)Get list of fields within this tag with the specified id
List<TagField> list = fields.get(id);
if (list == null)
{
return new ArrayList<TagField>();
}
return list;
|
public java.util.List | getFields(FieldKey id)
List<TagField> list = fields.get(id.name());
if (list == null)
{
return new ArrayList<TagField>();
}
return list;
|
public java.util.Iterator | getFields()
final Iterator<Map.Entry<String, List<TagField>>> it = this.fields.entrySet().iterator();
return new Iterator<TagField>()
{
private Iterator<TagField> fieldsIt;
private void changeIt()
{
if (!it.hasNext())
{
return;
}
Map.Entry<String, List<TagField>> e = it.next();
List<TagField> l = e.getValue();
fieldsIt = l.iterator();
}
public boolean hasNext()
{
if (fieldsIt == null)
{
changeIt();
}
return it.hasNext() || (fieldsIt != null && fieldsIt.hasNext());
}
public TagField next()
{
if (!fieldsIt.hasNext())
{
changeIt();
}
return fieldsIt.next();
}
public void remove()
{
fieldsIt.remove();
}
};
|
public java.lang.String | getFirst(FieldKey genericKey)Retrieve the first value that exists for this generic key
return getValue(genericKey,0);
|
public java.lang.String | getFirst(java.lang.String id)
List<TagField> l = getFields(id);
return (l.size() != 0) ? l.get(0).toString() : "";
|
public org.jaudiotagger.tag.images.Artwork | getFirstArtwork()
List<Artwork> artwork = getArtworkList();
if(artwork.size()>0)
{
return artwork.get(0);
}
return null;
|
public abstract TagField | getFirstField(FieldKey genericKey)
|
public TagField | getFirstField(java.lang.String id)
List<TagField> l = getFields(id);
return (l.size() != 0) ? l.get(0) : null;
|
public java.lang.String | getItem(java.lang.String id, int index)
List<TagField> l = getFields(id);
return (l.size()>index) ? l.get(index).toString() : "";
|
public java.lang.String | getSubValue(FieldKey id, int n, int m)The m parameter is effectively ignored
return getValue(id,n);
|
public boolean | hasCommonFields()Does this tag contain any comon fields
return commonNumber != 0;
|
public boolean | hasField(java.lang.String id)Does this tag contain a field with the specified id
return getFields(id).size() != 0;
|
public boolean | hasField(FieldKey fieldKey)
return hasField(fieldKey.name());
|
protected abstract boolean | isAllowedEncoding(java.lang.String enc)Determines whether the given charset encoding may be used for the
represented tagging system.
|
public boolean | isEmpty()Is this tag empty
return fields.size() == 0;
|
public boolean | setEncoding(java.lang.String enc)Set or add encoding
if (!isAllowedEncoding(enc))
{
return false;
}
Iterator it = getFields();
while (it.hasNext())
{
TagField field = (TagField) it.next();
if (field instanceof TagTextField)
{
((TagTextField) field).setEncoding(enc);
}
}
return true;
|
public void | setField(FieldKey genericKey, java.lang.String value)Create new field and set it in the tag
TagField tagfield = createField(genericKey,value);
setField(tagfield);
|
public void | setField(TagField field)Set field
Changed:Just because field is empty it doesn't mean it should be deleted. That should be the choice
of the developer. (Or does this break things)
if (field == null)
{
return;
}
// If there is already an existing field with same id
// and both are TextFields, we replace the first element
List<TagField> list = fields.get(field.getId());
if (list != null)
{
list.set(0, field);
return;
}
// Else we put the new field in the fields.
list = new ArrayList<TagField>();
list.add(field);
fields.put(field.getId(), list);
if (field.isCommon())
{
commonNumber++;
}
|
public void | setField(org.jaudiotagger.tag.images.Artwork artwork)Create field and then set within tag itself
this.setField(createField(artwork));
|
public java.lang.String | toString()(overridden)
StringBuffer out = new StringBuffer();
out.append("Tag content:\n");
Iterator it = getFields();
while (it.hasNext())
{
TagField field = (TagField) it.next();
out.append("\t");
out.append(field.getId());
out.append(":");
out.append(field.toString());
out.append("\n");
}
return out.toString().substring(0, out.length() - 1);
|