entagged.audioformats.generic
Class OldTag

java.lang.Object
  extended by entagged.audioformats.generic.OldTag

public class OldTag
extends Object

This class stores all the meta-data (artist, album, ..) contained in an AudioFile.

All the set operation are not "real-time", they only apply to this object. To commit the modification, either the AudioFile's commit() or the AudioFileIO.write(AudioFile) have to be called

There are two types of fields contained in a Tag. The most commonly used (the common fields) are accessible through get/set methods, like the artist, tha album, the track number, etc.

Each tag format has then specific fields (eg. graphics, urls, etc) that do not exist in the other formats, or that cannot be mapped to common fields

To retreive the content of these specific fields, the getSpecificields() can be called giving the names of the specific fields stored in this tag

This ensures that all the old meta-data contained in a tag read from AudioFileIO is kept and rewritten when the tag is updated

Since:
v0.01
Version:
$Id: OldTag.java 287 2009-04-26 23:28:35Z shred $
See Also:
AudioFile

Field Summary
static String[] DEFAULT_GENRES
          This final field contains all the tags that id3v1 supports.
protected  Hashtable fields
           
 
Constructor Summary
OldTag()
          Creates a new empty tag, all the common fields are initialized to the empty string, and no specific fields exists.
 
Method Summary
 String getAlbum()
          Returns the album of this song, eg: "Led Zeppelin IV".
 String getArtist()
          Returns the artist of this song, eg: "Led Zeppelin".
 String getComment()
          Returns the comment associated with this song, eg: "Recorded live at the Royal Albert Hall".
 String getGenre()
          Returns the genre of this song, eg: "Classic Rock".
 String getSpecificField(String s)
          Returns the specific field's content.
 Iterator getSpecificFields()
          This creates an iterator over the specific fields for this tag.
 String getTitle()
          Returns the title of this song, eg: "Stairway to Heaven".
 String getTrack()
          Returns the track number of this song.
 String getYear()
          Returns the date of this song.
 boolean isEmpty()
          Checks wether all the common fields (artist, genre, ..) are empty, that is: contains the empty string or only spaces.
 boolean isSpecificEmpty()
          Checks wether all the specific fields (other than artist, genre, ..) are empty, that is: contains the empty string or only spaces.
 void setAlbum(String s)
          Sets the new album for this song, replacing the previous one.
 void setArtist(String s)
          Sets the new artist for this song, replacing the previous one.
 void setComment(String s)
          Sets the new comment of this song, replacing the previous one.
 void setGenre(String s)
          Sets the new genre for this song, replacing the previous one.
 void setTitle(String s)
          Sets the title for this song, replacing the previous one.
 void setTrack(String s)
          Sets the new track number for this song, replacing the previous one.
 void setYear(String s)
          Sets the new date for this song, replacing the previous one.
 String toString()
          Returns a multi-line string showing all the meta-data of this tag (the common fields, and any specific field).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_GENRES

public static final String[] DEFAULT_GENRES
This final field contains all the tags that id3v1 supports. The list has the same order as the id3v1 genres. To be perfectly compatible (with id3v1) the genre field should match one of these genre (case ignored). You can also use this list to present a list of basic (modifiable) possible choices for the genre field.


fields

protected Hashtable fields
Constructor Detail

OldTag

public OldTag()

Creates a new empty tag, all the common fields are initialized to the empty string, and no specific fields exists.

Method Detail

getTitle

public String getTitle()

Returns the title of this song, eg: "Stairway to Heaven".

If there wasn't such a field in the AudioFile, an empty String is returned

Returns:
Returns the title of this song

getAlbum

public String getAlbum()

Returns the album of this song, eg: "Led Zeppelin IV".

If there wasn't such a field in the AudioFile, an empty String is returned

Returns:
Returns the album of this song

getArtist

public String getArtist()

Returns the artist of this song, eg: "Led Zeppelin".

If there wasn't such a field in the AudioFile, an empty String is returned

Returns:
Returns the artist of this song

getGenre

public String getGenre()

Returns the genre of this song, eg: "Classic Rock".

If there wasn't such a field in the AudioFile, an empty String is returned

Returns:
Returns the genre of this song

getTrack

public String getTrack()

Returns the track number of this song.

The String can be anything, so don't expect a simple number, it could be "10" but also "10 / 15"

If there wasn't such a field in the AudioFile, an empty String is returned

Returns:
Returns the track number of this song

getYear

public String getYear()

Returns the date of this song.

Most of the time the year of release of the album eg: "1970", but this can also be an arbitrary string like "19 december 1934"

If there wasn't such a field in the AudioFile, an empty String is returned

Returns:
Returns the date of this song

getComment

public String getComment()

Returns the comment associated with this song, eg: "Recorded live at the Royal Albert Hall".

