Implementation of AnnotationSet. Has a number of indices, all bar one of which are null by default and are only constructed when asked for. Has lots of get methods with various selection criteria; these return views into the set, which are nonetheless valid sets in their own right (but will not nece
| 90 | * |
| 91 | */ |
| 92 | public class AnnotationSetImpl extends AbstractSet<Annotation> implements |
| 93 | AnnotationSet { |
| 94 | /** Freeze the serialization UID. */ |
| 95 | static final long serialVersionUID = 1479426765310434166L; |
| 96 | /** The name of this set */ |
| 97 | String name = null; |
| 98 | /** The document this set belongs to */ |
| 99 | DocumentImpl doc; |
| 100 | /** Maps annotation ids (Integers) to Annotations */ |
| 101 | transient protected HashMap<Integer, Annotation> annotsById; |
| 102 | /** Maps offsets (Longs) to nodes */ |
| 103 | transient RBTreeMap<Long,Node> nodesByOffset = null; |
| 104 | /** |
| 105 | * This field is used temporarily during serialisation to store all the |
| 106 | * annotations that need to be saved. At all other times, this will be null; |
| 107 | */ |
| 108 | private Annotation[] annotations; |
| 109 | /** Maps annotation types (Strings) to AnnotationSets */ |
| 110 | transient Map<String, AnnotationSet> annotsByType = null; |
| 111 | /** |
| 112 | * Maps node ids (Integers) to Annotations or a Collection of Annotations that |
| 113 | * start from that node |
| 114 | */ |
| 115 | transient Map<Integer, Object> annotsByStartNode; |
| 116 | protected transient Vector<AnnotationSetListener> annotationSetListeners; |
| 117 | private transient Vector<GateListener> gateListeners; |
| 118 | |
| 119 | /** |
| 120 | * A caching value that greatly improves the performance of get |
| 121 | * methods that have a defined beginning and end. By tracking the |
| 122 | * maximum length that an annotation can be, we know the maximum |
| 123 | * amount of nodes outside of a specified range that must be checked |
| 124 | * to see if an annotation starting at one of those nodes crosses into |
| 125 | * the range. This mechanism is not perfect because we do not check if |
| 126 | * we have to decrease it if an annotation is removed from the set. |
| 127 | * However, usually annotations are removed because they are about to |
| 128 | * be replaced with another one that is >= to the length of the one |
| 129 | * being replaced, so this isn't a big deal. At worst, it means that |
| 130 | * the get methods simply checks a few more start positions than it |
| 131 | * needs to. |
| 132 | */ |
| 133 | protected transient Long longestAnnot = 0l; |
| 134 | |
| 135 | protected RelationSet relations = null; |
| 136 | |
| 137 | // Empty AnnotationSet to be returned instead of null |
| 138 | //public final static AnnotationSet emptyAS; |
| 139 | |
| 140 | //static { |
| 141 | //emptyAnnotationSet = new ImmutableAnnotationSetImpl(null,null); |
| 142 | //} |
| 143 | |
| 144 | /** Construction from Document. */ |
| 145 | public AnnotationSetImpl(Document doc) { |
| 146 | annotsById = new HashMap<Integer, Annotation>(); |
| 147 | this.doc = (DocumentImpl)doc; |
| 148 | } // construction from document |
| 149 |
nothing calls this directly
no test coverage detected