source: trunk/greenstone3-extensions/gs3build/src/org/greenstone/gsdl3/gs3build/indexers/AbstractIndexer.java@ 12188

Last change on this file since 12188 was 12188, checked in by kjdon, 18 years ago

Initial revision

  • Property svn:keywords set to Author Date Id Revision
File size: 2.2 KB
Line 
1package org.greenstone.gsdl3.gs3build.indexers;
2
3import java.util.*;
4
5import org.w3c.dom.Document;
6import org.w3c.dom.Element;
7import org.w3c.dom.NamedNodeMap;
8import org.w3c.dom.Node;
9import org.w3c.dom.NodeList;
10import org.w3c.dom.Text;
11
12import org.greenstone.gsdl3.gs3build.util.DOMUtils;
13import org.greenstone.gsdl3.util.GSXML;
14
15public abstract class AbstractIndexer implements IndexerInterface
16{
17 class CollectionIndex
18 { String level;
19 String name;
20 List fields;
21
22 public CollectionIndex(String indexName, Node node)
23 { this.fields = new ArrayList();
24 this.name = indexName;
25 this.level = IndexerManager.DEFAULT_LEVEL;
26
27 NodeList children = node.getChildNodes();
28 for (int c = 0; c < children.getLength(); c ++) {
29 Node child = children.item(c);
30
31 if (child.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
32 String name = child.getNodeName();
33
34 if (name.equals(GSXML.LEVEL_ELEM)) {
35 String levelName = DOMUtils.getNodeChildText(children.item(c));
36 this.level = levelName;
37 }
38 else if (name.equals(GSXML.FIELD_ELEM)) {
39 String fieldName = DOMUtils.getNodeChildText(children.item(c));
40 this.fields.add(fieldName.toString());
41 }
42 }
43 }
44 if (this.fields.size() == 0) {
45 this.fields.add(IndexerManager.DEFAULT_FIELD);
46 }
47 }
48
49 public void prepareIndexer(IndexerInterface indexer)
50 { //indexer.addIndex(this.name, this.level, this.fields.get(0).toString());
51 }
52 }
53
54
55 public boolean configure(org.w3c.dom.Node searchNode)
56 {
57 NodeList indexChildren = searchNode.getChildNodes();
58
59 // check for <index> tag children
60 for (int i = 0; i < indexChildren.getLength(); i ++) {
61 String childName = indexChildren.item(i).getNodeName();
62
63 if (childName.equals(GSXML.INDEX_ELEM))
64 { NamedNodeMap atts = indexChildren.item(i).getAttributes();
65
66 Node attribute = atts.getNamedItem(GSXML.NAME_ATT);
67 String indexName = attribute.getNodeValue();
68
69 // create the local indexer representation
70 CollectionIndex index = new CollectionIndex(indexName, indexChildren.item(i));
71
72 // prepare it...
73 index.prepareIndexer(this);
74 }
75 }
76 return true;
77 }
78
79 public void tidyup()
80 {
81 }
82}
Note: See TracBrowser for help on using the repository browser.