Package eu.clarin.sru.client.fcs
Class DataViewHits
- java.lang.Object
-
- eu.clarin.sru.client.fcs.DataView
-
- eu.clarin.sru.client.fcs.DataViewHits
-
- Direct Known Subclasses:
DataViewHitsWithLexAnnotations
public class DataViewHits extends DataView
A Data View implementation that stores the content of a HITS Data View.
-
-
Field Summary
Fields Modifier and Type Field Description protected intmax_offsetstatic StringTYPEThe MIME type for CLARIN-FCS KWIC data views.
-
Constructor Summary
Constructors Modifier Constructor Description protectedDataViewHits(String pid, String ref, String text, int[] offsets, int offsets_idx)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetHitCount()Get the total number of hits in the result.int[]getHitOffsets(int idx)Get the offsets pointing to range in the text content that yield the hit.StringgetText()Get the text content of the hit.-
Methods inherited from class eu.clarin.sru.client.fcs.DataView
getMimeType, getPid, getRef, isMimeType
-
-
-
-
Field Detail
-
TYPE
public static final String TYPE
The MIME type for CLARIN-FCS KWIC data views.- See Also:
- Constant Field Values
-
max_offset
protected final int max_offset
-
-
Constructor Detail
-
DataViewHits
protected DataViewHits(String pid, String ref, String text, int[] offsets, int offsets_idx)
Constructor.- Parameters:
pid- a persistent identifier ornullref- a reference URI ornulltext- the textual content of the hitsoffsets- an array of (start, end) offset pairs that indicate the part of the text, that is considered a hitoffsets_idx- the largest index (= hit_count * 2) within the offsets array plus one- Throws:
NullPointerException- if any mandatory argument isnullIllegalArgumentException- if any argument is illegal
-
-
Method Detail
-
getHitCount
public int getHitCount()
Get the total number of hits in the result.- Returns:
- the number of hits
-
getText
public String getText()
Get the text content of the hit. Usually this is complete sentence.- Returns:
- the text content of the hit
-
getHitOffsets
public int[] getHitOffsets(int idx)
Get the offsets pointing to range in the text content that yield the hit.- Parameters:
idx- the hit to retrieve. Must be larger than0and smaller than the result ofgetHitCount().- Returns:
- An array of two elements. The first array element is the start offset, the second array element is the end offset of the hit range.
- Throws:
ArrayIndexOutOfBoundsException- of theidxargument is out of bounds.
-
-