Overview  Package  Tree HessianPHP

HessianPHP.Protocol

Class HessianWriter

HessianPHP.Protocol.HessianProtocolHandler
|
+--HessianPHP.Protocol.HessianWriter

class HessianWriter
extends HessianProtocolHandler

Hessian protocol writer, inspired and partially based on hessianlib.py by Caucho.


TODO:

Author:
Manolo Gómez
Version:
1.0

Field Summary
public var$fault
Fields inherited from HessianPHP.Protocol.HessianProtocolHandler
$stream $pos $len $refs $error $dateProvider $typemap
Method Summary
public voidsetFault

Sets the reply as a fault, following Hessian spec

public voidwriteObject

Serializes a PHP value into a Hessian stream using reflection.

public stringwriteReply

Writes a Hessian reply with a return object.

public stringwriteCall

Writes a Hessian method call and serializes arguments.

public voidwriteBool
public voidwriteString
public voidwriteHeader
public voidwriteBytes
public voidwriteFault
public voidwriteInt
public voidwriteLong
public voidwriteDate
public voidwriteDouble
public voidwriteStringData
public booleanwriteReference

Checks internal reference map to see if an object has already been written to output stream.

public voidwriteList
public voidwriteMap
public booleanisArrayAssoc

Very simple way to check if an array is associative.

public booleanisList

EXPERIMENTAL: Algorithm to check if a php associative array is *exactly* an ordered list.

public voidwriteResource
Methods inherited from HessianPHP.Protocol.HessianProtocolHandler
HessianProtocolHandler, clearRefs, setStream, setDateProvider, setTypeMap
Field Detail

fault

public var $fault = false
Method Detail

setFault()

public void setFault(string code,
                     string message,
                     mixed detail = null)

Sets the reply as a fault, following Hessian spec

Parameters:
code - Code number of the fault
message - Descriptive message of the fault
detail - Optional argument with detail of the fault, usually a stack trace

writeObject()

public void writeObject(mixed value)

Serializes a PHP value into a Hessian stream using reflection.

Depending on the type it calls one of the writing functions of this class.

Parameters:
value - Value to be serialized

writeReply()

public string writeReply(mixed object)

Writes a Hessian reply with a return object.

If a fault has been set, it writes the fault instead

Parameters:
object - Object to be returned in the reply
Returns:
Hessian reply

writeCall()

public string writeCall(string method,
                        array params)

Writes a Hessian method call and serializes arguments.

Parameters:
method - Method to be called
params - Arguments of the method
Returns:
Hessian call

writeBool()

public void writeBool(var $value)
Parameters:
$value

writeString()

public void writeString(var $value)
Parameters:
$value

writeHeader()

public void writeHeader(var $value)
Parameters:
$value

writeBytes()

public void writeBytes(var $value)
Parameters:
$value

writeFault()

public void writeFault(var $code,
                       var $message,
                       var $detail)
Parameters:
$code
$message
$detail

writeInt()

public void writeInt(var $value)
Parameters:
$value

writeLong()

public void writeLong(var $value)
Parameters:
$value

writeDate()

public void writeDate(var $value)
Parameters:
$value

writeDouble()

public void writeDouble(var $value)
Parameters:
$value

writeStringData()

public void writeStringData(var $value)
Parameters:
$value

writeReference()

public boolean writeReference(mixed value)

Checks internal reference map to see if an object has already been written to output stream.

If it has, it only writes a reference to it and returns true, otherwise returns false WARNING: in PHP4, don't use circular references or this function will crash!

Parameters:
value - object
Returns:
is reference writen?

writeList()

public void writeList(var $value)
Parameters:
$value

writeMap()

public void writeMap(var $value)
Parameters:
$value

isArrayAssoc()

public boolean isArrayAssoc(array array)

Very simple way to check if an array is associative.

PHP doesn't have a way to tell an associative array from one that only has numbers as keys. Never mind the foreach, it's *faster* than other ways. Stops when a key is of string type or the key is negative, yes, you are read it well, array keys can be negative (and also null, and false, and...)

Parameters:
array - Array to check
Returns:
is associative?

isList()

public boolean isList(array array)

EXPERIMENTAL: Algorithm to check if a php associative array is *exactly* an ordered list.

It uses a property of ordered lists numeric keys, they correspond to the 0,1,2...n series of continuous integers, therefore you can check if an array is an ordered list by calculating the sum of its keys by hand and then using a formula. If both values match, it is an ordered list. Just Slightly slower than isArrayAssoc but safer. (currently not being used)

Parameters:
array - Array to check
Returns:
is an ordered list?

writeResource()

public void writeResource(var $handle)
Parameters:
$handle

Overview  Package  Tree HessianPHP