| 339 | } |
| 340 | |
| 341 | public static AnnotationSet getAnnotationsEndingAtOffset(AnnotationSet annotationSet, Long endOffset) { |
| 342 | List<Annotation> endsAt = new ArrayList<Annotation>(); |
| 343 | |
| 344 | // start can't be negative |
| 345 | Long start = endOffset > 0 ? endOffset - 1 : 0; |
| 346 | |
| 347 | // it seems we can ask for beyond the document without error |
| 348 | Long end = endOffset + 1; |
| 349 | |
| 350 | // get annotations that overlap this bit |
| 351 | AnnotationSet annotations = annotationSet.get(start,end); |
| 352 | |
| 353 | // filter to get just those that end at the offset |
| 354 | for (Annotation a : annotations) { |
| 355 | if (a.getEndNode().getOffset().equals(endOffset)) { |
| 356 | endsAt.add(a); |
| 357 | } |
| 358 | } |
| 359 | |
| 360 | // return the annotations we've found, if any |
| 361 | return Factory.createImmutableAnnotationSet(annotationSet.getDocument(), endsAt); |
| 362 | } |
| 363 | |
| 364 | /** |
| 365 | * Get all the annotations from the source annotation set that lie within |