Class MediaTypes

java.lang.Object
com.codename1.backend.web.MediaTypes

public final class MediaTypes extends Object

Media-type matching for a route's consumes and produces, called by the generated router before it binds anything.

Type names are compared without case folding through toLowerCase, which is locale sensitive; parameters (; charset=utf-8) are ignored, and either side may use a * wildcard for the type or the subtype.

Internal to generated code.

  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    acceptable(String accept, String offered)
    Whether a request whose Accept header is accept takes any of offered, a comma separated list; when it does not, the route answers 406.
    static boolean
    consumable(String contentType, String accepted)
    Whether a request whose Content-Type is contentType may reach a route that consumes accepted, a comma separated list.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • consumable

      public static boolean consumable(String contentType, String accepted)
      Whether a request whose Content-Type is contentType may reach a route that consumes accepted, a comma separated list. A request with no Content-Type is not consumable: it is answered 415, as Spring answers it.
    • acceptable

      public static boolean acceptable(String accept, String offered)
      Whether a request whose Accept header is accept takes any of offered, a comma separated list; when it does not, the route answers 406. No Accept header accepts anything, and a range with q=0 accepts nothing.