/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package net.domesdaybook.matcher.singlebyte;

import net.domesdaybook.matcher.sequence.SequenceMatcher;

/**
 *
 * @author matt
 */
public abstract class AbstractSingleByteSequence implements SingleByteMatcher {
    
 /**
     * @inheritDoc
     * 
     * Returns this for position 0, null otherwise.
     */
    @Override
    public SingleByteMatcher getByteMatcherForPosition(final int position) {
        return position == 0 ? this : null;
    }

    
    /**
     * {@inheritDoc}
     *
     * Always returns 1.
     */ 
    @Override
    public int length() {
        return 1;
    }
    

    /**
     * {@inheritDoc}
     *
     * Always returns this.
     */ 
    @Override
    public SequenceMatcher reverse() {
        return this;
    }    
    
    
}

@@ -382,22 +382,46 @@
  0, 
-null otherwise
+or throws an IndexOutOfBoundsException
 .%0A  
@@ -525,23 +525,20 @@
         
-return 
+if (
 position
@@ -546,22 +546,147 @@
 == 0
- ? this : null
+) %7B%0A            return this;%0A        %7D%0A        throw new IndexOutOfBoundsException(%22SingleByteMatchers only have a matcher at position 0.%22)
 ;%0A  

Make single byte matchers throw an indexoutofboundsexception if an attempt is made to get a singlebytematcher other than in position zero.