[ Index ] |
|
Code source de Symfony 1.0.0 |
1 <?php 2 3 /* 4 * $Id: AbstractHandler.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/parser/ExpatParseException.php'; 24 25 /** 26 * This is an abstract class all SAX handler classes must extend 27 * 28 * @author Andreas Aderhold <andi@binarycloud.com> 29 * @copyright © 2001,2002 THYRELL. All rights reserved 30 * @version $Revision: 1.6 $ 31 * @package phing.parser 32 */ 33 abstract class AbstractHandler { 34 35 public $parentHandler = null; 36 public $parser = null; 37 38 /** 39 * Constructs a SAX handler parser. 40 * 41 * The constructor must be called by all derived classes. 42 * 43 * @param object the parser object 44 * @param object the parent handler of this handler 45 */ 46 protected function __construct($parser, $parentHandler) { 47 $this->parentHandler = $parentHandler; 48 $this->parser = $parser; 49 $this->parser->setHandler($this); 50 } 51 52 /** 53 * Gets invoked when a XML open tag occurs 54 * 55 * Must be overloaded by the child class. Throws an ExpatParseException 56 * if there is no handler registered for an element. 57 * 58 * @param string the name of the XML element 59 * @param array the attributes of the XML element 60 */ 61 public function startElement($name, $attribs) { 62 throw new ExpatParseException("Unexpected element $name"); 63 } 64 65 /** 66 * Gets invoked when element closes method. 67 * 68 */ 69 protected function finished() {} 70 71 /** 72 * Gets invoked when a XML element ends. 73 * 74 * Can be overloaded by the child class. But should not. It hands 75 * over control to the parentHandler of this. 76 * 77 * @param string the name of the XML element 78 */ 79 public function endElement($name) { 80 $this->finished(); 81 $this->parser->setHandler($this->parentHandler); 82 } 83 84 /** 85 * Invoked by occurance of #PCDATA. 86 * 87 * @param string the name of the XML element 88 * @exception ExpatParserException if there is no CDATA but method 89 * was called 90 * @access public 91 */ 92 public function characters($data) { 93 $s = trim($data); 94 if (strlen($s) > 0) { 95 throw new ExpatParseException("Unexpected text '$s'", $this->parser->getLocation()); 96 } 97 } 98 }
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 |