[ Index ]
 

Code source de Symfony 1.0.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/vendor/phing/parser/ -> DataTypeHandler.php (source)

   1  <?php
   2  /*
   3   *  $Id: DataTypeHandler.php 3076 2006-12-18 08:52:12Z fabien $
   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  include_once 'phing/RuntimeConfigurable.php';
  23  
  24  /**
  25   * Configures a Project (complete with Targets and Tasks) based on
  26   * a XML build file.
  27   * <p>
  28   * Design/ZE2 migration note:
  29   * If PHP would support nested classes. All the phing/parser/*Filter
  30   * classes would be nested within this class
  31   *
  32   * @author      Andreas Aderhold <andi@binarycloud.com>
  33   * @copyright © 2001,2002 THYRELL. All rights reserved
  34   * @version   $Revision: 1.8 $ $Date: 2005/11/02 13:55:33 $
  35   * @access    public
  36   * @package   phing.parser
  37   */
  38  
  39  class DataTypeHandler extends AbstractHandler {
  40  
  41      private $target;
  42      private $element;
  43      private $wrapper;
  44  
  45      /**
  46       * Constructs a new DataTypeHandler and sets up everything.
  47       *
  48       * @param AbstractSAXParser $parser The XML parser (default: ExpatParser)
  49       * @param AbstractHandler $parentHandler The parent handler that invoked this handler.
  50       * @param ProjectConfigurator $configurator The ProjectConfigurator object
  51       * @param Target $target The target object this datatype is contained in (null for top-level datatypes).
  52       */
  53      function __construct(AbstractSAXParser $parser, AbstractHandler $parentHandler, ProjectConfigurator $configurator, $target = null) { // FIXME b2 typehinting
  54          parent::__construct($parser, $parentHandler);
  55          $this->target = $target;
  56          $this->configurator = $configurator;
  57      }
  58  
  59      /**
  60       * Executes initialization actions required to setup the data structures
  61       * related to the tag.
  62       * <p>
  63       * This includes:
  64       * <ul>
  65       * <li>creation of the datatype object</li>
  66       * <li>calling the setters for attributes</li>
  67       * <li>adding the type to the target object if any</li>
  68       * <li>adding a reference to the task (if id attribute is given)</li>
  69           * </ul>
  70       *
  71       * @param  string  the tag that comes in
  72       * @param  array   attributes the tag carries
  73       * @throws ExpatParseException if attributes are incomplete or invalid
  74       * @access public
  75       */
  76      function init($propType, $attrs) {
  77          // shorthands
  78          $project = $this->configurator->project;
  79          $configurator = $this->configurator;
  80  
  81          try {//try
  82              $this->element = $project->createDataType($propType);
  83  
  84              if ($this->element === null) {
  85                  throw new BuildException("Unknown data type $propType");
  86              }
  87  
  88              if ($this->target !== null) {
  89                  $this->wrapper = new RuntimeConfigurable($this->element, $propType);
  90                  $this->wrapper->setAttributes($attrs);
  91                  $this->target->addDataType($this->wrapper);
  92              } else {
  93                  $configurator->configure($this->element, $attrs, $project);
  94                  $configurator->configureId($this->element, $attrs);
  95              }
  96  
  97          } catch (BuildException $exc) {
  98              throw new ExpatParseException($exc, $this->parser->getLocation());
  99          }
 100      }
 101  
 102      /**
 103       * Handles character data.
 104       *
 105       * @param  string  the CDATA that comes in
 106       * @access public
 107       */
 108      function characters($data) {
 109          $project = $this->configurator->project;
 110          try {//try
 111              $this->configurator->addText($project, $this->element, $data);
 112          } catch (BuildException $exc) {
 113              throw new ExpatParseException($exc->getMessage(), $this->parser->getLocation());
 114          }
 115      }
 116  
 117      /**
 118       * Checks for nested tags within the current one. Creates and calls
 119       * handlers respectively.
 120       *
 121       * @param  string  the tag that comes in
 122       * @param  array   attributes the tag carries
 123       * @access public
 124       */
 125      function startElement($name, $attrs) {
 126          $nef = new NestedElementHandler($this->parser, $this, $this->configurator, $this->element, $this->wrapper, $this->target);
 127          $nef->init($name, $attrs);
 128      }
 129      
 130     /**
 131      * Overrides endElement for data types. Tells the type
 132      * handler that processing the element had been finished so
 133      * handlers know they can perform actions that need to be
 134      * based on the data contained within the element.
 135      *
 136      * @param  string  the name of the XML element
 137      * @return void
 138      */
 139     function endElement($name) {
 140         $this->element->parsingComplete();
 141         parent::endElement($name);
 142     }
 143           
 144  }


Généré le : Fri Mar 16 22:42:14 2007 par Balluche grâce à PHPXref 0.7