Location: PHPKode > projects > Rthree > r3-1.9.0/r3/generate/OutputFactory.php
<?php

/**
 * provides {@link r3_generate_Output} class
 *
 *
 * Copyright (c) 2007 Yahoo! Inc.  All rights reserved.
 * The copyrights embodied in the content of this file are licensed under the BSD
 * open source license
 *
 * @package r3
 * @subpackage generate
 */
/**
 */

/**
 * provides {@link r3_generate_Output} class
 *
 * @package r3
 * @subpackage generate
 */
abstract class r3_generate_Output {
    private $buffer;
    private $open = false;
    private $bufferlen=1024;

    function output( $str , r3_generate_GenerateContext $context ){
        if ( ! $this->open ) {
            throw new r3_util_Exception( "attempt to write to unopened output handler" );
        }
        $this->buffer .= $str;
        if ( strlen( $this->buffer ) > $this->bufferlen ) {
            $this->flush( $context );
        }
    }

    protected function flush( r3_generate_GenerateContext $context ) {
        $this->doOutput( $this->buffer, $context );
        $this->buffer='';
    }

    function open( r3_generate_GenerateContext $context ) {
        if ( $this->open ) {
            return true;
        }
        $this->doOpen( $context );
        $this->open = true;
    }

    function close( r3_generate_GenerateContext $context ) {
        if ( ! $this->open ) {
            return true;
        }
        $this->flush( $context );
        $this->doClose( $context );
        $this->open = false;
    }

    abstract function doOutput( $str, r3_generate_GenerateContext $context );
    abstract function doOpen( r3_generate_GenerateContext $context );
    abstract function doClose( r3_generate_GenerateContext $context );
}

?>
Return current item: Rthree