[ Index ] |
|
Code source de Symfony 1.0.0 |
1 <?php 2 3 /* 4 * $Id: BaseFilterReader.php 3076 2006-12-18 08:52:12Z fabien $ 5 * 6 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 7 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 8 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 9 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 10 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 11 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 12 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 13 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 14 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 15 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 16 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 17 * 18 * This software consists of voluntary contributions made by many individuals 19 * and is licensed under the LGPL. For more information please see 20 * <http://phing.info>. 21 */ 22 23 include_once 'phing/system/io/FilterReader.php'; 24 include_once 'phing/system/io/StringReader.php'; 25 26 27 /** 28 * Base class for core filter readers. 29 * 30 * @author <a href="mailto:yl@seasonfive.com">Yannick Lecaillez</a> 31 * @version $Revision: 1.8 $ $Date: 2004/05/20 02:24:10 $ 32 * @access public 33 * @see FilterReader 34 * @package phing.filters 35 */ 36 class BaseFilterReader extends FilterReader { 37 38 /** Have the parameters passed been interpreted? */ 39 protected $initialized = false; 40 41 /** The Phing project this filter is part of. */ 42 protected $project = null; 43 44 /** 45 * Constructor used by Phing's introspection mechanism. 46 * The original filter reader is only used for chaining 47 * purposes, never for filtering purposes (and indeed 48 * it would be useless for filtering purposes, as it has 49 * no real data to filter). ChainedReaderHelper uses 50 * this placeholder instance to create a chain of real filters. 51 * 52 * @param Reader $in 53 */ 54 function __construct($in = null) { 55 if ($in === null) { 56 $dummy = ""; 57 $in = new StringReader($dummy); 58 } 59 parent::__construct($in); 60 } 61 62 /** 63 * Returns the initialized status. 64 * 65 * @return boolean whether or not the filter is initialized 66 */ 67 function getInitialized() { 68 return $this->initialized; 69 } 70 71 /** 72 * Sets the initialized status. 73 * 74 * @param boolean $initialized Whether or not the filter is initialized. 75 */ 76 function setInitialized($initialized) { 77 $this->initialized = (boolean) $initialized; 78 } 79 80 /** 81 * Sets the project to work with. 82 * 83 * @param object $project The project this filter is part of. 84 * Should not be <code>null</code>. 85 */ 86 function setProject(Project $project) { 87 // type check, error must never occur, bad code of it does 88 $this->project = $project; 89 } 90 91 /** 92 * Returns the project this filter is part of. 93 * 94 * @return object The project this filter is part of 95 */ 96 function getProject() { 97 return $this->project; 98 } 99 100 /** 101 * Reads characters. 102 * 103 * @param off Offset at which to start storing characters. 104 * @param len Maximum number of characters to read. 105 * 106 * @return Characters read, or -1 if the end of the stream 107 * has been reached 108 * 109 * @throws IOException If an I/O error occurs 110 */ 111 function read($len = null) { 112 return $this->in->read($len); 113 } 114 115 /** 116 * Reads a line of text ending with '\n' (or until the end of the stream). 117 * The returned String retains the '\n'. 118 * 119 * @return the line read, or <code>null</code> if the end of the 120 stream has already been reached 121 * 122 * @throws IOException if the underlying reader throws one during 123 * reading 124 */ 125 function readLine() { 126 $line = null; 127 128 while ( ($ch = $this->in->read(1)) !== -1 ) { 129 $line .= $ch; 130 if ( $ch === "\n" ) 131 break; 132 } 133 134 return $line; 135 } 136 137 /** 138 * Returns whether the end of file has been reached with input stream. 139 * @return boolean 140 */ 141 function eof() { 142 return $this->in->eof(); 143 } 144 145 /** 146 * Convenience method to support logging in filters. 147 * @param string $msg Message to log. 148 * @param int $level Priority level. 149 */ 150 function log($msg, $level = PROJECT_MSG_INFO) { 151 if ($this->project !== null) { 152 $this->project->log("[filter:".get_class($this)."] ".$msg, $level); 153 } 154 } 155 } 156 157 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Fri Mar 16 22:42:14 2007 | par Balluche grâce à PHPXref 0.7 |