/**
 * This class is the abstracted version of a cross-browser <code>StringBuffer</code>, as in Java(tm).  
 * It may be used with <code>StringBuffer</code> independently of any other JavaScript code.<br><br>
 * The dominant versions of Firefox and Opera (versions 1.x and up) have fixed the string concatenation 
 * problem with the <code>+</code> and <code>+=</code> operator that
 * has plagued Internet Explorer v6 and less (and perhaps v7), and Mozilla web browsers 
 * (including Netscape 7 and below).  The string concatenation problem is very severe on these browsers.
 * <br><br>
 * This StringBuffer class provides string concatenation on Firefox and Opera that comes very close to their
 * native performance, while giving a performance boost of about six-fold to Internet Explorer, plus 
 * more gains in overall JavaScript application speed by avoiding unnecessary memory allocation on browsers
 * that have the problem with string concatentation using the <code>+=</code> operator.
 * <br><br>
 * Testing results show that this class strikes an optimal balance, in a single class, between optimizing String 
 * concatenation for Internet Explorer/some other web browsers and delivering the extra-fast performance 
 * offered by Firefox and Opera.
 * <br><br>
 * Please note that this class is highly optimized for execution speed.  Take great care before altering its code.
 * For example, the <code>StringBuffer</code> methods that use the <code>+=</code> operator are in fact set 
 * in the concrete class, since they are more easily accessed there and since they need to be in order to 
 * avoid impacting the performance on Firefox and other browsers that do not have a problem with string
 * concatenation using the <code>+=</code> operator.  Both sets of methods (using <code>Array</code> and using
 * <code>+=</code>) cannot be set in the concrete class, since a single method identifier must point to them to 
 * maintain compliance with a proper <code>StringBuffer</code> interface.
 * <br><br>
 * <a href="mailto:ehudsons@andrew.cmu.edu">Ellen Hudson-Snyder</a>, 
 * <a href="mailto:evedar@andrew.cmu.edu">Elvin Vedar</a>,
 * <a href="mailto:cbalz@andrew.cmu.edu">Christopher M. Balz</a>.
 * <br><br>CVS Version Info:<br>
 *  $Id: AbstractStringBuffer.js,v 1.4 2005/12/27 01:05:54 cbalz Exp $   
 * <br><br>
 * @boolean-prop <code>this.booIsFixed</code>  Whether or not we are running on a browser with the problem with 
 *                                             <code>+=</code> described above.
 * @author Team GigaToasted (Fall-2005-CMU-NASA/Google-Practicum Subteam) 
 * @version 1.0
 * <br><br>
 */


/**
 * Create an <code>AbstractStringBuffer</code> class.  This constructor is only 
 * called once during the operation of the application -- at initialization.
 */
function AbstractStringBuffer() {
  var agt = navigator.userAgent.toLowerCase();
  this.booIsFixed  = ( agt.indexOf('firefox') != -1 || agt.indexOf('opera') != -1 );  
  this.append      = AbstractStringBuffer_appendArray;
  this.toString    = AbstractStringBuffer_toStringFromArray;
}


/**
 * This method appends to the string with the <code>push</code> method of 
 * an object of type <code>Array</code>.
 * @param pArrStrings  <code>Array</code> An array containing the string or strings to append.
 */
function AbstractStringBuffer_appendArray( pArrStrings ) {
    this.arrStrings.push( pArrStrings.join( "" ) );
}


/**
 * This method returns a string that was 
 * concatenated by means of an object of type <code>Array</code>.
 * @return <code>string</code> The concatenated string.
 */
function AbstractStringBuffer_toStringFromArray() {
    return this.arrStrings.join( "" );
}
