/*
 *  eXist Open Source Native XML Database
 *  Copyright (C) 2001-2015 The eXist Project
 *  http://exist-db.org
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public License
 *  as published by the Free Software Foundation; either version 2
 *  of the License, or (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
package org.exist.indexing;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.exist.dom.persistent.AttrImpl;
import org.exist.dom.persistent.ElementImpl;
import org.exist.dom.persistent.AbstractCharacterData;
import org.exist.storage.NodePath;
import org.exist.storage.txn.Txn;

/**
 * Default implementation of a StreamListener. By default forwards all events to
 * the next listener in the chain (if there is any). Overwrite methods to handle events
 * (but don't forget to call the super method as well).
 */
public abstract class AbstractStreamListener implements StreamListener {

    protected final static Logger LOG = LogManager.getLogger(AbstractStreamListener.class);
    
    private StreamListener next = null;

    @Override
    public void setNextInChain(StreamListener listener) {
        this.next = listener;
    }

    @Override
    public StreamListener getNextInChain() {
        return next;
    }

    @Override
    public void startElement(Txn transaction, ElementImpl element, NodePath path) {
        if (next != null)
            {next.startElement(transaction, element, path);}
    }

    @Override
    public void attribute(Txn transaction, AttrImpl attrib, NodePath path) {
        if (next != null) {
            next.attribute(transaction, attrib, path);
        }
    }

    @Override
    public void endElement(Txn transaction, ElementImpl element, NodePath path) {
        if (next != null) {
            next.endElement(transaction, element, path);
        }
    }

    @Override
    public void characters(Txn transaction, AbstractCharacterData text, NodePath path) {
        if (next != null) {
            next.characters(transaction, text, path);
        }
    }

    @Override
    public abstract IndexWorker getWorker();
}

@@ -1676,16 +1676,22 @@
 InChain(
+final 
 StreamLi
@@ -1868,32 +1868,38 @@
 id startElement(
+final 
 Txn transaction,
@@ -1890,32 +1890,38 @@
 Txn transaction,
+ final
  ElementImpl ele
@@ -1917,32 +1917,38 @@
 entImpl element,
+ final
  NodePath path) 
@@ -1974,16 +1974,18 @@
 != null)
+ %7B
 %0A       
@@ -1989,17 +1989,16 @@
         
-%7B
 next.sta
@@ -2035,16 +2035,25 @@
 , path);
+%0A        
 %7D%0A    %7D%0A
@@ -2093,16 +2093,22 @@
 tribute(
+final 
 Txn tran
@@ -2115,16 +2115,22 @@
 saction,
+ final
  AttrImp
@@ -2138,16 +2138,22 @@
  attrib,
+ final
  NodePat
@@ -2303,16 +2303,22 @@
 Element(
+final 
 Txn tran
@@ -2325,16 +2325,22 @@
 saction,
+ final
  Element
@@ -2352,16 +2352,22 @@
 element,
+ final
  NodePat
@@ -2519,16 +2519,22 @@
 racters(
+final 
 Txn tran
@@ -2541,16 +2541,22 @@
 saction,
+ final
  Abstrac
@@ -2575,16 +2575,22 @@
 ta text,
+ final
  NodePat
@@ -2700,67 +2700,7 @@
    %7D
-%0A%0A    @Override%0A    public abstract IndexWorker getWorker();
 %0A%7D%0A

Reformat code layout