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