TV-Browser 3.3.3 API

tvdataservice
Class MutableProgram

java.lang.Object
  extended by tvdataservice.MutableProgram
All Implemented Interfaces:
Program
Direct Known Subclasses:
OnDemandProgram

public class MutableProgram
extends java.lang.Object
implements Program

One program. Consists of the Channel, the time, the title and some extra information.

Author:
Til Schneider, www.murfman.de

Field Summary
protected static Marker[] EMPTY_MARKER_ARR
          A plugin array that can be shared by all the programs that are not marked by any plugin.
static java.lang.String ID_DATE_FORMAT
          The date format, which is used in the unique ID
static int MAX_SHORT_INFO_LENGTH
          The maximum length of a short info.
protected  java.lang.String mTitle
          Contains the title
 
Fields inherited from interface devplugin.Program
DEFAULT_PROGRAM_IMPORTANCE, HIGHER_MEDIUM_MARK_PRIORITY, HIGHER_MEDIUM_PROGRAM_IMPORTANCE, INFO_AUDIO_DESCRIPTION, INFO_AUDIO_DOLBY_DIGITAL_5_1, INFO_AUDIO_DOLBY_SURROUND, INFO_AUDIO_MONO, INFO_AUDIO_STEREO, INFO_AUDIO_TWO_CHANNEL_TONE, INFO_CATEGORIE_ARTS, INFO_CATEGORIE_CHILDRENS, INFO_CATEGORIE_DOCUMENTARY, INFO_CATEGORIE_MAGAZINE_INFOTAINMENT, INFO_CATEGORIE_MOVIE, INFO_CATEGORIE_NEWS, INFO_CATEGORIE_OTHERS, INFO_CATEGORIE_SERIES, INFO_CATEGORIE_SHOW, INFO_CATEGORIE_SPORTS, INFO_LIVE, INFO_NEW, INFO_ORIGINAL_WITH_SUBTITLE, INFO_SIGN_LANGUAGE, INFO_SUBTITLE_FOR_AURALLY_HANDICAPPED, INFO_VISION_16_TO_9, INFO_VISION_4_TO_3, INFO_VISION_BLACK_AND_WHITE, INFO_VISION_HD, IS_VALID_STATE, LOWER_MEDIUM_MARK_PRIORITY, LOWER_MEDIUM_PROGRAM_IMPORTANCE, MARK_PRIORITY, MAX_MARK_PRIORITY, MAX_PROGRAM_IMPORTANCE, MEDIUM_MARK_PRIORITY, MEDIUM_PROGRAM_IMPORTANCE, MIN_MARK_PRIORITY, MIN_PROGRAM_IMPORTANCE, NO_MARK_PRIORITY, WAS_DELETED_STATE, WAS_UPDATED_STATE
 
Constructor Summary
MutableProgram(Channel channel, Date localDate, boolean isLoading)
          Creates a new instance of MutableProgram.
MutableProgram(Channel channel, Date localDate, int localHours, int localMinutes, boolean isLoading)
          Creates a new instance of MutableProgram.
 
Method Summary
 void addChangeListener(javax.swing.event.ChangeListener listener)
          Adds a ChangeListener to the program.
 boolean equals(java.lang.Object o)
           
 boolean equalsAllFields(MutableProgram program)
          check if two programs are identical by their field contents
protected  void fireStateChanged()
          Send a ChangeEvent, whose source is this program, to each listener.
