function write(Iterator $list, $writer)
 {
     $writer->logMsg('iterator writer');
     $writer->refmap->objectlist[] = $list;
     $total = $this->getCount($list);
     $class = get_class($list);
     $type = $writer->typemap->getRemoteType($class);
     $mappedType = $type ? $type : $class;
     // OJO con esto
     $islist = HessianUtils::isListIterate($list);
     if ($islist) {
         list($stream, $terminate) = $this->listHeader($writer, $mappedType, $total);
         foreach ($list as $value) {
             $stream .= $writer->writeValue($value);
         }
         if ($terminate) {
             $stream .= 'Z';
         }
     } else {
         if ($this->usetype && $mappedType) {
             $stream = 'M';
             $stream .= $writer->writeType($mappedType);
         } else {
             $stream = 'H';
         }
         foreach ($elements as $key => $value) {
             $stream .= $writer->writeValue($key);
             $stream .= $writer->writeValue($value);
         }
         $stream .= 'Z';
     }
     return new HessianStreamResult($stream);
 }
 function write(Iterator $list, $writer)
 {
     $writer->logMsg('iterator writer');
     $writer->refmap->objectlist[] = $list;
     $total = $this->getCount($list);
     $class = get_class($list);
     $type = $writer->typemap->getRemoteType($class);
     $islist = HessianUtils::isListIterate($list);
     if ($islist) {
         $stream = 'V';
         if ($this->usetype && $type) {
             $stream .= $writer->writeType($type);
         }
         if ($total !== false) {
             $stream .= $writer->writeInt($total);
         }
         foreach ($list as $value) {
             $stream .= $writer->writeValue($value);
         }
         $stream .= 'z';
     } else {
         $stream = 'M';
         if ($this->usetype) {
             $mapType = $type ? $type : $class;
             $stream .= $writer->writeType($mapType);
         }
         foreach ($elements as $key => $value) {
             $stream .= $writer->writeValue($key);
             $stream .= $writer->writeValue($value);
         }
         $stream .= 'z';
     }
     return new HessianStreamResult($stream);
 }
 /**
  * Creates a new HessianService instace to serve remote requests from Hessian clients
  * @param $serviceObject Class name or object instance
  * @param mixed $options array or HessianOptions object
  */
 function __construct($serviceObject, $options = null)
 {
     $this->options = HessianOptions::resolveOptions($options);
     if ($serviceObject) {
         $this->registerObject($serviceObject);
     }
     $this->options->detectVersion = true;
     $this->typemap = new HessianTypeMap($this->options->typeMap);
     $this->factory = new HessianFactory();
     // timezones
     HessianUtils::setTimeZone($this->options->timeZone);
 }
Beispiel #4
0
 function readUTF8Bytes($len)
 {
     $string = $this->read($len);
     $pos = 0;
     $pass = 1;
     while ($pass <= $len) {
         $charCode = ord($string[$pos]);
         if ($charCode < 0x80) {
             $pos++;
         } elseif (($charCode & 0xe0) == 0xc0) {
             $pos += 2;
             $string .= $this->read(1);
         } elseif (($charCode & 0xf0) == 0xe0) {
             $pos += 3;
             $string .= $this->read(2);
         }
         $pass++;
     }
     if (HessianUtils::isInternalUTF8()) {
         return $string;
     }
     return utf8_decode($string);
     /*$string = '';
     		for($i=0;$i<$len;$i++){
     			$ch = $this->read(1);
     			$charCode = ord($ch);
     			if($charCode < 0x80)
     				$string .= $ch;
     			elseif(($charCode & 0xe0) == 0xc0) {
     				$string .= $ch.$this->read(1);
     			} elseif (($charCode & 0xf0) == 0xe0) {
     				$string .= $ch.$this->read(2);
     			} else {
     				throw new HessianParsingException("Bad utf-8 encoding at pos ".$this->stream->pos);
     			}
     		}
     		if(HessianUtils::isInternalUTF8())
     			return $string;
     		return utf8_decode($string);*/
 }
Beispiel #5
0
 function writeDouble($value)
 {
     $stream = 'D';
     $stream .= HessianUtils::doubleBytes($value);
     return $stream;
 }
 function writeDouble($value)
 {
     $frac = abs($value) - floor(abs($value));
     if ($value == 0.0) {
         return pack('c', 0x5b);
     }
     if ($value == 1.0) {
         return pack('c', 0x5c);
     }
     // Issue 10, Fix thanks to nesnnaho...@googlemail.com,
     if ($frac == 0 && $this->between($value, -127, 128)) {
         return pack('c', 0x5d) . pack('c', $value);
     }
     if ($frac == 0 && $this->between($value, -32768, 32767)) {
         $stream = pack('c', 0x5e);
         $stream .= HessianUtils::floatBytes($value);
         return $stream;
     }
     // TODO double 4 el del 0.001, revisar
     $mills = (int) ($value * 1000);
     if (0.001 * $mills == $value) {
         $stream = pack('c', 0x5f);
         $stream .= pack('c', $mills >> 24);
         $stream .= pack('c', $mills >> 16);
         $stream .= pack('c', $mills >> 8);
         $stream .= pack('c', $mills);
         return $stream;
     }
     // 64 bit double
     $stream = 'D';
     $stream .= HessianUtils::doubleBytes($value);
     return $stream;
 }
Beispiel #7
0
 function parseString($code, $num)
 {
     $end = false;
     $string = '';
     while (!$end) {
         $tempLen = unpack('n', $this->read(2));
         $len = $tempLen[1];
         if ($code == 's' || $code == 'x') {
             $code = $this->read(1);
         } else {
             $end = true;
         }
         $string .= $this->readUTF8Bytes($len);
         //$end = true;
     }
     if (HessianUtils::isInternalUTF8()) {
         return $string;
     }
     return utf8_decode($string);
 }
Beispiel #8
0
 /**
  * Resolves if the machine arquitecture is big or little endian by comparing two binary packed
  * values
  */
 public static function isLittleEndian()
 {
     if (!is_null(self::$littleEndian)) {
         return self::$littleEndian;
     }
     $machineLong = pack("L", 1);
     // Machine dependent
     $indepLong = pack("N", 1);
     // Machine independent
     self::$littleEndian = $machineLong[0] != $indepLong[0];
     return self::$littleEndian;
 }