text:
#include <config.h>

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "compat.h"
#include "dck.h"
#include "display.h"
#include "infrastructure/startup_manager.h"
#include "machine.h"
#include "memory_pages.h"
#include "module.h"
#include "periph.h"
#include "scld.h"
#include "spectrum.h"
#include "ui/ui.h"
#include "z80/z80.h"

scld scld_last_dec;                 /* The last byte sent to Timex DEC port */

libspectrum_byte scld_last_hsr = 0; /* The last byte sent to Timex HSR port */

memory_page * timex_home[MEMORY_PAGES_IN_64K];
memory_page timex_exrom[MEMORY_PAGES_IN_64K];
memory_page timex_dock[MEMORY_PAGES_IN_64K];

static void scld_reset( int hard_reset );
static void scld_from_snapshot( libspectrum_snap *snap );
static void scld_to_snapshot( libspectrum_snap *snap );

static module_info_t scld_module_info = {

  /* .reset = */ scld_reset,
  /* .romcs = */ NULL,
  /* .snapshot_enabled = */ NULL,
  /* .snapshot_from = */ scld_from_snapshot,
  /* .snapshot_to = */ scld_to_snapshot,

};

static libspectrum_byte scld_dec_read( libspectrum_word port, libspectrum_byte *attached );
static libspectrum_byte scld_hsr_read( libspectrum_word port, libspectrum_byte *attached );

static const periph_port_t scld_ports[] = {
  { 0x00ff, 0x00f4, scld_hsr_read, scld_hsr_write },
  { 0x00ff, 0x00ff, scld_dec_read, scld_dec_write },
  { 0, 0, NULL, NULL }
};

static const periph_t scld_periph = {
  /* .option = */ NULL,
  /* .ports = */ scld_ports,
  /* .hard_reset = */ 0,
  /* .activate = */ NULL,
};

static int
scld_init( void *context )
{
  module_register( &scld_module_info );
  periph_register( PERIPH_TYPE_SCLD, &scld_periph );

  return 0;
}

void
scld_register_startup( void )
{
  startup_manager_module dependencies[] = { STARTUP_MANAGER_MODULE_SETUID };
  startup_manager_register( STARTUP_MANAGER_MODULE_SCLD, dependencies,
                            ARRAY_SIZE( dependencies ), scld_init, NULL,
                            NULL );
}

static libspectrum_byte
scld_dec_read( libspectrum_word port GCC_UNUSED, libspectrum_byte *attached )
{
  *attached = 0xff; /* TODO: check this */

  return scld_last_dec.byte;
}

void
scld_dec_write( libspectrum_word port GCC_UNUSED, libspectrum_byte b )
{
  scld old_dec = scld_last_dec;
  scld new_dec;
  libspectrum_byte ink,paper;

  /* We use new_dec as we don't want to have the new colours, modes etc.
     to take effect until we have updated the critical region */
  new_dec.byte = b;

  /* If we changed the active screen, or change the colour in hires
   * mode, update the critical region and mark the entire display file as
   * dirty so we redraw it on the next pass */
  if( new_dec.mask.scrnmode != old_dec.mask.scrnmode ||
      new_dec.name.hires != old_dec.name.hires ||
      ( new_dec.name.hires &&
           ( new_dec.mask.hirescol != old_dec.mask.hirescol ) ) ) {
    display_update_critical( 0, 0 );
    display_refresh_main_screen();
  }

  /* Commit change to scld_last_dec */
  scld_last_dec = new_dec;

  /* If we just reenabled interrupts, check for a retriggered interrupt */
  if( old_dec.name.intdisable && !scld_last_dec.name.intdisable )
    z80_interrupt();

  if( scld_last_dec.name.altmembank != old_dec.name.altmembank )
    machine_current->memory_map();

  display_parse_attr( hires_get_attr(), &ink, &paper );
  display_set_hires_border( paper );
}

static void
scld_reset( int hard_reset GCC_UNUSED )
{
  scld_last_dec.byte = 0;
}

void
scld_hsr_write( libspectrum_word port GCC_UNUSED, libspectrum_byte b )
{
  scld_last_hsr = b;

  machine_current->memory_map();
}

static libspectrum_byte
scld_hsr_read( libspectrum_word port GCC_UNUSED, libspectrum_byte *attached )
{
  *attached = 0xff; /* TODO: check this */

  return scld_last_hsr;
}

libspectrum_byte
hires_get_attr( void )
{
  return( hires_convert_dec( scld_last_dec.byte ) );
}

libspectrum_byte
hires_convert_dec( libspectrum_byte attr )
{
  scld colour;

  colour.byte = attr;

  switch ( colour.mask.hirescol )
  {
    case BLACKWHITE:   return 0x47;
    case BLUEYELLOW:   return 0x4e;
    case REDCYAN:      return 0x55;
    case MAGENTAGREEN: return 0x5c;
    case GREENMAGENTA: return 0x63;
    case CYANRED:      return 0x6a;
    case YELLOWBLUE:   return 0x71;
    default:	       return 0x78; /* WHITEBLACK */
  }
}

void
scld_memory_map( void )
{
  int i;
  memory_page *exrom_dock;

  exrom_dock =
    scld_last_dec.name.altmembank ? timex_exrom : timex_dock;

  for( i = 0; i < 8; i++ )
    if( scld_last_hsr & (1 << i) )
      memory_map_8k( i * 0x2000, exrom_dock, i );
}

/* Initialise the memory map to point to the home bank */
void
scld_memory_map_home( void )
{
  int i;

  for( i = 0; i < MEMORY_PAGES_IN_64K; i++ )
    memory_map_page( timex_home, i );
}

static void
scld_dock_exrom_from_snapshot( memory_page *dest, int page_num, int writable,
                               void *source )
{
  int i;
  libspectrum_byte *data = memory_pool_allocate( 0x2000 );

  memcpy( data, source, 0x2000 );

  for( i = 0; i < MEMORY_PAGES_IN_8K; i++ ) {
    memory_page *page = &dest[ page_num * MEMORY_PAGES_IN_8K + i ];
    page->offset = i * MEMORY_PAGE_SIZE;
    page->page_num = page_num;
    page->writable = writable;
    page->page = data + page->offset;
    page->save_to_snapshot = 1;
  }

  /* Reset contention for pages */
  scld_set_exrom_dock_contention();
}

static void
scld_from_snapshot( libspectrum_snap *snap )
{
  size_t i;
  int capabilities = machine_current->capabilities;

  if( capabilities & ( LIBSPECTRUM_MACHINE_CAPABILITY_TIMEX_MEMORY |
      LIBSPECTRUM_MACHINE_CAPABILITY_SE_MEMORY ) )
    scld_hsr_write( 0x00f4, libspectrum_snap_out_scld_hsr( snap ) );

  if( capabilities & LIBSPECTRUM_MACHINE_CAPABILITY_TIMEX_VIDEO )
    scld_dec_write( 0x00ff, libspectrum_snap_out_scld_dec( snap ) );

  if( libspectrum_snap_dock_active( snap ) ) {

    dck_active = 1;

    for( i = 0; i < 8; i++ ) {

      if( libspectrum_snap_dock_cart( snap, i ) )
        scld_dock_exrom_from_snapshot( timex_dock, i,
          libspectrum_snap_dock_ram( snap, i ),
          libspectrum_snap_dock_cart( snap, i ) );

      if( libspectrum_snap_exrom_cart( snap, i ) )
        scld_dock_exrom_from_snapshot( timex_exrom, i,
          libspectrum_snap_exrom_ram( snap, i ),
          libspectrum_snap_exrom_cart( snap, i ) );

    }

    if( capabilities & LIBSPECTRUM_MACHINE_CAPABILITY_TIMEX_DOCK )
      ui_menu_activate( UI_MENU_ITEM_MEDIA_CARTRIDGE_DOCK_EJECT, 1 );

    machine_current->memory_map();
  }

}

static void
scld_to_snapshot( libspectrum_snap *snap )
{
  size_t i;
  libspectrum_byte *buffer;

  libspectrum_snap_set_out_scld_hsr( snap, scld_last_hsr );
  libspectrum_snap_set_out_scld_dec( snap, scld_last_dec.byte );

  if( dck_active ) {

    libspectrum_snap_set_dock_active( snap, 1 );

    for( i = 0; i < 8; i++ ) {

      memory_page *exrom_base = &timex_exrom[i * MEMORY_PAGES_IN_8K],
        *dock_base = &timex_dock[i * MEMORY_PAGES_IN_8K];
      int j;

      /* In theory, Fuse could somehow have set up a memory map in which the
         first 4Kb of a DOCK page is writable, but the second 4Kb is not, and
         this structure is not representable in a snapshot.

         However, there's currently no code which could produce this situation
         so for simplicity's sake, we assume the properties of the lowest page
         in the 8Kb chunk apply to all the pages */

      if( exrom_base->save_to_snapshot || exrom_base->writable ) {
        buffer = libspectrum_new( libspectrum_byte, 0x2000 );

        libspectrum_snap_set_exrom_ram( snap, i, exrom_base->writable );
        for( j = 0; j < MEMORY_PAGES_IN_8K; j++ ) {
          memory_page *page = exrom_base + j;
          memcpy( buffer + j * MEMORY_PAGE_SIZE, page->page, MEMORY_PAGE_SIZE );
        }
        libspectrum_snap_set_exrom_cart( snap, i, buffer );
      }

      if( dock_base->save_to_snapshot || dock_base->writable ) {
        buffer = libspectrum_new( libspectrum_byte, 0x2000 );

        libspectrum_snap_set_dock_ram( snap, i, dock_base->writable );
        for( j = 0; j < MEMORY_PAGES_IN_8K; j++ ) {
          memory_page *page = dock_base + j;
          memcpy( buffer + j * MEMORY_PAGE_SIZE, page->page, MEMORY_PAGE_SIZE );
        }
        libspectrum_snap_set_dock_cart( snap, i, buffer );
      }

    }

  }
}

/* Map 16K of memory and record default mapping for dock */
void
scld_home_map_16k( libspectrum_word address, memory_page source[],
                   int page_num )
{
  int i;

  memory_map_16k( address, source, page_num );

  for( i = 0; i < MEMORY_PAGES_IN_16K; i++ ) {
    int page = ( address >> MEMORY_PAGE_SIZE_LOGARITHM ) + i;
    timex_home[ page ] = &source[ page_num * MEMORY_PAGES_IN_16K + i ];
  }
}

/* Set contention for SCLD, contended in home, Dock and Exrom in the 0x4000 -
   0x7FFF range */
void
scld_set_exrom_dock_contention( void )
{
  int i;
  const int page_num = 1;

  for( i = 0; i < MEMORY_PAGES_IN_16K; i++ ) {
    timex_exrom[ page_num * MEMORY_PAGES_IN_16K + i ].contended = 1;
    timex_dock[ page_num * MEMORY_PAGES_IN_16K + i ].contended = 1;
  }
}


text:
var util = require("util");
var choreography = require("temboo/core/choreography");

/*
    GetLoadServingEntities
    Returns a list of LoadServingEntity objects based a specified search criteria.
*/

