Class Observation

java.lang.Object
jwat.Observation
All Implemented Interfaces:
Comparable<Object>

public class Observation extends Object implements Comparable<Object>
This class represents a single observation retrieved from a log file. Every element is a double number that represents either the true value or the converted value representing a string, date or other types.
Author:
Brambilla Davide matr 667986, Fumagalli Claudio 667971
  • Constructor Summary

    Constructors
    Constructor
    Description
    Observation(double[] obsList, int ID)
    Constructor, creates an instance of observation which contains the values passed through obsList double list.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Comparable interface method overridden, to allow to sort observations according to sortIndex value
    int
     
    double
    getIndex(int Index)
    Return to Ith element stored in the observation instance
    int
    Returns the size ( number of elements ) of the observation
    boolean
    Getter
    void
    setID(int ID)
     
    void
    setIndex(int Index, double val)
    Stores the val value passed in the Index-th element of the instance
    void
    setSorter(int Index)
    Sets up element on which perform compareTo method
    void
    setValid(boolean b)
    Sets the validity of the observation.
     

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Observation

      public Observation(double[] obsList, int ID)
      Constructor, creates an instance of observation which contains the values passed through obsList double list.
      Parameters:
      obsList - Elements of observation
  • Method Details

    • getID

      public int getID()
    • setID

      public void setID(int ID)
    • compareTo

      public int compareTo(Object obj)
      Comparable interface method overridden, to allow to sort observations according to sortIndex value
      Specified by:
      compareTo in interface Comparable<Object>
      Parameters:
      obj - element to compare to this instance
      Returns:
      a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
    • getIndex

      public double getIndex(int Index) throws ArrayIndexOutOfBoundsException
      Return to Ith element stored in the observation instance
      Parameters:
      Index - element position
      Returns:
      Ith element
      Throws:
      ArrayIndexOutOfBoundsException - Index out of the range allowed
    • setIndex

      public void setIndex(int Index, double val) throws ArrayIndexOutOfBoundsException
      Stores the val value passed in the Index-th element of the instance
      Parameters:
      Index - element position
      val - value to store
      Throws:
      ArrayIndexOutOfBoundsException - Index out of the range allowed
    • getSize

      public int getSize()
      Returns the size ( number of elements ) of the observation
      Returns:
      Size of the observation
    • setSorter

      public void setSorter(int Index) throws ArrayIndexOutOfBoundsException
      Sets up element on which perform compareTo method
      Parameters:
      Index - index of element
      Throws:
      ArrayIndexOutOfBoundsException - if the operation cannot be completed
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • setValid

      public void setValid(boolean b)
      Sets the validity of the observation. This method is used to apply sampling operation without the loss of the original observation and to sync on these values all variables
      Parameters:
      b - validity value
    • isValid

      public boolean isValid()
      Getter
      Returns:
      validity of the observation