Apache CXF API

org.apache.cxf.jaxrs.provider.xmlbeans
Class XMLBeansElementProvider

java.lang.Object
  extended by org.apache.cxf.jaxrs.provider.AbstractConfigurableProvider
      extended by org.apache.cxf.jaxrs.provider.xmlbeans.XMLBeansElementProvider
All Implemented Interfaces:
javax.ws.rs.ext.MessageBodyReader<org.apache.xmlbeans.XmlObject>, javax.ws.rs.ext.MessageBodyWriter<org.apache.xmlbeans.XmlObject>
Direct Known Subclasses:
XMLBeansJSONProvider

@Produces(value={"application/xml","application/*+xml","text/xml"})
@Consumes(value={"application/xml","application/*+xml","text/xml"})
@Provider
public class XMLBeansElementProvider
extends AbstractConfigurableProvider
implements javax.ws.rs.ext.MessageBodyReader<org.apache.xmlbeans.XmlObject>, javax.ws.rs.ext.MessageBodyWriter<org.apache.xmlbeans.XmlObject>

Provider for XMLBeans data objects.


Constructor Summary
XMLBeansElementProvider()
           
 
Method Summary
 long getSize(org.apache.xmlbeans.XmlObject t, Class<?> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mt)
          
 boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mt)
          
 boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mt)
          
protected  boolean isXmlBean(Class<?> type)
          Check if a Class is a valid XMLBeans data object.
protected  org.apache.xmlbeans.XmlObject parseXmlBean(Class<?> type, InputStream inStream)
          Create an XMLBean data object from an InputStream
protected  org.apache.xmlbeans.XmlObject parseXmlBean(Class<?> type, Reader reader)
          Create an XMLBean data object using a stream Reader
protected  org.apache.xmlbeans.XmlObject parseXmlBean(Class<?> type, XMLStreamReader reader)
          Create an XMLBean object from an XML stream.
 org.apache.xmlbeans.XmlObject readFrom(Class<org.apache.xmlbeans.XmlObject> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType m, javax.ws.rs.core.MultivaluedMap<String,String> headers, InputStream is)
          
 void writeTo(org.apache.xmlbeans.XmlObject t, Class<?> cls, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType m, javax.ws.rs.core.MultivaluedMap<String,Object> headers, OutputStream entityStream)
          
 
Methods inherited from class org.apache.cxf.jaxrs.provider.AbstractConfigurableProvider
getBus, getConsumeMediaTypes, getEnableBuffering, getEnableStreaming, getProduceMediaTypes, init, isPayloadEmpty, isPayloadEmpty, setBus, setConsumeMediaTypes, setEnableBuffering, setEnableStreaming, setProduceMediaTypes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLBeansElementProvider

public XMLBeansElementProvider()
Method Detail

readFrom

public org.apache.xmlbeans.XmlObject readFrom(Class<org.apache.xmlbeans.XmlObject> type,
                                              Type genericType,
                                              Annotation[] annotations,
                                              javax.ws.rs.core.MediaType m,
                                              javax.ws.rs.core.MultivaluedMap<String,String> headers,
                                              InputStream is)
                                       throws IOException

Specified by:
readFrom in interface javax.ws.rs.ext.MessageBodyReader<org.apache.xmlbeans.XmlObject>
Throws:
IOException

writeTo

public void writeTo(org.apache.xmlbeans.XmlObject t,
                    Class<?> cls,
                    Type genericType,
                    Annotation[] annotations,
                    javax.ws.rs.core.MediaType m,
                    javax.ws.rs.core.MultivaluedMap<String,Object> headers,
                    OutputStream entityStream)
             throws IOException

Specified by:
writeTo in interface javax.ws.rs.ext.MessageBodyWriter<org.apache.xmlbeans.XmlObject>
Throws:
IOException

getSize

public long getSize(org.apache.xmlbeans.XmlObject t,
                    Class<?> type,
                    Type genericType,
                    Annotation[] annotations,
                    javax.ws.rs.core.MediaType mt)

Specified by:
getSize in interface javax.ws.rs.ext.MessageBodyWriter<org.apache.xmlbeans.XmlObject>

isReadable

public boolean isReadable(Class<?> type,
                          Type genericType,
                          Annotation[] annotations,
                          javax.ws.rs.core.MediaType mt)

Specified by:
isReadable in interface javax.ws.rs.ext.MessageBodyReader<org.apache.xmlbeans.XmlObject>

isWriteable

public boolean isWriteable(Class<?> type,
                           Type genericType,
                           Annotation[] annotations,
                           javax.ws.rs.core.MediaType mt)

Specified by:
isWriteable in interface javax.ws.rs.ext.MessageBodyWriter<org.apache.xmlbeans.XmlObject>

parseXmlBean

protected org.apache.xmlbeans.XmlObject parseXmlBean(Class<?> type,
                                                     XMLStreamReader reader)
Create an XMLBean object from an XML stream.

Parameters:
type - declared type of the target object
reader - stream reader for the XML stream
Returns:
an XMLBean data object, or none if unable to process

parseXmlBean

protected org.apache.xmlbeans.XmlObject parseXmlBean(Class<?> type,
                                                     InputStream inStream)
Create an XMLBean data object from an InputStream

Parameters:
type - declared type of the required object
inStream -
Returns:
an XMLBean object if successful, otherwise null

parseXmlBean

protected org.apache.xmlbeans.XmlObject parseXmlBean(Class<?> type,
                                                     Reader reader)
Create an XMLBean data object using a stream Reader

Parameters:
type - declared type of the desired XMLBean data object
reader -
Returns:
an instance of the required object, otherwise null

isXmlBean

protected boolean isXmlBean(Class<?> type)
Check if a Class is a valid XMLBeans data object. The check procedure involves looking for the Interface XmlObject in the target type's declaration. Assumed to be sufficient to identify the type as an XMLBean. From the javadoc (2.3.0) for XmlObject: "Corresponds to the XML Schema xs:anyType, the base type for all XML Beans."

Parameters:
type -
Returns:
true if found to be an XMLBean object, otherwise false

Apache CXF API

Apache CXF