var GetLoadServingEntities = function(session) {
    /*
        Create a new instance of the GetLoadServingEntities Choreo. A TembooSession object, containing a valid
        set of Temboo credentials, must be supplied.
	*/
    var location = "/Library/Genability/TariffData/GetLoadServingEntities"
    GetLoadServingEntities.super_.call(this, session, location);

    /*
    Define a callback that will be used to appropriately format the results of this Choreo.
    */
    var newResultSet = function(resultStream) {
        return new GetLoadServingEntitiesResultSet(resultStream);
    }

	/*
	Obtain a new InputSet object, used to specify the input values for an execution of this Choreo.
	*/
    this.newInputSet = function() {
        return new GetLoadServingEntitiesInputSet();
    }

	/*
	Execute this Choreo with the specified inputs, calling the specified callback upon success,
	and the specified errorCallback upon error.
	*/
    this.execute = function(inputs, callback, errorCallback) {
        this._execute(inputs, newResultSet, callback, errorCallback);
    }
}

/*
An InputSet with methods appropriate for specifying the inputs to the GetLoadServingEntities
Choreo. The InputSet object is used to specify input parameters when executing this Choreo.
*/

var GetLoadServingEntitiesInputSet = function() {
    GetLoadServingEntitiesInputSet.super_.call(this);
        /*
        Set the value of the AccountID input for this Choreo. ((optional, string) The unique ID of the Account to find LSEs for. When passed in, the search will look for a territoryId on the Account and use that to find all LSEs that provide service within that territory.)
        */
        this.set_AccountID = function(value) {
            this.setInput("AccountID", value);
        }

        /*
        Set the value of the AppID input for this Choreo. ((conditional, string) The App ID provided by Genability.)
        */
        this.set_AppID = function(value) {
            this.setInput("AppID", value);
        }

        /*
        Set the value of the AppKey input for this Choreo. ((required, string) The App Key provided by Genability.)
        */
        this.set_AppKey = function(value) {
            this.setInput("AppKey", value);
        }

        /*
        Set the value of the EndsWith input for this Choreo. ((optional, string) When true, the search will only return results that end with the specified search string. Otherwise, any match of the search string will be returned as a result.)
        */
        this.set_EndsWith = function(value) {
            this.setInput("EndsWith", value);
        }

        /*
        Set the value of the IsRegex input for this Choreo. ((optional, boolean) When true, the provided search string will be regarded as a regular expression and the search will return results matching the regular expression.)
        */
        this.set_IsRegex = function(value) {
            this.setInput("IsRegex", value);
        }

        /*
        Set the value of the PageCount input for this Choreo. ((optional, integer) The number of results to return. Defaults to 25.)
        */
        this.set_PageCount = function(value) {
            this.setInput("PageCount", value);
        }

        /*
        Set the value of the PageStart input for this Choreo. ((optional, integer) The page number to begin the result set from. Defaults to 1.)
        */
        this.set_PageStart = function(value) {
            this.setInput("PageStart", value);
        }

        /*
        Set the value of the SearchOn input for this Choreo. ((optional, string) Comma separated list of fields to query on. When searchOn is specified, the text provided in the search string field will be searched within these fields.)
        */
        this.set_SearchOn = function(value) {
            this.setInput("SearchOn", value);
        }

        /*
        Set the value of the Search input for this Choreo. ((optional, string) The string of text to search on. This can also be a regular expression, in which case you should set the 'isRegex' flag to true.)
        */
        this.set_Search = function(value) {
            this.setInput("Search", value);
        }

        /*
        Set the value of the SortOn input for this Choreo. ((optional, string) Comma separated list of fields to sort on.)
        */
        this.set_SortOn = function(value) {
            this.setInput("SortOn", value);
        }

        /*
        Set the value of the SortOrder input for this Choreo. ((optional, string) Comma separated list of ordering. Possible values are 'ASC' and 'DESC'. Default is 'ASC'. This list corresponds to the field list used in the SortOn input.)
        */
        this.set_SortOrder = function(value) {
            this.setInput("SortOrder", value);
        }

        /*
        Set the value of the StartsWith input for this Choreo. ((optional, boolean) When true, the search will only return results that begin with the specified search string. Otherwise, any match of the search string will be returned as a result.)
        */
        this.set_StartsWith = function(value) {
            this.setInput("StartsWith", value);
        }

}

/*
A ResultSet with methods tailored to the values returned by the GetLoadServingEntities Choreo.
The ResultSet object is used to retrieve the results of a Choreo execution.
*/

var GetLoadServingEntitiesResultSet = function(resultStream) {
    GetLoadServingEntitiesResultSet.super_.call(this, resultStream);
        /*
        Retrieve the value for the "Response" output from this Choreo execution. ((json) The response from Genability.)
        */
        this.get_Response = function() {
            return this.getResult("Response");
        }
}

util.inherits(GetLoadServingEntities, choreography.Choreography);
util.inherits(GetLoadServingEntitiesInputSet, choreography.InputSet);
util.inherits(GetLoadServingEntitiesResultSet, choreography.ResultSet);
exports.GetLoadServingEntities = GetLoadServingEntities;

/*
    GetLoadServingEntity
    Returns a Load Serving Entity with a given ID.
*/

var GetLoadServingEntity = function(session) {
    /*
        Create a new instance of the GetLoadServingEntity Choreo. A TembooSession object, containing a valid
        set of Temboo credentials, must be supplied.
	*/
    var location = "/Library/Genability/TariffData/GetLoadServingEntity"
    GetLoadServingEntity.super_.call(this, session, location);

    /*
    Define a callback that will be used to appropriately format the results of this Choreo.
    */
    var newResultSet = function(resultStream) {
        return new GetLoadServingEntityResultSet(resultStream);
    }

	/*
	Obtain a new InputSet object, used to specify the input values for an execution of this Choreo.
	*/
    this.newInputSet = function() {
        return new GetLoadServingEntityInputSet();
    }

	/*
	Execute this Choreo with the specified inputs, calling the specified callback upon success,
	and the specified errorCallback upon error.
	*/
    this.execute = function(inputs, callback, errorCallback) {
        this._execute(inputs, newResultSet, callback, errorCallback);
    }
}

/*
An InputSet with methods appropriate for specifying the inputs to the GetLoadServingEntity
Choreo. The InputSet object is used to specify input parameters when executing this Choreo.
*/

var GetLoadServingEntityInputSet = function() {
    GetLoadServingEntityInputSet.super_.call(this);
        /*
        Set the value of the AppID input for this Choreo. ((conditional, string) The App ID provided by Genability.)
        */
        this.set_AppID = function(value) {
            this.setInput("AppID", value);
        }

        /*
        Set the value of the AppKey input for this Choreo. ((required, string) The App Key provided by Genability.)
        */
        this.set_AppKey = function(value) {
            this.setInput("AppKey", value);
        }

        /*
        Set the value of the LSEID input for this Choreo. ((required, integer) The id of a particular Load Serving Entity to return.)
        */
        this.set_LSEID = function(value) {
            this.setInput("LSEID", value);
        }

}

/*
A ResultSet with methods tailored to the values returned by the GetLoadServingEntity Choreo.
The ResultSet object is used to retrieve the results of a Choreo execution.
*/

var GetLoadServingEntityResultSet = function(resultStream) {
    GetLoadServingEntityResultSet.super_.call(this, resultStream);
        /*
        Retrieve the value for the "Response" output from this Choreo execution. ((json) The response from Genability.)
        */
        this.get_Response = function() {
            return this.getResult("Response");
        }
}

util.inherits(GetLoadServingEntity, choreography.Choreography);
util.inherits(GetLoadServingEntityInputSet, choreography.InputSet);
util.inherits(GetLoadServingEntityResultSet, choreography.ResultSet);
exports.GetLoadServingEntity = GetLoadServingEntity;

/*
    GetMetricsForZipCode
    Returns a place object and associated facts and metrics with a given zip code.
*/

var GetMetricsForZipCode = function(session) {
    /*
        Create a new instance of the GetMetricsForZipCode Choreo. A TembooSession object, containing a valid
        set of Temboo credentials, must be supplied.
	*/
    var location = "/Library/Genability/TariffData/GetMetricsForZipCode"
    GetMetricsForZipCode.super_.call(this, session, location);

    /*
    Define a callback that will be used to appropriately format the results of this Choreo.
    */
    var newResultSet = function(resultStream) {
        return new GetMetricsForZipCodeResultSet(resultStream);
    }

	/*
	Obtain a new InputSet object, used to specify the input values for an execution of this Choreo.
	*/
    this.newInputSet = function() {
        return new GetMetricsForZipCodeInputSet();
    }

	/*
	Execute this Choreo with the specified inputs, calling the specified callback upon success,
	and the specified errorCallback upon error.
	*/
    this.execute = function(inputs, callback, errorCallback) {
        this._execute(inputs, newResultSet, callback, errorCallback);
    }
}

/*
An InputSet with methods appropriate for specifying the inputs to the GetMetricsForZipCode
Choreo. The InputSet object is used to specify input parameters when executing this Choreo.
*/

var GetMetricsForZipCodeInputSet = function() {
    GetMetricsForZipCodeInputSet.super_.call(this);
        /*
        Set the value of the AppID input for this Choreo. ((conditional, string) The App ID provided by Genability.)
        */
        this.set_AppID = function(value) {
            this.setInput("AppID", value);
        }

        /*
        Set the value of the AppKey input for this Choreo. ((required, string) The App Key provided by Genability.)
        */
        this.set_AppKey = function(value) {
            this.setInput("AppKey", value);
        }

        /*
        Set the value of the ZipCode input for this Choreo. ((optional, string) The zip code for the place object you want to return.)
        */
        this.set_ZipCode = function(value) {
            this.setInput("ZipCode", value);
        }

}

/*
A ResultSet with methods tailored to the values returned by the GetMetricsForZipCode Choreo.
The ResultSet object is used to retrieve the results of a Choreo execution.
*/

var GetMetricsForZipCodeResultSet = function(resultStream) {
    GetMetricsForZipCodeResultSet.super_.call(this, resultStream);
        /*
        Retrieve the value for the "Response" output from this Choreo execution. ((json) The response from Genability.)
        */
        this.get_Response = function() {
            return this.getResult("Response");
        }
}

util.inherits(GetMetricsForZipCode, choreography.Choreography);
util.inherits(GetMetricsForZipCodeInputSet, choreography.InputSet);
util.inherits(GetMetricsForZipCodeResultSet, choreography.ResultSet);
exports.GetMetricsForZipCode = GetMetricsForZipCode;

/*
    GetPropertyKey
    Returns an individual Property Key using a given key name.
*/

