Location: PHPKode > projects > Rthree > r3-1.9.0/r3/generate/Output.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 ) {
        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( );
        }
    }

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

    protected function buffer( ) {
        return $this->buffer;
    }

    protected function append( $str ) {
        $this->buffer .= $str;
    }

    function context() {
        return $this->currentContext;
    }

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

    function isOpen() {
        return $this->open;
    }

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

    function getBuffer( ) {
        return $this->buffer;
    }

    function cleanBuffer( ) {
        $this->buffer = '';
    }

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

?>
Return current item: Rthree