com.tffenterprises.music.tag.id3v2.frame
Class YearFrame

java.lang.Object
  extended by com.tffenterprises.music.tag.id3v2.Frame
      extended by com.tffenterprises.music.tag.id3v2.frame.BaseFrame
          extended by com.tffenterprises.music.tag.id3v2.frame.TextBasedFrame
              extended by com.tffenterprises.music.tag.id3v2.frame.TextFrame
                  extended by com.tffenterprises.music.tag.id3v2.frame.YearFrame
All Implemented Interfaces:
DateFrame, java.io.Serializable, java.lang.Cloneable

public class YearFrame
extends TextFrame
implements DateFrame, java.io.Serializable, java.lang.Cloneable

This class is the ID3v2 TYER frame type, which holds a four-character numeric string representing a year.

Version:
1.0d1 $Date: 2002/10/12 19:59:22 $
Author:
Guillaume Lessard
See Also:
Serialized Form

Field Summary
static java.lang.String MY_ID
          The Frame ID for a YearFrame.
private  int year
          The year is the data.
 
Fields inherited from class com.tffenterprises.music.tag.id3v2.frame.TextBasedFrame
BOM_CHAR, BOM_CHAR_STRING, ENCODING_STRINGS, ISO_8859_1, NULL_BOM_STRING, NULL_CHAR, NULL_CHAR_STRING, UNICODE, UNICODE_BIG, UNICODE_LITTLE, UTF8
 
Constructor Summary
YearFrame()
          Constructs a new YearFrame with no data.
YearFrame(FrameHeader header)
          Constructs a new instance using the specified FrameHeader object.
 
Method Summary
 void addDate(java.util.Calendar c)
          Sets the year of the frame.
 void addDate(java.util.Date d)
          Sets the year of the frame.
 void addDateRange(java.util.Calendar begin, java.util.Calendar end)
          Sets the year of the frame.
 void clearDate()
          Clears the frame data.
 java.lang.Object clone()
          Returns a clone of this ID3v2 frame.
 boolean equals(java.lang.Object other)
          Compares this ID3v2 frame with another object.
 java.util.Calendar getDate()
          Get the first date for this frame.
 java.util.Enumeration getDates()
          Get all dates for this frame.
 java.lang.String getText()
          Returns the text contained in this frame.
 boolean isSet()
          Whether this frame's data has been set.
static int SanitizeYear(int year)
          Determine whether the supplied integer value is a decent value for the year of a recording date or the release date of a record, and return a decent value based on the input.
 void setDate(java.util.Calendar c)
          Sets the year of the frame.
 void setDate(java.util.Date d)
          Sets the year of the frame.
 void setDateRange(java.util.Calendar begin, java.util.Calendar end)
          Sets a date range for the frame.
 void setText(java.lang.String frameText)
          Sets the text contained in this frame.
 void setYear(int y)
          Sets the year of the frame.
 
Methods inherited from class com.tffenterprises.music.tag.id3v2.frame.TextFrame
getRawData, isOfRepeatableType, setRawData, toString
 
Methods inherited from class com.tffenterprises.music.tag.id3v2.frame.TextBasedFrame
getNullBytes, getTextEncoding, getTextEncoding, getTextEncoding, is8859String, read8859Characters, read8859String, readCharacters, readString, readUnicodeCharacters, readUnicodeString
 
Methods inherited from class com.tffenterprises.music.tag.id3v2.frame.BaseFrame
getBytes, getChecksum, getFormatFlags, getFrameID, getHeader, getStatusFlags, hashCode, isChanged, setChanged, setFormatFlags, setStatusFlags, toByteArray, updateChecksum, writeTo
 
Methods inherited from class com.tffenterprises.music.tag.id3v2.Frame
FromByteArray, FromByteArray, FromInputStream, GetFrameClassForID, getNewInstance, getNewInstance, getNewInstance, MinimumLength, RegisterFrameClass, UnregisterFrameClass
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MY_ID

public static final java.lang.String MY_ID
The Frame ID for a YearFrame.

See Also:
Constant Field Values

year

private int year
The year is the data.

Constructor Detail

YearFrame

YearFrame()
Constructs a new YearFrame with no data.


YearFrame

public YearFrame(FrameHeader header)
Constructs a new instance using the specified FrameHeader object.

Parameters:
header - The FrameHeader to be used for this frame.
Method Detail

SanitizeYear

public static int SanitizeYear(int year)
Determine whether the supplied integer value is a decent value for the year of a recording date or the release date of a record, and return a decent value based on the input.

Parameters:
year - the year during whith the track was recorded or released.
Returns:
the sanitized version of the same year.

clone

public java.lang.Object clone()
Returns a clone of this ID3v2 frame.

Overrides:
clone in class TextFrame
Returns:
a clone of this ID3v2 frame.

equals

public boolean equals(java.lang.Object other)
Compares this ID3v2 frame with another object.

Overrides:
equals in class TextFrame
Parameters:
other - The other object.
Returns:
true if the two objects are equivalent, false otherwise.

getText

public java.lang.String getText()
Returns the text contained in this frame.

Overrides:
getText in class TextFrame
Returns:
the text contained in this frame.

setText

public void setText(java.lang.String frameText)
Sets the text contained in this frame.

Overrides:
setText in class TextFrame
Parameters:
frameText - The text.
Throws:
java.lang.IllegalArgumentException - if the text is null or not parseable.

setYear

public void setYear(int y)
Sets the year of the frame.

Parameters:
y - the year to use for the frame.

clearDate

public void clearDate()
Clears the frame data.

Specified by:
clearDate in interface DateFrame

isSet

public boolean isSet()
Whether this frame's data has been set.

Specified by:
isSet in interface DateFrame
Returns:
true if this frame's data has been set.

setDate

public void setDate(java.util.Calendar c)
Sets the year of the frame.

Specified by:
setDate in interface DateFrame
Parameters:
c - the date to use for the frame's year.

setDate

public void setDate(java.util.Date d)
Sets the year of the frame.

Specified by:
setDate in interface DateFrame
Parameters:
d - the date to use for the frame's year.

setDateRange

public void setDateRange(java.util.Calendar begin,
                         java.util.Calendar end)
Sets a date range for the frame. This frame type doesn't use date ranges, so this simply sets the year using the beginning of the date range.

Specified by:
setDateRange in interface DateFrame
Parameters:
begin - the beginning date
end - the ending date.

addDate

public void addDate(java.util.Calendar c)
Sets the year of the frame. This frame doesn't use multiple dates, so this simply sets the date.

Specified by:
addDate in interface DateFrame
Parameters:
c - the date to use for the frame's year.

addDate

public void addDate(java.util.Date d)
Sets the year of the frame. This frame doesn't use multiple date, so this simply sets the date.

Specified by:
addDate in interface DateFrame
Parameters:
d - the date to use for the frame's year.

addDateRange

public void addDateRange(java.util.Calendar begin,
                         java.util.Calendar end)
Sets the year of the frame. This frame doesn't use ranges or multiple dates, so this method sets the year using the beginning of the range.

Specified by:
addDateRange in interface DateFrame
Parameters:
begin - the beginning date.
end - the ending date.

getDate

public java.util.Calendar getDate()
Get the first date for this frame. This returns a clone of the object held internally.

Specified by:
getDate in interface DateFrame
Returns:
the first date for this frame.

getDates

public java.util.Enumeration getDates()
Get all dates for this frame. The dates will be returned as Calendar objects If there is a range of dates in the list, it will be returned as a Vector (of length 2) of Calendar objects.

Specified by:
getDates in interface DateFrame
Returns:
an enumeration of all dates for this frame.