var GetPropertyKey = function(session) {
    /*
        Create a new instance of the GetPropertyKey Choreo. A TembooSession object, containing a valid
        set of Temboo credentials, must be supplied.
	*/
    var location = "/Library/Genability/TariffData/GetPropertyKey"
    GetPropertyKey.super_.call(this, session, location);

    /*
    Define a callback that will be used to appropriately format the results of this Choreo.
    */
    var newResultSet = function(resultStream) {
        return new GetPropertyKeyResultSet(resultStream);
    }

	/*
	Obtain a new InputSet object, used to specify the input values for an execution of this Choreo.
	*/
    this.newInputSet = function() {
        return new GetPropertyKeyInputSet();
    }

	/*
	Execute this Choreo with the specified inputs, calling the specified callback upon success,
	and the specified errorCallback upon error.
	*/
    this.execute = function(inputs, callback, errorCallback) {
        this._execute(inputs, newResultSet, callback, errorCallback);
    }
}

/*
An InputSet with methods appropriate for specifying the inputs to the GetPropertyKey
Choreo. The InputSet object is used to specify input parameters when executing this Choreo.
*/

var GetPropertyKeyInputSet = function() {
    GetPropertyKeyInputSet.super_.call(this);
        /*
        Set the value of the AppID input for this Choreo. ((conditional, string) The App ID provided by Genability.)
        */
        this.set_AppID = function(value) {
            this.setInput("AppID", value);
        }

        /*
        Set the value of the AppKey input for this Choreo. ((required, string) The App Key provided by Genability.)
        */
        this.set_AppKey = function(value) {
            this.setInput("AppKey", value);
        }

        /*
        Set the value of the KeyName input for this Choreo. ((required, string) The key name for the property key you want to return.)
        */
        this.set_KeyName = function(value) {
            this.setInput("KeyName", value);
        }

}

/*
A ResultSet with methods tailored to the values returned by the GetPropertyKey Choreo.
The ResultSet object is used to retrieve the results of a Choreo execution.
*/

var GetPropertyKeyResultSet = function(resultStream) {
    GetPropertyKeyResultSet.super_.call(this, resultStream);
        /*
        Retrieve the value for the "Response" output from this Choreo execution. ((json) The response from Genability.)
        */
        this.get_Response = function() {
            return this.getResult("Response");
        }
}

util.inherits(GetPropertyKey, choreography.Choreography);
util.inherits(GetPropertyKeyInputSet, choreography.InputSet);
util.inherits(GetPropertyKeyResultSet, choreography.ResultSet);
exports.GetPropertyKey = GetPropertyKey;

/*
    GetPropertyKeys
    Returns a list of Property Keys based on a specified search criteria.
*/

var GetPropertyKeys = function(session) {
    /*
        Create a new instance of the GetPropertyKeys Choreo. A TembooSession object, containing a valid
        set of Temboo credentials, must be supplied.
	*/
    var location = "/Library/Genability/TariffData/GetPropertyKeys"
    GetPropertyKeys.super_.call(this, session, location);

    /*
    Define a callback that will be used to appropriately format the results of this Choreo.
    */
    var newResultSet = function(resultStream) {
        return new GetPropertyKeysResultSet(resultStream);
    }

	/*
	Obtain a new InputSet object, used to specify the input values for an execution of this Choreo.
	*/
    this.newInputSet = function() {
        return new GetPropertyKeysInputSet();
    }

	/*
	Execute this Choreo with the specified inputs, calling the specified callback upon success,
	and the specified errorCallback upon error.
	*/
    this.execute = function(inputs, callback, errorCallback) {
        this._execute(inputs, newResultSet, callback, errorCallback);
    }
}

/*
An InputSet with methods appropriate for specifying the inputs to the GetPropertyKeys
Choreo. The InputSet object is used to specify input parameters when executing this Choreo.
*/

var GetPropertyKeysInputSet = function() {
    GetPropertyKeysInputSet.super_.call(this);
        /*
        Set the value of the AppID input for this Choreo. ((conditional, string) The App ID provided by Genability.)
        */
        this.set_AppID = function(value) {
            this.setInput("AppID", value);
        }

        /*
        Set the value of the AppKey input for this Choreo. ((required, string) The App Key provided by Genability.)
        */
        this.set_AppKey = function(value) {
            this.setInput("AppKey", value);
        }

        /*
        Set the value of the EntityID input for this Choreo. ((optional, string) Filters the result so that only Properties that belong to this EntityID are returned. When specified, EntityType must also be specified.)
        */
        this.set_EntityID = function(value) {
            this.setInput("EntityID", value);
        }

        /*
        Set the value of the EntityType input for this Choreo. ((optional, string) Filters the result so that only Properties that belong to this EntityType are returned. When specified, EntityID must also be specified.)
        */
        this.set_EntityType = function(value) {
            this.setInput("EntityType", value);
        }

        /*
        Set the value of the PageCount input for this Choreo. ((optional, integer) The number of results to return. Defaults to 25.)
        */
        this.set_PageCount = function(value) {
            this.setInput("PageCount", value);
        }

        /*
        Set the value of the PageStart input for this Choreo. ((optional, integer) The page number to begin the result set from. Defaults to 1.)
        */
        this.set_PageStart = function(value) {
            this.setInput("PageStart", value);
        }

}

/*
A ResultSet with methods tailored to the values returned by the GetPropertyKeys Choreo.
The ResultSet object is used to retrieve the results of a Choreo execution.
*/

var GetPropertyKeysResultSet = function(resultStream) {
    GetPropertyKeysResultSet.super_.call(this, resultStream);
        /*
        Retrieve the value for the "Response" output from this Choreo execution. ((json) The response from Genability.)
        */
        this.get_Response = function() {
            return this.getResult("Response");
        }
}

util.inherits(GetPropertyKeys, choreography.Choreography);
util.inherits(GetPropertyKeysInputSet, choreography.InputSet);
util.inherits(GetPropertyKeysResultSet, choreography.ResultSet);
exports.GetPropertyKeys = GetPropertyKeys;

/*
    GetSeasonGroups
    Returns a list of Season Groups for a given Load Serving Entity.
*/

var GetSeasonGroups = function(session) {
    /*
        Create a new instance of the GetSeasonGroups Choreo. A TembooSession object, containing a valid
        set of Temboo credentials, must be supplied.
	*/
    var location = "/Library/Genability/TariffData/GetSeasonGroups"
    GetSeasonGroups.super_.call(this, session, location);

    /*
    Define a callback that will be used to appropriately format the results of this Choreo.
    */
    var newResultSet = function(resultStream) {
        return new GetSeasonGroupsResultSet(resultStream);
    }

	/*
	Obtain a new InputSet object, used to specify the input values for an execution of this Choreo.
	*/
    this.newInputSet = function() {
        return new GetSeasonGroupsInputSet();
    }

	/*
	Execute this Choreo with the specified inputs, calling the specified callback upon success,
	and the specified errorCallback upon error.
	*/
    this.execute = function(inputs, callback, errorCallback) {
        this._execute(inputs, newResultSet, callback, errorCallback);
    }
}

/*
An InputSet with methods appropriate for specifying the inputs to the GetSeasonGroups
Choreo. The InputSet object is used to specify input parameters when executing this Choreo.
*/

var GetSeasonGroupsInputSet = function() {
    GetSeasonGroupsInputSet.super_.call(this);
        /*
        Set the value of the AppID input for this Choreo. ((conditional, string) The App ID provided by Genability.)
        */
        this.set_AppID = function(value) {
            this.setInput("AppID", value);
        }

        /*
        Set the value of the AppKey input for this Choreo. ((required, string) The App Key provided by Genability.)
        */
        this.set_AppKey = function(value) {
            this.setInput("AppKey", value);
        }

        /*
        Set the value of the EndsWith input for this Choreo. ((optional, string) When true, the search will only return results that end with the specified search string. Otherwise, any match of the search string will be returned as a result.)
        */
        this.set_EndsWith = function(value) {
            this.setInput("EndsWith", value);
        }

        /*
        Set the value of the IsRegex input for this Choreo. ((optional, boolean) When true, the provided search string will be regarded as a regular expression and the search will return results matching the regular expression.)
        */
        this.set_IsRegex = function(value) {
            this.setInput("IsRegex", value);
        }

        /*
        Set the value of the LSEID input for this Choreo. ((required, integer) The LSE Id whose Seasons to return.)
        */
        this.set_LSEID = function(value) {
            this.setInput("LSEID", value);
        }

        /*
        Set the value of the PageCount input for this Choreo. ((optional, integer) The number of results to return. Defaults to 25.)
        */
        this.set_PageCount = function(value) {
            this.setInput("PageCount", value);
        }

        /*
        Set the value of the PageStart input for this Choreo. ((optional, integer) The page number to begin the result set from. Defaults to 1.)
        */
        this.set_PageStart = function(value) {
            this.setInput("PageStart", value);
        }

        /*
        Set the value of the SearchOn input for this Choreo. ((optional, string) Comma separated list of fields to query on. When searchOn is specified, the text provided in the search string field will be searched within these fields.)
        */
        this.set_SearchOn = function(value) {
            this.setInput("SearchOn", value);
        }

        /*
        Set the value of the Search input for this Choreo. ((optional, string) The string of text to search on. This can also be a regular expression, in which case you should set the 'isRegex' flag to true.)
        */
        this.set_Search = function(value) {
            this.setInput("Search", value);
        }

        /*
        Set the value of the SortOn input for this Choreo. ((optional, string) Comma separated list of fields to sort on.)
        */
        this.set_SortOn = function(value) {
            this.setInput("SortOn", value);
        }

        /*
        Set the value of the SortOrder input for this Choreo. ((optional, string) Comma separated list of ordering. Possible values are 'ASC' and 'DESC'. Default is 'ASC'. This list corresponds to the field list used in the SortOn input.)
        */
        this.set_SortOrder = function(value) {
            this.setInput("SortOrder", value);
        }

        /*
        Set the value of the StartsWith input for this Choreo. ((optional, boolean) When true, the search will only return results that begin with the specified search string. Otherwise, any match of the search string will be returned as a result.)
        */
        this.set_StartsWith = function(value) {
            this.setInput("StartsWith", value);
        }

}

/*
A ResultSet with methods tailored to the values returned by the GetSeasonGroups Choreo.
The ResultSet object is used to retrieve the results of a Choreo execution.
*/

var GetSeasonGroupsResultSet = function(resultStream) {
    GetSeasonGroupsResultSet.super_.call(this, resultStream);
        /*
        Retrieve the value for the "Response" output from this Choreo execution. ((json) The response from Genability.)
        */
        this.get_Response = function() {
            return this.getResult("Response");
        }
}

util.inherits(GetSeasonGroups, choreography.Choreography);
util.inherits(GetSeasonGroupsInputSet, choreography.InputSet);
util.inherits(GetSeasonGroupsResultSet, choreography.ResultSet);
exports.GetSeasonGroups = GetSeasonGroups;

/*
    GetTariff
    Returns an individual Tariff object with a given id.
*/

var GetTariff = function(session) {
    /*
        Create a new instance of the GetTariff Choreo. A TembooSession object, containing a valid
        set of Temboo credentials, must be supplied.
	*/
    var location = "/Library/Genability/TariffData/GetTariff"
    GetTariff.super_.call(this, session, location);

    /*
    Define a callback that will be used to appropriately format the results of this Choreo.
    */
    var newResultSet = function(resultStream) {
        return new GetTariffResultSet(resultStream);
    }

	/*
	Obtain a new InputSet object, used to specify the input values for an execution of this Choreo.
	*/
    this.newInputSet = function() {
        return new GetTariffInputSet();
    }

	/*
	Execute this Choreo with the specified inputs, calling the specified callback upon success,
	and the specified errorCallback upon error.
	*/
    this.execute = function(inputs, callback, errorCallback) {
        this._execute(inputs, newResultSet, callback, errorCallback);
    }
}

