001/*-----------------------------------------------------------------------+
002 | com.teamscale.checks
003 |                                                                       |
004   $Id$            
005 |                                                                       |
006 | Copyright (c)  2009-2015 CQSE GmbH                                 |
007 +-----------------------------------------------------------------------*/
008package eu.cqse.check.framework.core.xpath.functions;
009
010import eu.cqse.check.framework.scanner.ETokenType;
011import eu.cqse.check.framework.shallowparser.TokenStreamUtils;
012import eu.cqse.check.framework.shallowparser.framework.ShallowEntity;
013
014/**
015 * A function that is querying for nodes, that contain all given token types.
016 */
017public class AllTokensSelectionFunction extends TokenSelectionFunctionBase {
018
019        /** The function's name. */
020        public static final String NAME = "tokens";
021
022        /** Constructor. */
023        public AllTokensSelectionFunction() {
024                super(NAME);
025        }
026
027        /** {@inheritDoc} */
028        @Override
029        protected boolean checkNode(ShallowEntity node, ETokenType[] arguments) {
030                return TokenStreamUtils.containsAll(node.ownStartTokens(), arguments);
031        }
032}