php.java.bridge
Class Response

java.lang.Object
  extended by php.java.bridge.Response

public final class Response
extends java.lang.Object

This class is used to write the response to the front-end.

Author:
jostb

Field Summary
static int COERCE_WRITER
          A specialized writer which casts the value.
static int VALUES_WRITER
          A specialized writer which writes arrays as values.
 
Constructor Summary
Response(JavaBridge bridge)
          Creates a new response object.
 
Method Summary
 Response copyResponse()
          Flush the current output buffer and create a new Response object where are writers have their default value
 void flush()
          Write the response.
 boolean isAsync()
          Checks whether the asynchronous protocol is used
 php.java.bridge.Response.Writer setAsyncVoidWriter()
          Selects a specialized writer which does not write anything and does not generate a result proxy Used by async.
 php.java.bridge.Response.Writer setAsyncWriter()
          Selects a specialized writer which does not write anything.
 php.java.bridge.Response.Writer setDefaultWriter()
          Selects the default writer
 php.java.bridge.Response.Writer setObjectWriter()
          Selects a specialized writer which always writes or , even for NULL, Class and Exception values.
 void setResult(java.lang.Object value, java.lang.Class type, boolean hasDeclaredExceptions)
          Set the result packet.
 void setResultClass(java.lang.Class value)
          Set the result packet.
 void setResultException(java.lang.Throwable value, boolean hasDeclaredExceptions)
          Set the result packet.
 void setResultProcedure(long object, java.lang.String cname, java.lang.String name, java.lang.Object[] args)
          Set the result packet.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

VALUES_WRITER

public static final int VALUES_WRITER
A specialized writer which writes arrays as values. Used by getValues() and in php 4.

See Also:
JavaBridge.getValues(Object), Constant Field Values

COERCE_WRITER

public static final int COERCE_WRITER
A specialized writer which casts the value. Used by cast().

See Also:
JavaBridge.cast(Object, Class), Constant Field Values
Constructor Detail

Response

public Response(JavaBridge bridge)
Creates a new response object. The object is re-used for each packed.

Parameters:
bridge - The bridge.
Method Detail

copyResponse

public Response copyResponse()
                      throws java.io.IOException
Flush the current output buffer and create a new Response object where are writers have their default value

Returns:
the fresh response
Throws:
java.io.IOException

setResultProcedure

public void setResultProcedure(long object,
                               java.lang.String cname,
                               java.lang.String name,
                               java.lang.Object[] args)
Set the result packet.

Parameters:
object - The result object.
cname - The php name of the procedure
name - The java name of the procedure
args - The arguments

setResultException

public void setResultException(java.lang.Throwable value,
                               boolean hasDeclaredExceptions)
Set the result packet.

Parameters:
value - The throwable
hasDeclaredExceptions - true if the method has declared to throw exception(s), false otherwise

setResultClass

public void setResultClass(java.lang.Class value)
Set the result packet.

Parameters:
value - The result object.

setResult

public void setResult(java.lang.Object value,
                      java.lang.Class type,
                      boolean hasDeclaredExceptions)
Set the result packet.

Parameters:
value - The result object.
type - The type of the result object.
hasDeclaredExceptions - true if the method/procedure has declared exceptions, false otherwise

isAsync

public boolean isAsync()
Checks whether the asynchronous protocol is used

Returns:
true if the current writer is an AsyncWriter, false otherwise

setAsyncWriter

public php.java.bridge.Response.Writer setAsyncWriter()
Selects a specialized writer which does not write anything. Used by async. protocol.

Returns:
The async. writer

setAsyncVoidWriter

public php.java.bridge.Response.Writer setAsyncVoidWriter()
Selects a specialized writer which does not write anything and does not generate a result proxy Used by async. protocol.

Returns:
The async. writer

setObjectWriter

public php.java.bridge.Response.Writer setObjectWriter()
Selects a specialized writer which always writes or , even for NULL, Class and Exception values. This triggers the client cache so that it selects the AsyncNull or AsyncWriter.

Returns:
The async. writer

setDefaultWriter

public php.java.bridge.Response.Writer setDefaultWriter()
Selects the default writer

Returns:
The default writer

flush

public void flush()
           throws java.io.IOException
Write the response.

Throws:
java.io.IOException

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object