/*
An InputSet with methods appropriate for specifying the inputs to the GetTariff
Choreo. The InputSet object is used to specify input parameters when executing this Choreo.
*/

var GetTariffInputSet = function() {
    GetTariffInputSet.super_.call(this);
        /*
        Set the value of the AppID input for this Choreo. ((conditional, string) The App ID provided by Genability.)
        */
        this.set_AppID = function(value) {
            this.setInput("AppID", value);
        }

        /*
        Set the value of the AppKey input for this Choreo. ((required, string) The App Key provided by Genability.)
        */
        this.set_AppKey = function(value) {
            this.setInput("AppKey", value);
        }

        /*
        Set the value of the MasterTariffID input for this Choreo. ((required, integer) The master tariff id. This can be retrieved in the output of the GetTariffs Choreo.)
        */
        this.set_MasterTariffID = function(value) {
            this.setInput("MasterTariffID", value);
        }

        /*
        Set the value of the PopulateProperties input for this Choreo. ((optional, boolean) Set to "true" to populate the properties for the returned Tariffs.)
        */
        this.set_PopulateProperties = function(value) {
            this.setInput("PopulateProperties", value);
        }

        /*
        Set the value of the PopulateRates input for this Choreo. ((optional, boolean) Set to "true" to populate the rate details for the returned Tariffs.)
        */
        this.set_PopulateRates = function(value) {
            this.setInput("PopulateRates", value);
        }

}

/*
A ResultSet with methods tailored to the values returned by the GetTariff Choreo.
The ResultSet object is used to retrieve the results of a Choreo execution.
*/

var GetTariffResultSet = function(resultStream) {
    GetTariffResultSet.super_.call(this, resultStream);
        /*
        Retrieve the value for the "Response" output from this Choreo execution. ((json) The response from Genability.)
        */
        this.get_Response = function() {
            return this.getResult("Response");
        }
}

util.inherits(GetTariff, choreography.Choreography);
util.inherits(GetTariffInputSet, choreography.InputSet);
util.inherits(GetTariffResultSet, choreography.ResultSet);
exports.GetTariff = GetTariff;

/*
    GetTariffs
    Returns a list of Tariff objects based a specified search criteria.
*/

var GetTariffs = function(session) {
    /*
        Create a new instance of the GetTariffs Choreo. A TembooSession object, containing a valid
        set of Temboo credentials, must be supplied.
	*/
    var location = "/Library/Genability/TariffData/GetTariffs"
    GetTariffs.super_.call(this, session, location);

    /*
    Define a callback that will be used to appropriately format the results of this Choreo.
    */
    var newResultSet = function(resultStream) {
        return new GetTariffsResultSet(resultStream);
    }

	/*
	Obtain a new InputSet object, used to specify the input values for an execution of this Choreo.
	*/
    this.newInputSet = function() {
        return new GetTariffsInputSet();
    }

	/*
	Execute this Choreo with the specified inputs, calling the specified callback upon success,
	and the specified errorCallback upon error.
	*/
    this.execute = function(inputs, callback, errorCallback) {
        this._execute(inputs, newResultSet, callback, errorCallback);
    }
}

/*
An InputSet with methods appropriate for specifying the inputs to the GetTariffs
Choreo. The InputSet object is used to specify input parameters when executing this Choreo.
*/

var GetTariffsInputSet = function() {
    GetTariffsInputSet.super_.call(this);
        /*
        Set the value of the AccountID input for this Choreo. ((optional, string) The unique ID of the Account to find tariffs for. Values passed in will override those from the Account.)
        */
        this.set_AccountID = function(value) {
            this.setInput("AccountID", value);
        }

        /*
        Set the value of the AppID input for this Choreo. ((conditional, string) The App ID provided by Genability.)
        */
        this.set_AppID = function(value) {
            this.setInput("AppID", value);
        }

        /*
        Set the value of the AppKey input for this Choreo. ((required, string) The App Key provided by Genability.)
        */
        this.set_AppKey = function(value) {
            this.setInput("AppKey", value);
        }

        /*
        Set the value of the CustomerClasses input for this Choreo. ((optional, string) Returns only these customer classes. Valid values are: RESIDENTIAL, GENERAL.)
        */
        this.set_CustomerClasses = function(value) {
            this.setInput("CustomerClasses", value);
        }

        /*
        Set the value of the EffectiveOn input for this Choreo. ((optional, date) Returns only tariffs that are effective on this date.)
        */
        this.set_EffectiveOn = function(value) {
            this.setInput("EffectiveOn", value);
        }

        /*
        Set the value of the EndsWith input for this Choreo. ((optional, string) When true, the search will only return results that end with the specified search string. Otherwise, any match of the search string will be returned as a result.)
        */
        this.set_EndsWith = function(value) {
            this.setInput("EndsWith", value);
        }

        /*
        Set the value of the FromDateTime input for this Choreo. ((optional, date) Returns only tariffs that are effective on or after this date.)
        */
        this.set_FromDateTime = function(value) {
            this.setInput("FromDateTime", value);
        }

        /*
        Set the value of the IsRegex input for this Choreo. ((optional, boolean) When true, the provided search string will be regarded as a regular expression and the search will return results matching the regular expression.)
        */
        this.set_IsRegex = function(value) {
            this.setInput("IsRegex", value);
        }

        /*
        Set the value of the LSEID input for this Choreo. ((optional, integer) Filter tariffs for a specific LSE.)
        */
        this.set_LSEID = function(value) {
            this.setInput("LSEID", value);
        }

        /*
        Set the value of the PageCount input for this Choreo. ((optional, integer) The number of results to return. Defaults to 25.)
        */
        this.set_PageCount = function(value) {
            this.setInput("PageCount", value);
        }

        /*
        Set the value of the PageStart input for this Choreo. ((optional, integer) The page number to begin the result set from. Defaults to 1.)
        */
        this.set_PageStart = function(value) {
            this.setInput("PageStart", value);
        }

        /*
        Set the value of the PopulateProperties input for this Choreo. ((optional, boolean) Set to "true" to populate the properties for the returned Tariffs.)
        */
        this.set_PopulateProperties = function(value) {
            this.setInput("PopulateProperties", value);
        }

        /*
        Set the value of the PopulateRates input for this Choreo. ((optional, boolean) Set to "true" to populate the rate details for the returned Tariffs.)
        */
        this.set_PopulateRates = function(value) {
            this.setInput("PopulateRates", value);
        }

        /*
        Set the value of the SearchOn input for this Choreo. ((optional, string) Comma separated list of fields to query on. When searchOn is specified, the text provided in the search string field will be searched within these fields.)
        */
        this.set_SearchOn = function(value) {
            this.setInput("SearchOn", value);
        }

        /*
        Set the value of the Search input for this Choreo. ((optional, string) The string of text to search on. This can also be a regular expression, in which case you should set the 'isRegex' flag to true.)
        */
        this.set_Search = function(value) {
            this.setInput("Search", value);
        }

        /*
        Set the value of the SortOn input for this Choreo. ((optional, string) Comma separated list of fields to sort on.)
        */
        this.set_SortOn = function(value) {
            this.setInput("SortOn", value);
        }

        /*
        Set the value of the SortOrder input for this Choreo. ((optional, string) Comma separated list of ordering. Possible values are 'ASC' and 'DESC'. Default is 'ASC'. This list corresponds to the field list used in the SortOn input.)
        */
        this.set_SortOrder = function(value) {
            this.setInput("SortOrder", value);
        }

        /*
        Set the value of the StartsWith input for this Choreo. ((optional, boolean) When true, the search will only return results that begin with the specified search string. Otherwise, any match of the search string will be returned as a result.)
        */
        this.set_StartsWith = function(value) {
            this.setInput("StartsWith", value);
        }

        /*
        Set the value of the TariffTypes input for this Choreo. ((optional, string) Returns only these tariff types. Valid values are: DEFAULT, ALTERNATIVE, OPTIONAL_EXTRA, RIDER.)
        */
        this.set_TariffTypes = function(value) {
            this.setInput("TariffTypes", value);
        }

        /*
        Set the value of the ToDateTime input for this Choreo. ((optional, date) Returns only tariffs that are effective on or before this date.)
        */
        this.set_ToDateTime = function(value) {
            this.setInput("ToDateTime", value);
        }

        /*
        Set the value of the ZipCode input for this Choreo. ((optional, string) Return tariffs for a given zip or post code.)
        */
        this.set_ZipCode = function(value) {
            this.setInput("ZipCode", value);
        }

}

/*
A ResultSet with methods tailored to the values returned by the GetTariffs Choreo.
The ResultSet object is used to retrieve the results of a Choreo execution.
*/

var GetTariffsResultSet = function(resultStream) {
    GetTariffsResultSet.super_.call(this, resultStream);
        /*
        Retrieve the value for the "Response" output from this Choreo execution. ((json) The response from Genability.)
        */
        this.get_Response = function() {
            return this.getResult("Response");
        }
}

util.inherits(GetTariffs, choreography.Choreography);
util.inherits(GetTariffsInputSet, choreography.InputSet);
util.inherits(GetTariffsResultSet, choreography.ResultSet);
exports.GetTariffs = GetTariffs;

/*
    GetTerritories
    Returns a list of Territory objects based a specified search criteria.
*/

var GetTerritories = function(session) {
    /*
        Create a new instance of the GetTerritories Choreo. A TembooSession object, containing a valid
        set of Temboo credentials, must be supplied.
	*/
    var location = "/Library/Genability/TariffData/GetTerritories"
    GetTerritories.super_.call(this, session, location);

    /*
    Define a callback that will be used to appropriately format the results of this Choreo.
    */
    var newResultSet = function(resultStream) {
        return new GetTerritoriesResultSet(resultStream);
    }

	/*
	Obtain a new InputSet object, used to specify the input values for an execution of this Choreo.
	*/
    this.newInputSet = function() {
        return new GetTerritoriesInputSet();
    }

	/*
	Execute this Choreo with the specified inputs, calling the specified callback upon success,
	and the specified errorCallback upon error.
	*/
    this.execute = function(inputs, callback, errorCallback) {
        this._execute(inputs, newResultSet, callback, errorCallback);
    }
}

/*
An InputSet with methods appropriate for specifying the inputs to the GetTerritories
Choreo. The InputSet object is used to specify input parameters when executing this Choreo.
*/