Some tag format allow multi-line comments, line are separated with "\n" strings ("\\n" in java not "\n"). That means the String returned may have to be parsed to transform those strings in newline characters ("\n" in java)

If there wasn't such a field in the AudioFile, an empty String is returned

Returns:
Returns the comment associated with this song

setTitle

public void setTitle(String s)

Sets the title for this song, replacing the previous one.

s can be an arbitrary string, but keep in mind that some tag formats have limited space to store informations, if s is too long, it will be cut at the maximum length allowed by the tag format

If a null string is passed, it is converted to an empty String

Parameters:
s - the new title of this song

setAlbum

public void setAlbum(String s)

Sets the new album for this song, replacing the previous one.

s can be an arbitrary string, but keep in mind that some tag formats have limited space to store informations, if s is too long, it will be cut at the maximum length allowed by the tag format

If a null string is passed, it is converted to an empty String

Parameters:
s - the new album for this song

setArtist

public void setArtist(String s)

Sets the new artist for this song, replacing the previous one.

s can be an arbitrary string, but keep in mind that some tag formats have limited space to store informations, if s is too long, it will be cut at the maximum length allowed by the tag format

If a null string is passed, it is converted to an empty String

Parameters:
s - the new artist for this song

setGenre

public void setGenre(String s)

Sets the new genre for this song, replacing the previous one.

Some formats does not support an arbitrary string as genre and use a predefined list of genres, with an index. If this is the case, the given genre will be matched against a predefined list, if a correspondance is found, that index is used, if not, a "no genre" or equivalent will be used instead

s can be an arbitrary string, but keep in mind that some tag formats have limited space to store informations, if s is too long, it will be cut at the maximum length allowed by the tag format

If a null string is passed, it is converted to an empty String

Parameters:
s - the new genre for this song

setTrack

public void setTrack(String s)

Sets the new track number for this song, replacing the previous one.

Some formats use a single byte track encoding, allowing tracks to be only a number from 0 to 255. If this is the case, and the track number is not a simple number (like "19/30"), the track number is set to 0

s can be an arbitrary string, but keep in mind that some tag formats have limited space to store informations, if s is too long, it will be cut at the maximum length allowed by the tag format

If a null string is passed, it is converted to an empty String

Parameters:
s - the new track number for this song

setYear

public void setYear(String s)

Sets the new date for this song, replacing the previous one.

s can be an arbitrary string, but keep in mind that some tag formats have limited space to store informations, if s is too long, it will be cut at the maximum length allowed by the tag format

If a null string is passed, it is converted to an empty String

Parameters:
s - the new date for this song

setComment

public void setComment(String s)

Sets the new comment of this song, replacing the previous one.

Some tag allow multi-line formats, using the "\n" string ("\\n" in java) but not the newline character ("\n" in java)

s can be an arbitrary string, but keep in mind that some tag formats have limited space to store informations, if s is too long, it will be cut at the maximum length allowed by the tag format

If a null string is passed, it is converted to an empty String

Parameters:
s - the new comment for this song

getSpecificFields

public Iterator getSpecificFields()

This creates an iterator over the specific fields for this tag. Specific fields are tag-format specific fields (other than artist, album, etc).

If this tag was created by new Tag(), the iterator will be empty

To retreive the value associated to a specific field use the getSpecificField(String) method in this class

Example: an ogg file can contain an arbitrary number of arbitrary fields, so a field like MYCUSTOMFIELD cannot be mapped to artist, album, or other common field, it is instead stored as a specific field that can be retreived using this iterator

Returns:
an iterator over the specific fields of this tag

getSpecificField

public String getSpecificField(String s)

Returns the specific field's content.

if s is not a valid specific field, the empty string is returned

Valid specific fields are returned by the iterator created by getSpecificFields() method

Note that some specific fields can have binary value (not a human readable string), the binary data can be obtained back using the getBytes() method on the String

Parameters:
s - the specific field to retreive
Returns:
the value associated to this specific field, or the empty string if the field wasn't valid

isEmpty

public boolean isEmpty()

Checks wether all the common fields (artist, genre, ..) are empty, that is: contains the empty string or only spaces.

Specific fields can exist even if this returns true, use the isSpecificEmpty() to check if the specific fields are also empty

Returns:
a boolean indicating if the common fields of this tag are empty or not

isSpecificEmpty

public boolean isSpecificEmpty()

Checks wether all the specific fields (other than artist, genre, ..) are empty, that is: contains the empty string or only spaces.

Common fields can exist even if this returns true, use the isEmpty() to check if the common fields are also empty

Returns:
a boolean indicating if the specific fields of this tag are empty or not

toString

public String toString()

Returns a multi-line string showing all the meta-data of this tag (the common fields, and any specific field).

Specific fields are denoted with a "-" appended to the field name

Overrides:
toString in class Object
Returns:
the contents of this tag


Copyright © 2007-2011 shredzone.org. All Rights Reserved.