I am currently making some changes in the default pattern capture group token filter code to meet my requirement. I am a beginner in JAVA so finding it a bit hard to fully understand the code and make changes, I have successfully done my changes in the increment token() method and got the desired result as per my requirement. But, currently I am stuck while making changes in the preserve original part of the code.
I only want help regarding understanding the following code and rest I will do the changes myself. Can anyone please help in understanding the working of this code like what is happening here? if (preserveOriginal) { currentMatcher = 0; // offsetAtt.setOffset(222, 333); // offsetAtt.setOffset(offsetAtt.startOffset() , offsetAtt.endOffset()); } else if (nextCapture()) { final int start = matchers[currentMatcher] .start(currentGroup[currentMatcher]); final int end = matchers[currentMatcher] .end(currentGroup[currentMatcher]); // if we start at 0 we can simply set the length and save the copy if (start == 0) { charTermAttr.setLength(end); } else { charTermAttr.copyBuffer(spare.chars(), start, end - start); } currentGroup[currentMatcher]++; } Link to the entire code file is: https://www.tabnine.com/web/assistant/code/rs/5c65edff1095a500018f6f23#L141 Any help will be very useful. Regards, Dishant