Return the length of the document content covered by an Annotation as an int -- if the content is too long for an int, the method will throw a GateRuntimeException. Use getLengthLong(SimpleAnnotation ann) if this situation could occur. @param ann the annotation for which to determine the length @ret
(SimpleAnnotation ann)
| 73 | * @return the length of the document content covered by this annotation. |
| 74 | */ |
| 75 | public static int length(SimpleAnnotation ann) { |
| 76 | long len = lengthLong(ann); |
| 77 | if (len > java.lang.Integer.MAX_VALUE) { |
| 78 | throw new GateRuntimeException( |
| 79 | "Length of annotation too big to be returned as an int: "+len); |
| 80 | } else { |
| 81 | return (int)len; |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * Return the length of the document content covered by an Annotation as a |