All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.seninp.jmotif.sax.motif.MotifRecord Maven / Gradle / Ivy

Go to download

An implementation of time series Symbolic Aggregate approXimation and HOTSAX algorithms.

The newest version!
package net.seninp.jmotif.sax.motif;

import java.util.ArrayList;
import java.util.TreeSet;

/**
 * Keeps motifs organized.
 * 
 * @author psenin
 *
 */
public class MotifRecord {

  private int location;
  private TreeSet occurrences;

  /**
   * Constructor.
   * 
   * @param motifLiocation the motif location.
   * @param motifOccurrences occurrence locations.
   */
  public MotifRecord(int motifLiocation, ArrayList motifOccurrences) {
    this.location = motifLiocation;
    this.occurrences = new TreeSet();
    this.occurrences.addAll(motifOccurrences);
  }

  /**
   * The location setter.
   * 
   * @param location the motif location.
   */
  public void setLocation(int location) {
    this.location = location;
  }

  /**
   * The location getter.
   * 
   * @return the motif location.
   */
  public int getLocation() {
    return location;
  }

  /**
   * Gets the occurrence frequency.
   * 
   * @return the motif occurrence frequency (itself isnt included).
   */
  public int getFrequency() {
    return this.occurrences.size();
  }

  /**
   * The occurrences array (copy) getter.
   * 
   * @return motif occurrences.
   */
  public ArrayList getOccurrences() {
    ArrayList res = new ArrayList(this.occurrences.size());
    for (Integer e : this.occurrences) {
      res.add(e);
    }
    return res;
  }

  /**
   * The location setter.
   * 
   * @param newLocation the motif location.
   */
  public void add(int newLocation) {
    if (!this.occurrences.contains(newLocation)) {
      this.occurrences.add(newLocation);
    }
  }

  @Override
  public String toString() {
    return "MotifRecord [location=" + this.location + ", freq=" + this.occurrences.size()
        + ", occurrences=" + occurrences + "]";
  }

  public boolean isEmpty() {
    return occurrences.isEmpty();
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy