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
Method Summary |
java.lang.String |
getCallback()
Returns the name of the JavaScript callback method. |
java.nio.channels.ReadableByteChannel |
getChannel()
|
MediaType |
getMediaType()
|
long |
getSize()
|
Status |
getStatus()
Returns the actual status code. |
java.io.InputStream |
getStream()
|
java.lang.String |
getText()
|
void |
write(java.io.OutputStream outputStream)
Writes the callback method wrapper first, including the actual HTTP
status code, then the existing JSON content as a body. |
void |
write(java.nio.channels.WritableByteChannel writableChannel)
|
void |
write(java.io.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 java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
JsonpRepresentation
public JsonpRepresentation(java.lang.String callback,
Status status,
Representation wrappedRepresentation)
- Constructor.
- Parameters:
callback
- The name of the JavaScript callback method.status
- The actual status code.wrappedRepresentation
-
getCallback
public java.lang.String getCallback()
- Returns the name of the JavaScript callback method.
- Returns:
- The name of the JavaScript callback method.
getChannel
public java.nio.channels.ReadableByteChannel getChannel()
throws java.io.IOException
- Overrides:
getChannel
in class WrapperRepresentation
- Throws:
java.io.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 java.io.InputStream getStream()
throws java.io.IOException
- Overrides:
getStream
in class WrapperRepresentation
- Throws:
java.io.IOException
getText
public java.lang.String getText()
throws java.io.IOException
- Overrides:
getText
in class WrapperRepresentation
- Throws:
java.io.IOException
write
public void write(java.io.Writer writer)
throws java.io.IOException
- Overrides:
write
in class WrapperRepresentation
- Throws:
java.io.IOException
write
public void write(java.io.OutputStream outputStream)
throws java.io.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:
java.io.IOException
write
public void write(java.nio.channels.WritableByteChannel writableChannel)
throws java.io.IOException
- Overrides:
write
in class WrapperRepresentation
- Throws:
java.io.IOException
Copyright © 2005-2014 Restlet.