static java.lang.String generateShortInfoFromDescription(java.lang.String shortInfo)
          Trim text for shortinfo-field
 byte[] getBinaryField(ProgramFieldType type)
          Gets the value of a binary field from the program.
 Channel getChannel()
          Returns the channel object of this program.
 Date getDate()
          Returns the date of this program.
 java.lang.String getDateString()
          get the date of this program as nicely formatted string
 java.lang.String getDescription()
          Returns a description about the program.
 java.lang.String getEndTimeString()
          get the end time of this program as nicely formatted string
 int getFieldCount()
          Gets the number of fields this program has.
 java.util.Iterator<ProgramFieldType> getFieldIterator()
          Gets an iterator over the types of all fields this program has.
 int getHours()
          Gets the hour-component of the start time of the program.
 java.lang.String getID()
          Gets the ID of this program.
 int getInfo()
          Returns additional information of the program (or zero).
 int getIntField(ProgramFieldType type)
          Gets the value of a int field from the program.
 java.lang.String getIntFieldAsString(ProgramFieldType type)
          Gets the value of a int field as String.
 int getLength()
          Gets the length of this program in minutes.
 Date getLocalDate()
           
 int getLocalStartTime()
           
 Marker[] getMarkerArr()
          Gets all Markers that have marked this program.
 int getMarkPriority()
          Gets the priority of the marking of this program.
 int getMinutes()
          Gets the minute-component of the start time of the program.
protected  java.lang.Object getObjectValueField(ProgramFieldType type)
          access method to object field values. this allows ondemand programs to reimplement the access
 int getProgramState()
          Returns the state of this program.
 java.lang.String getShortInfo()
          Returns a short information about the program (about three lines).
 int getStartTime()
          Gets the the start time of the program in minutes after midnight.
 java.lang.String getTextField(ProgramFieldType type)
          Gets the value of a text field from the program.
 int getTimeField(ProgramFieldType type)
          Gets the value of a time field from the program.
 java.lang.String getTimeFieldAsString(ProgramFieldType type)
          Gets the value of a time field as String of the pattern "h:mm".
 java.lang.String getTimeString()
          get the start time of this program as nicely formatted string
 java.lang.String getTitle()
          Returns the title of this program.
 java.lang.String getUniqueID()
          Gets the unique ID of this program.
 boolean hasFieldValue(ProgramFieldType type)
          checks if the given field has a non-null value. use this method if you don't need the value of the field, but only the knowledge about existence
 int hashCode()
           
 boolean isExpired()
          Gets whether this program is expired.
 boolean isOnAir()
          Gets whether this program is marked as "on air".
 void mark(Marker marker)
          Marks the program for a plugin.
 void mark(Plugin javaPlugin)
          Marks the program for a Java plugin.
 void removeChangeListener(javax.swing.event.ChangeListener listener)
          Removes a ChangeListener from the program.
 void setBinaryField(ProgramFieldType type, byte[] value)
          Set a binary field.
 void setDescription(java.lang.String description)
          Sets a description about the program.
 void setInfo(int info)
          Sets additional information of the program (or zero).
 void setIntField(ProgramFieldType type, int value)
          Set an int field.
 void setLength(int length)
          Sets the length of this program in minutes.
protected  void setMarkerArr(Marker[] marker)
          Sets the marker array of this program.
protected  void setMarkPriority(int markPriority)
          Sets the mark priority for this program
protected  void setObjectValueField(ProgramFieldType type, java.lang.Object value)
           
 void setProgramLoadingIsComplete()
          Sets the loading state to false.
protected  void setProgramState(int state)
          Sets the state of this program to a program state.
 void setShortInfo(java.lang.String shortInfo)
          Sets a short information about the program (about three lines).
 void setTextField(ProgramFieldType type, java.lang.String inValue)
          Set a text field.
 void setTimeField(ProgramFieldType type, int value)
          Set a time field.
 void setTitle(java.lang.String title)
          Sets the title of this program.
 java.lang.String toString()
          Gets a String representation of this program for debugging.
 void unmark(Marker marker)
          Removes the marks from the program for a plugin.
 void unmark(Plugin javaPlugin)
          Removes the marks from the program for a Java plugin.
 void validateMarking()
          Informs the ChangeListeners for repainting if a Plugin uses more than one Icon for the Program.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_SHORT_INFO_LENGTH

public static final int MAX_SHORT_INFO_LENGTH
The maximum length of a short info. Used for generating a short info out of a (long) description.

See Also:
Constant Field Values

EMPTY_MARKER_ARR

protected static final Marker[] EMPTY_MARKER_ARR
A plugin array that can be shared by all the programs that are not marked by any plugin.


