Documentation is available at ColumnFixture.php
- <?php
- /**
- * FIT Fixture ColumnFixture
- *
- * $Id$
- *
- * @author Luis A. Floreani <luis.floreani@gmail.com>
- * @author gERD Schaufelberger <gerd@php-tools.net>
- * @package FIT
- * @subpackage Fixture
- * @license LGPL http://www.gnu.org/copyleft/lesser.html
- * @copyright Copyright (c) 2002-2005 Cunningham & Cunningham, Inc.
- */
- /**
- * load class Fixture
- */
- include_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'Fixture.php';
- /**
- * load class TypeAdapter
- */
- include_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'TypeAdapter.php';
- /**
- * FIT Fixture: ColumnFixture
- *
- * @version 0.1.0
- * @package FIT
- * @subpackage Fixture
- */
- class ColumnFixture extends Fixture {
- /**
- * TypeAdapter
- * @var object
- */
- protected $columnBindings;
- /**
- * Excecution state
- * @var bool
- */
- protected $hasExecuted = false;
- /**
- * Process a table's row
- *
- * @param Parce rows
- */
- public function doRows( Parse $rows ) {
- $this->bind( $rows->parts );
- parent::doRows( $rows->more );
- }
- /**
- * Process a table's row
- *
- * @param Parce rows
- */
- public function doRow( $row ) {
- $this->hasExecuted = false;
- try {
- $this->reset();
- parent::doRow( $row );
- if( !$this->hasExecuted ) {
- $this->execute();
- }
- }
- catch( Exception $e ) {
- $this->exception($row->leaf(), $e);
- }
- }
- /**
- * @param Parce cell
- * @param int column
- */
- public function doCell($cell, $column) {
- $a = $this->columnBindings[$column];
- try {
- $text = $cell->text();
- if (strcmp($text,"")==0) {
- $this->check($cell, $a);
- } else if ($a == null) {
- $this->ignore($cell);
- } else if ($a->field != null) {
- $a->set($a->parse($text));
- } else if ($a->method != null) {
- $this->check($cell, $a);
- }
- } catch(Exception $e) {
- $this->exception($cell, $e);
- }
- }
- /**
- * @param Parce cell
- * @param TypeAdapter $a
- */
- public function check($cell, $a) {
- if (!$this->hasExecuted) {
- try {
- $this->execute();
- } catch (Exception $e) {
- $this->exception ($cell, $e);
- }
- $this->hasExecuted = true;
- }
- parent::check($cell, $a);
- }
- /**
- * @param Parse heads (ej: x, y, plus(), times(), etc)
- */
- protected function bind($heads) {
- $this->columnBindings = array($heads->size());
- //echo "<br>SIZE=" . $heads->size() . "<br>";
- for ($i=0; $heads != null; $heads = $heads->more) {
- //echo "<br>".$heads->text();
- $name = $heads->text();
- $suffix = "()";
- try {
- if ($name == "") {
- $this->columnBindings[$i] = null;
- } else if (strstr($name, $suffix) !== false) {
- $this->columnBindings[$i] = $this->bindMethod(substr($name, 0, strlen($name)-strlen($suffix)));
- } else {
- $this->columnBindings[$i] = $this->bindField($name);
- }
- } catch (Exception $e) {
- $this->exception($heads, $e);
- }
- $i=$i+1;
- }
- }
- /**
- * @param String name
- * @return TypeAdapter
- */
- protected function bindMethod($name) {
- return TypeAdapter::onMethod($this, $name);
- }
- /**
- * @param String name
- * @return TypeAdapter
- */
- protected function bindField($name) {
- return TypeAdapter::onField($this, $name);
- }
- public function reset() {
- }
- public function execute() {
- }
- }
- ?>
Documentation generated on Sun, 02 Apr 2006 16:01:03 +0200 by phpDocumentor 1.3.0RC5