Module tvbrowser

Class TvDataInventory


  • public class TvDataInventory
    extends java.lang.Object
    Remembers the day programs that are known to the user (or the user's plugins).

    This way the TV data directory may be changed by other users, other clients or by hand and events of these changes will be sent anyway. This ensures that all plugins can react on data changed by third parties.

    Author:
    Til Schneider, www.murfman.de
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int KNOWN  
      static int OTHER_VERSION  
      static int UNKNOWN  
    • Constructor Summary

      Constructors 
      Constructor Description
      TvDataInventory()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String[] getKnownDayPrograms()
      Gets the keys of all known day programs.
      int getKnownStatus​(Date date, Channel channel, int version)
      Gets whether the given day program is already known to the user.
      void readData​(java.io.File file)
      Loads the inventory list.
      void setKnown​(Date date, Channel channel, int version)
      Sets the day program to "known to the user".
      void setUnknown​(Date date, Channel channel)
      Sets the day program to "NOT known to the user".
      void setUnknown​(java.lang.String key)
      Sets the day program to "NOT known to the user".
      void writeData​(java.io.File file)
      Saves the inventory list.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TvDataInventory

        public TvDataInventory()
    • Method Detail

      • getKnownStatus

        public int getKnownStatus​(Date date,
                                  Channel channel,
                                  int version)
        Gets whether the given day program is already known to the user.

        Returns

        • UNKNOWN if the day program is totally unknown.
        • OTHER_VERSION if the day program is known but in another version.
        • KNOWN if the day program is known in the given version.
        Parameters:
        date - The day program's date
        channel - The day program's channel
        version - The day program's version (e.g. file size)
        Returns:
        whether the given day program is already known to the user.
      • setKnown

        public void setKnown​(Date date,
                             Channel channel,
                             int version)
        Sets the day program to "known to the user".
        Parameters:
        date - The day program's date
        channel - The day program's channel
        version - The day program's version (e.g. file size)
      • setUnknown

        public void setUnknown​(Date date,
                               Channel channel)
        Sets the day program to "NOT known to the user".
        Parameters:
        date - The day program's date
        channel - The day program's channel
      • setUnknown

        public void setUnknown​(java.lang.String key)
        Sets the day program to "NOT known to the user".
        Parameters:
        key - The key to remove.
      • getKnownDayPrograms

        public java.lang.String[] getKnownDayPrograms()
        Gets the keys of all known day programs.

        The keys of the day programs are equal to their file name.

        Returns:
        The keys of all known day programs.
        See Also:
        TvDataBase.getDayProgramKey(Date, Channel)
      • readData

        public void readData​(java.io.File file)
                      throws java.io.IOException,
                             java.lang.ClassNotFoundException
        Loads the inventory list.
        Parameters:
        file - The file to read the data from.
        Throws:
        java.io.IOException - Thrown if an IO operation went wrong.
        java.lang.ClassNotFoundException - Thrown if a class could not be found.
        See Also:
        writeData(File)
      • writeData

        public void writeData​(java.io.File file)
                       throws java.io.IOException
        Saves the inventory list.

        It is essential that this list is saved at the shut down of TV-Browser! If TV-Browser failes to save the plugin data then the inventory list should NOT be saved too. Doing so the plugins will update themselves automatically on the next startup, because new TV data will be treated as unknown.

        Parameters:
        file - The file to write the data to.
        Throws:
        java.io.IOException - Thrown if an IO operation went wrong.
        See Also:
        readData(File)