Class JsonStructureBodyWriter

  • All Implemented Interfaces:
    javax.ws.rs.ext.MessageBodyWriter<JsonStructure>

    @Provider
    @Produces({"application/json","text/json","*/*"})
    public class JsonStructureBodyWriter
    extends java.lang.Object
    implements javax.ws.rs.ext.MessageBodyWriter<JsonStructure>
    JAX-RS MessageBodyWriter for JsonStructure. This allows JsonStructure, JsonArray and JsonObject to be return type of a resource method.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.lang.String JSON  
      private static java.lang.String PLUS_JSON  
      private JsonWriterFactory wf  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      long getSize​(JsonStructure jsonStructure, java.lang.Class<?> aClass, java.lang.reflect.Type type, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)  
      private void init()  
      boolean isWriteable​(java.lang.Class<?> aClass, java.lang.reflect.Type type, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)  
      private static boolean supportsMediaType​(javax.ws.rs.core.MediaType mediaType)  
      void writeTo​(JsonStructure jsonStructure, java.lang.Class<?> aClass, java.lang.reflect.Type type, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MultivaluedMap<java.lang.String,​java.lang.Object> stringObjectMultivaluedMap, java.io.OutputStream outputStream)  
      • Methods inherited from class java.lang.Object

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

      • JsonStructureBodyWriter

        public JsonStructureBodyWriter()
    • Method Detail

      • init

        @PostConstruct
        private void init()
      • isWriteable

        public boolean isWriteable​(java.lang.Class<?> aClass,
                                   java.lang.reflect.Type type,
                                   java.lang.annotation.Annotation[] annotations,
                                   javax.ws.rs.core.MediaType mediaType)
        Specified by:
        isWriteable in interface javax.ws.rs.ext.MessageBodyWriter<JsonStructure>
      • supportsMediaType

        private static boolean supportsMediaType​(javax.ws.rs.core.MediaType mediaType)
        Returns:
        true for all media types of the pattern */json and */*+json.
      • getSize

        public long getSize​(JsonStructure jsonStructure,
                            java.lang.Class<?> aClass,
                            java.lang.reflect.Type type,
                            java.lang.annotation.Annotation[] annotations,
                            javax.ws.rs.core.MediaType mediaType)
        Specified by:
        getSize in interface javax.ws.rs.ext.MessageBodyWriter<JsonStructure>
      • writeTo

        public void writeTo​(JsonStructure jsonStructure,
                            java.lang.Class<?> aClass,
                            java.lang.reflect.Type type,
                            java.lang.annotation.Annotation[] annotations,
                            javax.ws.rs.core.MediaType mediaType,
                            javax.ws.rs.core.MultivaluedMap<java.lang.String,​java.lang.Object> stringObjectMultivaluedMap,
                            java.io.OutputStream outputStream)
                     throws java.io.IOException,
                            javax.ws.rs.WebApplicationException
        Specified by:
        writeTo in interface javax.ws.rs.ext.MessageBodyWriter<JsonStructure>
        Throws:
        java.io.IOException
        javax.ws.rs.WebApplicationException