org.restlet.ext.json
Class JsonpRepresentation
java.lang.Object
org.restlet.representation.Variant
org.restlet.representation.RepresentationInfo
org.restlet.representation.Representation
org.restlet.util.WrapperRepresentation
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
Methods inherited from class org.restlet.util.WrapperRepresentation |
exhaust, getAvailableSize, getCharacterSet, getDigest, getDisposition, getEncodings, getExpirationDate, getLanguages, getLocationRef, getModificationDate, getRange, getReader, getTag, getWrappedRepresentation, isAvailable, isTransient, release, setAvailable, setCharacterSet, setDigest, setDisposition, setEncodings, setExpirationDate, setLanguages, setLocationRef, setLocationRef, setMediaType, setModificationDate, setRange, setSize, setTag, setTransient |
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
-
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
Copyright © 2005-2014 Restlet.