Class GenericAnnotations

    • Constructor Detail

      • GenericAnnotations

        public GenericAnnotations()
        Creates an empty annotation set.
      • GenericAnnotations

        public GenericAnnotations​(String storage)
        Creates an annotation set initialized with a storage string created with toString().
        Parameters:
        storage - the storage string to use.
      • GenericAnnotations

        public GenericAnnotations​(GenericAnnotation annotation)
        Creates an annotation set and add a given one.
        Parameters:
        annotation - the annotation to add.
    • Method Detail

      • createFromString

        public static GenericAnnotations createFromString​(String storage)
        Creates a new GenericAnnotations object from a storage string.
        Parameters:
        storage - the serialized representation of the object.
        Returns:
        a new GenericAnnotations object.
      • addAnnotations

        public static void addAnnotations​(IWithAnnotations nameable,
                                          GenericAnnotations newSet)
        Adds a set of annotations to a given INameable object (e.g. TextUnit, TextContainer, etc.). If the object has no annotation set already attached, one is created and attached, otherwise all the annotations of the set passed as argument are added to the existing set.
        Parameters:
        nameable - the object where to attached the new set.
        newSet - the new set to add (can be null: then nothing is attached).
      • addAnnotations

        public static void addAnnotations​(Code code,
                                          GenericAnnotations newSet)
        Adds a set of annotations to a given inline code. If the inline code has no annotation set attached yet one is created and attached, otherwise all the annotations of the set passed as argument are added to the existing set.
        Parameters:
        code - the code where to add the annotation.
        newSet - the new set to add (can be null: then nothing is attached).
      • size

        public int size()
        Gets the number of annotations in this annotation set.
        Returns:
        the number of annotations in this annotation set.
      • isEmpty

        public boolean isEmpty()
        Returns true if there are terms in this annotation.
        Returns:
        true if terms exist in this annotation.
      • getAnnotations

        public List<GenericAnnotation> getAnnotations​(String type)
        Gets a list of all the annotations of a given type.

        The returned list is a new list but its items are the same as the items in the original list.

        Parameters:
        type - the type of annotation to look for.
        Returns:
        the list of all annotations of the given type, the list may be empty but is never null.
      • getFirstAnnotation

        public GenericAnnotation getFirstAnnotation​(String type)
        Gets the first occurrence of an annotation for a given type.
        Parameters:
        type - the type of annotation to retrieve.
        Returns:
        the first annotation of the given type, or null if none exists.
      • getAllAnnotations

        public List<GenericAnnotation> getAllAnnotations()
        Gets the unmodifiable list of all the annotation in this annotation set.
        Returns:
        the live list, or an empty one if there are no annotations.
      • hasAnnotation

        public boolean hasAnnotation​(String type)
        Indicates if there is at least one annotation of a given type.
        Parameters:
        type - the type of annotation to look for.
        Returns:
        true if there is at least one annotation of a given type, false otherwise.
      • clear

        public void clear()
        Removes all annotations from this list.
      • remove

        public void remove​(GenericAnnotation annotation)
        Removes a given annotation from this list.
        Parameters:
        annotation - the annotation to remove.
      • add

        public GenericAnnotation add​(String type)
        Creates an new annotation and add it to this object.
        Parameters:
        type - the type of annotation to create.
        Returns:
        the new annotation.
      • add

        public void add​(GenericAnnotation annotation)
        Adds an existing annotation to this object.
        Parameters:
        annotation - the annotation to add.
      • addAll

        public void addAll​(GenericAnnotations annotations)
        Adds all annotations of a given set of annotations to this object.
        Parameters:
        annotations - the set of annotations to add.
      • addAll

        public void addAll​(List<GenericAnnotation> newItems)
        Adds all the annotations from a given list to this object.
        Parameters:
        newItems - the list of annotations to add.
      • toString

        public String toString()
        Description copied from class: InlineAnnotation
        Gets a storage string representation of the whole annotation that can be used for serialization.
        Specified by:
        toString in interface IAnnotation
        Overrides:
        toString in class InlineAnnotation
        Returns:
        The storage string representation of this annotation.