PageRenderTime 38ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/framework/vendor/zend/Zend/Pdf/Element/Stream.php

http://zoop.googlecode.com/
PHP | 117 lines | 35 code | 17 blank | 65 comment | 0 complexity | fed57ba614d7b5a600d5abfcc80aed81 MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.1
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Pdf
  17. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  18. * @license http://framework.zend.com/license/new-bsd New BSD License
  19. * @version $Id: Stream.php 20096 2010-01-06 02:05:09Z bkarwin $
  20. */
  21. /** Internally used classes */
  22. require_once 'Zend/Pdf.php';
  23. /** Zend_Pdf_Element */
  24. require_once 'Zend/Pdf/Element.php';
  25. /**
  26. * PDF file 'stream' element implementation
  27. *
  28. * @category Zend
  29. * @package Zend_Pdf
  30. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  31. * @license http://framework.zend.com/license/new-bsd New BSD License
  32. */
  33. class Zend_Pdf_Element_Stream extends Zend_Pdf_Element
  34. {
  35. /**
  36. * Object value
  37. *
  38. * @var Zend_Memory_Container
  39. */
  40. public $value;
  41. /**
  42. * Object constructor
  43. *
  44. * @param string $val
  45. */
  46. public function __construct($val)
  47. {
  48. $this->value = Zend_Pdf::getMemoryManager()->create($val);
  49. }
  50. /**
  51. * Return type of the element.
  52. *
  53. * @return integer
  54. */
  55. public function getType()
  56. {
  57. return Zend_Pdf_Element::TYPE_STREAM;
  58. }
  59. /**
  60. * Stream length.
  61. * (Method is used to avoid string copying, which may occurs in some cases)
  62. *
  63. * @return integer
  64. */
  65. public function length()
  66. {
  67. return strlen($this->value->getRef());
  68. }
  69. /**
  70. * Clear stream
  71. *
  72. */
  73. public function clear()
  74. {
  75. $ref = &$this->value->getRef();
  76. $ref = '';
  77. $this->value->touch();
  78. }
  79. /**
  80. * Append value to a stream
  81. *
  82. * @param mixed $val
  83. */
  84. public function append($val)
  85. {
  86. $ref = &$this->value->getRef();
  87. $ref .= (string)$val;
  88. $this->value->touch();
  89. }
  90. /**
  91. * Return object as string
  92. *
  93. * @param Zend_Pdf_Factory $factory
  94. * @return string
  95. */
  96. public function toString($factory = null)
  97. {
  98. return "stream\n" . $this->value->getRef() . "\nendstream";
  99. }
  100. }