ID_DATE_FORMAT

public static final java.lang.String ID_DATE_FORMAT
The date format, which is used in the unique ID

See Also:
Constant Field Values

mTitle

protected java.lang.String mTitle
Contains the title

Constructor Detail

MutableProgram

public MutableProgram(Channel channel,
                      Date localDate,
                      int localHours,
                      int localMinutes,
                      boolean isLoading)
Creates a new instance of MutableProgram.

The parameters channel, date, hours and minutes build the ID. That's why they are not mutable.

Parameters:
channel - The channel object of this program.
localDate - The date of this program.
localHours - The hour-component of the start time of the program.
localMinutes - The minute-component of the start time of the program.
isLoading - If the program is currently being created.
See Also:
setProgramLoadingIsComplete()

MutableProgram

public MutableProgram(Channel channel,
                      Date localDate,
                      boolean isLoading)
Creates a new instance of MutableProgram.

The parameters channel, date, hours and minutes build the ID. That's why they are not mutable.

Parameters:
channel - The channel object of this program.
localDate - The date of this program.
isLoading - If the program is currently loading.
See Also:
setProgramLoadingIsComplete()
Method Detail

addChangeListener

public void addChangeListener(javax.swing.event.ChangeListener listener)
Adds a ChangeListener to the program.

Specified by:
addChangeListener in interface Program
Parameters:
listener - the ChangeListener to add
See Also:
fireStateChanged(), removeChangeListener(javax.swing.event.ChangeListener)

removeChangeListener

public void removeChangeListener(javax.swing.event.ChangeListener listener)
Removes a ChangeListener from the program.

Specified by:
removeChangeListener in interface Program
Parameters:
listener - the ChangeListener to remove
See Also:
fireStateChanged(), addChangeListener(javax.swing.event.ChangeListener)

fireStateChanged

protected void fireStateChanged()
Send a ChangeEvent, whose source is this program, to each listener.

See Also:
addChangeListener(javax.swing.event.ChangeListener), EventListenerList

getTimeString

public final java.lang.String getTimeString()
Description copied from interface: Program
get the start time of this program as nicely formatted string

Specified by:
getTimeString in interface Program
Returns:
the start time string

getEndTimeString

public final java.lang.String getEndTimeString()
Description copied from interface: Program
get the end time of this program as nicely formatted string

Specified by:
getEndTimeString in interface Program
Returns:
the end time string

getDateString

public final java.lang.String getDateString()
Description copied from interface: Program
get the date of this program as nicely formatted string

Specified by:
getDateString in interface Program
Returns:
the date string

isOnAir

public boolean isOnAir()
Gets whether this program is marked as "on air".

Specified by:
isOnAir in interface Program

mark

public final void mark(Plugin javaPlugin)
Marks the program for a Java plugin.

Specified by:
mark in interface Program
Parameters:
javaPlugin - The plugin to mark the program for.

unmark

public final void unmark(Plugin javaPlugin)
Removes the marks from the program for a Java plugin.

If the program wasn't marked for the plugin, nothing happens.

Specified by:
unmark in interface Program
Parameters:
javaPlugin - The plugin to remove the mark for.

mark

public final void mark(Marker marker)
Marks the program for a plugin.

Specified by:
mark in interface Program
Parameters:
marker - The plugin to mark the program for.

unmark

public final void unmark(Marker marker)
Removes the marks from the program for a plugin.

If the program wasn't marked for the plugin, nothing happens.

Specified by:
unmark in interface Program
Parameters:
marker - The plugin to remove the mark for.

getMarkerArr

public Marker[] getMarkerArr()
Description copied from interface: Program
Gets all Markers that have marked this program.

Specified by:
getMarkerArr in interface Program

isExpired

public boolean isExpired()
Gets whether this program is expired.

Specified by:
isExpired in interface Program

getID

public java.lang.String getID()
Gets the ID of this program. This ID is unique for a certain date.

Specified by:
getID in interface Program
Returns:
The ID of this program.

getUniqueID

