Class FileValueDescriptorIntersector

java.lang.Object
de.xima.fc.workflow.FileValueDescriptorIntersector

public final class FileValueDescriptorIntersector extends Object
  • Method Details

    • contentTypeMatches

      public static boolean contentTypeMatches(Set<String> contentTypes, String contentType)
      Check if a given content type matches the constraints imposed by the content types restriction of a file list descriptor.
      Parameters:
      contentTypes - The content type restriction of a file list descriptor.
      contentType - The content type to check.
      Returns:
      True if the content type matches the restriction, false otherwise.
    • extensionMatches

      public static boolean extensionMatches(Set<String> extensions, String extension)
      Check if a given file extension matches the constraints imposed by the extensions restriction of a file list descriptor.
      Parameters:
      extensions - The extensions restriction of a file list descriptor.
      extension - The file extension to check.
      Returns:
      True if the file extension matches the restriction, false otherwise.
    • intersectContentTypes

      public static Set<String> intersectContentTypes(Set<String> lhs, Set<String> rhs)
      Intersects two sets of content type restrictions. The intersection of two sets of content type restrictions is a new set of content type restrictions that matches every input matched by both restrictions. When the input sets are incompatible, the intersection is an empty set.

      Examples:

          intersectContentTypes(Set.of("text/plain"), Set.of("text/plain")) = Set.of("text/plain")
          intersectContentTypes(Set.of("text/plain"), Set.of("application/json")) = Set.of()
          intersectContentTypes(Set.of("text/plain"), Set.of("text/*")) = Set.of("text/plain")
          intersectContentTypes(Set.of("text/*"), Set.of("application/*")) = Set.of()
          intersectContentTypes(Set.of("text/*"), Set.of("text/*")) = Set.of("text/*")
          intersectContentTypes(Set.of("text/plain", "image/*"), Set.of("text/plain", "image/jpeg"))
            = Set.of("text/plain", "image/png)
          intersectContentTypes(Set.of("*/*"), Set.of("text/*")) = Set.of("text/*")
          intersectContentTypes(Set.of("*/*"), Set.of("text/plain")) = Set.of("text/plain")
      
      Parameters:
      lhs - The left hand side set of content type restrictions.
      rhs - The right hand side set of content type restrictions.
      Returns:
      The intersected set of content type restrictions.
    • intersectContentTypes

      public static String intersectContentTypes(String lhs, String rhs)
      Intersects two content type restrictions from a file list descriptor. The intersection of two content type restrictions is a new content type restriction that matches those content types that are matched by both given restrictions. When the input content type restrictions are incompatible, the intersection is null.
      Parameters:
      lhs - The left hand side content type restriction.
      rhs - The right hand side content type restriction.
      Returns:
      The intersected content type restriction, or null if the content type restrictions are incompatible.
    • intersectExtensions

      public static Set<String> intersectExtensions(Set<String> lhs, Set<String> rhs)
      Intersects two sets of extension restrictions. The intersection of two sets of extension restrictions is a new set of extension restrictions that matches every input matched by both restrictions. When the input sets are incompatible, the intersection is an empty set.

      Examples:

          intersectExtensions(Set.of("pdf"), Set.of("pdf")) = Set.of("pdf")
          intersectExtensions(Set.of("pdf"), Set.of("png")) = Set.of()
          intersectExtensions(Set.of("pdf"), Set.of("*")) = Set.of("pdf")
          intersectExtensions(Set.of("*"), Set.of("*")) = Set.of("*")
          intersectExtensions(Set.of("pdf", "*"), Set.of("*")) = Set.of("*")
      
      Parameters:
      lhs - The left hand side set of extension restrictions.
      rhs - The right hand side set of extension restrictions.
      Returns:
      The intersected set of content type restrictions.
    • intersectExtensions

      public static String intersectExtensions(String lhs, String rhs)
      Intersects two extension restrictions from a file list descriptor. The intersection of two extension restriction is a new extension restriction that matches those content types that are matched by both given restrictions. When the input extension restrictions are incompatible, the intersection is null.
      Parameters:
      lhs - The left hand side extension restriction.
      rhs - The right hand side extension restriction.
      Returns:
      The intersected extension restriction, or null if the extension restrictions are incompatible.
    • intersectFileListDescriptors

      public static IFileListDescriptor intersectFileListDescriptors(IFileListDescriptor lhs, IFileListDescriptor rhs)
      Intersects two file list descriptors. The intersection of two file list descriptors is a new file list descriptor that allows only files that is allowed by both input descriptors, but no other files. When the input descriptors are incompatible, the intersection is an empty file list descriptor.

      This operation is, for the most part, symmetric / commutative. The only exception is the attribute map of the files. When both input descriptors have an attribute with the same key but different values, the value from the right hand side is used.

      Parameters:
      lhs - The left hand side file list descriptor.
      rhs - The right hand side file list descriptor.
      Returns:
      The intersected file list descriptor.
    • intersectFileValueDescriptors

      public static IFileValueDescriptor intersectFileValueDescriptors(IFileValueDescriptor lhs, IFileValueDescriptor rhs)
      Intersects two file value descriptors. The intersection of two file value descriptors is a new file value descriptor that allows only files that is allowed by both input descriptors, but no other files. When the input descriptors are incompatible, the intersection is an empty file value descriptor.

      If the left hand side is null, the right hand side is returned. If the right hand side is null, the left hand side is returned. If both are null, an empty file value descriptor is returned. Effectively, this means that null is treated as a wildcard that matches any file.

      Parameters:
      lhs - The left hand side file value descriptor.
      rhs - The right hand side file value descriptor.
      Returns:
      The intersected file value descriptor.
    • intersectMimeTypes

      @Deprecated public static String intersectMimeTypes(String lhs, String rhs)
      Deprecated.
      Intersects two mime types. The intersection of two mime types is a new mime type that matches both input mime types. When the input mime types are incompatible, the intersection is null.
      Parameters:
      lhs - The left hand side mime type.
      rhs - The right hand side mime type.
      Returns:
      The intersected mime type or null if the mime types are incompatible.