com.supermap.services.rest.encoders

Class XMLEncoder

  • All Implemented Interfaces:
    javax.ws.rs.ext.MessageBodyWriter


    @Provider
    public class XMLEncoder
    extends Encoder
    implements javax.ws.rs.ext.MessageBodyWriter
    

    ${services_rest_encoders_XMLEncoder_Title}

    ${services_rest_encoders_XMLEncoder_Description}

    • Constructor Summary

      Constructors 
      Constructor and Description
      XMLEncoder()
      The Constructor.
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      protected java.util.List<MediaType> createSupportedMediaTypes()
      ${services_rest_encoders_XMLEncoder_method_createSupportedMediaTypes_Title}
      protected javax.xml.transform.Transformer createTransformer()
      Gets the XML converter The converter instance can handle XML from different sources and write the conversion output to various receivers.
      long getSize(java.lang.Object arg0, java.lang.Class arg1, java.lang.reflect.Type arg2, java.lang.annotation.Annotation[] arg3, javax.ws.rs.core.MediaType arg4)
      Determines the length of the object to be written after serialization.
      boolean isWriteable(java.lang.Class arg0, java.lang.reflect.Type arg1, java.lang.annotation.Annotation[] arg2, javax.ws.rs.core.MediaType arg3)
      Determines whether the present expression supports the representation of the specified media type.
      Representation toRepresentation(MediaType mediaType, java.lang.Object resourceObj)
      ${services_rest_encoders_XMLEncoder_method_toRepresentation_Title}
      void writeTo(java.lang.Object arg0, java.lang.Class arg1, java.lang.reflect.Type arg2, java.lang.annotation.Annotation[] arg3, javax.ws.rs.core.MediaType arg4, javax.ws.rs.core.MultivaluedMap arg5, java.io.OutputStream arg6)
      Generates an HTTP response for the specified media type.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • XMLEncoder

        public XMLEncoder()
        

        The Constructor.

    • Method Detail

      • isWriteable

        public boolean isWriteable(java.lang.Class arg0,
                          java.lang.reflect.Type arg1,
                          java.lang.annotation.Annotation[] arg2,
                          javax.ws.rs.core.MediaType arg3)
        

        Determines whether the present expression supports the representation of the specified media type.

        Specified by:
        isWriteable in interface javax.ws.rs.ext.MessageBodyWriter
        Parameters:
        arg0 - To generate an expression object.
        arg1 - Specifies the media type.
        arg2 - annotation array, the resource has these annotation methods to return to the object to be written.
        arg3 - The media type of the expected response.
        Returns:
        Returns true if this expression generator supports the specified media type, false otherwise.
      • getSize

        public long getSize(java.lang.Object arg0,
                   java.lang.Class arg1,
                   java.lang.reflect.Type arg2,
                   java.lang.annotation.Annotation[] arg3,
                   javax.ws.rs.core.MediaType arg4)
        

        Determines the length of the object to be written after serialization. Is called before the HTTP response is generated.

        Specified by:
        getSize in interface javax.ws.rs.ext.MessageBodyWriter
        Parameters:
        arg0 - To generate an expression object.
        arg1 - The Java class that corresponds to the object to be generated.
        arg2 - To generate an expression object type.
        arg2 - annotation array, the resource has these annotation methods to return to the object to be written.
        arg4 - HTTP The media type of the HTTP response.
        Returns:
        the length of the object to be written.
      • writeTo

        public void writeTo(java.lang.Object arg0,
                   java.lang.Class arg1,
                   java.lang.reflect.Type arg2,
                   java.lang.annotation.Annotation[] arg3,
                   javax.ws.rs.core.MediaType arg4,
                   javax.ws.rs.core.MultivaluedMap arg5,
                   java.io.OutputStream arg6)
                     throws java.io.IOException,
                            javax.ws.rs.WebApplicationException
        

        Generates an HTTP response for the specified media type.

        Specified by:
        writeTo in interface javax.ws.rs.ext.MessageBodyWriter
        Parameters:
        arg0 - To generate an expression object.
        arg1 - The Java class that corresponds to the object to be generated.
        arg2 - To generate an expression object type.
        arg2 - annotation array, the resource has these annotation methods to return to the object to be written.
        arg4 - HTTP The media type of the response.
        arg5 - HTTP Response to the message header.
        arg6 - HTTP Response.
        Throws:
        java.io.IOException - When the read and write process is wrong.
        javax.ws.rs.WebApplicationException - When the HTTP response fails.
      • createSupportedMediaTypes

        protected java.util.List<MediaType> createSupportedMediaTypes()
        

        ${services_rest_encoders_XMLEncoder_method_createSupportedMediaTypes_Title}

        ${services_rest_encoders_XMLEncoder_method_createSupportedMediaTypes_Description}

        Specified by:
        createSupportedMediaTypes in class Encoder
        Returns:
        ${services_rest_encoders_XMLEncoder_method_createSupportedMediaTypes_return}
      • toRepresentation

        public Representation toRepresentation(MediaType mediaType,
                                      java.lang.Object resourceObj)
        

        ${services_rest_encoders_XMLEncoder_method_toRepresentation_Title}

        ${services_rest_encoders_XMLEncoder_method_toRepresentation_Description}

        Specified by:
        toRepresentation in class Encoder
        Parameters:
        mediaType - ${services_rest_encoders_XMLEncoder_method_toRepresentation_param_mediaType}
        resourceObj - ${services_rest_encoders_XMLEncoder_method_toRepresentation_param_resourceObj}
        Returns:
        ${services_rest_encoders_XMLEncoder_method_toRepresentation_return}
      • createTransformer

        protected javax.xml.transform.Transformer createTransformer()
                                                             throws java.io.IOException
        

        Gets the XML converter The converter instance can handle XML from different sources and write the conversion output to various receivers.

        Returns:
        XML converter
        Throws:
        java.io.IOException - The exception is thrown when an error occurs in the read and write process.