Restlet Framework 2.2.3
Java Enterprise Edition

org.restlet.ext.json
Class JsonpRepresentation

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.util.WrapperRepresentation
                  extended by org.restlet.ext.json.JsonpRepresentation

public class JsonpRepresentation
extends WrapperRepresentation

Wrappers that adds a JSONP header and footer to JSON representations. The goal is to make them accessible to web browser without restriction from single origin policies.

Author:
Mark Kharitonov

Field Summary
 
Fields inherited from class org.restlet.representation.Representation
UNKNOWN_SIZE
 
Constructor Summary
JsonpRepresentation(String callback, Status status, Representation wrappedRepresentation)
          Constructor.
 
Method Summary
 String getCallback()
          Returns the name of the JavaScript callback method.
 ReadableByteChannel getChannel()
           
 MediaType getMediaType()
           
 long getSize()
           
 Status getStatus()
          Returns the actual status code.
 InputStream getStream()
           
 String getText()
           
 void write(OutputStream outputStream)
          Writes the callback method wrapper first, including the actual HTTP status code, then the existing JSON content as a body.
 void write(WritableByteChannel writableChannel)
           
 void write(Writer writer)
           
 
Methods inherited from class org.restlet.util.WrapperRepresentation
exhaust, getAvailableSize, getCharacterSet, getDigest, getDisposition, getEncodings, getExpirationDate, getLanguages, getLocationRef, getModificationDate, getRange, getReader, getRegistration, getTag, getWrappedRepresentation, isAvailable, isSelectable, isTransient, release, setAvailable, setCharacterSet, setDigest, setDisposition, setEncodings, setExpirationDate, setLanguages, setLocationRef, setLocationRef, setMediaType, setModificationDate, setRange, setSize, setTag, setTransient
 
Methods inherited from class org.restlet.representation.Representation
append, hasKnownSize, isEmpty, setListener
 
Methods inherited from class org.restlet.representation.Variant
createClientInfo, equals, includes, isCompatible, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JsonpRepresentation

public JsonpRepresentation(String callback,
                           Status status,
                           Representation wrappedRepresentation)
Constructor.

Parameters:
callback - The name of the JavaScript callback method.
status - The actual status code.
wrappedRepresentation -
Method Detail

getCallback

public String getCallback()
Returns the name of the JavaScript callback method.

Returns:
The name of the JavaScript callback method.

getChannel

public ReadableByteChannel getChannel()
                               throws IOException
Overrides:
getChannel in class WrapperRepresentation
Throws:
IOException

getMediaType

public MediaType getMediaType()
Overrides:
getMediaType in class WrapperRepresentation

getSize

public long getSize()
Overrides:
getSize in class WrapperRepresentation

getStatus

public Status getStatus()
Returns the actual status code.

Returns:
The actual status code.

getStream

public InputStream getStream()
                      throws IOException
Overrides:
getStream in class WrapperRepresentation
Throws:
IOException

getText

public String getText()
               throws IOException
Overrides:
getText in class WrapperRepresentation
Throws:
IOException

write

public void write(Writer writer)
           throws IOException
Overrides:
write in class WrapperRepresentation
Throws:
IOException

write

public void write(OutputStream outputStream)
           throws IOException
Writes the callback method wrapper first, including the actual HTTP status code, then the existing JSON content as a body.

Overrides:
write in class WrapperRepresentation
Throws:
IOException

write

public void write(WritableByteChannel writableChannel)
           throws IOException
Overrides:
write in class WrapperRepresentation
Throws:
IOException

Restlet Framework 2.2.3
Java Enterprise Edition

Copyright © 2005-2014 Restlet.