| LrModel.java |
1 package debugger.resources.lr;
2
3 import gate.LanguageResource;
4 import gate.Document;
5 import gate.corpora.DocumentImpl;
6
7 /**
8 * Copyright (c) Ontos AG (http://www.ontosearch.com).
9 * This class is part of JAPE Debugger component for
10 * GATE (Copyright (c) "The University of Sheffield" see http://gate.ac.uk/) <br>
11 * @author Andrey Shafirin, Vladimir Karasev
12 */
13
14 public class LrModel //extends DefaultMutableTreeNode
15 {
16 LanguageResource lr;
17 String storedContent;
18
19 public LrModel(LanguageResource lr) {
20 this.lr = lr;
21 if (lr instanceof Document) {
22 storedContent = ((Document) lr).getContent().toString();
23 }
24 }
25
26 public String getText() {
27 if (lr instanceof Document) {
28 return ((Document) lr).getContent().toString();
29 }
30 /*
31 else if(lr instanceof CorpusImpl)
32 {
33 return ((CorpusImpl) lr).getDocumentNames().toString();
34 }
35 */
36 return "";
37 }
38
39 public String getStoredContent() {
40 return storedContent;
41 }
42
43 public void synchronize() {
44 if (lr instanceof Document) {
45 storedContent = ((Document) lr).getContent().toString();
46 }
47 }
48
49 // public Enumeration children()
50 // {
51 // List c = new ArrayList(children);
52 // Collections.sort(c, new Comparator()
53 // {
54 // public int compare(Object o1, Object o2)
55 // {
56 // String name1 = o1.toString();
57 // String name2 = o2.toString();
58 // return name1.compareToIgnoreCase(name2);
59 // }
60 // });
61 // return new Vector(c).elements();
62 // }
63
64 public LanguageResource getLr() {
65 return lr;
66 }
67
68 public boolean equals(Object obj) {
69 if (obj instanceof LrModel) {
70 return this.lr.equals(((LrModel) obj).lr);
71 }
72 return super.equals(obj);
73 }
74
75 public String toString() {
76 return lr.getName();
77 }
78
79 public String getName() {
80 return lr.getName();
81 }
82 }
83