private ObservableIndexedDocument( DocumentHandler<N, E, T> handler, RawDocument<N, E, T> substrate, AnnotationTree<Object> annotations, DocumentSchema schema) { super(substrate, annotations, schema); AnnotationSetListener<Object> listener = new AnnotationSetListener<Object>() { @Override public void onAnnotationChange(int start, int end, String key, Object newValue) { event(new AnnotationChanged<N, E, T>(start, end, key, (String) newValue)); } }; annotations.setListener(listener); this.handler = handler; }