1   /*
2    *  Lookup.java
3    *
4    *  Copyright (c) 1998-2001, The University of Sheffield.
5    *
6    *  This file is part of GATE (see http://gate.ac.uk/), and is free
7    *  software, licenced under the GNU Library General Public License,
8    *  Version 2, June 1991 (in the distribution as file licence.html,
9    *  and also available at http://gate.ac.uk/gate/licence.html).
10   *
11   *  Valentin Tablan, 11/07/2000
12   *
13   *  $Id: Lookup.java,v 1.6 2001/11/09 15:15:48 nasso Exp $
14   */
15  
16  package gate.creole.gazetteer;
17  
18  /**
19   * Used to describe a type of lookup annotations. A lookup is described by a
20   * major type a minor type and a list of languages.
21   * All these values are strings (the list of languages is a string and it is
22   * intended to represesnt a comma separated list).
23   *
24   */
25  public class Lookup implements java.io.Serializable {
26  
27    /** Debug flag
28     */
29    private static final boolean DEBUG = false;
30  
31    /**
32     * Creates a new Lookup value with the given major and minor types and
33     * languages.
34     *
35     * @param major
36     * @param minor
37     * @param languages
38     */
39    public Lookup(String major, String minor, String languages){
40      majorType = major;
41      minorType = minor;
42      this.languages = languages;
43    }
44  
45    /**
46     * Tha major type for this lookup, e.g. "Organisation"
47     *
48     */
49    public String majorType;
50    /**
51     * The minor type for this lookup, e.g. "Company"
52     *
53     */
54    public String minorType;
55    /**
56     * The languages for this lookup, e.g. "English, French"
57     *
58     */
59    public String languages;
60  
61    /**
62     * Returns a string representation of this lookup in the format
63     * majorType.minorType
64     *
65     */
66    public String toString(){
67      if(null == minorType) return majorType;
68      else return majorType + "." + minorType;
69    }
70  
71    /**
72     *  Two lookups are equal if they have the same string representation
73     *  (major type and minor type).
74     * @param obj
75     */
76    public boolean equals(Object obj){
77      if(obj instanceof Lookup) return obj.toString().equals(toString());
78      else return false;
79    } // equals
80  
81    /**    *
82     */
83    public int hashCode(){ return toString().hashCode();}
84  
85  } // Lookup
86