package ca.ubc.ece.salt.sdjsb.analysis.learning.apis;

/**
 * Stores a keyword and the context under which it is used (which we call its type).
 */
public class Keyword {
	
	/** The context under which the keyword is used. **/
	public KeywordType type;
	
	/** The keyword text. **/
	public String keyword;
	
	public Keyword(KeywordType type, String keyword) {
		this.type = type;
		this.keyword = keyword;
	}
	
	@Override
	public boolean equals(Object obj) {
		if(obj instanceof Keyword) {
			Keyword that = (Keyword) obj;
			if(this.type == that.type && this.keyword == that.keyword) return true;
		}
		return false;
	}
	
	@Override
	public int hashCode() {
		return this.toString().hashCode();
	}
	
	@Override 
	public String toString() {
		return this.type.toString() + "_" + this.keyword;
	}

	/**
	 * The possible types for a keyword.
	 */
	public enum KeywordType {
		UNKNOWN,
		RESERVED,
		PACKAGE,
		CLASS,
		METHOD_CALL,
		METHOD_NAME,
		FIELD,
		CONSTANT,
		ARGUMENT,
		PARAMETER,
		EXCEPTION,
		EVENT
	}

}
@@ -164,18 +164,16 @@
 yword %7B%0A
-%09%0A
 %09/** The
@@ -214,24 +214,24 @@
 s used. **/%0A
+
 %09public Keyw
@@ -244,18 +244,17 @@
 e type;%0A
-%09
 %0A
+
 %09/** The
@@ -296,17 +296,85 @@
 eyword;%0A
-%09
+%0A%09/** The API this keyword associates to */%0A%09public AbstractAPI api;%0A
 %0A%09public
@@ -463,25 +463,24 @@
 keyword;%0A%09%7D%0A
-%09
 %0A%09@Override%0A

Add AbstractAPI field to Keyword