1 11 package org.eclipse.jface.text.source.projection; 12 13 import java.util.HashSet ; 14 import java.util.Iterator ; 15 import java.util.Set ; 16 17 import org.eclipse.jface.text.source.Annotation; 18 19 27 public class AnnotationBag extends Annotation { 28 29 private Set fAnnotations; 30 31 36 public AnnotationBag(String type) { 37 super(type, false, null); 38 } 39 40 45 public void add(Annotation annotation) { 46 if (fAnnotations == null) 47 fAnnotations= new HashSet (2); 48 fAnnotations.add(annotation); 49 } 50 51 56 public void remove(Annotation annotation) { 57 if (fAnnotations != null) { 58 fAnnotations.remove(annotation); 59 if (fAnnotations.isEmpty()) 60 fAnnotations= null; 61 } 62 } 63 64 69 public boolean isEmpty() { 70 return fAnnotations == null; 71 } 72 73 80 public Iterator iterator() { 81 if (!isEmpty()) 82 return fAnnotations.iterator(); 83 return null; 84 } 85 } 86 | Popular Tags |