org.restlet.ext.jibx
Class JibxRepresentation<T>

java.lang.Object
  extended by org.restlet.representation.Variant
      extended by org.restlet.representation.RepresentationInfo
          extended by org.restlet.representation.Representation
              extended by org.restlet.representation.CharacterRepresentation
                  extended by org.restlet.representation.WriterRepresentation
                      extended by org.restlet.ext.jibx.JibxRepresentation<T>
Type Parameters:
T - The type to wrap.

public class JibxRepresentation<T>
extends WriterRepresentation

An XML representation based on JiBX that provides easy translation between XML representations and Java objects with JiBX bindings.

Author:
Florian Schwarz
See Also:
JiBX project

Field Summary
 
Fields inherited from class org.restlet.representation.Representation
UNKNOWN_SIZE
 
Constructor Summary
JibxRepresentation(MediaType mediaType, T object)
          Creates a JIBX representation from an existing Java object.
JibxRepresentation(MediaType mediaType, T object, String bindingName)
          Creates a JIBX representation from an existing Java object.
JibxRepresentation(Representation xmlRepresentation, Class<?> bindingClass)
          Creates a new JIBX representation, that can be used to convert the input XML into a Java object.
JibxRepresentation(Representation xmlRepresentation, Class<?> bindingClass, String bindingName)
          Creates a new JIBX representation, that can be used to convert the input XML into a Java object.
 
Method Summary
 T getObject()
          Returns the wrapped Java object.
 void setObject(T object)
          Sets the wrapped Java object.
 void write(Writer writer)
          Marshals the document and writes the representation to a stream of characters.
 
Methods inherited from class org.restlet.representation.WriterRepresentation
getReader
 
Methods inherited from class org.restlet.representation.CharacterRepresentation
getChannel, getStream, write, write
 
Methods inherited from class org.restlet.representation.Representation
append, exhaust, getAvailableSize, getDigest, getDisposition, getExpirationDate, getRange, getRegistration, getSize, getText, hasKnownSize, isAvailable, isEmpty, isSelectable, isTransient, release, setAvailable, setDigest, setDisposition, setExpirationDate, setListener, setRange, setSize, setTransient
 
Methods inherited from class org.restlet.representation.RepresentationInfo
getModificationDate, getTag, setModificationDate, setTag
 
Methods inherited from class org.restlet.representation.Variant
createClientInfo, equals, getCharacterSet, getEncodings, getLanguages, getLocationRef, getMediaType, includes, isCompatible, setCharacterSet, setEncodings, setLanguages, setLocationRef, setLocationRef, setMediaType, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JibxRepresentation

public JibxRepresentation(MediaType mediaType,
                          T object)
Creates a JIBX representation from an existing Java object. This allows a translation from a Java object to a XML representation.

Parameters:
mediaType - The representation's media type (usually MediaType.APPLICATION_XML or MediaType.TEXT_XML).
object - The Java object.

JibxRepresentation

public JibxRepresentation(MediaType mediaType,
                          T object,
                          String bindingName)
Creates a JIBX representation from an existing Java object. This allows a translation from a Java object to a XML representation.

Parameters:
mediaType - The representation's media type (usually MediaType.APPLICATION_XML or MediaType.TEXT_XML).
object - The Java object.
bindingName - The name of the JIBX binding to use.

JibxRepresentation

public JibxRepresentation(Representation xmlRepresentation,
                          Class<?> bindingClass)
Creates a new JIBX representation, that can be used to convert the input XML into a Java object. The XML is not validated.

Parameters:
xmlRepresentation - The XML wrapped in a representation.
bindingClass - The Target Java class for binding.

JibxRepresentation

public JibxRepresentation(Representation xmlRepresentation,
                          Class<?> bindingClass,
                          String bindingName)
Creates a new JIBX representation, that can be used to convert the input XML into a Java object. The XML is not validated.

Parameters:
xmlRepresentation - The XML wrapped in a representation.
bindingClass - The Target Java class for binding.
bindingName - The name of the JIBX binding to use.
Method Detail

getObject

public T getObject()
            throws JiBXException,
                   IOException
Returns the wrapped Java object.

Returns:
The wrapped Java object.
Throws:
JiBXException - If unmarshalling XML with JIBX fails.
IOException - If any error occurs attempting to get the stream of the xmlRepresentation.

setObject

public void setObject(T object)
Sets the wrapped Java object.

Parameters:
object - The Java object to set.

write

public void write(Writer writer)
           throws IOException
Marshals the document and writes the representation to a stream of characters.

Specified by:
write in class Representation
Parameters:
writer - The writer to use when writing.
Throws:
IOException - If any error occurs attempting to write the stream.


Copyright © 2005-2013 Restlet.