Class ExternalResource

  • All Implemented Interfaces:
    Resource, Serializable

    public class ExternalResource
    extends Object
    implements Resource
    ExternalResource implements source for resources fetched from location specified by URL:s. The resources are fetched directly by the client terminal and are not fetched through the terminal adapter.
    Since:
    3.0
    Author:
    Vaadin Ltd.
    See Also:
    Serialized Form
    • Constructor Detail

      • ExternalResource

        public ExternalResource​(URL sourceURL)
        Creates a new resource instance for processing the resource directly from the given URL.

        The given source URL will be validated against the "safeUrlSchemes" configuration.

        Parameters:
        sourceURL - the source URL
        Throws:
        IllegalArgumentException - if sourceURL uses a scheme that is not considered safe
      • ExternalResource

        public ExternalResource​(URL sourceURL,
                                String mimeType)
        Creates a new resource instance for processing the resource directly from the given URL.

        The given source URL will be validated against the "safeUrlSchemes" configuration.

        Parameters:
        sourceURL - the source URL
        mimeType - the MIME Type
        Throws:
        IllegalArgumentException - if sourceURL uses a scheme that is not considered safe
      • ExternalResource

        public ExternalResource​(String sourceURL)
        Creates a new resource instance for processing the resource directly from the given URL.

        The given source URL will be validated against the "safeUrlSchemes" configuration.

        Parameters:
        sourceURL - the source URL
        Throws:
        IllegalArgumentException - if sourceURL uses a scheme that is not considered safe
      • ExternalResource

        public ExternalResource​(String sourceURL,
                                String mimeType)
        Creates a new resource instance for processing the resource directly from the given URL.

        The given source URL will be validated against the "safeUrlSchemes" configuration.

        Parameters:
        sourceURL - the source URL.
        mimeType - the MIME Type
        Throws:
        IllegalArgumentException - if sourceURL uses a scheme that is not considered safe
      • ExternalResource

        public ExternalResource​(URL sourceURL,
                                boolean allowUnsafe)
        Creates a new resource instance for processing the resource directly from the given URL.

        If the given allowUnsafe parameter is false, the given source URL will be validated against the "safeUrlSchemes" configuration. Otherwise all URLs will be considered safe and the given URL won't be validated.

        Parameters:
        sourceURL - the source URL
        allowUnsafe - true for skipping the URL validation, false otherwise
        Throws:
        IllegalArgumentException - if sourceURL uses a scheme that is not considered safe
        Since:
      • ExternalResource

        public ExternalResource​(URL sourceURL,
                                String mimeType,
                                boolean allowUnsafe)
        Creates a new resource instance for processing the resource directly from the given URL.

        If the given allowUnsafe parameter is false, the given source URL will be validated against the "safeUrlSchemes" configuration. Otherwise all URLs will be considered safe and and the given URL won't be validated.

        Parameters:
        sourceURL - the source URL
        mimeType - the MIME Type
        allowUnsafe - true for skipping the URL validation, false otherwise
        Throws:
        IllegalArgumentException - if sourceURL uses a scheme that is not considered safe
        Since:
      • ExternalResource

        public ExternalResource​(String sourceURL,
                                boolean allowUnsafe)
        Creates a new resource instance for processing the resource directly from the given URL.

        If the given allowUnsafe parameter is false, the given source URL will be validated against the "safeUrlSchemes" configuration. Otherwise all URLs will be considered safe and and the given URL won't be validated.

        Parameters:
        sourceURL - the source URL
        allowUnsafe - true for skipping the URL validation, false otherwise
        Throws:
        IllegalArgumentException - if sourceURL uses a scheme that is not considered safe
        Since:
      • ExternalResource

        public ExternalResource​(String sourceURL,
                                String mimeType,
                                boolean allowUnsafe)
        Creates a new resource instance for processing the resource directly from the given URL.

        If the given allowUnsafe parameter is false, the given source URL will be validated against the "safeUrlSchemes" configuration. Otherwise all URLs will be considered safe and and the given URL won't be validated.

        Parameters:
        sourceURL - the source URL
        mimeType - the MIME Type
        allowUnsafe - true for skipping the URL validation, false otherwise
        Throws:
        IllegalArgumentException - if sourceURL uses a scheme that is not considered safe
        Since:
    • Method Detail

      • getURL

        public String getURL()
        Gets the URL of the external resource.
        Returns:
        the URL of the external resource.
      • setMIMEType

        public void setMIMEType​(String mimeType)
        Sets the MIME type of the resource.