/** 
 * Project    : KANT (LMT)
 * Source Name: Morphology.java
 * Copyright  : Copyright (c) LTI, Carnegie Mellon University
 * Description: Class for morphology. This is a parent class of MorphNoun, MorphVerb, MorphAdj class.
 * @version     1.0 (created by jko - 10/01/01)
 **/

package lmt;

import java.sql.*;
import java.util.*;

public class Morphology {
  String concept_id;
  String con_double;
  String active;
  String irr_active;
  String pos;
	
  /** constructor 
   **/		
  Morphology() {
    concept_id = "";		
    con_double = "";
    active = "";
    irr_active = "";
  }
	
  //setters and getters
  public String getConceptID() {
    return concept_id;
  }	
  public void setConceptID(String concept_id) {
    if ( concept_id == null )
      concept_id = "";
    this.concept_id = concept_id;
  }		
  public String getConDouble() {
    return con_double;
  }	
  public void setConDouble(String con_double) {
    if ( con_double == null )
      con_double = "";		
    this.con_double = con_double;
  }	
  public void setActive (String active) {
    this.active = active;
  }	
  public void setIrrActive (String irr_active) {
    if ( irr_active == null )
      irr_active = "";		
    this.irr_active = irr_active;
  }
	
  /** Get all morphology information which has the concept_id
   *  Based on pos, it fetches the appropriated morphological features
   * @param pos a string representing POS(part of speech)
   * @param concept_id a string representing concept_id
   * @return MorphVerb fetched from the database.
   **/	
  public static Morphology fetchMorph(SQLConnection con, String pos, String concept_id) {
    Morphology morph = null;
		
    //Debug.debug("Morphology-fetchMorph: pos=" + pos + " concept_id=" + concept_id);
    if ( pos != null ) {
      if ( pos.equals("ADJ") ||
	   pos.equals("ADVERB") ) 
	morph = MorphAdj.fetchMorph(con, concept_id);
      else if (pos.equals("VERB") ||
	       pos.equals("AUX") ) 
	morph = MorphVerb.fetchMorph(con, concept_id);
      else if (pos.equals("NOUN") ||
	       pos.equals("PROP") ||
	       pos.equals("UNIT") ) 
	morph = MorphNoun.fetchMorph(con, concept_id);		
    }
    return morph;
  }

  public void makeQuery(Vector queryVector, String pos) {
    //Debug.debug("updateMorphology: pos - " + pos);
    if ( pos.equals("ADJ") ||
	 pos.equals("ADVERB") ) 
      ((MorphAdj)this).makeQuery(queryVector);		
    else if (pos.equals("VERB") ||
	     pos.equals("AUX") ) 
      ((MorphVerb)this).makeQuery(queryVector);		
    else if (pos.equals("NOUN") ||
	     pos.equals("PROP") ||
	     pos.equals("UNIT") ) 
      ((MorphNoun)this).makeQuery(queryVector);	
  }			
}
