1 17 package org.alfresco.repo.search.impl.lucene.query; 18 19 import java.io.IOException ; 20 21 27 public class AnyStructuredFieldPosition extends AbstractStructuredFieldPosition 28 { 29 30 33 public AnyStructuredFieldPosition(String termText) 34 { 35 super(termText, true, false); 36 if (termText == null) 37 { 38 setTerminal(false); 39 } 40 } 41 42 public AnyStructuredFieldPosition() 43 { 44 super(null, false, false); 45 } 46 47 53 public int matches(int start, int end, int offset) throws IOException 54 { 55 if (getCachingTermPositions() != null) 57 { 58 setTerminal(true); 59 int realPosition = 0; 60 int adjustedPosition = 0; 61 getCachingTermPositions().reset(); 62 int count = getCachingTermPositions().freq(); 63 for (int i = 0; i < count; i++) 64 { 65 realPosition = getCachingTermPositions().nextPosition(); 66 adjustedPosition = realPosition - start; 67 if ((end != -1) && (realPosition > end)) 68 { 69 return -1; 70 } 71 if (adjustedPosition > offset) 72 { 73 return adjustedPosition; 74 } 75 } 76 } 77 else 78 { 79 setTerminal(false); 81 return offset; 82 } 83 return -1; 84 } 85 86 public String getDescription() 87 { 88 return "Any"; 89 } 90 91 } 92 | Popular Tags |