1   /*
2    *  Copyright (c) 1998-2005, The University of Sheffield.
3    *
4    *  This file is part of GATE (see http://gate.ac.uk/), and is free
5    *  software, licenced under the GNU Library General Public License,
6    *  Version 2, June 1991 (in the distribution as file licence.html,
7    *  and also available at http://gate.ac.uk/gate/licence.html).
8    *
9    *  Niraj Aswani, 21/10/2003
10   *
11   *  $Id: Variable.java,v 1.3 2005/01/11 13:51:33 ian Exp $
12   */
13  
14  package gate.creole.morph;
15  
16  /**
17   * <p>Description: This is an interface which should be implemented by every
18   * new variable type. Variable here is considered to have more than one values.
19   * Example of built-in varilables for morpher are StringSet, CharacterRange,
20   * CharacterSet.
21   * </p>
22   */
23  public abstract class Variable {
24  
25    protected int pointer = 0;
26  
27    /** name of the variable */
28    protected String varName = "";
29  
30    /** value of the variable */
31    protected String varValue = "";
32  
33    /** method tells if next element is available to fetch */
34    public abstract boolean hasNext();
35  
36    /** should return the next element in the variable */
37    public abstract String next();
38  
39    /** Sets the variable name and pattern for the variable */
40    public abstract boolean set(String varName, String pattern);
41  
42    /** should tell variable has one of the values with varValue */
43    public abstract boolean contains(String varValue);
44  
45    /**
46     * this method returns the formatted pattern, which could be recognized
47     * by the regular expressions
48     */
49    public String getPattern() {
50      return varValue;
51    }
52  
53    /**
54     * resets the pointer to the begining
55     */
56    public void resetPointer() {
57      pointer = 0;
58    }
59  }