public java.lang.String getUniqueID()
Gets the unique ID of this program. In contrast to getID() this method returns an ID, which is unique for all programs. This value becomes invalid when changing the application time zone.

Specified by:
getUniqueID in interface Program
Returns:
An unique ID of this program.

getBinaryField

public byte[] getBinaryField(ProgramFieldType type)
Description copied from interface: Program
Gets the value of a binary field from the program.

Specified by:
getBinaryField in interface Program
Parameters:
type - The type of the wanted field. Must have a binary format.
Returns:
The value of the field or null, if there is no value for this field.

getTextField

public java.lang.String getTextField(ProgramFieldType type)
Description copied from interface: Program
Gets the value of a text field from the program.

Specified by:
getTextField in interface Program
Parameters:
type - The type of the wanted field. Must have a text format.
Returns:
The value of the field or null, if there is no value for this field.

getObjectValueField

protected java.lang.Object getObjectValueField(ProgramFieldType type)
access method to object field values. this allows ondemand programs to reimplement the access

Parameters:
type -
Returns:
object stored in the field

getIntField

public int getIntField(ProgramFieldType type)
Description copied from interface: Program
Gets the value of a int field from the program.

Specified by:
getIntField in interface Program
Parameters:
type - The type of the wanted field. Must have a int format.
Returns:
The value of the field or -1, if there is no value for this field.

getIntFieldAsString

public java.lang.String getIntFieldAsString(ProgramFieldType type)
Gets the value of a int field as String.

Specified by:
getIntFieldAsString in interface Program
Parameters:
type - The type of the wanted field. Must have a int format.
Returns:
The value of the field as String or null, if there is no value for this field.

getTimeField

public int getTimeField(ProgramFieldType type)
Description copied from interface: Program
Gets the value of a time field from the program.

Specified by:
getTimeField in interface Program
Parameters:
type - The type of the wanted field. Must have a time format.
Returns:
The value of the field or -1, if there is no value for this field.

getTimeFieldAsString

public java.lang.String getTimeFieldAsString(ProgramFieldType type)
Gets the value of a time field as String of the pattern "h:mm".

Specified by:
getTimeFieldAsString in interface Program
Parameters:
type - The type of the wanted field. Must have a time format.
Returns:
The value of the field as String or null, if there is no value for this field.

getFieldCount

public int getFieldCount()
Gets the number of fields this program has.

Specified by:
getFieldCount in interface Program
Returns:
the number of fields this program has.

getFieldIterator

public java.util.Iterator<ProgramFieldType> getFieldIterator()
Gets an iterator over the types of all fields this program has.

Specified by:
getFieldIterator in interface Program
Returns:
an iterator over ProgramFieldTypes.

setBinaryField

public void setBinaryField(ProgramFieldType type,
                           byte[] value)
Set a binary field.

Parameters:
type - The type of the field.
value - The binary value to set.

setObjectValueField

protected void setObjectValueField(ProgramFieldType type,
                                   java.lang.Object value)

setTextField

public void setTextField(ProgramFieldType type,
                         java.lang.String inValue)
Set a text field.

Parameters:
type - The type of the field.
inValue - The text value to set.

setIntField

public void setIntField(ProgramFieldType type,
                        int value)
Set an int field.

Parameters:
type - The type of the field.
value - The int value to set.

setTimeField

public void setTimeField(ProgramFieldType type,
                         int value)
Set a time field.

Parameters:
type - The type of the field.
value - The time value to set.

generateShortInfoFromDescription

public static java.lang.String generateShortInfoFromDescription(java.lang.String shortInfo)
Trim text for shortinfo-field

Parameters:
shortInfo - generate Text from this field
Returns:
Text that fits into shortInfo
Since:
2.7

setTitle

public void setTitle(java.lang.String title)
Sets the title of this program.

Parameters:
title - the new title of this program.

getTitle

public java.lang.String getTitle()
Returns the title of this program.

Specified by:
getTitle in interface Program
Returns:
the title of this program.

setShortInfo

public void setShortInfo(java.lang.String shortInfo)
Sets a short information about the program (about three lines). May be null.

If the length of the short info exceeds 100 characters it will be cut using a smart algorithm.

Parameters:
shortInfo - The new short info.

getShortInfo

public java.lang.String getShortInfo()
Returns a short information about the program (about three lines). May be null.

Specified by:
getShortInfo in interface Program
Returns:
The short info.

setDescription

public void setDescription(java.lang.String description)
Sets a description about the program. May be null.

Parameters:
description - The description.

getDescription

public java.lang.String getDescription()
Returns a description about the program. May be null.

Specified by:
getDescription in interface Program
Returns:
The description.

getStartTime

public int getStartTime()
Gets the the start time of the program in minutes after midnight.

Specified by:
getStartTime in interface Program
Returns:
the start time.

getHours

public int getHours()
Gets the hour-component of the start time of the program.

Specified by:
getHours in interface Program
Returns:
the hour-component of the start time.

getMinutes

public int getMinutes()
Gets the minute-component of the start time of the program.

Specified by:
getMinutes in interface Program
Returns:
the minute-component of the start time.

getLocalStartTime

public int getLocalStartTime()
Returns:
The local start time.

setLength

public void setLength(int length)
Sets the length of this program in minutes.

Parameters:
length - the new length.

getLength

public int getLength()
Description copied from interface: Program
Gets the length of this program in minutes.

Specified by:
getLength in interface Program
Returns:
the length in minutes or -1, if the length is unknown.

setInfo

public void setInfo(int info)
Sets additional information of the program (or zero).

Parameters:
info - The new additional information.

getInfo

public int getInfo()
Returns additional information of the program (or zero).

Specified by:
getInfo in interface Program
Returns:
the new additional information.

getChannel

public Channel getChannel()
Returns the channel object of this program.

Specified by:
getChannel in interface Program
Returns:
The channel.

getDate

public Date getDate()
Returns the date of this program.

Specified by:
getDate in interface Program
Returns:
the date.

getLocalDate

public Date getLocalDate()
Returns:
The local date

toString

public java.lang.String toString()
Gets a String representation of this program for debugging.

Overrides:
toString in class java.lang.Object
Returns:
A String representation for debugging.

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equalsAllFields

public boolean equalsAllFields(MutableProgram program)
check if two programs are identical by their field contents

Parameters:
program -
Returns:
true, if all fields are equal
Since:
2.6

setProgramState

protected void setProgramState(int state)
Sets the state of this program to a program state.

Parameters:
state - The state of this program.
Since:
2.2

getProgramState

public int getProgramState()
Returns the state of this program.

Specified by:
getProgramState in interface Program
Returns:
The program state.
Since:
2.2

validateMarking

public final void validateMarking()
Informs the ChangeListeners for repainting if a Plugin uses more than one Icon for the Program.

Specified by:
validateMarking in interface Program
Since:
2.2.2
See Also:
Plugin.getMarkIconsForProgram(Program)

setMarkerArr

protected void setMarkerArr(Marker[] marker)
Sets the marker array of this program.

Parameters:
marker - The marker array.
Since:
2.2.1

setProgramLoadingIsComplete

public void setProgramLoadingIsComplete()
Sets the loading state to false. Call this after creation of the program from the data service.

Since:
2.2.2

getMarkPriority

public int getMarkPriority()
Gets the priority of the marking of this program.

Specified by:
getMarkPriority in interface Program
Returns:
The mark priority.
Since:
2.5.1

setMarkPriority

protected void setMarkPriority(int markPriority)
Sets the mark priority for this program

Since:
2.5.1

hasFieldValue

public boolean hasFieldValue(ProgramFieldType type)
Description copied from interface: Program
checks if the given field has a non-null value. use this method if you don't need the value of the field, but only the knowledge about existence

Specified by:
hasFieldValue in interface Program
Parameters:
type - field type
Returns:
field is set

TV-Browser 3.3.3 API

TV-Browser 3.3.3, Copyright (C) 2004-2008 TV-Browser Team (dev@tvbrowser.org)