Class WebContent


  • public class WebContent
    extends java.lang.Object
    • Constructor Detail

      • WebContent

        public WebContent()
    • Method Detail

      • contentTypeCanonical

        public static java.lang.String contentTypeCanonical​(java.lang.String contentType)
        Return our "canonical" name for a Content Type. This should be the standard one, no X-*, no alternative names.
      • matchContentType

        public static boolean matchContentType​(ContentType ct1,
                                               ContentType ct2)
        Match content type (ignores charsets and other parameters)
      • matchContentType

        public static boolean matchContentType​(java.lang.String ct1,
                                               java.lang.String ct2)
      • isHtmlForm

        public static boolean isHtmlForm​(ContentType ct)
      • isMultiPartForm

        public static boolean isMultiPartForm​(ContentType ct)
      • determineCT

        public static ContentType determineCT​(java.lang.String contentTypeStr,
                                              Lang hintLang,
                                              java.lang.String target)

        Determine the content type to be used, given the target URL, the content-type from Content Negotiation and a hint language. This is a pragmatic balance. A content-type of "text/plain" is ignored - it is too often wrong.

        The decision is

        Content type (but not text/plain) > hint > file extension.
        We make content type (via content negotiation) strongest because a server may return something unexpected because that is all it can do. We are assuming servers don't lie. The "hint" is really a hint just for file extension override.

        In the case of no file extension, this reduces to the hint being the default choice if conneg does not produce anything useful.

        Parameters:
        contentTypeStr - Content-Type string
        hintLang - Default language
        target - The URL of the target (file extension may be used)
        Returns:
        ContentType or null
      • contentTypeToLangResultSet

        public static Lang contentTypeToLangResultSet​(java.lang.String contentType)
        Map content-type to lang for SPARQL results, with pragmatic adapters.