001/**
002 * AbstractSimplePrimitiveGuard.java
003 * 
004 * Copyright (c) 2004-2012, Nicole C. Tedesco. All rights reserved.
005 * 
006 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
007 * use this file except in compliance with the License. You may obtain a copy of
008 * the License at:
009 * 
010 * http://www.apache.org/licenses/LICENSE-2.0
011 * 
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
014 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
015 * License for the specific language governing permissions and limitations under
016 * the License.
017 */
018
019package net.sf.jaccumulator.lex;
020
021import net.sf.jaccumulator.primitives.Primitive;
022
023/**
024 * Common simple (non-composite) {@link Guard Guards} against {@link Primitive}
025 * signals
026 * 
027 * @param <MODEL>
028 *        the model type to test against
029 * 
030 * @since JAccumulator 4.0
031 * @author Nicole Tedesco (<a
032 *         href="mailto:nicole@tedesco.name">nicole@tedesco.name</a>)
033 */
034public abstract class AbstractSimplePrimitiveGuard<MODEL>
035    extends
036        AbstractPrimitiveGuard<MODEL>
037{
038    public AbstractSimplePrimitiveGuard()
039    {
040    }
041
042    @Override
043    public final Logic getChildConjunction()
044    {
045        return Logic.IS;
046    }
047
048    @Override
049    public final NullGuard<MODEL> getNullGuardAt( final int anIndex )
050        throws IndexOutOfBoundsException
051    {
052        throw new IndexOutOfBoundsException("Index: " + anIndex);
053    }
054
055    @Override
056    public final int getNullGuardChildCount()
057    {
058        return 0;
059    }
060
061    @Override
062    public final PrimitiveGuard<MODEL> getPrimitiveGuardAt( final int anIndex )
063        throws IndexOutOfBoundsException
064    {
065        throw new IndexOutOfBoundsException("Index: " + anIndex);
066    }
067
068    @Override
069    public final int getPrimitiveGuardChildCount()
070    {
071        return 0;
072    }
073
074    @Override
075    public final RealGuard<MODEL> getRealGuardAt( final int anIndex )
076        throws IndexOutOfBoundsException
077    {
078        throw new IndexOutOfBoundsException("Index: " + anIndex);
079    }
080
081    @Override
082    public final int getRealGuardChildCount()
083    {
084        return 0;
085    }
086
087    @Override
088    public final ScalarGuard<MODEL> getScalarGuardAt( final int anIndex )
089        throws IndexOutOfBoundsException
090    {
091        throw new IndexOutOfBoundsException("Index: " + anIndex);
092    }
093
094    @Override
095    public final int getScalarGuardChildCount()
096    {
097        return 0;
098    }
099
100    @Override
101    public final TextGuard<MODEL> getTextGuardAt( final int anIndex )
102        throws IndexOutOfBoundsException
103    {
104        throw new IndexOutOfBoundsException("Index: " + anIndex);
105    }
106
107    @Override
108    public final int getTextGuardChildCount()
109    {
110        return 0;
111    }
112
113    @Override
114    public final boolean isCompositeGuard()
115    {
116        return false;
117    }
118
119    @Override
120    public final boolean isSimpleGuard()
121    {
122        return true;
123    }
124}