4A Server -  2.0
 All Classes Namespaces Files Functions Variables Enumerator
SequenceNodeIterator.java
Go to the documentation of this file.
1 /*
2  * Project: Server for annotations sharing
3  * Subproject: Position of fragment of text in XML document
4  * Author: Peter Bartoš
5  * Edited by: Ing. Jaroslav Dytrych idytrych@fit.vutbr.cz
6  * File: SequenceNodeIterator.java
7  * Description: Sequence node iterator
8  */
9 
10 /**
11  * @file SequenceNodeIterator.java
12  *
13  * @brief Sequence node iterator
14  */
15 
16 package cz.vutbr.fit.knot.annotations.fragmentUpdater.nodeIterators;
17 
19 import javax.xml.xpath.XPathExpression;
20 import javax.xml.xpath.XPathExpressionException;
21 import org.w3c.dom.Document;
22 
23 /**
24  * Sequence node iterator
25  *
26  * @brief Sequence node iterator
27  * @author Peter Bartoš
28  */
30 
31  /**
32  * Overriden init() method
33  *
34  * @param document XML document whose nodes will be iterated through
35  * @param expr expression according to which iterating will be provided, in this method is ignored, because sequence iterating is used
36  */
37  @Override
38  public void init(Document document, XPathExpression expr) throws XPathExpressionException {
39 
40  timestamp = System.currentTimeMillis();
41 
42  this.document = document;
43  this.nodeList = XPathHelper.evaluateXPath(document, expr);
44  this.currentNodeIndex = 0;
45  firstNode = true;
46 
47  nextNode = document.getDocumentElement();
48  while (nextNode.hasChildNodes()) {
49  nextNode = nextNode.getFirstChild();
50  }
51  }
52 
53  /**
54  * Overriden toString() method
55  *
56  * @return string representation of class
57  */
58  @Override
59  public String toString() {
60  return "Sequence";
61  }
62 } // class SequenceNodeIterator