/*
* <copyright>
* Copyright (c) 2001 by Hyperwave AG
* </copyright>
*
* <file>
* Name:    CSResourceReader.js
* Created: 2001-04-03 Mair Martin
* $Id: CSResourceReader.js,v 1.3 2003/07/03 08:05:58 mmair Exp $
* </file>
*/

initPackage ( "com.hyperwave.res" );
loadClass ( "com.hyperwave.res.AbstractResourceReader" );

//------------------------------------------------------------
/**
 * A <code>CSResourceReader</code> represents a possibility for dealing
 * with resources from a file on client side. The class is normally
 * not used explicitely by the programmer but instantiated using the
 * method <code>toSource()</code> of <code>ResourceReader</code>.
 * 
 * @author Mair Martin
 */
// <JSClass Name="com.hyperwave.res.CSResourceReader">

  //------------------------------------------------------------
  /**
   * Creates a <code>CSResourceReader</code> to have the possibility of a 
   * resource reader also on client side. The parameter of the constructor 
   * defines the resource array for the reader. Normally the resource was 
   * read in on server side already and transported to client side using
   * method <code>toSource()</code> of <code>ResourceReader</code>.
   * @param aParam: String: valid JavaScript representation of a resource 
   *                        array for the reader. (Escaped and unescaped).
   */
  com.hyperwave.res.CSResourceReader = function ( aParam )
  {
    if ( aParam == "__proto__" )
      return;

    if ( aParam == null )
    {
      this.error_ = new com.hyperwave.res.ResourceException (
        "com.hyperwave.res.CSResourceReader: Constructed without resource array" );
      return;
    }

    this.base$ = com.hyperwave.res.AbstractResourceReader;
    this.base$ ( aParam );
    delete this.base$;

    this.resArray_ = aParam;
    this._createKeyArray();
  }
  class$ = doInherit ( com.hyperwave.res.CSResourceReader,
                       com.hyperwave.res.AbstractResourceReader );
  
  //------------------------------------------------------------
  /**
   * creates the internal property <code>keyArray_</code> from the 
   * given property <code>resArray_</code>
   */
  class$._createKeyArray = function ()
  {
    this.keyArray_ = new Array();
    for (var key in this.resArray_)
    {
      this.keyArray_ [this.keyArray_.length] = key;
    }
  }

// </JSClass>
//----------------------------------------------------------------------------

