FileDocCategorySizeDatePackage
ContentType.javaAPI Docjid3 0.4626246Sun Feb 06 18:11:17 GMT 2005org.blinkenlights.jid3.v2

ContentType

public class ContentType extends Object
author
paul Represents the content type of the track (ie. its genre details).

Fields Summary
private Set
m_oGenreSet
private String
m_sRefinement
private boolean
m_bIsRemix
private boolean
m_bIsCover
Constructors Summary
public ContentType()
Creates a new instance of ContentType

    
           
     
    
        m_oGenreSet = new TreeSet();
        m_bIsRemix = false;
        m_bIsCover = false;
    
Methods Summary
public booleanequals(java.lang.Object oOther)
Compare ContentTypes for equality by genre and refinement values.

param
oOther object to check against
return
true if equal, false otherwise

        if ((oOther == null) || (!(oOther instanceof ContentType)))
        {
            return false;
        }
        
        ContentType oOtherContentType = (ContentType)oOther;
        
        if (!m_oGenreSet.equals(oOtherContentType.m_oGenreSet))
        {
            return false;
        }
        if ( ((m_sRefinement == null) && (oOtherContentType.m_sRefinement != null)) ||
             ((m_sRefinement != null) && (oOtherContentType.m_sRefinement == null)) ||
             (!m_sRefinement.equals(oOtherContentType.m_sRefinement)) )
        {
            return false;
        }
        if (m_bIsRemix != oOtherContentType.m_bIsRemix)
        {
            return false;
        }
        if (m_bIsCover != oOtherContentType.m_bIsCover)
        {
            return false;
        }
        
        return true;
    
public org.blinkenlights.jid3.v2.ContentType$Genre[]getGenres()
Get all of the set genres in this content type.

return
an array of all of the set genres

        return (Genre[])m_oGenreSet.toArray(new Genre[0]);
    
public java.lang.StringgetRefinement()
Get the current refinement, if set, for this content type.

return
the refinement currently specified, or null if no refinement has been set

        return m_sRefinement;
    
public booleanisCover()
Check whether or not this content type describes a recording which is a cover.

return
true if the recording is a cover, false otherwise

        return m_bIsCover;
    
public booleanisRemix()
Check whether or not this content type describes a recording which is a remix.

return
true if the recording is a remix, false otherwise

        return m_bIsRemix;
    
public booleanisSet(org.blinkenlights.jid3.v2.ContentType$Genre oGenre)
Check whether a given genre is set.

param
oGenre the genre to check
return
true if the genre is set, false otherwise

        return m_oGenreSet.contains(oGenre);
    
public booleansetGenre(org.blinkenlights.jid3.v2.ContentType$Genre oGenre)
Set a given genre for this recording. More than one genre can be set independently.

param
oGenre the genre to be set
return
true if this genre was not already set, false otherwise

        return m_oGenreSet.add(oGenre);
    
public voidsetIsCover(boolean bIsCover)
Toggle whether or not the recording described by this content type is a cover.

param
bIsCover whether this is a cover or not

        m_bIsCover = bIsCover;
    
public voidsetIsRemix(boolean bIsRemix)
Toggle whether or not the recording described by this content type is a remix.

param
bIsRemix whether this is a remix or not

        m_bIsRemix = bIsRemix;
    
public voidsetRefinement(java.lang.String sRefinement)
Set a refinement for the genre of the recording repesented by this content type. Refinements are free-form text, and can be used where no existing genre accurately describes the content.

param
sRefinement a refinement description for this content type

        m_sRefinement = sRefinement;
    
public java.lang.StringtoString()
Get the string representation of this content type.

return
a string representing the content type, as it is stored in the frame

        // build text string
        StringBuffer sbContentType = new StringBuffer();
        // genre byte values in sequence, surrounded by brackets
        ContentType.Genre[] aoGenre = getGenres();
        for (int i=0; i < aoGenre.length; i++)
        {
            sbContentType.append("(" + aoGenre[i].getByteValue() + ")");
        }
        // cover code if specified
        if (isCover())
        {
            sbContentType.append("(CR)");
        }
        // remix code if specified
        if (isRemix())
        {
            sbContentType.append("(RX)");
        }
        // refinement comes last, if specified
        if (getRefinement() != null)
        {
            String sRefinement = getRefinement();
            // if refinement begins with opening bracket, we must double it as an escape sequence
            if (sRefinement.startsWith("("))
            {
                sbContentType.append("(");
            }
            sbContentType.append(sRefinement);
        }
        
        return sbContentType.toString();
    
public booleanunsetGenre(org.blinkenlights.jid3.v2.ContentType$Genre oGenre)
Unset a given genre for this recording.

param
oGenre the genre to be unset
return
true if this genre was previously set, false otherwise

        return m_oGenreSet.remove(oGenre);