Hit.java
001 /*
002  *  Hit.java
003  *
004  *  Niraj Aswani, 19/March/07
005  *
006  *  $Id: Hit.html,v 1.0 2007/03/19 16:22:01 niraj Exp $
007  */
008 package gate.creole.annic;
009 
010 /**
011  * Hit is a unit of result that is returned when user searches the annic
012  * index. It stores the four things: document ID (String), start and end
013  * offsets (int) and the query that matched this hit.
014  
015  @author niraj
016  
017  */
018 public class Hit implements java.io.Serializable {
019 
020   /**
021    * serial version id
022    */
023   private static final long serialVersionUID = 3257562927719658297L;
024 
025   /**
026    * Start OFfset of the found pattern
027    */
028   protected int startOffset;
029 
030   /**
031    * End Offset of the found pattern
032    */
033   protected int endOffset;
034 
035   /**
036    * Document ID - the document this Hit belongs to
037    */
038   protected String documentID;
039 
040   /**
041    * Annotation Set Name - the annotation set this Hit belongs to
042    */
043   protected String annotationSetName;
044   
045   /**
046    * Query that matches with this instance of Hit.
047    */
048   protected String queryString;
049 
050   /**
051    * Constructor
052    @param docID
053    @param annotationSetName
054    @param startOffset
055    @param endOffset
056    @param queryString
057    */
058   public Hit(String docID, String annotationSetName, int startOffset, int endOffset, String queryString) {
059     this.documentID = docID;
060     this.annotationSetName = annotationSetName;
061     this.startOffset = startOffset;
062     this.endOffset = endOffset;
063     this.queryString = queryString;
064   }
065 
066   /**
067    * Returns the start offset of the matching part (query matched part)
068    
069    @return
070    */
071   public int getStartOffset() {
072     return startOffset;
073   }
074 
075   /**
076    * Returns the end offset of the matching part (query matched part)
077    
078    @return
079    */
080   public int getEndOffset() {
081     return endOffset;
082   }
083 
084   /**
085    * Returns the document ID
086    
087    @return
088    */
089   public String getDocumentID() {
090     return this.documentID;
091   }
092 
093   /**
094    * Returns the query for which the current pattern was matched
095    
096    @return
097    */
098   public String getQueryString() {
099     return this.queryString;
100   }
101 
102   /**
103    * Returns the annotation set this pattern belongs to.
104    @return
105    */
106   public String getAnnotationSetName() {
107     return annotationSetName;
108   }
109 
110 }