// Entry<Integer, RutaBasic> floorEntry = endAnchors.floorEntry(anchor);
// Entry<Integer, RutaBasic> ceilingEntry = endAnchors.ceilingEntry(anchor);
// if (floorEntry != null && ceilingEntry != null) {
// RutaBasic floor = floorEntry.getValue();
// RutaBasic ceiling = ceilingEntry.getValue();
RutaBasic floor = getFloor(endAnchors, anchor);
if (floor == null) {
floor = getFloor(beginAnchors, anchor);
}
RutaBasic ceiling = getCeiling(endAnchors, anchor);
if (floor != null && ceiling != null) {
RutaBasic toSplit = null;
if (floor.getEnd() > anchor) {
toSplit = floor;
} else {
toSplit = ceiling;
}
int newEnd = toSplit.getEnd();
cas.removeFsFromIndexes(toSplit);
toSplit.setEnd(anchor);
RutaBasic newTMB = new RutaBasic(getJCas(), anchor, newEnd);
newTMB.setLowMemoryProfile(lowMemoryProfile);
cas.addFsToIndexes(toSplit);
cas.addFsToIndexes(newTMB);
beginAnchors.put(floor.getBegin(), floor);
beginAnchors.put(newTMB.getBegin(), newTMB);
beginAnchors.put(ceiling.getBegin(), ceiling);
endAnchors.put(floor.getEnd(), floor);
endAnchors.put(newTMB.getEnd(), newTMB);
endAnchors.put(ceiling.getEnd(), ceiling);
return true;
} else {
// TODO this should never happen! test it!
}