1 package org.apache.lucene.index; 2 3 18 19 public class SegmentTermPositionVector extends SegmentTermVector implements TermPositionVector { 20 protected int[][] positions; 21 protected TermVectorOffsetInfo[][] offsets; 22 public static final int[] EMPTY_TERM_POS = new int[0]; 23 24 public SegmentTermPositionVector(String field, String terms[], int termFreqs[], int[][] positions, TermVectorOffsetInfo[][] offsets) { 25 super(field, terms, termFreqs); 26 this.offsets = offsets; 27 this.positions = positions; 28 } 29 30 37 public TermVectorOffsetInfo[] getOffsets(int index) { 38 TermVectorOffsetInfo[] result = TermVectorOffsetInfo.EMPTY_OFFSET_INFO; 39 if(offsets == null) 40 return null; 41 if (index >=0 && index < offsets.length) 42 { 43 result = offsets[index]; 44 } 45 return result; 46 } 47 48 53 public int[] getTermPositions(int index) { 54 int[] result = EMPTY_TERM_POS; 55 if(positions == null) 56 return null; 57 if (index >=0 && index < positions.length) 58 { 59 result = positions[index]; 60 } 61 62 return result; 63 } 64 } | Popular Tags |