Class AnnotationLoaderUtil

java.lang.Object
net.sf.basedb.core.snapshot.AnnotationLoaderUtil
All Implemented Interfaces:
Filter<AnnotationSnapshot>

public class AnnotationLoaderUtil extends Object implements Filter<AnnotationSnapshot>
Utility implementation for simple loading of primary annotations via SnapshotManager.
Since:
3.4
Author:
Nicklas
  • Field Details

  • Constructor Details

    • AnnotationLoaderUtil

      public AnnotationLoaderUtil(DbControl dc, SnapshotManager manager, AnnotationType at)
      Create a loder that uses the given snapshot manager to load annotations for a single annotation type. The loader will load only primary annotations.
    • AnnotationLoaderUtil

      public AnnotationLoaderUtil(DbControl dc, SnapshotManager manager, AnnotationType at, boolean searchPrimary, boolean searchInherited)
      Create a loder that uses the given snapshot manager to load annotations for a single annotation type. The loader can be configured to load primary and/or inherited annotations.
      Since:
      3.5
  • Method Details

    • evaluate

      public boolean evaluate(AnnotationSnapshot snapshot)
      Description copied from interface: Filter
      Evaluate if the given object should pass the filter or not.
      Specified by:
      evaluate in interface Filter<AnnotationSnapshot>
      Parameters:
      snapshot - The object to evaluate
      Returns:
      TRUE if the object passes the filter, FALSE otherwise
    • getId

      public int getId()
      The ID of the annotation type that this loader load annotations from.
    • getAnnotationType

      public AnnotationType getAnnotationType()
      The annotation type that this loader load annotations from.
    • useBulletList

      public boolean useBulletList()
      When displaying annotations with multiple values, should use a bullet list be used or a simple comma-separated list. Bullet lists are used for text annotation that are not enumerations.
      Since:
      3.19.9
    • isSearchingPrimaryAnnotations

      public boolean isSearchingPrimaryAnnotations()
      Is this loader searching for primary annotations?
      Since:
      3.5
    • isSearchingInheritedAnnotations

      public boolean isSearchingInheritedAnnotations()
      Is this loader searching for inherited annotations?
      Since:
      3.5
    • find

      public boolean find(AnnotationSetSnapshot setSnapshot)
      Same as findAll but only return a boolean instead of the number of snapshots found.
      Returns:
      TRUE if an annotation was found, FALSE if not
      See Also:
    • find

      public boolean find(AnnotationSetSnapshot setSnapshot, Filter<AnnotationSnapshot> filter)
      Same as findAll but only return a boolean instead of the number of snapshots found.
      Returns:
      TRUE if an annotation was found, FALSE if not
      Since:
      3.11
      See Also:
    • findAll

      public int findAll(AnnotationSetSnapshot setSnapshot)
      Find and load annotations from the given annotation set snapshot.
      Returns:
      The number of snapshots found
      Since:
      3.5
    • findAll

      public int findAll(AnnotationSetSnapshot setSnapshot, Filter<AnnotationSnapshot> filter)
      Find and load annotations from the given annotation set snapshot using an optional extra filter.
      Returns:
      The number of snapshots found
      Since:
      3.11
    • getSnapshot

      public AnnotationSnapshot getSnapshot()
      Get the snapshot for the last annotation found when calling findAll(AnnotationSetSnapshot). Note! If multiple annotation snapshots were found, this will only return the first hit.
      Returns:
      A snapshot or null if no annotations are found
    • getSnapshots

      public List<AnnotationSnapshot> getSnapshots()
      Get all snapshots found by the last findAll(AnnotationSetSnapshot) call.
      Returns:
      A list with AnnotationSnapshot objects
    • getValues

      public List<? extends Serializable> getValues()
      Get the values from the last annotation found when calling find(AnnotationSetSnapshot)
      Returns:
      A list of annotation values or null if no annotations are found
    • getUnit

      public Unit getUnit()
      Get the unit of the last annotation values that was found by find(AnnotationSetSnapshot). Note that if multiple annotations was found with different units the default unit of the annotation type is used.
      Returns:
      A string or null if the annotation doesn't use units
    • getUnitSymbol

      public String getUnitSymbol()
      Get the unit symbol of the last annotation values that was found by find(AnnotationSetSnapshot).
      Returns:
      A string or null if the annotation doesn't use units
    • isInCategoryOrSubtype

      public boolean isInCategoryOrSubtype(AnnotationTypeCategory category, ItemSubtype subtype)
      Checks if this annotation type is related to the given category or subtype. Both parameters may be null in which case TRUE is returned. If the category is not null only AnnotationTypeCategory.isInCategory(AnnotationType) is checked. If the category is null then ItemSubtype.isInRelatedCategory(AnnotationType) is checked.
      Parameters:
      category - An annotation type category or null
      subtype - An item subtype or null
      Since:
      3.20