Reader.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. /*
  3. * $Id: Reader.php 905 2010-10-05 16:28:03Z mrook $
  4. *
  5. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  6. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  7. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  8. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  9. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  10. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  11. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  12. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  13. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  14. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  15. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  16. *
  17. * This software consists of voluntary contributions made by many individuals
  18. * and is licensed under the LGPL. For more information please see
  19. * <http://phing.info>.
  20. */
  21. /**
  22. * Abstract class for reading character streams.
  23. *
  24. * @author Hans Lellelid <hans@xmpl.org>
  25. * @author Yannick Lecaillez <yl@seasonfive.com>
  26. * @version $Revision: 905 $
  27. * @package phing.system.io
  28. */
  29. abstract class Reader {
  30. /**
  31. * Read data from source.
  32. *
  33. * If length is specified, then only that number of chars is read,
  34. * otherwise stream is read until EOF.
  35. *
  36. * @param int $len
  37. */
  38. abstract public function read($len = null);
  39. /**
  40. * Close stream.
  41. * @throws IOException if there is an error closing stream
  42. */
  43. abstract public function close();
  44. /**
  45. * Returns the filename, url, etc. that is being read from.
  46. * This is critical for, e.g., ExpatParser's ability to know
  47. * the filename that is throwing an ExpatParserException, etc.
  48. * @return string
  49. */
  50. abstract function getResource();
  51. /**
  52. * Move stream position relative to current pos.
  53. * @param int $n
  54. */
  55. public function skip($n) {}
  56. /**
  57. * Reset the current position in stream to beginning or last mark (if supported).
  58. */
  59. public function reset() {}
  60. /**
  61. * If supported, places a "marker" (like a bookmark) at current stream position.
  62. * A subsequent call to reset() will move stream position back
  63. * to last marker (if supported).
  64. */
  65. public function mark() {}
  66. /**
  67. * Whether marking is supported.
  68. * @return boolean
  69. */
  70. public function markSupported() {
  71. return false;
  72. }
  73. /**
  74. * Is stream ready for reading.
  75. * @return boolean
  76. */
  77. public function ready() {
  78. return true;
  79. }
  80. }