Class LinkedResources


  • public final class LinkedResources
    extends java.lang.Object
    Represents a set of linked resources (i.e. resources defined by link elements in a Package Document), with predictable iteration order.
    • Field Detail

      • resourcesById

        private final java.util.Map<java.lang.String,​LinkedResource> resourcesById
      • resourcesByURL

        private final com.google.common.collect.ListMultimap<io.mola.galimatias.URL,​LinkedResource> resourcesByURL
    • Constructor Detail

      • LinkedResources

        private LinkedResources​(java.lang.Iterable<LinkedResource> resources)
    • Method Detail

      • getById

        public com.google.common.base.Optional<LinkedResource> getById​(java.lang.String id)
        Search the linked resource with the given ID.
        Parameters:
        id - the ID of the resource to search, can be null.
        Returns:
        An Optional containing the linked resource if found, or Optional.absent() if not found.
      • getByURL

        public java.util.List<LinkedResource> getByURL​(io.mola.galimatias.URL url)
        Search the linked resource with the given URL. All resource whose href URL minus fragment is equal to the given URL are returned, in document order.
        Parameters:
        url - the URL (without fragment) of the resource to search, can be null.
        Returns:
        A list of linked resources referencing the resource at url or a fragment thereof ; an empty list is returned if no such resource is found.
      • asList

        public java.util.List<LinkedResource> asList()
        Returns the list of all linked resources in this set, in document order.
        Returns:
        the list of all linked resources in this set.
      • hasResource

        public boolean hasResource​(io.mola.galimatias.URL url)
        Returns true if this set contains a linked resource referencing the given resource (or fragment thereof).