001/*-----------------------------------------------------------------------+
002 | com.teamscale.checks
003 |                                                                       |
004   $Id$            
005 |                                                                       |
006 | Copyright (c)  2009-2015 CQSE GmbH                                 |
007 +-----------------------------------------------------------------------*/
008package eu.cqse.check.base;
009
010import java.util.List;
011
012import eu.cqse.check.framework.core.CheckException;
013import eu.cqse.check.framework.scanner.IToken;
014import eu.cqse.check.framework.shallowparser.framework.ShallowEntity;
015
016/**
017 * Base class for checks that select entities via xPath and process the tokens
018 * of each selected entity.
019 */
020public abstract class EntityTokenCheckBase extends EntityCheckBase {
021
022        /** {@inheritDoc} */
023        @Override
024        protected void processEntity(ShallowEntity entity) throws CheckException {
025                processTokens(entity.ownStartTokens());
026                if (entity.hasChildren()) {
027                        processTokens(entity.ownEndTokens());
028                }
029        }
030
031        /** Process the start or end tokens for a selected entity. */
032        protected abstract void processTokens(List<IToken> tokens) throws CheckException;
033}