Documentation of 'com.jstatcom.ts.TSHolder' Java class
TSHolder
com.jstatcom.ts

Class TSHolder

  • All Implemented Interfaces:
    ProjectDataHandler


    public class TSHolder
    extends java.lang.Object
    implements ProjectDataHandler
    Holds all available TS at runtime. The identifying keys are the names of the time series. The names are converted to lowercase, which makes the lookup case insensitive. It also provides methods for adding, removing, and reading of time series. This class is designed as a Singleton (Gamma et al., 1995) and can be accessed by the static getInstance method.

    Classes can register themselves as PropertyChangeListeners to the TSHolder if they should be notified when TS_ADDED or TS_REMOVED events happen.

    This class is designed to be thread-save for adding, removing, and reading of time series.

    See Also:
    TS, TSList
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static java.lang.String ALL_TS_REMOVED 
      static java.lang.String TS_ADDED
      PropertyChange values.
      static java.lang.String TS_REMOVED 
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void addPropertyChangeListener(java.beans.PropertyChangeListener listener) 
      int addTS(TS newTimeSeries)
      Adds a new TS to this TSHolder.
      boolean contains(java.lang.String name)
      Returns whether the TSHolder contains a TS with the given name.
      TS[] getAllTS()
      Gets all time series.
      javax.swing.ListModel getAsListModel()
      Gets TSHolder represented as a ListModel with the names in alphabetical order.
      static TSHolder getInstance()
      Returns Singleton instance of a TSHolder.
      ProjectData getProjectData()
      Gets the project data from this shared data repository.
      ProjectDataTypes getProjectDataType()
      Returns time series data type.
      TS getTS(java.lang.String name)
      Retrieves a time series for a given name.
      java.util.Iterator<java.lang.String> getTSNames()
      Returns names of all available time series.
      void removeAllTS()
      Removes all time series from the map and fires an ALL_TS_REMOVED PropertyChangeEvent if there were any series removed.
      void removePropertyChangeListener(java.beans.PropertyChangeListener listener) 
      void removeTS(java.lang.String name)
      Removes a time series from the map and fires a TS_REMOVED PropertyChangeEvent.
      void setProjectData(ProjectData pData)
      Sets the project data to this shared data repository for time series.
      void setTS(TS[] newTimeSeries)
      Clears all currently stored time series and adds the series contained in newTimeSeries.
      java.lang.String toString()
      String representation of this TSHolder.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Method Detail

      • addPropertyChangeListener

        public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
      • setTS

        public void setTS(TS[] newTimeSeries)
        Clears all currently stored time series and adds the series contained in newTimeSeries.
        Parameters:
        newTimeSeries - array of time series to add
      • addTS

        public int addTS(TS newTimeSeries)
        Adds a new TS to this TSHolder. If a series has less than 2 observations, an error message is displayed. If a series with the same name already exists, a question is displayed, whether the existing series should be overwritten. This method returns JOptionPane.YES_OPTION if newTimeSeries was null.

        If the series was added, a TS_ADDED PropertyChangeEvent is fired.

        Parameters:
        newTimeSeries - the new TS to add
        Returns:
        One of JOptionPane.YES_OPTION, JOptionPane.NO_OPTION or JOptionPane.CANCEL_OPTION, which the calling method can process accordingly. If JOptionPane.YES_OPTION is returned, the time series was added successfully.
      • contains

        public boolean contains(java.lang.String name)
        Returns whether the TSHolder contains a TS with the given name. The lookup is case insensitive.
        Parameters:
        name - String with the name to be looked up
        Returns:
        true if series is contained, false otherwise
      • getAsListModel

        public javax.swing.ListModel getAsListModel()
        Gets TSHolder represented as a ListModel with the names in alphabetical order.
        Returns:
        the ListModel that is in sync with this object
      • getInstance

        public static TSHolder getInstance()
        Returns Singleton instance of a TSHolder.
        Returns:
        TSHolder instance to be shared
      • getTS

        public TS getTS(java.lang.String name)
        Retrieves a time series for a given name.
        Parameters:
        name - of the time series to get
        Returns:
        TS with the given name, null if it does not exist
      • getAllTS

        public TS[] getAllTS()
        Gets all time series.
        Returns:
        array of all series
      • getTSNames

        public java.util.Iterator<java.lang.String> getTSNames()
        Returns names of all available time series.
        Returns:
        iterator with names of all hashed TS
      • removePropertyChangeListener

        public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
      • removeTS

        public void removeTS(java.lang.String name)
        Removes a time series from the map and fires a TS_REMOVED PropertyChangeEvent. Nothing happens, if no series with the given name was stored.
        Parameters:
        name - of the time series to get
      • removeAllTS

        public void removeAllTS()
        Removes all time series from the map and fires an ALL_TS_REMOVED PropertyChangeEvent if there were any series removed.
      • toString

        public java.lang.String toString()
        String representation of this TSHolder.
        Overrides:
        toString in class java.lang.Object
        Returns:
        string containing name and names of all included TS
      • setProjectData

        public void setProjectData(ProjectData pData)
        Sets the project data to this shared data repository for time series.
        Specified by:
        setProjectData in interface ProjectDataHandler
        Parameters:
        pData - project data to set
      • getProjectData

        public ProjectData getProjectData()
        Gets the project data from this shared data repository. Typically this method is used for serialization.
        Specified by:
        getProjectData in interface ProjectDataHandler
        Returns:
        project data assembled from this data repository

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.