001/* 002 * BioJava development code 003 * 004 * This code may be freely distributed and modified under the 005 * terms of the GNU Lesser General Public Licence. This should 006 * be distributed with the code. If you do not have a copy, 007 * see: 008 * 009 * http://www.gnu.org/copyleft/lesser.html 010 * 011 * Copyright for this code is held jointly by the individual 012 * authors. These should be listed in @author doc comments. 013 * 014 * For more information on the BioJava project and its aims, 015 * or to join the biojava-l mailing list, visit the home page 016 * at: 017 * 018 * http://www.biojava.org/ 019 * 020 */ 021 022package org.biojava.bio.search; 023 024import org.biojava.bio.symbol.SymbolList; 025 026/** 027 * Interface for things that perform matches. 028 * 029 * <p> 030 * These will almost always be produced by a factory method on a BioPattern 031 * object. 032 * </p> 033 * 034 * @author Matthew Pocock 035 */ 036public interface BioMatcher { 037 /** 038 * Attempt to find the next match. 039 * 040 * <p> 041 * If the pattern can be found, then this will return true. If it could not, 042 * then it will return false. This is convenient within for or while loops. 043 * </p> 044 * 045 * <p> 046 * Each time this is called, the next match will be found. The start() and 047 * end() values will increase each time, regardless of wether you called any 048 * other methods. 049 * </p> 050 * 051 * @return true if there is another match 052 */ 053 boolean find(); 054 055 /** 056 * Get the first symbol index that matches the pattern. 057 * 058 * @return the start of the current match 059 * @throws java.lang.IllegalStateException if there is no current match 060 */ 061 int start(); 062 063 /** 064 * Get the last symbol index that matches the pattern. 065 * 066 * @return the end of the current match 067 * @throws java.lang.IllegalStateException if there is no current match 068 */ 069 int end(); 070 071 /** 072 * Get the matching region as a SymbolList. 073 * 074 * @return the matching symbols 075 * @throws java.lang.IllegalStateException if there is no current match 076 */ 077 SymbolList group(); 078 079}