public void setDocument(DocumentImpl doc, int newMode) {
   document = doc;
   mode = newMode;
   IndexSpec indexConf = document.getCollection().getIndexConfiguration(document.getBroker());
   if (indexConf != null) config = indexConf.getFulltextIndexSpec();
   engine.setDocument(document);
 }
 public StoredNode getReindexRoot(StoredNode node, NodePath path, boolean includeSelf) {
   if (node.getNodeType() == Node.ATTRIBUTE_NODE) return null;
   IndexSpec indexConf =
       node.getDocument().getCollection().getIndexConfiguration(node.getDocument().getBroker());
   if (indexConf != null) {
     FulltextIndexSpec config = indexConf.getFulltextIndexSpec();
     if (config == null) return null;
     boolean reindexRequired = false;
     int len =
         node.getNodeType() == Node.ELEMENT_NODE && !includeSelf
             ? path.length() - 1
             : path.length();
     for (int i = 0; i < len; i++) {
       QName qn = path.getComponent(i);
       if (config.hasQNameIndex(qn)) {
         reindexRequired = true;
         break;
       }
     }
     if (reindexRequired) {
       StoredNode topMost = null;
       StoredNode currentNode = node;
       while (currentNode != null) {
         if (config.hasQNameIndex(currentNode.getQName())) topMost = currentNode;
         currentNode = (StoredNode) currentNode.getParentNode();
       }
       return topMost;
     }
   }
   return null;
 }