| MappingNode.java |
1 /*
2 * MappingNode.java
3 *
4 * Copyright (c) 2002, 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, June1991.
9 *
10 * A copy of this licence is included in the distribution in the file
11 * licence.html, and is also available at http://gate.ac.uk/gate/licence.html.
12 *
13 * borislav popov 02/2002
14 *
15 */
16 package gate.creole.gazetteer;
17
18
19
20 /**Represents a single node from the mapping definition*/
21 public class MappingNode{
22
23 /** the gazetteer list filename */
24 private String list;
25 /** the class associated with the list */
26 private String classID;
27 /** the ontology to which the class belongs */
28 private String ontologyID;
29
30 /**Creates a new mapping node given a string representation.
31 * @param node a node from the mapping definition
32 * @throws InvalidFormatException if the node is misformatted
33 */
34 public MappingNode(String node) throws InvalidFormatException {
35 int firstColumn = node.indexOf(':');
36 int lastColumn = node.lastIndexOf(':');
37 if (-1 == firstColumn || -1 == lastColumn ) {
38 throw new InvalidFormatException();
39 }
40 list = node.substring(0,firstColumn);
41 ontologyID = node.substring(firstColumn+1,lastColumn);
42 classID = node.substring(lastColumn+1);
43 }// MappingNode construct
44
45 /**Creates a new mapping node given its members
46 * @param aList the gaz list file name
47 * @param anOntologyID the ontology
48 * @param aClassID the class
49 */
50 public MappingNode(String aList, String anOntologyID,String aClassID) {
51 list = aList;
52 classID = aClassID;
53 ontologyID = anOntologyID;
54 }
55
56 /**Sets gaz list for the node
57 * @param aList a gazetteer list file name */
58 public void setList(String aList) {
59 list = aList;
60 }
61
62 /** Gets the list of the node
63 * @return the gazetteer list file name*/
64 public String getList(){
65 return list;
66 }
67
68 /** Sets the class ID
69 * @param theClassID the class id */
70 public void setClassID(String theClassID) {
71 classID = theClassID;
72 }
73
74 /** Gets the class id
75 * @return the class id */
76 public String getClassID(){
77 return classID;
78 }
79
80 /** Sets the ontology id
81 * @param id the ontology id */
82 public void setOntologyID(String id) {
83 ontologyID = id;
84 }
85
86 /** Gets the ontology id
87 * @return the ontology id */
88 public String getOntologyID(){
89 return ontologyID;
90 }
91
92 /**
93 * Gets the string representation of the node
94 * @return the string representation of the node
95 */
96 public String toString() {
97 return list + ":" + ontologyID + ":" + classID;
98 }
99 } // class MappingNode