javax.ws.rs.client

Class Entity<T>

  • Type Parameters:
    T - entity type.

    public final class Entity<T>
    extends Object
    Encapsulates message entity including the associated variant information.
    Author:
    Marek Potociar
    • Method Detail

      • entity

        public static <T> Entity<T> entity(T entity,
                                           MediaType mediaType)
        Create an entity using a supplied content media type.
        Type Parameters:
        T - entity Java type.
        Parameters:
        entity - entity data.
        mediaType - entity content type.
        Returns:
        entity instance.
      • entity

        public static <T> Entity<T> entity(T entity,
                                           MediaType mediaType,
                                           Annotation[] annotations)
        Create an entity using a supplied content media type.
        Type Parameters:
        T - entity Java type.
        Parameters:
        entity - entity data.
        mediaType - entity content type.
        annotations - entity annotations.
        Returns:
        entity instance.
      • entity

        public static <T> Entity<T> entity(T entity,
                                           String mediaType)
        Create an entity using a supplied content media type.
        Type Parameters:
        T - entity Java type.
        Parameters:
        entity - entity data.
        mediaType - entity content type.
        Returns:
        entity instance.
        Throws:
        IllegalArgumentException - if the supplied string cannot be parsed or is null.
      • entity

        public static <T> Entity<T> entity(T entity,
                                           Variant variant)
        Create an entity using a supplied content media type.
        Type Parameters:
        T - entity Java type.
        Parameters:
        entity - entity data.
        variant - entity variant information.
        Returns:
        entity instance.
      • entity

        public static <T> Entity<T> entity(T entity,
                                           Variant variant,
                                           Annotation[] annotations)
        Create an entity using a supplied content media type.
        Type Parameters:
        T - entity Java type.
        Parameters:
        entity - entity data.
        variant - entity variant information.
        annotations - entity annotations.
        Returns:
        entity instance.
      • text

        public static <T> Entity<T> text(T entity)
        Create a "text/plain" entity.
        Type Parameters:
        T - entity Java type.
        Parameters:
        entity - entity data.
        Returns:
        "text/plain" entity instance.
      • xml

        public static <T> Entity<T> xml(T entity)
        Create an "application/xml" entity.
        Type Parameters:
        T - entity Java type.
        Parameters:
        entity - entity data.
        Returns:
        "application/xml" entity instance.
      • html

        public static <T> Entity<T> html(T entity)
        Create a "text/html" entity.
        Type Parameters:
        T - entity Java type.
        Parameters:
        entity - entity data.
        Returns:
        "text/html" entity instance.
      • getVariant

        public Variant getVariant()
        Get entity variant information.
        Returns:
        entity variant information.
      • getMediaType

        public MediaType getMediaType()
        Get entity media type.
        Returns:
        entity media type.
      • getEncoding

        public String getEncoding()
        Get entity encoding.
        Returns:
        entity encoding.
      • getLanguage

        public Locale getLanguage()
        Get entity language.
        Returns:
        entity language.
      • getEntity

        public T getEntity()
        Get entity data.
        Returns:
        entity data.
      • getAnnotations

        public Annotation[] getAnnotations()
        Get the entity annotations.
        Returns:
        entity annotations if set, an empty annotation array if no entity annotations have been specified.

Document created the 11/06/2005, last modified the 18/08/2025
Source of the printed document:https://www.gaudry.be/en/java-api-javaee-rf-javax/ws/rs/client/Entity.html

The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.

References

  1. View the html document Language of the document:fr Manuel PHP : https://docs.oracle.com/en/java/, Class Entity

These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author of this site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.