var GetTerritoriesInputSet = function() {
    GetTerritoriesInputSet.super_.call(this);
        /*
        Set the value of the AppID input for this Choreo. ((conditional, string) The App ID provided by Genability.)
        */
        this.set_AppID = function(value) {
            this.setInput("AppID", value);
        }

        /*
        Set the value of the AppKey input for this Choreo. ((required, string) The App Key provided by Genability.)
        */
        this.set_AppKey = function(value) {
            this.setInput("AppKey", value);
        }

        /*
        Set the value of the ContainsItemType input for this Choreo. ((optional, string) Filters the result set to include a particular type of territory. Valid values are: CITY, ZIPCODE, STATE, COUNTY.)
        */
        this.set_ContainsItemType = function(value) {
            this.setInput("ContainsItemType", value);
        }

        /*
        Set the value of the ContainsItemValue input for this Choreo. ((optional, string) Used in combination with the ContainsItemType value. Filters the Types by this value.)
        */
        this.set_ContainsItemValue = function(value) {
            this.setInput("ContainsItemValue", value);
        }

        /*
        Set the value of the EndsWith input for this Choreo. ((optional, string) When true, the search will only return results that end with the specified search string. Otherwise, any match of the search string will be returned as a result.)
        */
        this.set_EndsWith = function(value) {
            this.setInput("EndsWith", value);
        }

        /*
        Set the value of the IsRegex input for this Choreo. ((optional, boolean) When true, the provided search string will be regarded as a regular expression and the search will return results matching the regular expression.)
        */
        this.set_IsRegex = function(value) {
            this.setInput("IsRegex", value);
        }

        /*
        Set the value of the LSEID input for this Choreo. ((optional, integer) Filters the result set to only include territories within this LSE ID.)
        */
        this.set_LSEID = function(value) {
            this.setInput("LSEID", value);
        }

        /*
        Set the value of the MasterTariffID input for this Choreo. ((optional, integer) For tariffs with prices varying by geographic location, this will return the list of those territories covered by this tariff.)
        */
        this.set_MasterTariffID = function(value) {
            this.setInput("MasterTariffID", value);
        }

        /*
        Set the value of the PageCount input for this Choreo. ((optional, integer) The number of results to return. Defaults to 25.)
        */
        this.set_PageCount = function(value) {
            this.setInput("PageCount", value);
        }

        /*
        Set the value of the PageStart input for this Choreo. ((optional, integer) The page number to begin the result set from. Defaults to 1.)
        */
        this.set_PageStart = function(value) {
            this.setInput("PageStart", value);
        }

        /*
        Set the value of the PopulateItems input for this Choreo. ((optional, boolean) If set to "true", returns a list of territory items for each territory in the result set.)
        */
        this.set_PopulateItems = function(value) {
            this.setInput("PopulateItems", value);
        }

        /*
        Set the value of the PopulateLSES input for this Choreo. ((optional, string) If set to "true", the response includes a list of TerritoryLses which are all the LSEs providing service in this territory.)
        */
        this.set_PopulateLSES = function(value) {
            this.setInput("PopulateLSES", value);
        }

        /*
        Set the value of the SearchOn input for this Choreo. ((optional, string) Comma separated list of fields to query on. When searchOn is specified, the text provided in the search string field will be searched within these fields.)
        */
        this.set_SearchOn = function(value) {
            this.setInput("SearchOn", value);
        }

        /*
        Set the value of the Search input for this Choreo. ((optional, string) The string of text to search on. This can also be a regular expression, in which case you should set the 'isRegex' flag to true.)
        */
        this.set_Search = function(value) {
            this.setInput("Search", value);
        }

        /*
        Set the value of the SortOn input for this Choreo. ((optional, string) Comma separated list of fields to sort on.)
        */
        this.set_SortOn = function(value) {
            this.setInput("SortOn", value);
        }

        /*
        Set the value of the SortOrder input for this Choreo. ((optional, string) Comma separated list of ordering. Possible values are 'ASC' and 'DESC'. Default is 'ASC'. This list corresponds to the field list used in the SortOn input.)
        */
        this.set_SortOrder = function(value) {
            this.setInput("SortOrder", value);
        }

        /*
        Set the value of the StartsWith input for this Choreo. ((optional, boolean) When true, the search will only return results that begin with the specified search string. Otherwise, any match of the search string will be returned as a result.)
        */
        this.set_StartsWith = function(value) {
            this.setInput("StartsWith", value);
        }

        /*
        Set the value of the UsageTypes input for this Choreo. ((optional, string) Filters the result set to only include territories of the specified usageType. valid values are: SERVICE, TARIFF.)
        */
        this.set_UsageTypes = function(value) {
            this.setInput("UsageTypes", value);
        }

}

/*
A ResultSet with methods tailored to the values returned by the GetTerritories Choreo.
The ResultSet object is used to retrieve the results of a Choreo execution.
*/

var GetTerritoriesResultSet = function(resultStream) {
    GetTerritoriesResultSet.super_.call(this, resultStream);
        /*
        Retrieve the value for the "Response" output from this Choreo execution. ((json) The response from Genability.)
        */
        this.get_Response = function() {
            return this.getResult("Response");
        }
}

util.inherits(GetTerritories, choreography.Choreography);
util.inherits(GetTerritoriesInputSet, choreography.InputSet);
util.inherits(GetTerritoriesResultSet, choreography.ResultSet);
exports.GetTerritories = GetTerritories;

/*
    GetTerritory
    Returns a an individual Territory objects with a given id.
*/

var GetTerritory = function(session) {
    /*
        Create a new instance of the GetTerritory Choreo. A TembooSession object, containing a valid
        set of Temboo credentials, must be supplied.
	*/
    var location = "/Library/Genability/TariffData/GetTerritory"
    GetTerritory.super_.call(this, session, location);

    /*
    Define a callback that will be used to appropriately format the results of this Choreo.
    */
    var newResultSet = function(resultStream) {
        return new GetTerritoryResultSet(resultStream);
    }

	/*
	Obtain a new InputSet object, used to specify the input values for an execution of this Choreo.
	*/
    this.newInputSet = function() {
        return new GetTerritoryInputSet();
    }

	/*
	Execute this Choreo with the specified inputs, calling the specified callback upon success,
	and the specified errorCallback upon error.
	*/
    this.execute = function(inputs, callback, errorCallback) {
        this._execute(inputs, newResultSet, callback, errorCallback);
    }
}

/*
An InputSet with methods appropriate for specifying the inputs to the GetTerritory
Choreo. The InputSet object is used to specify input parameters when executing this Choreo.
*/

var GetTerritoryInputSet = function() {
    GetTerritoryInputSet.super_.call(this);
        /*
        Set the value of the AppID input for this Choreo. ((conditional, string) The App ID provided by Genability.)
        */
        this.set_AppID = function(value) {
            this.setInput("AppID", value);
        }

        /*
        Set the value of the AppKey input for this Choreo. ((required, string) The App Key provided by Genability.)
        */
        this.set_AppKey = function(value) {
            this.setInput("AppKey", value);
        }

        /*
        Set the value of the PopulateItems input for this Choreo. ((optional, boolean) If set to "true", returns a list of territory items for each territory in the result set.)
        */
        this.set_PopulateItems = function(value) {
            this.setInput("PopulateItems", value);
        }

        /*
        Set the value of the TerritoryID input for this Choreo. ((required, integer) The id for the territory to retrieve. This can be retrieved in the output of the GetTerritories Choreo.)
        */
        this.set_TerritoryID = function(value) {
            this.setInput("TerritoryID", value);
        }

}

/*
A ResultSet with methods tailored to the values returned by the GetTerritory Choreo.
The ResultSet object is used to retrieve the results of a Choreo execution.
*/

var GetTerritoryResultSet = function(resultStream) {
    GetTerritoryResultSet.super_.call(this, resultStream);
        /*
        Retrieve the value for the "Response" output from this Choreo execution. ((json) The response from Genability.)
        */
        this.get_Response = function() {
            return this.getResult("Response");
        }
}

util.inherits(GetTerritory, choreography.Choreography);
util.inherits(GetTerritoryInputSet, choreography.InputSet);
util.inherits(GetTerritoryResultSet, choreography.ResultSet);
exports.GetTerritory = GetTerritory;

/*
    GetTimeOfUseGroup
    Returns a particular Time of Use Group with a given touGroupId and lseId.
*/

var GetTimeOfUseGroup = function(session) {
    /*
        Create a new instance of the GetTimeOfUseGroup Choreo. A TembooSession object, containing a valid
        set of Temboo credentials, must be supplied.
	*/
    var location = "/Library/Genability/TariffData/GetTimeOfUseGroup"
    GetTimeOfUseGroup.super_.call(this, session, location);

    /*
    Define a callback that will be used to appropriately format the results of this Choreo.
    */
    var newResultSet = function(resultStream) {
        return new GetTimeOfUseGroupResultSet(resultStream);
    }

	/*
	Obtain a new InputSet object, used to specify the input values for an execution of this Choreo.
	*/
    this.newInputSet = function() {
        return new GetTimeOfUseGroupInputSet();
    }

	/*
	Execute this Choreo with the specified inputs, calling the specified callback upon success,
	and the specified errorCallback upon error.
	*/
    this.execute = function(inputs, callback, errorCallback) {
        this._execute(inputs, newResultSet, callback, errorCallback);
    }
}

/*
An InputSet with methods appropriate for specifying the inputs to the GetTimeOfUseGroup
Choreo. The InputSet object is used to specify input parameters when executing this Choreo.
*/

var GetTimeOfUseGroupInputSet = function() {
    GetTimeOfUseGroupInputSet.super_.call(this);
        /*
        Set the value of the AppID input for this Choreo. ((required, string) The App ID provided by Genability.)
        */
        this.set_AppID = function(value) {
            this.setInput("AppID", value);
        }

        /*
        Set the value of the AppKey input for this Choreo. ((required, string) The App Key provided by Genability.)
        */
        this.set_AppKey = function(value) {
            this.setInput("AppKey", value);
        }

        /*
        Set the value of the EndsWith input for this Choreo. ((optional, string) When true, the search will only return results that end with the specified search string. Otherwise, any match of the search string will be returned as a result.)
        */
        this.set_EndsWith = function(value) {
            this.setInput("EndsWith", value);
        }

        /*
        Set the value of the IsRegex input for this Choreo. ((optional, boolean) When true, the provided search string will be regarded as a regular expression and the search will return results matching the regular expression.)
        */
        this.set_IsRegex = function(value) {
            this.setInput("IsRegex", value);
        }

        /*
        Set the value of the LSEID input for this Choreo. ((conditional, integer) Used to retrieve a TOU Group for a specific LSE.)
        */
        this.set_LSEID = function(value) {
            this.setInput("LSEID", value);
        }

        /*
        Set the value of the PageCount input for this Choreo. ((optional, integer) The number of results to return. Defaults to 25.)
        */
        this.set_PageCount = function(value) {
            this.setInput("PageCount", value);
        }

        /*
        Set the value of the PageStart input for this Choreo. ((optional, integer) The page number to begin the result set from. Defaults to 1.)
        */
        this.set_PageStart = function(value) {
            this.setInput("PageStart", value);
        }

        /*
        Set the value of the SearchOn input for this Choreo. ((optional, string) Comma separated list of fields to query on. When searchOn is specified, the text provided in the search string field will be searched within these fields.)
        */
        this.set_SearchOn = function(value) {
            this.setInput("SearchOn", value);
        }

        /*
        Set the value of the Search input for this Choreo. ((optional, string) The string of text to search on. This can also be a regular expression, in which case you should set the 'isRegex' flag to true.)
        */
        this.set_Search = function(value) {
            this.setInput("Search", value);
        }

        /*
        Set the value of the SortOn input for this Choreo. ((optional, string) Comma separated list of fields to sort on.)
        */
        this.set_SortOn = function(value) {
            this.setInput("SortOn", value);
        }

        /*
        Set the value of the SortOrder input for this Choreo. ((optional, string) Comma separated list of ordering. Possible values are 'ASC' and 'DESC'. Default is 'ASC'. This list corresponds to the field list used in the SortOn input.)
        */
        this.set_SortOrder = function(value) {
            this.setInput("SortOrder", value);
        }

        /*
        Set the value of the StartsWith input for this Choreo. ((optional, boolean) When true, the search will only return results that begin with the specified search string. Otherwise, any match of the search string will be returned as a result.)
        */
        this.set_StartsWith = function(value) {
            this.setInput("StartsWith", value);
        }

        /*
        Set the value of the TOUGroupID input for this Choreo. ((conditional, integer) Used to retrieve a TOU Group by its ID (required when LSE ID is provided).)
        */
        this.set_TOUGroupID = function(value) {
            this.setInput("TOUGroupID", value);
        }

}

/*
A ResultSet with methods tailored to the values returned by the GetTimeOfUseGroup Choreo.
The ResultSet object is used to retrieve the results of a Choreo execution.
*/

var GetTimeOfUseGroupResultSet = function(resultStream) {
    GetTimeOfUseGroupResultSet.super_.call(this, resultStream);
        /*
        Retrieve the value for the "Response" output from this Choreo execution. ((json) The response from Genability.)
        */
        this.get_Response = function() {
            return this.getResult("Response");
        }
}

util.inherits(GetTimeOfUseGroup, choreography.Choreography);
util.inherits(GetTimeOfUseGroupInputSet, choreography.InputSet);
util.inherits(GetTimeOfUseGroupResultSet, choreography.ResultSet);
exports.GetTimeOfUseGroup = GetTimeOfUseGroup;

/*
    GetTimeOfUseGroupIntervals
    Returns all the Intervals for a Time of Use Group within a given date range.
*/

var GetTimeOfUseGroupIntervals = function(session) {
    /*
        Create a new instance of the GetTimeOfUseGroupIntervals Choreo. A TembooSession object, containing a valid
        set of Temboo credentials, must be supplied.
	*/
    var location = "/Library/Genability/TariffData/GetTimeOfUseGroupIntervals"
    GetTimeOfUseGroupIntervals.super_.call(this, session, location);

    /*
    Define a callback that will be used to appropriately format the results of this Choreo.
    */
    var newResultSet = function(resultStream) {
        return new GetTimeOfUseGroupIntervalsResultSet(resultStream);
    }

	/*
	Obtain a new InputSet object, used to specify the input values for an execution of this Choreo.
	*/
    this.newInputSet = function() {
        return new GetTimeOfUseGroupIntervalsInputSet();
    }

	/*
	Execute this Choreo with the specified inputs, calling the specified callback upon success,
	and the specified errorCallback upon error.
	*/
    this.execute = function(inputs, callback, errorCallback) {
        this._execute(inputs, newResultSet, callback, errorCallback);
    }
}

/*
An InputSet with methods appropriate for specifying the inputs to the GetTimeOfUseGroupIntervals
Choreo. The InputSet object is used to specify input parameters when executing this Choreo.
*/

var GetTimeOfUseGroupIntervalsInputSet = function() {
    GetTimeOfUseGroupIntervalsInputSet.super_.call(this);
        /*
        Set the value of the AppID input for this Choreo. ((required, string) The App ID provided by Genability.)
        */
        this.set_AppID = function(value) {
            this.setInput("AppID", value);
        }

        /*
        Set the value of the AppKey input for this Choreo. ((required, string) The App Key provided by Genability.)
        */
        this.set_AppKey = function(value) {
            this.setInput("AppKey", value);
        }

        /*
        Set the value of the FromDateTime input for this Choreo. ((optional, date) The starting date and time of the requested Intervals (in ISO 8601 format). Defaults to current date if not specified.)
        */
        this.set_FromDateTime = function(value) {
            this.setInput("FromDateTime", value);
        }

        /*
        Set the value of the LSEID input for this Choreo. ((required, integer) Used to retrieve a TOU Group for a specific LSE.)
        */
        this.set_LSEID = function(value) {
            this.setInput("LSEID", value);
        }

        /*
        Set the value of the PageCount input for this Choreo. ((optional, integer) The number of results to return. Defaults to 25.)
        */
        this.set_PageCount = function(value) {
            this.setInput("PageCount", value);
        }

        /*
        Set the value of the PageStart input for this Choreo. ((optional, integer) The page number to begin the result set from. Defaults to 1.)
        */
        this.set_PageStart = function(value) {
            this.setInput("PageStart", value);
        }

        /*
        Set the value of the TOUGroupID input for this Choreo. ((required, integer) Used to retrieve a TOU Group by its ID.)
        */
        this.set_TOUGroupID = function(value) {
            this.setInput("TOUGroupID", value);
        }

        /*
        Set the value of the ToDateTime input for this Choreo. ((optional, date) The ending date and time of the requested Intervals (in ISO 8601 format). If not specified, defaults to one week ahead of the current date.)
        */
        this.set_ToDateTime = function(value) {
            this.setInput("ToDateTime", value);
        }

}

/*
A ResultSet with methods tailored to the values returned by the GetTimeOfUseGroupIntervals Choreo.
The ResultSet object is used to retrieve the results of a Choreo execution.
*/

var GetTimeOfUseGroupIntervalsResultSet = function(resultStream) {
    GetTimeOfUseGroupIntervalsResultSet.super_.call(this, resultStream);
        /*
        Retrieve the value for the "Response" output from this Choreo execution. ((json) The response from Genability.)
        */
        this.get_Response = function() {
            return this.getResult("Response");
        }
}

util.inherits(GetTimeOfUseGroupIntervals, choreography.Choreography);
util.inherits(GetTimeOfUseGroupIntervalsInputSet, choreography.InputSet);
util.inherits(GetTimeOfUseGroupIntervalsResultSet, choreography.ResultSet);
exports.GetTimeOfUseGroupIntervals = GetTimeOfUseGroupIntervals;

/*
    GetZipCodeDetails
    Returns the details for a given zip code.
*/

var GetZipCodeDetails = function(session) {
    /*
        Create a new instance of the GetZipCodeDetails Choreo. A TembooSession object, containing a valid
        set of Temboo credentials, must be supplied.
	*/
    var location = "/Library/Genability/TariffData/GetZipCodeDetails"
    GetZipCodeDetails.super_.call(this, session, location);

    /*
    Define a callback that will be used to appropriately format the results of this Choreo.
    */
    var newResultSet = function(resultStream) {
        return new GetZipCodeDetailsResultSet(resultStream);
    }

	/*
	Obtain a new InputSet object, used to specify the input values for an execution of this Choreo.
	*/
    this.newInputSet = function() {
        return new GetZipCodeDetailsInputSet();
    }

	/*
	Execute this Choreo with the specified inputs, calling the specified callback upon success,
	and the specified errorCallback upon error.
	*/
    this.execute = function(inputs, callback, errorCallback) {
        this._execute(inputs, newResultSet, callback, errorCallback);
    }
}

/*
An InputSet with methods appropriate for specifying the inputs to the GetZipCodeDetails
Choreo. The InputSet object is used to specify input parameters when executing this Choreo.
*/

var GetZipCodeDetailsInputSet = function() {
    GetZipCodeDetailsInputSet.super_.call(this);
        /*
        Set the value of the AppID input for this Choreo. ((conditional, string) The App ID provided by Genability.)
        */
        this.set_AppID = function(value) {
            this.setInput("AppID", value);
        }

        /*
        Set the value of the AppKey input for this Choreo. ((required, string) The App Key provided by Genability.)
        */
        this.set_AppKey = function(value) {
            this.setInput("AppKey", value);
        }

        /*
        Set the value of the PageCount input for this Choreo. ((optional, integer) The number of results to return. Defaults to 25.)
        */
        this.set_PageCount = function(value) {
            this.setInput("PageCount", value);
        }

        /*
        Set the value of the PageStart input for this Choreo. ((optional, integer) The page number to begin the result set from. Defaults to 1.)
        */
        this.set_PageStart = function(value) {
            this.setInput("PageStart", value);
        }

        /*
        Set the value of the ZipCode input for this Choreo. ((optional, string) A zip code to search with.)
        */
        this.set_ZipCode = function(value) {
            this.setInput("ZipCode", value);
        }

}

/*
A ResultSet with methods tailored to the values returned by the GetZipCodeDetails Choreo.
The ResultSet object is used to retrieve the results of a Choreo execution.
*/

var GetZipCodeDetailsResultSet = function(resultStream) {
    GetZipCodeDetailsResultSet.super_.call(this, resultStream);
        /*
        Retrieve the value for the "Response" output from this Choreo execution. ((json) The response from Genability.)
        */
        this.get_Response = function() {
            return this.getResult("Response");
        }
}

util.inherits(GetZipCodeDetails, choreography.Choreography);
util.inherits(GetZipCodeDetailsInputSet, choreography.InputSet);
util.inherits(GetZipCodeDetailsResultSet, choreography.ResultSet);
exports.GetZipCodeDetails = GetZipCodeDetails;

redpajama_set_name: RedPajamaGithub


text:
package cmd

import (
	"context"

	"github.com/spf13/cobra"
)

// networksCmd represents the networks command
var networksCmd = &cobra.Command{
	Use:   "networks",
	Short: "Prints networks",
	Long: `Prints a list of all the networks available on the server.

You can also specify a filter to query for a single network.`,
	Run: func(cmd *cobra.Command, args []string) {
		switch len(args) {
		case 0:
			results(cl().Networks(context.Background()))

		case 1:
			results(cl().Network(context.Background(), filter(args[0])))

		default:
			fail("too many parameters")
		}
	},
}

func init() {
	RootCmd.AddCommand(networksCmd)
}


text:
package main

import (
	"sync/atomic"
	"unsafe"

	"github.com/nsf/termbox-go"
)

// Each function returns one of the following patterns:
//
// - any Frame, non-nil error: fatal error occurred, program must terminate.
// - nil Frame, nil error: the action completed but the Frame is unchanged.
// - non-nil Frame, nil error: the action completed and the Frame changed.
type Frame interface {
	Render(x0, y0, x1, y1 int) (Frame, error)
	Mouse(mx, my, w, h int) (Frame, error)
	Key(key termbox.Key, mod termbox.Modifier) (Frame, error)
	Ch(ch rune, mod termbox.Modifier) (Frame, error)
}

var currentFrame = new(Frame)

func CurrentFrame() *Frame {
	return (*Frame)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(&currentFrame))))
}

func SetFrame(old, new *Frame) bool {
	if atomic.CompareAndSwapPointer((*unsafe.Pointer)(unsafe.Pointer(&currentFrame)), unsafe.Pointer(old), unsafe.Pointer(new)) {
		select {
		case rerender <- struct{}{}:
		default:
		}
		return true
	}
	return false
}


text:
package todomvcfx.matcher;

import javafx.scene.control.CheckBox;
import org.hamcrest.Matcher;
import org.hamcrest.Factory;
import org.testfx.matcher.base.GeneralMatchers;

public class CheckBoxMatchers {

    @Factory
    public static Matcher<CheckBox> isSelected(boolean selected) {
        String descriptionText = selected ? "is selected" : "is not selected";

        return GeneralMatchers.typeSafeMatcher(CheckBox.class, descriptionText, (checkBox) -> checkBox.isSelected() == selected);
    }

    @Factory
    public static Matcher<CheckBox> isSelected() {
        return isSelected(true);
    }

    @Factory
    public static Matcher<CheckBox> isNotSelected() {
        return isSelected(false);
    }

}


text:
package org.compass.core.cascade;

/**
 * Allows filtering of create/save/delete cascade operations.
 */
public interface CompassCascadeFilter {

    /**
     * Should the create cascade operation be filtered or not
     *
     * @param obj The object being cascade-created
     * @return true if the event should be filtered, false otherwise
     */
    boolean shouldFilterCreate(Object obj);

    /**
     * Should the save cascade operation be filtered or not
     *
     * @param obj The object being cascade-saved
     * @return true if the event should be filtered, false otherwise
     */
    boolean shouldFilterSave(Object obj);

    /**
     * Should the delete cascade operation be filtered or not
     *
     * @param obj The object being cascade-deleted
     * @return true if the event should be filtered, false otherwise
     */
    boolean shouldFilterDelete(Object obj);
}


text:
class WageDecorator < Draper::Decorator
  delegate_all

  def wage_from
    return l(object.wage_from, format: "%Y-%m-%d") if object.wage_from
    ""
  end

  def wage_to
    return l(object.wage_to, format: "%Y-%m-%d") if object.wage_to
    ""
  end
  def payment_date
    return l(object.payment_date, format: "%Y-%m-%d") if object.payment_date
    ""
  end
  def state
    l = 'default'
    case object.state
      when 'preliminary'
        l = 'info'
        str = h.t(:preliminary)
      when 'calculated'
        l = 'warning'
        str = h.t(:calculated)
      when 'wage_reported'
        l = 'success'
        str = h.t(:reported)
     end
    h.labelify(str, l)
  end
end


text:
/*----------------------------------------------------------------------------
 * CMSIS-RTOS 'main' function template
 *---------------------------------------------------------------------------*/

#define osObjectsPublic                     // define objects in main module
#include "osObjects.h"                      // RTOS object definitions

/*
 * main: initialize and start the system
 */
int main (void) {
  osKernelInitialize ();                    // initialize CMSIS-RTOS

  // initialize peripherals here

  // create 'thread' functions that start executing,
  // example: tid_name = osThreadCreate (osThread(name), NULL);

	osKernelStart ();                         // start thread execution
}


text:
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE114_Process_Control__w32_char_environment_66b.c
Label Definition File: CWE114_Process_Control__w32.label.xml
Template File: sources-sink-66b.tmpl.c
*/
/*
 * @description
 * CWE: 114 Process Control
 * BadSource: environment Read input from an environment variable
 * GoodSource: Hard code the full pathname to the library
 * Sinks:
 *    BadSink : Load a dynamic link library
 * Flow Variant: 66 Data flow: data passed in an array from one function to another in different source files
 *
 * */

#include "std_testcase.h"

#include <wchar.h>

#define ENV_VARIABLE "ADD"

#ifdef _WIN32
#define GETENV getenv
#else
#define GETENV getenv
#endif

#include <windows.h>

#ifndef OMITBAD

void CWE114_Process_Control__w32_char_environment_66b_badSink(char * dataArray[])
{
    /* copy data out of dataArray */
    char * data = dataArray[2];
    {
        HMODULE hModule;
        /* POTENTIAL FLAW: If the path to the library is not specified, an attacker may be able to
         * replace his own file with the intended library */
        hModule = LoadLibraryA(data);
        if (hModule != NULL)
        {
            FreeLibrary(hModule);
            printLine("Library loaded and freed successfully");
        }
        else
        {
            printLine("Unable to load library");
        }
    }
}

#endif /* OMITBAD */

#ifndef OMITGOOD

/* goodG2B uses the GoodSource with the BadSink */
void CWE114_Process_Control__w32_char_environment_66b_goodG2BSink(char * dataArray[])
{
    char * data = dataArray[2];
    {
        HMODULE hModule;
        /* POTENTIAL FLAW: If the path to the library is not specified, an attacker may be able to
         * replace his own file with the intended library */
        hModule = LoadLibraryA(data);
        if (hModule != NULL)
        {
            FreeLibrary(hModule);
            printLine("Library loaded and freed successfully");
        }
        else
        {
            printLine("Unable to load library");
        }
    }
}

#endif /* OMITGOOD */


text:
/*
 * Hibernate Validator, declare and validate application constraints
 *
 * License: Apache License, Version 2.0
 * See the license.txt file in the root directory or <http://www.apache.org/licenses/LICENSE-2.0>.
 */

/**
 *
This package contains the main class of Hibernate Validator annotation processor.

 *
The annotation processor implementation named {@link org.hibernate.validator.ap.ConstraintValidationProcessor}
 * delegates constraint verifications to the implemented checks.

 */
package org.hibernate.validator.ap;


text:
#ifndef BOOST_SPIRIT_DEPRECATED_INCLUDE_BINDERS
#define BOOST_SPIRIT_DEPRECATED_INCLUDE_BINDERS

#include <boost/version.hpp>

#if BOOST_VERSION >= 103800
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__DMC__)
#  pragma message ("Warning: This header is deprecated. Please use: boost/spirit/include/phoenix1_binders.hpp")
#elif defined(__GNUC__) || defined(__HP_aCC) || defined(__SUNPRO_CC) || defined(__IBMCPP__)
#  warning "This header is deprecated. Please use: boost/spirit/include/phoenix1_binders.hpp"
#endif
#endif

#include <boost/spirit/include/phoenix1_binders.hpp>

#endif


text:
title: Getting Started
description: The getting started page guides you through starting a new documentation project using the documentation scaffold.
lunr: true
nav_sort: 2
nav_groups:
  - primary
nav_subgroup: true
tags:
  - starting
  - setup
---
To start a new documentation project, start by cloning or forking the [docs-scaffold](https://github.com/TelenorFrontend/docs-scaffold) repository.

Fork using the graphical interface on GitHub, or run the following command.

```shell
$ git clone https://github.com/TelenorFrontend/docs-scaffold.git
```

The docs-scaffold includes build scripts, templates, layouts, example pages and a little javascript that you can use as-is or modify to your liking.

Make sure you install all dependencies by running

```shell
$ npm install
```

Start by modifying the config files in the `config` folder, and the documentation itself in the `docs` folder.

To start the development server run the following command.

```shell
$ npm run dev
```

To build the documentation run the npm script `build`. This will package all the assets and generate static html pages from the documentation in the `docs` folder.

```shell
$ npm run build
```

To deploy the newly generated documentation, simply publish the `build` folder to any web server.


text:
<?php

declare(strict_types=1);

namespace BlockHorizons\BlockSniper\brush\type;

use BlockHorizons\BlockSniper\brush\Type;
use Generator;
use pocketmine\block\Air;
use pocketmine\block\Block;
use pocketmine\math\Facing;

class PlantType extends Type{

	/** @var Block[] */
	private $soilBlocks;

	protected function fill() : Generator{
		$this->soilBlocks = $this->properties->getSoilBlocks();
		foreach($this->mustGetBlocks() as $block){
			foreach($this->soilBlocks as $soil){
				if($block->getId() !== $soil->getId() || $block->getMeta() !== $soil->getMeta()){
					continue;
				}
				$blockUp = $this->side($block->getPosition(), Facing::UP);
				if($blockUp instanceof Air){
					yield $block;
					$this->putBlock($blockUp->getPosition(), $this->randomBrushBlock());
					break;
				}
			}
		}
	}

	/**
	 * @return string
	 */
	public function getName() : string{
		return "Plant";
	}
}


text:
<resources>

	<string name="app_name">MessagingStyle Sample</string>
  <string name="talk">Talk to Me!</string>
  <string name="title">MessagingStyle Test</string>

</resources>


text:
var config = {paths: {
	'df': 'Df_Core/my/all'
	,'dfHasValue': 'Df_Core/my/hasValue'
	,'df-lodash': 'https://cdn.jsdelivr.net/lodash/4.14.1/lodash'
	,'df-lodash-local': 'Df_Core/thirdParty/lodash'
	// 2019-08-01 https://github.com/flesler/jquery.scrollTo
	,'df-scroll': 'Df_Core/thirdParty/scrollTo'
	,'df-uniform': 'Df_Core/my/uniform'
	/**
	 * 2017-10-18
	 * Note 1.
	 * «JavaScript Unicode 8.0 Normalization - NFC, NFD, NFKC, NFKD»: https://github.com/walling/unorm
	 * Note 2.
	 * `The ineligible characters should be automatically replaced by the corresponding eligible ones
	 * while prefilling the cardholder's name
	 * (if «Prefill the cardholder's name from the billing address?» option is enabled)`:
	 * https://github.com/mage2pro/core/issues/37#issuecomment-337537967
	 */
	,'df-unorm': 'Df_Core/thirdParty/unorm'
	,'Df_Core/ColorPicker': 'Df_Core/thirdParty/ColorPicker/main'
	,'Df_Core/Handsontable': 'Df_Core/thirdParty/Handsontable/main'
	,'Df_Core/HighlightJs': 'Df_Core/thirdParty/HighlightJs/main'
	,'Df_Core/Mask': 'Df_Core/thirdParty/Mask/main'
	,'Df_Core/Select2': 'Df_Core/thirdParty/Select2/main'
	,'Df_Core/TableSorter': 'Df_Core/thirdParty/TableSorter/main'
}};


text:
package org.apache.rave.gadgets.oauth.service;

import org.apache.rave.gadgets.oauth.service.impl.DefaultOAuthTokenInfoService;
import org.apache.rave.model.OAuthTokenInfo;
import org.apache.rave.portal.model.impl.OAuthTokenInfoImpl;
import org.apache.rave.portal.repository.OAuthTokenInfoRepository;
import org.apache.shindig.auth.SecurityToken;
import org.apache.shindig.gadgets.oauth.OAuthStore;
import org.junit.Before;
import org.junit.Test;

import static org.easymock.EasyMock.createNiceMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.expectLastCall;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;

/**
 * Test for {@link org.apache.rave.gadgets.oauth.service.impl.DefaultOAuthTokenInfoService}
 */
public class DefaultOAuthTokenInfoServiceTest {
    private SecurityToken securityToken;
    OAuthStore.TokenInfo tokenInfo;
    private OAuthTokenInfoService service;
    private OAuthTokenInfoRepository repository;

    private static final String VALID_USER = "john.doe";
    private static final String INVALID_USER = "Invalid user";
    private static final String APP_URL = "http://localhost:8080/samplecontainer/examples/oauth.xml";
    private static final String NOT_USED = "NOT USED";
    private static final String TOKEN_NAME = "";
    private static final String SERVICE_NAME = "testService";

    @Before
    public void setUp() throws Exception {
        securityToken = createNiceMock(SecurityToken.class);
        tokenInfo = createNiceMock(OAuthStore.TokenInfo.class);
        repository = createNiceMock(OAuthTokenInfoRepository.class);
        service = new DefaultOAuthTokenInfoService(repository);

    }

    @Test
    public void testFindOAuthTokenInfo() throws Exception {
        OAuthTokenInfo dbOAuthTokenInfo = getOAuthTokenInfo();
        expect(repository.findOAuthTokenInfo(VALID_USER, APP_URL, NOT_USED, TOKEN_NAME, SERVICE_NAME))
                .andReturn(dbOAuthTokenInfo);
        replay(repository);
        OAuthTokenInfo oAuthTokenInfo = service.findOAuthTokenInfo(VALID_USER, APP_URL, NOT_USED,
                TOKEN_NAME, SERVICE_NAME);
        assertNotNull(oAuthTokenInfo);
        assertEquals(APP_URL, oAuthTokenInfo.getAppUrl());

    }

    @Test
    public void testFindOAuthTokenInfo_nullValue() throws Exception {
        expect(repository.findOAuthTokenInfo(INVALID_USER, APP_URL, NOT_USED, TOKEN_NAME, SERVICE_NAME))
                .andReturn(null);
        replay(repository);

        OAuthTokenInfo oAuthTokenInfo = service.findOAuthTokenInfo(INVALID_USER, APP_URL, NOT_USED,
                TOKEN_NAME, SERVICE_NAME);

        assertNull(oAuthTokenInfo);

    }

    @Test
    public void testDeleteOAuthTokenInfo() {
        OAuthTokenInfo dbOAuthTokenInfo = getOAuthTokenInfo();
        expect(repository.findOAuthTokenInfo(VALID_USER, APP_URL, NOT_USED, TOKEN_NAME, SERVICE_NAME))
                .andReturn(dbOAuthTokenInfo);
        repository.delete(dbOAuthTokenInfo);
        expectLastCall();
        replay(repository);
        service.deleteOAuthTokenInfo(VALID_USER, APP_URL, NOT_USED, TOKEN_NAME, SERVICE_NAME);
        verify(repository);
    }

    private OAuthTokenInfo getOAuthTokenInfo() {
        expect(securityToken.getAppUrl()).andReturn(APP_URL);
        expect(tokenInfo.getAccessToken()).andReturn("accessToken");
        expect(tokenInfo.getSessionHandle()).andReturn("sessionHandle");
        expect(tokenInfo.getTokenExpireMillis()).andReturn(3600000L);
        expect(tokenInfo.getTokenSecret()).andReturn("tokenSecret");
        replay(securityToken, tokenInfo);
        return new OAuthTokenInfoImpl(securityToken.getAppUrl(), SERVICE_NAME, TOKEN_NAME, tokenInfo.getAccessToken(),
                tokenInfo.getSessionHandle(), tokenInfo.getTokenSecret(),
                securityToken.getViewerId(), tokenInfo.getTokenExpireMillis());
    }
}


text:
function RenderManager()
{

}


text:
package alec_wam.CrystalMod.tiles.machine.power.engine.furnace;

import alec_wam.CrystalMod.util.ItemStackTools;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;

public class ContainerEngineFurnace extends Container
{
    public TileEntityEngineFurnace tileFurnace;

    public ContainerEngineFurnace(EntityPlayer player, TileEntityEngineFurnace tileEntity)
    {
    	this.tileFurnace = (tileEntity);

        this.addSlotToContainer(new Slot(tileFurnace, 0, 54, 45));
    	this.addPlayerInventory(player.inventory);
    }

    @Override
    public boolean canInteractWith(EntityPlayer player)
    {
        return (this.tileFurnace != null && this.tileFurnace.isUsableByPlayer(player));
    }

    protected void addPlayerInventory(InventoryPlayer paramInventoryPlayer)
    {
        for (int i = 0; i < 3; i++)
        {
            for (int j = 0; j < 9; j++)
            {
                this.addSlotToContainer(new Slot(paramInventoryPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
            }
        }
        for (int i = 0; i < 9; i++)
            this.addSlotToContainer(new Slot(paramInventoryPlayer, i, 8 + i * 18, 142));
    }

    @Override
    public ItemStack transferStackInSlot(EntityPlayer player, int i)
    {
    	ItemStack itemstack = ItemStackTools.getEmptyStack();
    	int par2 = i;
		Slot slot = this.inventorySlots.get(par2);

		if (slot != null && slot.getHasStack())
		{
			ItemStack itemstack1 = slot.getStack();
			itemstack = itemstack1.copy();

			if (par2 == 0)
			{
				if (!this.mergeItemStack(itemstack1, 1, 38, true))
				{
					return ItemStackTools.getEmptyStack();
				}

				slot.onSlotChange(itemstack1, itemstack);
			}
			else if (par2 != 0)
			{
				if (TileEntityEngineFurnace.getItemEnergyValue(itemstack1) > 0)
				{
					if (!this.mergeItemStack(itemstack1, 0, 1, false))
					{

						return ItemStackTools.getEmptyStack();
					}
				}
				else if (par2 >= 1 && par2 < 30)
				{
					if (!this.mergeItemStack(itemstack1, 30, 38, false))
					{
						return ItemStackTools.getEmptyStack();
					}
				}
				else if (par2 >= 30 && par2 < 38 && !this.mergeItemStack(itemstack1, 1, 30, false))
				{
					return ItemStackTools.getEmptyStack();
				}
			}
			else if (!this.mergeItemStack(itemstack1, 1, 38, false))
			{
				return ItemStackTools.getEmptyStack();
			}

			if (ItemStackTools.isEmpty(itemstack1))
			{
				slot.putStack(ItemStackTools.getEmptyStack());
			}
			else
			{
				slot.onSlotChanged();
			}

			if (ItemStackTools.getStackSize(itemstack1) == ItemStackTools.getStackSize(itemstack))
			{
				return ItemStackTools.getEmptyStack();
			}

			slot.onTake(player, itemstack1);
		}

		return itemstack;
    }
}


text:
const express = require('express'),
  app = express(),
  path = require('path'),
  http = require('http').Server(app),
  bodyParser = require('body-parser'),
  UUID = require('uuid/v4'),
  io = require('socket.io')(http),
  // Project files
  Topics = require('./app/topics.js'),
  Random = require('./app/random.js');

// Initialize topics and users!
const users = {},
  topics = new Topics();

// Port
const port = process.env.PORT || 3001;

// Static files
app.use(express.static(path.join(__dirname, 'client/build')));

// Parse JSON body
app.use(bodyParser.json())

// Health
app.get('/api/status', (req, res) => {
  res.json({
    status: 'ok',
    stats: {
      topics: topics.countTopics(),
      rooms: topics.countRooms(),
      users: Object.keys(users).length
    },
    currentTopics: topics.currentTopics()
  });
});

// Join a topic :D
app.post('/api/topic/:topic/join', (req, res) => {
  let topic = req.params.topic,
    socketId = req.body.uuid;

  // Join a room
  // TODO: Validate clientId
  let room = topics.joinRoom(topic, socketId);
  res.json({
    room: {
      id: room.id
    }
  });
});

// Don't allow users to join directly
app.get('/api/topic/:topic/chat', (req, res) => {
  res.redirect('/topic/:topic');
});

app.get('*', (req, res) => {
  res.sendfile(path.join(__dirname, 'client/build', 'index.html'));
});

const buildUser = socket => {
  let id = UUID();
  return {
    client: {
      id,
      name: Random.name(),
      color: Random.color(),
      publicKey: undefined
    },
    socket,
    room: {}
  }
}

io.on('connection', socket => {
  // Return the socket
  let user = buildUser(socket);
  socket.clientId = user.client.id;
  users[socket.id] = user;

  // Emit the information of the user
  socket.emit('ready', { client: user.client, uuid: socket.id });

  socket.on('disconnect', () => {
    console.log('user disconnected');
    // Notify room
    let user = users[socket.id];
    if (user && user.room && user.room.id !== undefined) {
      // Notify users
      topics.leaveRoom(user.room.topic, user.room.id, socket.id);
      // Emit users
      io.sockets.in(user.room.id).emit('user leave', user.client);
    }

    // Remove the user
    delete users[socket.id];
  });

  socket.on('join room', (data) => {
    console.log('New user in the room: ' + data.room);
    let user = users[socket.id];
    user.room = { id: data.room, topic: data.topic };
    user.client = Object.assign({}, user.client, { publicKey: data.publicKey });
    // Emit new user
    io.sockets.in(user.room.id).emit('user join', user.client);
    // Emit current users
    socket.emit('current users',
      topics.roomUsers(user.room.topic, user.room.id, socket.id).map(socketId => {
        return users[socketId].client;
      })
    );
    // Join current one
    socket.join(user.room.id);
  });

  socket.on('leave room', () => {
    let user = users[socket.id];
    console.log('User left room: ' + user.room.id);

    if (user && user.room && user.room.id !== undefined) {
      socket.leave(user.room.id);
      topics.leaveRoom(user.room.topic, user.room.id, socket.id);

      // Emit new user
      io.sockets.in(user.room.id).emit('user leave', user.client);
    }
  });

  socket.on('send message', (data) => {
    let user = users[socket.id],
      message = { text: data.text, user: user.client };
    io.sockets.in(user.room.id).emit('new message', message);
  });
});

// Create the server
http.listen(port, () => {
  console.log('Our app is running on http://localhost:' + port);
});


text:
<?php
class Utils_SecurityTest extends PHPUnit_Framework_TestCase {
    public function testGenerateCSRFToken() {
        $_SERVER['HTTP_USER_AGENT'] = 'firefox'; // Doesn't need to be complicated
        $t = time();
        $token = Utils_Security::generateCSRFToken($t);
        $this->assertEquals(32, strlen($token));
        $this->assertEquals($token, Utils_Security::generateCSRFToken($t));
    }

    public function testValidateCSRFToken() {
        session_id("aaa");

        $_SERVER['HTTP_USER_AGENT'] = 'firefox';
        $t = time();
        $token = Utils_Security::generateCSRFToken($t);

        // Test changing user agents
        $this->assertTrue(Utils_Security::validateCSRFToken($t, $token));
        $_SERVER['HTTP_USER_AGENT'] = 'ie';
        $this->assertFalse(Utils_Security::validateCSRFToken($t, $token));

        // Test changing timestamps
        $this->assertFalse(Utils_Security::validateCSRFToken($t+1, $token));

        // Test changing session id
        session_id("bbb");
        $this->assertFalse(Utils_Security::validateCSRFToken($t, $token));
    }
}
?>