• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • Examples
  • File List

E:/E/GEAMP/www/openbiz/openbiz/others/Zend/Json/Server/Response.php

00001 <?php
00030 class Zend_Json_Server_Response
00031 {
00036     protected $_error;
00037 
00042     protected $_id;
00043 
00048     protected $_result;
00049 
00054     protected $_serviceMap;
00055 
00060     protected $_version;
00061 
00068     public function setResult($value)
00069     {
00070         $this->_result = $value;
00071         return $this;
00072     }
00073 
00079     public function getResult()
00080     {
00081         return $this->_result;
00082     }
00083 
00084     // RPC error, if response results in fault
00091     public function setError(Zend_Json_Server_Error $error)
00092     {
00093         $this->_error = $error;
00094         return $this;
00095     }
00096 
00102     public function getError()
00103     {
00104         return $this->_error;
00105     }
00106 
00112     public function isError()
00113     {
00114         return $this->getError() instanceof Zend_Json_Server_Error;
00115     }
00116 
00123     public function setId($name)
00124     {
00125         $this->_id = $name;
00126         return $this;
00127     }
00128 
00134     public function getId()
00135     {
00136         return $this->_id;
00137     }
00138 
00145     public function setVersion($version)
00146     {
00147         $version = (string) $version;
00148         if ('2.0' == $version) {
00149             $this->_version = '2.0';
00150         } else {
00151             $this->_version = null;
00152         }
00153 
00154         return $this;
00155     }
00156 
00162     public function getVersion()
00163     {
00164         return $this->_version;
00165     }
00166 
00172     public function toJson()
00173     {
00174         if ($this->isError()) {
00175             $response = array(
00176                 'error' => $this->getError()->toArray(),
00177                 'id'    => $this->getId(),
00178             );
00179         } else {
00180             $response = array(
00181                 'result' => $this->getResult(),
00182                 'id'     => $this->getId(),
00183             );
00184         }
00185 
00186         if (null !== ($version = $this->getVersion())) {
00187             $response['jsonrpc'] = $version;
00188         }
00189 
00190         require_once 'Zend/Json.php';
00191         return Zend_Json::encode($response);
00192     }
00193 
00199     public function getArgs()
00200     {
00201         return $this->_args;
00202     }
00203 
00210     public function setArgs($args)
00211     {
00212         $this->_args = $args;
00213         return $this;
00214     }
00215 
00222     public function setServiceMap($serviceMap)
00223     {
00224         $this->_serviceMap = $serviceMap;
00225         return $this;
00226     }
00227 
00233     public function getServiceMap()
00234     {
00235         return $this->_serviceMap;
00236     }
00237 
00243     public function __toString()
00244     {
00245         return $this->toJson();
00246     }
00247 }
00248 

Generated on Thu Apr 19 2012 17:01:17 for openbiz by  doxygen 1.7.2