/*
 * Copyright (c) Siemens AG 2008 
 *           (c) Universität Paderborn 2008 
 * Licensed under EUPL 1.1. 
 * 
 * Created on Apr 27, 2005
 * Diese Klasse speichert ein Term eines Dokumenets 
 */
package vkc.clusterer;

import java.util.HashSet;

public class TermEntry implements Comparable{
    private int		termIndex;	// einmalig berechneter Index für TermDokumnetenmatrix   

    private double	termWeight; // Gewicht aus SummaryEntry[] getKeyWords(..)
    
    private HashSet documentIds = new HashSet();// Entspricht DOCFREQ von Term k

    private String 	Term;		// Entspricht ein Keywort aus dem Dokument
    
    public TermEntry() {
        super();
    }

    /**
     * @return Returns the hashIndex.
     */
    public int getTermIndex() {
        return termIndex;
    }

    /**
     * @param hashIndex The hashIndex to set.
     */
    public void setTermIndex(int hashIndex) {
        this.termIndex = hashIndex;
    }
    
    /**
     * @return Returns the term.
     */
    public String getTerm() {
        return Term;
    }
    
    /**
     * @param term The term to set.
     */
    public void setTerm(String term) {
        Term = term;
    }
    
    /**
     * @return Returns the termWeight.
     */
    public double getTermWeight() {
        return termWeight;
    }
    
    /**
     * @param termWeight The termWeight to set.
     */
    public void setTermWeight(double termWeight) {
        this.termWeight = termWeight;
    }
    
    /**
     * @return Returns the documentIds.
     */
    public HashSet getDocumentIds() {
        return documentIds;
    }
    
    /**
     * @param documentIds The documentIds to set.
     */
    public void setDocumentIds(HashSet documentIds) {
        this.documentIds = documentIds;
    }
    
    public boolean equals(Object obj) {
        if (obj == null || !(obj instanceof TermEntry)) {
            return false;
        }
        
        TermEntry e = (TermEntry)obj;
        
        return this.getTerm().equals(e.getTerm());
    }

    public int compareTo(Object o) {
        if (o == null) {
            return 1;
        }
        
        if (!(o instanceof TermEntry)) {
            throw new ClassCastException();
        }
        
        TermEntry te = (TermEntry)o;

        if (getTermWeight() > te.getTermWeight()) {
            return 1;
        }

        if (getTermWeight() < te.getTermWeight()) {
            return -1;
        }
        
        return 0;
    }
}