Module tvbrowser
Package tvdataservice

Class MutableProgram

  • All Implemented Interfaces:
    Program

    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 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

      • 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
        Returns:
        true if this program if currently on air, false if not.
      • 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
        Returns:
        An array with all Marker that have marked this program.
      • isExpired

        public boolean isExpired()
        Gets whether this program is expired.
        Specified by:
        isExpired in interface Program
        Returns:
        true if this program is expired, false if not.
      • 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 - The program file type to get the value for.
        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.
      • 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 - The program to check.
        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
      • 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

        @Deprecated(since="4.2.2")
        public int getMarkPriority()
        Deprecated.
        since 4.2.2
        Gets the priority of the marking of this program.
        Specified by:
        getMarkPriority in interface Program
        Returns:
        The mark priority.
        Since:
        2.5.1
      • getMarkPriorityMax

        public int getMarkPriorityMax()
        Gets the priority of the marking of this program.
        Specified by:
        getMarkPriorityMax in interface Program
        Returns:
        The mark priority.
        Since:
        4.2.2
      • getMarkPriorities

        public java.lang.Integer[] getMarkPriorities()
        Gets an array of all marking priorities of this program.
        Specified by:
        getMarkPriorities in interface Program
        Returns:
        An array with all marking priorities of this program.
        Since:
        4.2.2
      • 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