text:
<?php

namespace Amadeus\Client\RequestOptions\Fare\GetFareFamilyDescription;

use Amadeus\Client\LoadParamsFromArray;

/**
 * CarrierInfo class.
 *
 * @package Amadeus\Client\RequestOptions\Fare\GetFareFamilyDescription
 * @author Artem Zakharchenko <artz.relax@gmail.com>
 */
class CarrierInfo extends LoadParamsFromArray
{
    /** @var string */
    public $airline;
}

redpajama_set_name: RedPajamaGithub


text:
//////////////////////////////////////////////////////////////////////////
//
//  Copyright (c) 2020, Cinesite VFX Ltd. All rights reserved.
//
//  Redistribution and use in source and binary forms, with or without
//  modification, are permitted provided that the following conditions are
//  met:
//
//      * Redistributions of source code must retain the above
//        copyright notice, this list of conditions and the following
//        disclaimer.
//
//      * Redistributions in binary form must reproduce the above
//        copyright notice, this list of conditions and the following
//        disclaimer in the documentation and/or other materials provided with
//        the distribution.
//
//      * Neither the name of John Haddon nor the names of
//        any other contributors to this software may be used to endorse or
//        promote products derived from this software without specific prior
//        written permission.
//
//  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
//  IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
//  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
//  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
//  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
//  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
//  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
//  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
//  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
//  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
//  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////

// Workaround for this bug in GCC 4.8 :
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59483
#include "boost/config.hpp"
#if defined(BOOST_GCC) && BOOST_GCC < 40900
	#define protected public
#endif

#include "GafferScene/MergeScenes.h"

#include "GafferScene/SceneAlgo.h"

#include "Gaffer/ArrayPlug.h"

#include "IECore/NullObject.h"

#include "unordered_set"

using namespace std;
using namespace Imath;
using namespace IECore;
using namespace Gaffer;
using namespace GafferScene;

size_t MergeScenes::g_firstPlugIndex = 0;
GAFFER_GRAPHCOMPONENT_DEFINE_TYPE( MergeScenes );

//////////////////////////////////////////////////////////////////////////
// Internal utilities
//////////////////////////////////////////////////////////////////////////

namespace
{

size_t first( const std::bitset<32> &inputs )
{
	for( size_t i = 0; i < inputs.size(); ++i )
	{
		if( inputs[i] )
		{
			return i;
		}
	}

	// We shouldn't get here, because all valid locations should
	// have at least one active input.
	assert( false );
	return 0;
}

} // namespace

//////////////////////////////////////////////////////////////////////////
// MergeScenes
//////////////////////////////////////////////////////////////////////////

MergeScenes::MergeScenes( const std::string &name )
	:	SceneProcessor( name, /* minInputs = */ 2, /* maxInputs = */ InputMask().size() )
{
	storeIndexOfNextChild( g_firstPlugIndex );

	addChild( new IntPlug( "transformMode", Plug::In, (int)Mode::Keep, (int)Mode::Keep, (int)Mode::Replace ) );
	addChild( new IntPlug( "attributesMode", Plug::In, (int)Mode::Keep, (int)Mode::Keep, (int)Mode::Merge ) );
	addChild( new IntPlug( "objectMode", Plug::In, (int)Mode::Keep, (int)Mode::Keep, (int)Mode::Replace ) );
	addChild( new IntPlug( "globalsMode", Plug::In, (int)Mode::Keep, (int)Mode::Keep, (int)Mode::Merge ) );
	addChild( new BoolPlug( "adjustBounds", Plug::In, true ) );
	addChild( new IntPlug( "__activeInputs", Plug::Out, 0 ) );
	addChild( new AtomicBox3fPlug( "__mergedDescendantsBound", Plug::Out ) );
}

MergeScenes::~MergeScenes()
{
}

Gaffer::IntPlug *MergeScenes::transformModePlug()
{
	return getChild<IntPlug>( g_firstPlugIndex );
}

const Gaffer::IntPlug *MergeScenes::transformModePlug() const
{
	return getChild<IntPlug>( g_firstPlugIndex );
}

Gaffer::IntPlug *MergeScenes::attributesModePlug()
{
	return getChild<IntPlug>( g_firstPlugIndex + 1 );
}

const Gaffer::IntPlug *MergeScenes::attributesModePlug() const
{
	return getChild<IntPlug>( g_firstPlugIndex + 1 );
}

Gaffer::IntPlug *MergeScenes::objectModePlug()
{
	return getChild<IntPlug>( g_firstPlugIndex + 2 );
}

const Gaffer::IntPlug *MergeScenes::objectModePlug() const
{
	return getChild<IntPlug>( g_firstPlugIndex + 2 );
}

Gaffer::IntPlug *MergeScenes::globalsModePlug()
{
	return getChild<IntPlug>( g_firstPlugIndex + 3 );
}

const Gaffer::IntPlug *MergeScenes::globalsModePlug() const
{
	return getChild<IntPlug>( g_firstPlugIndex + 3 );
}

Gaffer::BoolPlug *MergeScenes::adjustBoundsPlug()
{
	return getChild<BoolPlug>( g_firstPlugIndex + 4 );
}

const Gaffer::BoolPlug *MergeScenes::adjustBoundsPlug() const
{
	return getChild<BoolPlug>( g_firstPlugIndex + 4 );
}

Gaffer::IntPlug *MergeScenes::activeInputsPlug()
{
	return getChild<IntPlug>( g_firstPlugIndex + 5 );
}

const Gaffer::IntPlug *MergeScenes::activeInputsPlug() const
{
	return getChild<IntPlug>( g_firstPlugIndex + 5 );
}

Gaffer::AtomicBox3fPlug *MergeScenes::mergedDescendantsBoundPlug()
{
	return getChild<AtomicBox3fPlug>( g_firstPlugIndex + 6 );
}

const Gaffer::AtomicBox3fPlug *MergeScenes::mergedDescendantsBoundPlug() const
{
	return getChild<AtomicBox3fPlug>( g_firstPlugIndex + 6 );
}

void MergeScenes::affects( const Gaffer::Plug *input, AffectedPlugsContainer &outputs ) const
{
	SceneProcessor::affects( input, outputs );

	const ScenePlug *scene = inPlugs()->isAncestorOf( input ) ? input->parent<ScenePlug>() : nullptr;

	if( scene && input == scene->childNamesPlug() )
	{
		outputs.push_back( activeInputsPlug() );
	}

	if(
		( scene && input == scene->transformPlug() ) ||
		input == transformModePlug() ||
		input == activeInputsPlug()
	)
	{
		outputs.push_back( outPlug()->transformPlug() );
	}

	if(
		( scene && input == scene->boundPlug() ) ||
		( scene && input == scene->transformPlug() ) ||
		input == activeInputsPlug()
	)
	{
		outputs.push_back( mergedDescendantsBoundPlug() );
	}

	if(
		( scene && input == scene->boundPlug() ) ||
		( scene && input == scene->objectPlug() ) ||
		( scene && input == scene->transformPlug() ) ||
		input == transformModePlug() ||
		input == objectModePlug() ||
		input == adjustBoundsPlug() ||
		input == activeInputsPlug() ||
		input == mergedDescendantsBoundPlug()
	)
	{
		outputs.push_back( outPlug()->boundPlug() );
	}

	if(
		( scene && input == scene->attributesPlug() ) ||
		input == attributesModePlug() ||
		input == activeInputsPlug()
	)
	{
		outputs.push_back( outPlug()->attributesPlug() );
	}

	if(
		( scene && input == scene->objectPlug() ) ||
		input == objectModePlug() ||
		input == activeInputsPlug()
	)
	{
		outputs.push_back( outPlug()->objectPlug() );
	}

	if(
		( scene && input == scene->childNamesPlug() ) ||
		input == activeInputsPlug()
	)
	{
		outputs.push_back( outPlug()->childNamesPlug() );
	}

	if(
		( scene && input == scene->globalsPlug() ) ||
		input == globalsModePlug()
	)
	{
		outputs.push_back( outPlug()->globalsPlug() );
	}

	if( scene && input == scene->setNamesPlug() )
	{
		outputs.push_back( outPlug()->setNamesPlug() );
	}

	if( scene && input == scene->setPlug() )
	{
		outputs.push_back( outPlug()->setPlug() );
	}

}

void MergeScenes::hash( const Gaffer::ValuePlug *output, const Gaffer::Context *context, IECore::MurmurHash &h ) const
{
	SceneProcessor::hash( output, context, h );

	if( output == activeInputsPlug() )
	{
		hashActiveInputs( context, h );
	}
	else if( output == mergedDescendantsBoundPlug() )
	{
		hashMergedDescendantsBound( context, h );
	}
}

void MergeScenes::compute( Gaffer::ValuePlug *output, const Gaffer::Context *context ) const
{
	if( output == activeInputsPlug() )
	{
		static_cast<IntPlug *>( output )->setValue( computeActiveInputs( context ) );
	}
	else if( output == mergedDescendantsBoundPlug() )
	{
		static_cast<AtomicBox3fPlug *>( output )->setValue( computeMergedDescendantsBound( context ) );
	}
	else
	{
		SceneProcessor::compute( output, context );
	}
}

void MergeScenes::hashActiveInputs( const Gaffer::Context *context, IECore::MurmurHash &h ) const
{
	const ScenePath &scenePath = context->get<ScenePath>( ScenePlug::scenePathContextName );

	if( scenePath.empty() )
	{
		h.append( (uint64_t)connectedInputs().to_ulong() );
	}
	else
	{
		InputMask parentActiveInputs;
		{
			ScenePath parentPath = scenePath; parentPath.pop_back();
			ScenePlug::PathScope parentScope( context, parentPath );
			parentActiveInputs = activeInputsPlug()->getValue();
		}

		if( parentActiveInputs.count() == 1 )
		{
			h.append( (uint64_t)parentActiveInputs.to_ulong() );
		}
		else
		{
			InputMask activeInputs;
			visit(
				parentActiveInputs,
				[&scenePath, &activeInputs] ( InputType type, size_t index, const ScenePlug *scene ) {
					if( SceneAlgo::exists( scene, scenePath ) )
					{
						activeInputs[index] = true;
					}
					return true;
				}
			);
			h.append( (uint64_t)activeInputs.to_ulong() );
		}
	}
}

int MergeScenes::computeActiveInputs( const Gaffer::Context *context ) const
{
	const ScenePath &scenePath = context->get<ScenePath>( ScenePlug::scenePathContextName );

	InputMask result;
	if( scenePath.empty() )
	{
		// Root
		result = connectedInputs();
	}
	else
	{
		// Get active inputs from the parent.
		InputMask parentActiveInputs;
		{
			ScenePath parentPath = scenePath; parentPath.pop_back();
			ScenePlug::PathScope parentScope( context, parentPath );
			parentActiveInputs = activeInputsPlug()->getValue();
		}

		if( parentActiveInputs.count() == 1 )
		{
			// It is forbidden for anyone to evaluate us for a location
			// that doesn't exist. Therefore, if our parent only has
			// one active input, then that input must still be active for
			// us.
			result = parentActiveInputs;
		}
		else
		{
			// Figure out which of those parent inputs are
			// still active. Using the parent active inputs as
			// a mask reduces the number of existence queries
			// we must make when merging many sparsely overlapping
			// scenes.
			visit(
				parentActiveInputs,
				[&result, &scenePath] ( InputType type, size_t index, const ScenePlug *scene ) {
					if( SceneAlgo::exists( scene, scenePath ) )
					{
						result[index] = true;
					}
					return true;
				}
			);
		}
	}

	return result.to_ulong();
}

void MergeScenes::hashMergedDescendantsBound( const Gaffer::Context *context, IECore::MurmurHash &h ) const
{
	const InputMask activeInputs( activeInputsPlug()->getValue() );
	if( activeInputs.count() == 1 )
	{
		return;
	}

	ConstInternedStringVectorDataPtr childNamesData = outPlug()->childNamesPlug()->getValue();
	if( childNamesData->readable().empty() )
	{
		return;
	}

	const size_t firstActiveIndex = first( activeInputs );

	ScenePath childPath = context->get<ScenePath>( ScenePlug::scenePathContextName );
	childPath.push_back( InternedString() ); // Room for child name
	ScenePlug::PathScope childScope( context );

	for( const auto &childName : childNamesData->readable() )
	{
		childPath.back() = childName;
		childScope.setPath( childPath );
		const InputMask childActiveInputs( activeInputsPlug()->getValue() );
		if( childActiveInputs.count() == 1 && childActiveInputs[firstActiveIndex] )
		{
			continue;
		}

		const ScenePlug *childScene = inPlugs()->getChild<ScenePlug>( first( childActiveInputs ) );

		if( childActiveInputs.count() == 1 )
		{
			childScene->boundPlug()->hash( h );
		}
		else
		{
			mergedDescendantsBoundPlug()->hash( h );
		}

		childScene->transformPlug()->hash( h );
	};
}

const Imath::Box3f MergeScenes::computeMergedDescendantsBound( const Gaffer::Context *context ) const
{
	const InputMask activeInputs( activeInputsPlug()->getValue() );
	if( activeInputs.count() == 1 )
	{
		// All children coming from the first input. There can be no descendants to merge.
		return Box3f();
	}

	ConstInternedStringVectorDataPtr childNamesData = outPlug()->childNamesPlug()->getValue();
	if( childNamesData->readable().empty() )
	{
		// No children. There can be no descendants to merge.
		return Box3f();
	}

	const size_t firstActiveIndex = first( activeInputs );

	ScenePath childPath = context->get<ScenePath>( ScenePlug::scenePathContextName );
	childPath.push_back( InternedString() ); // Room for child name
	ScenePlug::PathScope childScope( context );

	Box3f result;
	for( const auto &childName : childNamesData->readable() )
	{
		childPath.back() = childName;
		childScope.setPath( childPath );
		const InputMask childActiveInputs( activeInputsPlug()->getValue() );
		if( childActiveInputs.count() == 1 && childActiveInputs[firstActiveIndex] )
		{
			// Child coming from first input only.
			// There can be no descendants to merge.
			continue;
		}

		const ScenePlug *childScene = inPlugs()->getChild<ScenePlug>( first( childActiveInputs ) );

		Box3f bound;
		if( childActiveInputs.count() == 1 )
		{
			// Child being merged in from another input.
			bound = childScene->boundPlug()->getValue();
		}
		else
		{
			// No child being merged in at this point, but
			// there may still be a descendant merge lower
			// in the hierarchy. Recurse.
			bound = mergedDescendantsBoundPlug()->getValue();
		}

		result.extendBy( transform( bound, childScene->transformPlug()->getValue() ) );
	};
	return result;
}

void MergeScenes::hashBound( const ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent, IECore::MurmurHash &h ) const
{
	// Pass through.

	const InputMask activeInputs( activeInputsPlug()->getValue() );
	if( activeInputs.count() == 1 || !adjustBoundsPlug()->getValue() )
	{
		h = inPlugs()->getChild<ScenePlug>( first( activeInputs ) )->boundPlug()->hash();
		return;
	}

	// Objects/transforms always from first active input.

	if( objectModePlug()->getValue() == (int)Mode::Keep && transformModePlug()->getValue() == (int)Mode::Keep )
	{
		SceneProcessor::hashBound( path, context, parent, h );
		inPlugs()->getChild<ScenePlug>( first( activeInputs ) )->boundPlug()->hash( h );
		mergedDescendantsBoundPlug()->hash( h );
		return;
	}

	// Worst case scenario

	SceneProcessor::hashBound( path, context, parent, h );
	outPlug()->objectPlug()->hash( h );
	h.append( hashOfTransformedChildBounds( path, outPlug() ) );
}

Imath::Box3f MergeScenes::computeBound( const ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent ) const
{
	// Pass through for simple cases.

	const InputMask activeInputs( activeInputsPlug()->getValue() );
	if( activeInputs.count() == 1 || !adjustBoundsPlug()->getValue() )
	{
		return inPlugs()->getChild<ScenePlug>( first( activeInputs ) )->boundPlug()->getValue();
	}

	// If objects and transforms always come from the first active input,
	// then the bound from the first input will already be correct for them.
	// We just need to extend it to account for any new descendants
	// being merged in from the other inputs.

	if( objectModePlug()->getValue() == (int)Mode::Keep && transformModePlug()->getValue() == (int)Mode::Keep )
	{
		Box3f result = inPlugs()->getChild<ScenePlug>( first( activeInputs ) )->boundPlug()->getValue();
		result.extendBy( mergedDescendantsBoundPlug()->getValue() );
		return result;
	}

	// Otherwise we're in the worst case scenario, and transforms and
	// objects can be taken from any input willy nilly. We have to
	// compute everything by brute force.

	Box3f result = SceneAlgo::bound( outPlug()->objectPlug()->getValue().get() );
	result.extendBy( unionOfTransformedChildBounds( path, outPlug() ) );
	return result;
}

void MergeScenes::hashTransform( const ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent, IECore::MurmurHash &h ) const
{
	visit(
		activeInputsPlug()->getValue(),
		[&] ( InputType type, size_t index, const ScenePlug *scene ) {
			h = scene->transformPlug()->hash();
			return false;
		},
		visitOrder( (Mode)transformModePlug()->getValue() )
	);
}

Imath::M44f MergeScenes::computeTransform( const ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent ) const
{
	M44f result;
	visit(
		activeInputsPlug()->getValue(),
		[&result] ( InputType type, size_t index, const ScenePlug *scene ) {
			result = scene->transformPlug()->getValue();
			return false;
		},
		visitOrder( (Mode)transformModePlug()->getValue() )
	);

	return result;
}

void MergeScenes::hashAttributes( const ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent, IECore::MurmurHash &h ) const
{
	visit(
		activeInputsPlug()->getValue(),
		[&] ( InputType type, size_t index, const ScenePlug *scene ) {
			switch( type )
			{
				case InputType::Sole :
					// Pass hash through unchanged
					h = scene->attributesPlug()->hash();
					break;
				case InputType::First :
					// Initialise hash and fall through
					SceneProcessor::hashAttributes( path, context, parent, h );
				case InputType::Other :
					// Merge input hash
					scene->attributesPlug()->hash( h );
			}
			return true;
		},
		visitOrder( (Mode)attributesModePlug()->getValue() )
	);
}

IECore::ConstCompoundObjectPtr MergeScenes::computeAttributes( const ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent ) const
{
	ConstCompoundObjectPtr result;
	CompoundObjectPtr merged;
	visit(
		activeInputsPlug()->getValue(),
		[&] ( InputType type, size_t index, const ScenePlug *scene ) {
			switch( type )
			{
				case InputType::Sole :
					// Pass input through unchanged.
					result = scene->attributesPlug()->getValue();
					break;
				case InputType::First :
					// Initialise merged result and
					// fall through.
					merged = new CompoundObject();
					result = merged;
				case InputType::Other :
					// Merge input attributes into result.
					ConstCompoundObjectPtr attributes = scene->attributesPlug()->getValue();
					for( const auto &a : attributes->members() )
					{
						merged->members()[a.first] = a.second;
					}
			}
			return true;
		},
		visitOrder( (Mode)attributesModePlug()->getValue() )
	);

	return result;
}

void MergeScenes::hashObject( const ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent, IECore::MurmurHash &h ) const
{
	visit(
		activeInputsPlug()->getValue(),
		[&] ( InputType type, size_t index, const ScenePlug *scene ) {
			switch( type )
			{
				case InputType::Sole :
					// Pass hash through unchanged.
					h = scene->objectPlug()->hash();
					break;
				case InputType::First :
					// Initialise hash and fall through.
					SceneProcessor::hashObject( path, context, parent, h );
				case InputType::Other :
					// Merge input hash.
					scene->objectPlug()->hash( h );
			}
			return true;
		},
		visitOrder( (Mode)objectModePlug()->getValue(), /* replaceOrder = */ VisitOrder::Backwards )
	);
}

IECore::ConstObjectPtr MergeScenes::computeObject( const ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent ) const
{
	ConstObjectPtr result = IECore::NullObject::defaultNullObject();
	visit(
		activeInputsPlug()->getValue(),
		[&result] ( InputType type, size_t index, const ScenePlug *scene ) {
			ConstObjectPtr o = scene->objectPlug()->getValue();
			if( runTimeCast<const NullObject>( o.get() ) )
			{
				// No object here, visit next input.
				return true;
			}
			else
			{
				result = o;
				// We found what we want, so no need to
				// visit any more inputs.
				return false;
			}
		},
		visitOrder( (Mode)objectModePlug()->getValue(), /* replaceOrder = */ VisitOrder::Backwards )
	);
	return result;
}

void MergeScenes::hashChildNames( const ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent, IECore::MurmurHash &h ) const
{
	visit(
		activeInputsPlug()->getValue(),
		[&] ( InputType type, size_t index, const ScenePlug *scene ) {
			switch( type )
			{
				case InputType::Sole :
					h = scene->childNamesPlug()->hash();
					break;
				case InputType::First :
					SceneProcessor::hashChildNames( path, context, parent, h );
				case InputType::Other :
					scene->childNamesPlug()->hash( h );
			}
			return true;
		}
	);
}

IECore::ConstInternedStringVectorDataPtr MergeScenes::computeChildNames( const ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent ) const
{
	ConstInternedStringVectorDataPtr result;
	InternedStringVectorDataPtr merged;
	unordered_set<InternedString> visited;

	visit(
		activeInputsPlug()->getValue(),
		[&] ( InputType type, size_t index, const ScenePlug *scene ) {
			switch( type )
			{
				case InputType::Sole :
				case InputType::First :
					result = scene->childNamesPlug()->getValue();
					break;
				case InputType::Other :
					ConstInternedStringVectorDataPtr toMerge = scene->childNamesPlug()->getValue();
					if( toMerge->readable().size() )
					{
						if( !merged )
						{
							merged = result->copy();
							result = merged;
							visited.insert( merged->readable().begin(), merged->readable().end() );
						}

						for( const auto & n : toMerge->readable() )
						{
							if( visited.insert( n ).second )
							{
								merged->writable().push_back( n );
							}
						}
					}
			}
			return true;
		}
	);

	return result;
}

void MergeScenes::hashGlobals( const Gaffer::Context *context, const ScenePlug *parent, IECore::MurmurHash &h ) const
{
	visit(
		connectedInputs(),
		[&] ( InputType type, size_t index, const ScenePlug *scene ) {
			switch( type )
			{
				case InputType::Sole :
					// Pass hash through unchanged.
					h = scene->globalsPlug()->hash();
					break;
				case InputType::First :
					// Initialise hash and fall through.
					SceneProcessor::hashGlobals( context, parent, h );
				case InputType::Other :
					// Merge input hash.
					scene->globalsPlug()->hash( h );
			}
			return true;
		},
		visitOrder( (Mode)globalsModePlug()->getValue() )
	);
}

IECore::ConstCompoundObjectPtr MergeScenes::computeGlobals( const Gaffer::Context *context, const ScenePlug *parent ) const
{
	ConstCompoundObjectPtr result;
	CompoundObjectPtr merged;
	visit(
		connectedInputs(),
		[&] ( InputType type, size_t index, const ScenePlug *scene ) {
			switch( type )
			{
				case InputType::Sole :
					// Pass input through unchanged.
					result = scene->globalsPlug()->getValue();
					break;
				case InputType::First :
					// Initialise merged result and
					// fall through.
					merged = new CompoundObject();
					result = merged;
				case InputType::Other :
					// Merge input globals into result.
					ConstCompoundObjectPtr globals = scene->globalsPlug()->getValue();
					for( const auto &g : globals->members() )
					{
						merged->members()[g.first] = g.second;
					}
			}
			return true;
		},
		visitOrder( (Mode)globalsModePlug()->getValue() )
	);

	return result;
}

void MergeScenes::hashSetNames( const Gaffer::Context *context, const ScenePlug *parent, IECore::MurmurHash &h ) const
{
	visit(
		connectedInputs(),
		[&] ( InputType type, size_t index, const ScenePlug *scene ) {
			switch( type )
			{
				case InputType::Sole :
					// Pass hash through unchanged.
					h = scene->setNamesPlug()->hash();
					break;
				case InputType::First :
					// Initialise hash and fall through.
					SceneProcessor::hashSetNames( context, parent, h );
				case InputType::Other :
					// Merge input hash.
					scene->setNamesPlug()->hash( h );
			}
			return true;
		}
	);
}

IECore::ConstInternedStringVectorDataPtr MergeScenes::computeSetNames( const Gaffer::Context *context, const ScenePlug *parent ) const
{
	ConstInternedStringVectorDataPtr result;
	InternedStringVectorDataPtr merged;
	visit(
		connectedInputs(),
		[&] ( InputType type, size_t index, const ScenePlug *scene ) {
			switch( type )
			{
				case InputType::Sole :
					// Pass input through unchanged.
					result = scene->setNamesPlug()->getValue();
					break;
				case InputType::First :
					// Initialise merged result and
					// fall through.
					merged = new InternedStringVectorData();
					result = merged;
				case InputType::Other :
					// This naive approach to merging set names preserves the order of the incoming names,
					// but at the expense of using linear search. We assume that the number of sets is small
					// enough and the InternedString comparison fast enough that this is OK.
					for( const auto &setName : scene->setNamesPlug()->getValue()->readable() )
					{
						if( std::find( merged->readable().begin(), merged->readable().end(), setName ) == merged->readable().end() )
						{
							 merged->writable().push_back( setName );
						}
					}
			}
			return true;
		}
	);

	return result;
}

void MergeScenes::hashSet( const IECore::InternedString &setName, const Gaffer::Context *context, const ScenePlug *parent, IECore::MurmurHash &h ) const
{
	visit(
		connectedInputs(),
		[&] ( InputType type, size_t index, const ScenePlug *scene ) {
			switch( type )
			{
				case InputType::Sole :
					// Pass hash through unchanged.
					h = scene->setPlug()->hash();
					break;
				case InputType::First :
					// Initialise hash and fall through.
					SceneProcessor::hashSet( setName, context, parent, h );
				case InputType::Other :
					// Merge input hash.
					scene->setPlug()->hash( h );
			}
			return true;
		}
	);
}

IECore::ConstPathMatcherDataPtr MergeScenes::computeSet( const IECore::InternedString &setName, const Gaffer::Context *context, const ScenePlug *parent ) const
{
	ConstPathMatcherDataPtr result;
	PathMatcherDataPtr merged;
	visit(
		connectedInputs(),
		[&] ( InputType type, size_t index, const ScenePlug *scene ) {
			switch( type )
			{
				case InputType::Sole :
					// Pass input through unchanged.
					result = scene->setPlug()->getValue();
					break;
				case InputType::First :
					// Initialise merged result and
					// fall through.
					merged = new PathMatcherData();
					result = merged;
				case InputType::Other :
					merged->writable().addPaths(
						scene->setPlug()->getValue()->readable()
					);
			}
			return true;
		}
	);

	return result;
}

MergeScenes::VisitOrder MergeScenes::visitOrder( Mode mode, VisitOrder replaceOrder ) const
{
	switch( mode )
	{
		case Mode::Replace :
			return replaceOrder;
		case Mode::Keep :
			return VisitOrder::FirstOnly;
		default :
			return VisitOrder::Forwards;
	}
}

MergeScenes::InputMask MergeScenes::connectedInputs() const
{
	InputMask result;
	for( size_t i = 0, e = inPlugs()->children().size(); i < e; ++i )
	{
		result[i] = (bool)inPlugs()->getChild<ScenePlug>( i )->getInput();
	}

	if( !result.count() )
	{
		result[0] = true;
	}

	return result;
}

template<typename Visitor>
void MergeScenes::visit( InputMask inputMask, Visitor &&visitor, VisitOrder order ) const
{
	assert( inputMask.count() );

	const bool backwards = order == VisitOrder::Backwards || order == VisitOrder::LastOnly;
	const int startIndex = backwards ? inPlugs()->children().size() - 1 : 0;
	const int endIndex = backwards ? -1 : inPlugs()->children().size();
	const int increment = backwards ? -1 : 1;

	InputType type;
	if( order == VisitOrder::FirstOnly || order == VisitOrder::LastOnly || inputMask.count() == 1 )
	{
		type = InputType::Sole;
	}
	else
	{
		type = InputType::First;
	}

	for( int i = startIndex; i != endIndex; i += increment )
	{
		if( inputMask[i] )
		{
			const bool c = visitor( type, i, inPlugs()->getChild<ScenePlug>( i ) );
			if( !c || order == VisitOrder::FirstOnly || order == VisitOrder::LastOnly )
			{
				break;
			}
			type = InputType::Other;
		}
	}
}


text:
package com.github.devicehive.rest.utils;

import java.util.List;

public class StringUtils {
    /**
     * Check if the given array contains the given value (with case-insensitive comparison).
     *
     * @param array The array
     * @param value The value to search
     * @return true if the array contains the value
     */
    public static boolean containsIgnoreCase(String[] array, String value) {
        for (String str : array) {
            if (value == null && str == null) return true;
            if (value != null && value.equalsIgnoreCase(str)) return true;
        }
        return false;
    }

    /**
     * Join an array of strings with the given separator.
     * <p>
     * Note: This might be replaced by utility method from commons-lang or guava someday
     * if one of those libraries is added as dependency.
     * </p>
     *
     * @param array     The array of strings
     * @param separator The separator
     * @return the resulting string
     */
    public static String join(String separator, String[] array) {
        int len = array.length;
        if (len == 0) return "";

        StringBuilder out = new StringBuilder();
        out.append(array[0]);
        for (int i = 1; i < len; i++) {
            out.append(separator).append(array[i]);
        }
        return out.toString();
    }

    public static String join(String delimiter, List<String> input) {
        if (delimiter == null || delimiter.isEmpty()) {
            throw new RuntimeException("Delimiter cannot be empty");
        }
        if (input == null || input.isEmpty()) {
            return "";
        }
        StringBuilder result = new StringBuilder();
        result.append(input.get(0));
        for (int i = 1; i < input.size(); i++) {
            result.append(delimiter).append(input.get(i));
        }
        return result.toString();
    }

    /**
     * Convert the given object to string with each line indented by 4 spaces
     * (except the first line).
     */
    public static String toIndentedString(Object o) {
        if (o == null) return "null";
        return o.toString().replace("\n", "\n    ");
    }
}


text:
<?php

/**
 * @file
 * Contains \Drupal\Tests\Core\Extension\ThemeHandlerTest.
 */

namespace Drupal\Tests\Core\Extension;

use Drupal\Core\Extension\Extension;
use Drupal\Core\Extension\InfoParser;
use Drupal\Core\Extension\ThemeHandler;
use Drupal\Core\Config\ConfigInstaller;
use Drupal\Core\KeyValueStore\KeyValueMemoryFactory;
use Drupal\Core\State\State;
use Drupal\Tests\UnitTestCase;

/**
 * @coversDefaultClass \Drupal\Core\Extension\ThemeHandler
 * @group Extension
 */
class ThemeHandlerTest extends UnitTestCase {

  /**
   * The mocked route builder indicator.
   *
   * @var \Drupal\Core\Routing\RouteBuilderIndicatorInterface|\PHPUnit_Framework_MockObject_MockObject
   */
  protected $routeBuilderIndicator;

  /**
   * The mocked info parser.
   *
   * @var \Drupal\Core\Extension\InfoParserInterface|\PHPUnit_Framework_MockObject_MockObject
   */
  protected $infoParser;

  /**
   * The mocked state backend.
   *
   * @var \Drupal\Core\State\StateInterface|\PHPUnit_Framework_MockObject_MockObject
   */
  protected $state;

  /**
   * The mocked config factory.
   *
   * @var \Drupal\Core\Config\ConfigFactoryInterface|\PHPUnit_Framework_MockObject_MockObject
   */
  protected $configFactory;

  /**
   * The mocked module handler.
   *
   * @var \Drupal\Core\Extension\ModuleHandlerInterface|\PHPUnit_Framework_MockObject_MockObject
   */
  protected $moduleHandler;

  /**
   * The mocked config installer.
   *
   * @var \Drupal\Core\Config\ConfigInstaller|\PHPUnit_Framework_MockObject_MockObject
   */
  protected $configInstaller;

  /**
   * The mocked config manager.
   *
   * @var \Drupal\Core\Config\ConfigManagerInterface|\PHPUnit_Framework_MockObject_MockObject
   */
  protected $configManager;

  /**
   * The extension discovery.
   *
   * @var \Drupal\Core\Extension\ExtensionDiscovery|\PHPUnit_Framework_MockObject_MockObject
   */
  protected $extensionDiscovery;

  /**
   * The CSS asset collection optimizer service.
   *
   * @var \Drupal\Core\Asset\AssetCollectionOptimizerInterface|\PHPUnit_Framework_MockObject_MockObject
   */
  protected $cssCollectionOptimizer;

  /**
   * The tested theme handler.
   *
   * @var \Drupal\Core\Extension\ThemeHandler|\Drupal\Tests\Core\Extension\TestThemeHandler
   */
  protected $themeHandler;

  /**
   * {@inheritdoc}
   */
  protected function setUp() {
    parent::setUp();

    $this->configFactory = $this->getConfigFactoryStub(array(
      'core.extension' => array(
        'module' => array(),
        'theme' => array(),
        'disabled' => array(
          'theme' => array(),
        ),
      ),
    ));
    $this->moduleHandler = $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface');
    $this->state = new State(new KeyValueMemoryFactory());
    $this->infoParser = $this->getMock('Drupal\Core\Extension\InfoParserInterface');
    $this->configInstaller = $this->getMock('Drupal\Core\Config\ConfigInstallerInterface');
    $this->configManager = $this->getMock('Drupal\Core\Config\ConfigManagerInterface');
    $this->routeBuilderIndicator = $this->getMock('Drupal\Core\Routing\RouteBuilderIndicatorInterface');
    $this->extensionDiscovery = $this->getMockBuilder('Drupal\Core\Extension\ExtensionDiscovery')
      ->disableOriginalConstructor()
      ->getMock();
    $this->cssCollectionOptimizer = $this->getMockBuilder('\Drupal\Core\Asset\CssCollectionOptimizer') //\Drupal\Core\Asset\AssetCollectionOptimizerInterface');
      ->disableOriginalConstructor()
      ->getMock();
    $logger = $this->getMock('Psr\Log\LoggerInterface');
    $this->themeHandler = new TestThemeHandler($this->root, $this->configFactory, $this->moduleHandler, $this->state, $this->infoParser, $logger, $this->cssCollectionOptimizer, $this->configInstaller, $this->configManager, $this->routeBuilderIndicator, $this->extensionDiscovery);

    $cache_backend = $this->getMock('Drupal\Core\Cache\CacheBackendInterface');
    $this->getContainerWithCacheBins($cache_backend);
  }

  /**
   * Tests rebuilding the theme data.
   *
   * @see \Drupal\Core\Extension\ThemeHandler::rebuildThemeData()
   */
  public function testRebuildThemeData() {
    $this->extensionDiscovery->expects($this->at(0))
      ->method('scan')
      ->with('theme')
      ->will($this->returnValue(array(
        'seven' => new Extension($this->root, 'theme', $this->root . '/core/themes/seven/seven.info.yml', 'seven.theme'),
      )));
    $this->extensionDiscovery->expects($this->at(1))
      ->method('scan')
      ->with('theme_engine')
      ->will($this->returnValue(array(
        'twig' => new Extension($this->root, 'theme_engine', $this->root . '/core/themes/engines/twig/twig.info.yml', 'twig.engine'),
      )));
    $this->infoParser->expects($this->once())
      ->method('parse')
      ->with($this->root . '/core/themes/seven/seven.info.yml')
      ->will($this->returnCallback(function ($file) {
        $info_parser = new InfoParser();
        return $info_parser->parse($file);
      }));
    $this->moduleHandler->expects($this->once())
      ->method('buildModuleDependencies')
      ->will($this->returnArgument(0));

    $this->moduleHandler->expects($this->once())
      ->method('alter');

    $theme_data = $this->themeHandler->rebuildThemeData();
    $this->assertCount(1, $theme_data);
    $info = $theme_data['seven'];

    // Ensure some basic properties.
    $this->assertInstanceOf('Drupal\Core\Extension\Extension', $info);
    $this->assertEquals('seven', $info->getName());
    $this->assertEquals($this->root . '/core/themes/seven/seven.info.yml', $info->getPathname());
    $this->assertEquals($this->root . '/core/themes/seven/seven.theme', $info->getExtensionPathname());
    $this->assertEquals($this->root . '/core/themes/engines/twig/twig.engine', $info->owner);
    $this->assertEquals('twig', $info->prefix);

    $this->assertEquals('twig', $info->info['engine']);
    $this->assertEquals(array('seven/global-styling'), $info->info['libraries']);
  }

  /**
   * Tests rebuild the theme data with theme parents.
   */
  public function testRebuildThemeDataWithThemeParents() {
    $this->extensionDiscovery->expects($this->at(0))
      ->method('scan')
      ->with('theme')
      ->will($this->returnValue(array(
        'test_subtheme' => new Extension($this->root, 'theme', $this->root . '/core/modules/system/tests/themes/test_subtheme/test_subtheme.info.yml', 'test_subtheme.info.yml'),
        'test_basetheme' => new Extension($this->root, 'theme', $this->root . '/core/modules/system/tests/themes/test_basetheme/test_basetheme.info.yml', 'test_basetheme.info.yml'),
      )));
    $this->extensionDiscovery->expects($this->at(1))
      ->method('scan')
      ->with('theme_engine')
      ->will($this->returnValue(array(
        'twig' => new Extension($this->root, 'theme_engine', $this->root . '/core/themes/engines/twig/twig.info.yml', 'twig.engine'),
      )));
    $this->infoParser->expects($this->at(0))
      ->method('parse')
      ->with($this->root . '/core/modules/system/tests/themes/test_subtheme/test_subtheme.info.yml')
      ->will($this->returnCallback(function ($file) {
        $info_parser = new InfoParser();
        return $info_parser->parse($file);
      }));
    $this->infoParser->expects($this->at(1))
      ->method('parse')
      ->with($this->root . '/core/modules/system/tests/themes/test_basetheme/test_basetheme.info.yml')
      ->will($this->returnCallback(function ($file) {
        $info_parser = new InfoParser();
        return $info_parser->parse($file);
      }));
    $this->moduleHandler->expects($this->once())
      ->method('buildModuleDependencies')
      ->will($this->returnArgument(0));

    $theme_data = $this->themeHandler->rebuildThemeData();
    $this->assertCount(2, $theme_data);

    $info_basetheme = $theme_data['test_basetheme'];
    $info_subtheme = $theme_data['test_subtheme'];

    // Ensure some basic properties.
    $this->assertInstanceOf('Drupal\Core\Extension\Extension', $info_basetheme);
    $this->assertEquals('test_basetheme', $info_basetheme->getName());
    $this->assertInstanceOf('Drupal\Core\Extension\Extension', $info_subtheme);
    $this->assertEquals('test_subtheme', $info_subtheme->getName());

    // Test the parent/child-theme properties.
    $info_subtheme->info['base theme'] = 'test_basetheme';
    $info_basetheme->sub_themes = array('test_subtheme');

    $this->assertEquals($this->root . '/core/themes/engines/twig/twig.engine', $info_basetheme->owner);
    $this->assertEquals('twig', $info_basetheme->prefix);
    $this->assertEquals($this->root . '/core/themes/engines/twig/twig.engine', $info_subtheme->owner);
    $this->assertEquals('twig', $info_subtheme->prefix);
  }

  /**
   * Tests getting the base themes for a set a defines themes.
   *
   * @param array $themes
   *   An array of available themes, keyed by the theme name.
   * @param string $theme
   *   The theme name to find all its base themes.
   * @param array $expected
   *   The expected base themes.
   *
   * @dataProvider providerTestGetBaseThemes
   */
  public function testGetBaseThemes(array $themes, $theme, array $expected) {
    $base_themes = $this->themeHandler->getBaseThemes($themes, $theme);
    $this->assertEquals($expected, $base_themes);
  }

  /**
   * Provides test data for testGetBaseThemes.
   *
   * @return array
   *   An array of theme test data.
   */
  public function providerTestGetBaseThemes() {
    $data = array();

    // Tests a theme without any base theme.
    $themes = array();
    $themes['test_1'] = (object) array(
      'name' => 'test_1',
      'info' => array(
        'name' => 'test_1',
      ),
    );
    $data[] = array($themes, 'test_1', array());

    // Tests a theme with a non existing base theme.
    $themes = array();
    $themes['test_1'] = (object) array(
      'name' => 'test_1',
      'info' => array(
        'name' => 'test_1',
        'base theme' => 'test_2',
      ),
    );
    $data[] = array($themes, 'test_1', array('test_2' => NULL));

    // Tests a theme with a single existing base theme.
    $themes = array();
    $themes['test_1'] = (object) array(
      'name' => 'test_1',
      'info' => array(
        'name' => 'test_1',
        'base theme' => 'test_2',
      ),
    );
    $themes['test_2'] = (object) array(
      'name' => 'test_2',
      'info' => array(
        'name' => 'test_2',
      ),
    );
    $data[] = array($themes, 'test_1', array('test_2' => 'test_2'));

    // Tests a theme with multiple base themes.
    $themes = array();
    $themes['test_1'] = (object) array(
      'name' => 'test_1',
      'info' => array(
        'name' => 'test_1',
        'base theme' => 'test_2',
      ),
    );
    $themes['test_2'] = (object) array(
      'name' => 'test_2',
      'info' => array(
        'name' => 'test_2',
        'base theme' => 'test_3',
      ),
    );
    $themes['test_3'] = (object) array(
      'name' => 'test_3',
      'info' => array(
        'name' => 'test_3',
      ),
    );
    $data[] = array(
      $themes,
      'test_1',
      array('test_2' => 'test_2', 'test_3' => 'test_3'),
    );

    return $data;
  }

}

/**
 * Extends the default theme handler to mock some drupal_ methods.
 */
class TestThemeHandler extends ThemeHandler {

  /**
   * {@inheritdoc}
   */
  protected function clearCssCache() {
    $this->clearedCssCache = TRUE;
  }

  /**
   * {@inheritdoc}
   */
  protected function themeRegistryRebuild() {
    $this->registryRebuild = TRUE;
  }

  /**
   * {@inheritdoc}
   */
  protected function systemThemeList() {
    return $this->systemList;
  }

  /**
   * {@inheritdoc}
   */
  protected function systemListReset() {
  }

}

if (!defined('DRUPAL_EXTENSION_NAME_MAX_LENGTH')) {
  define('DRUPAL_EXTENSION_NAME_MAX_LENGTH', 50);
}
if (!defined('DRUPAL_PHP_FUNCTION_PATTERN')) {
  define('DRUPAL_PHP_FUNCTION_PATTERN', '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*');
}
if (!defined('DRUPAL_MINIMUM_PHP')) {
  define('DRUPAL_MINIMUM_PHP', '5.3.10');
}


text:
/**
 * @file img_conf.h
 *
 */

#if 0 /*Remove this to enable the content (Delete the last #endif too!)*/

#ifndef IMG_CONF_H
#define IMG_CONF_H

/*********************
 *      INCLUDES
 *********************/

/*********************
 *      DEFINES
 *********************/

/* Enable here the used images
 * For example:
 * #define USE_IMG_EXAMPLE       1
 *
 * This is compatible with the images
 * generated by the image converter utility
 * For more information see: www.littlev.hu */

/**********************
 *      TYPEDEFS
 **********************/

/**********************
 * GLOBAL PROTOTYPES
 **********************/

/**********************
 *      MACROS
 **********************/

#endif

#endif /*Remove this to enable the content*/


text:
package org.ldp4j.rdf;

public abstract class Literal<T> extends Node {

	private final T value;

	Literal(T value) {
		if(value==null) {
			throw new IllegalArgumentException("Object 'value' cannot be null");
		}
		this.value = value;
	}

	private int compareLiterals(Literal<?> o1, Literal<?> o2) {
		boolean equals = o1.getValue().equals(o2.getValue());
		if(equals) {
			return 0;
		}
		return o1.getValue().toString().compareTo(o2.getValue().toString());
	}

	public T getValue() {
		return value;
	}

	@Override
	public int compareTo(Node o) {
		if(o==null) {
			return 1;
		}
		if(o==this) {
			return 0;
		}
		if(o instanceof URIRef || o instanceof BlankNode) {
			return 1;
		}
		return compareLiterals(this,(Literal<?>)o);
	}

	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		if(requiresQuotation()) {
			builder.append("\"").append(value).append("\"");
		} else {
			builder.append(value);
		}
		return builder.toString();
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 2;
		result = prime * result +  value.hashCode();
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (!(obj instanceof Literal)) {
			return false;
		}
		Literal<?> other = (Literal<?>) obj;
		return value.equals(other.value);
	}

	protected final boolean requiresQuotation() {
		return !((value instanceof Integer) || (value instanceof Double) || (value instanceof Boolean));
	}

}


text:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<meta name="copyright" content="(C) Copyright 2005" />
<meta name="DC.rights.owner" content="(C) Copyright 2005" />
<meta content="public" name="security" />
<meta content="index,follow" name="Robots" />
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta content="reference" name="DC.Type" />
<meta name="DC.Title" content="Limitations for database values" />
<meta content="limitations, database values, database" name="DC.subject" />
<meta content="limitations, database values, database" name="keywords" />
<meta scheme="URI" name="DC.Relation" content="rreflimits.html" />
<meta scheme="URI" name="DC.Relation" content="rrefdttlimits.html" />
<meta scheme="URI" name="DC.Relation" content="rrefidlengthlimits.html" />
<meta scheme="URI" name="DC.Relation" content="rrefnumericlimits.html" />
<meta scheme="URI" name="DC.Relation" content="rrefstringlimits.html" />
<meta scheme="URI" name="DC.Relation" content="rreflimitsxml.html" />
<meta content="XHTML" name="DC.Format" />
<meta content="rrefdbmlimits" name="DC.Identifier" />
<meta content="en-us" name="DC.Language" />
<link href="commonltr.css" type="text/css" rel="stylesheet" />
<title>Limitations for database values</title>

Limitations for database values

The following table lists limitations on various database
values in Derby.

Table 1. Database limitations

Value

Limit

Maximum columns in a table

1,012

Maximum columns in a view

5,000

Maximum indexes on a table

32,767 or storage capacity

Maximum tables referenced in an SQL statement or a
view

Storage capacity

Maximum elements in a select list

1,012

Maximum predicates in a WHERE or HAVING clause

Storage capacity

Maximum number of columns in a GROUP BY clause

32,677

Maximum number of columns in an ORDER BY clause

1,012

Maximum number of prepared statements

Storage capacity

Maximum declared cursors in a program

Storage capacity

Maximum number of cursors opened at one time

Storage capacity

Maximum number of constraints on a table

Storage capacity

Maximum level of subquery nesting

Storage capacity

Maximum number of subqueries in a single statement

Storage capacity

Maximum number of rows changed in a unit of work

Storage capacity

Maximum constants in a statement

Storage capacity

Maximum depth of cascaded triggers

16

Parent topic: Derby limitations

Related reference

DATE, TIME, and TIMESTAMP limitations

Limitations on identifier length

Numeric limitations

String limitations

XML limitations


text:
using System.Linq;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SkyScanner.Data;
using SkyScanner.Settings;

namespace SkyScanner.Test
{
    [TestClass]
    public class LocationTest : TestBase
    {
        [TestInitialize]
        public override void Setup()
        {
            base.Setup();
        }

        [TestMethod]
        public async Task Locations_Can_Be_Queried()
        {
            var locations = await Scanner.QueryLocation(new LocationAutosuggestSettings("London"));
            Assert.IsNotNull(locations);
            Assert.AreNotEqual(0, locations.Count);
        }

        [TestMethod]
        public async Task Locations_Can_Be_Queried_With_Different_Settings()
        {
            var locales = await Scanner.QueryLocale();
            var locationsEng = await Scanner.QueryLocation(new LocationAutosuggestSettings("London",
                LocationAutosuggestQueryType.Query, Market.Default, Currency.Default, locales.First(locale => locale.Code == "en-GB")));

            Assert.IsTrue(locationsEng.Count > 0);

            var locationsFr = await Scanner.QueryLocation(new LocationAutosuggestSettings("London",
                LocationAutosuggestQueryType.Query, Market.Default, Currency.Default, locales.First(locale => locale.Code == "fr-FR")));

            Assert.IsTrue(locationsFr.Count > 0);

            var locationsHeathrow = await Scanner.QueryLocation(new LocationAutosuggestSettings("LHR-sky",
                LocationAutosuggestQueryType.Id, Market.Default, Currency.Default, locales.First(locale => locale.Code == "fr-FR")));

            Assert.AreEqual(1, locationsHeathrow.Count);

            // todo this seems to not work anymore
            //var ipBased = await Scanner.QueryLocation(new LocationAutosuggestSettings("212.58.244.18-IP",
            //    LocationAutosuggestQueryType.Query, Market.Default, Currency.Default, locales.First(locale => locale.Code == "fr-FR")));

            //Assert.AreEqual(1, ipBased.Count);
            //Assert.AreEqual("LOND-sky", ipBased.First().PlaceId);

            var info = await Scanner.QueryLocation(new LocationAutosuggestSettings("LOND-sky",
                LocationAutosuggestQueryType.Id, Market.Default, Currency.Default, locales.First(locale => locale.Code == "fr-FR")));

            Assert.AreEqual(1, info.Count);
        }
    }
}


text:
This app loads [NetLog
files](https://www.chromium.org/developers/design-documents/network-stack/netlog)
generated by Chromium's `chrome://net-export`. Log data is processed and
visualized entirely on the client side (your browser). Data is never uploaded
to a remote endpoint.

The latest version of the net log viewer can be accessed at:

## [https://netlog-viewer.appspot.com/](https://netlog-viewer.appspot.com/)

See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to modify and run locally, or report bugs.


text:
namespace System.Net.Security {
  public enum EncryptionPolicy {
    AllowNoEncryption = 1,
    NoEncryption = 2,
    RequireEncryption = 0,
  }
  public delegate X509Certificate LocalCertificateSelectionCallback(object sender, string targetHost, X509CertificateCollection localCertificates, X509Certificate remoteCertificate, string[] acceptableIssuers);
  public delegate bool RemoteCertificateValidationCallback(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors);
  public class SslStream : Stream {
    public SslStream(Stream innerStream);
    public SslStream(Stream innerStream, bool leaveInnerStreamOpen);
    public SslStream(Stream innerStream, bool leaveInnerStreamOpen, RemoteCertificateValidationCallback userCertificateValidationCallback);
    public SslStream(Stream innerStream, bool leaveInnerStreamOpen, RemoteCertificateValidationCallback userCertificateValidationCallback, LocalCertificateSelectionCallback userCertificateSelectionCallback);
    public SslStream(Stream innerStream, bool leaveInnerStreamOpen, RemoteCertificateValidationCallback userCertificateValidationCallback, LocalCertificateSelectionCallback userCertificateSelectionCallback, EncryptionPolicy encryptionPolicy);
    public override bool CanRead { get; }
    public override bool CanSeek { get; }
    public override bool CanTimeout { get; }
    public override bool CanWrite { get; }
    public virtual bool CheckCertRevocationStatus { get; }
    public virtual CipherAlgorithmType CipherAlgorithm { get; }
    public virtual int CipherStrength { get; }
    public virtual HashAlgorithmType HashAlgorithm { get; }
    public virtual int HashStrength { get; }
    public virtual ExchangeAlgorithmType KeyExchangeAlgorithm { get; }
    public virtual int KeyExchangeStrength { get; }
    public override long Length { get; }
    public virtual X509Certificate LocalCertificate { get; }
    public override long Position { get; set; }
    public override int ReadTimeout { get; set; }
    public virtual X509Certificate RemoteCertificate { get; }
    public virtual SslProtocols SslProtocol { get; }
    public TransportContext TransportContext { get; }
    public override int WriteTimeout { get; set; }
    public virtual void AuthenticateAsClient(string targetHost);
    public virtual void AuthenticateAsClient(string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
    public virtual Task AuthenticateAsClientAsync(string targetHost);
    public virtual Task AuthenticateAsClientAsync(string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
    public virtual void AuthenticateAsServer(X509Certificate serverCertificate);
    public virtual void AuthenticateAsServer(X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
    public virtual Task AuthenticateAsServerAsync(X509Certificate serverCertificate);
    public virtual Task AuthenticateAsServerAsync(X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
    public override void Flush();
    public override int Read(byte[] buffer, int offset, int count);
    public override long Seek(long offset, SeekOrigin origin);
    public override void SetLength(long value);
    public void Write(byte[] buffer);
    public override void Write(byte[] buffer, int offset, int count);
  }
}
namespace System.Security.Authentication {
  public class AuthenticationException : Exception {
    public AuthenticationException();
    public AuthenticationException(string message);
    public AuthenticationException(string message, Exception innerException);
  }
}
namespace System.Security.Authentication.ExtendedProtection {
  public class ExtendedProtectionPolicy {
    public ExtendedProtectionPolicy(PolicyEnforcement policyEnforcement);
    public ExtendedProtectionPolicy(PolicyEnforcement policyEnforcement, ChannelBinding customChannelBinding);
    public ExtendedProtectionPolicy(PolicyEnforcement policyEnforcement, ProtectionScenario protectionScenario, ICollection customServiceNames);
    public ExtendedProtectionPolicy(PolicyEnforcement policyEnforcement, ProtectionScenario protectionScenario, ServiceNameCollection customServiceNames);
    public ChannelBinding CustomChannelBinding { get; }
    public ServiceNameCollection CustomServiceNames { get; }
    public static bool OSSupportsExtendedProtection { get; }
    public PolicyEnforcement PolicyEnforcement { get; }
    public ProtectionScenario ProtectionScenario { get; }
    public override string ToString();
  }
  public enum PolicyEnforcement {
    Always = 2,
    Never = 0,
    WhenSupported = 1,
  }
  public enum ProtectionScenario {
    TransportSelected = 0,
    TrustedProxy = 1,
  }
  public class ServiceNameCollection : ICollection, IEnumerable {
    public ServiceNameCollection(ICollection items);
    public int Count { get; }
    bool System.Collections.ICollection.IsSynchronized { get; }
    object System.Collections.ICollection.SyncRoot { get; }
    public bool Contains(string searchServiceName);
    public IEnumerator GetEnumerator();
    public ServiceNameCollection Merge(IEnumerable serviceNames);
    public ServiceNameCollection Merge(string serviceName);
    void System.Collections.ICollection.CopyTo(Array array, int index);
  }
}


text:
%%{init: {'themeVariables': { 'fontFamily': 'Inconsolata, Avenir, Helvetica, sans-serif', 'primaryColor': '#ff0000'}}}%%

graph TD
  classDef stdOp fill:#FFF,stroke:#A00,stroke-width:2px;
  classDef userHook fill:#B5B2A1,stroke:#A00,stroke-width:2px,stroke-dasharray: 5, 5;

  iam[Verify Static IAM Roles]
  class iam stdOp;

  preBuild[WorkflowHook - PreBuild]
  class preBuild userHook;

  compile[Compile for AWS Lambda Container]

  postBuild[WorkflowHook - PostBuild]
  class postBuild userHook;

  package[ZIP archive]
  class package stdOp;

  package_oci[OCI Build]
  class package_oci stdOp;

  userArchive[WorkflowHook - Archive]
  class userArchive userHook;

  upload[Upload Archive to S3]
  uploadAssets[Upload S3 Assets]
  packageAssets[Conditionally ZIP S3 Site Assets]
  class upload,packageAssets,uploadAssets stdOp;

  preMarshall[WorkflowHook - PreMarshall]
  class preMarshall userHook;

  generate[Marshal to CloudFormation]
  class generate stdOp;

  decorate[Call Lambda Decorators - Dynamic AWS Resources]
  class decorate stdOp;

  serviceDecorator[Service Decorator]
  class serviceDecorator userHook;

  postMarshall[WorkflowHook - PostMarshall]
  class postMarshall stdOp;

  uploadTemplate[Upload Template to S3]
  updateStack[Create/Update Stack]
  inplaceUpdates[In-place λ code updates]
  wait[Wait for Complete/Failure Result]

  class uploadTemplate,updateStack,inplaceUpdates,wait stdOp;

  iam-->preBuild
  preBuild-->|go|compile
  compile-->postBuild
  postBuild-->package
  postBuild-->package_oci
  package-->packageAssets
  package_oci-->packageAssets
  package-->userArchive
  package_oci-->upload
  userArchive-->upload
  packageAssets-->uploadAssets
  uploadAssets-->generate
  upload-->generate

  generate-->preMarshall
  preMarshall-->decorate
  decorate-->serviceDecorator
  serviceDecorator-->postMarshall
  postMarshall-->uploadTemplate
  uploadTemplate-->|standard|updateStack
  uploadTemplate-->|inplace|inplaceUpdates
  updateStack-->wait

This diagram is rendered with Mermaid. Please open an issue if it doesn't render properly.


text:
/*globals angular*/
/**
 * Created by rgladson on 7/8/2015.
 * Just because the language is javascript, there is no excuse to write bad code!™
 */

(function (angular, namespace, undefined) {
  "use strict";
  function buildRegistry() {
    var callBackRegistry = [];
    return {
      register: registerCallback,
      exec: executeCallback,
      execSilent: executeSilentCallback,
      get length() {
        return callBackRegistry.length;
      }
    };

    function registerCallback(callbackFn) {
      callbackFn.push(callbackFn);
      return function deRegisterCallback() {
        var idx;
        if (~(idx = callBackRegistry.indexOf(callbackFn))) {
          callBackRegistry.splice(idx, 1);
        }
      };
    }

    function executeCallback(argument) {
      return callBackRegistry.map(
        function runCallback(cbf) {
          return cbf(argument);
        }
      );
    }

    function executeSilentCallback(argument) {
      callBackRegistry.forEach(
        function runCallback(cbf) {
          return cbf(argument);
        }
      );
    }

  }

  function pubSub (registrar) {
    var directory = Object.create(null);
    return {
      subscribe: subscribe,
      publish: publish
    };

    function subscribe(channel, callback) {
      if (!directory[channel]) {
        directory[channel] = registrar();
      }
      // Return the unsubscriber to the registration
      return directory[channel].register(callback);
    }

    function publish(channel, message) {
      if (directory[channel]) {
        directory[channel].execSilent(message);
      }
    }
  }

  namespace.buildRegistry = buildRegistry;
  namespace.pubSub = function () {
    return pubSub(buildRegistry);
  };

  if (angular) {
    angular.module('crazyLikeAFox').factory('registrar', [function () {
      return buildRegistry;
    }]).factory('publishSubscribe', ['registrar', pubSub]);
  }
})(window.angular, crazyLikeAFox);


text:
/*
 * @(#)Cell.java
 *
 * $Id: Cell.java,v 1.27 2000/12/05 06:05:18 rkc10 Exp $
 *
 * Created on October 14, 2000, 6:23 PM
 */
package njfbrowser.spreadsheet;

import java.util.TreeSet;

/**
 * This is a wrapper class for all objects in the table.
 *

 * A cell has a value which is either text or a number.
 * If it is a formula cell it also has an expression associated with it.
 * In addition, a cell has a list of all cells that reference it.
 *
 * @author Ricky Chin
 * @version $Revision: 1.27 $
 */

public class Cell {

    /**
     * The integer code that denotes the cell holds text.
     */
    public static final int TEXT = 0;

    /**
     * The integer code that denotes the cell holds numbers.
     */
    public static final int NUMBER = 1;

    /**
     * The integer code that denotes the cell holds a formula.
     */
    public static final int FORMULA = 2;

    /**
     * Value of the cell. In a formula, value holds the evaluated value.
     */
    private Object value;

    /**
     * This expression contains the string and internal representation
     * of the formula if it exists.
     */
    private Formula expression;

    /**
     * The list of cells that reference this cell. When a cell is changes,
     * all cells on this list should notified.
     */
    private TreeSet refs;

    /**
     * Creates an empty cell
     */
    public Cell() {
        value = null;
        expression = null;
        refs = null;
    }

    /**
     * This constructor constructs a cell that will not have cells
     * referencing it and are not formulas. Basically only used for creating
     * the row and column labels.
     *

     * Warning: Do not use this with Formulas
     *
     * @param datum the value of the "label" cell (not a Formula)
     */
    public Cell(Object datum) {
        value = datum;
        expression = null;
        refs = null;
    }

    /**
     * The constructor creates a new data cell which is not a formula.
     *

     * Note: A normal cell's data is stored in value field
     * but expression (i.e. formula) field is null.
     *
     * @param datum     the value of the cell (text or number)
     * @param reference the list of cells that reference this one (can be null)
     */
    public Cell(Object datum, TreeSet reference) {
        value = datum;
        expression = null;
        refs = reference;
    }

    /**
     * This version of the constructor constructs a formula cell.
     *
     * @param thing     internal represenation of the formula
     * @param eVal      the evaluated value of the formula (thing)
     * @param reference the list of cells that reference this one (can be null)
     */
    public Cell(Formula thing, Object eVal, TreeSet reference) {
        expression = thing;
        value = eVal;
        refs = reference;
    }

    /**
     * This method returns the formula associated with the cell or null if it
     * does not exist.
     *
     * @return the formula (string and internal object) or null if does not
     * exist
     */
    public Formula getFormula() {
        return expression;
    }

    /**
     * If it is a data cell, it returns the data of the cell. If it is a
     * formula, it returns the previously evaluated value of the formula.
     *
     * @return the value (data or evaluated) of the cell
     */
    public Object getValue() {
        return value;
    }

    /**
     * Sets the value field of the cell.
     *
     * @param datum the object to set the value of cell to
     */
    public void setValue(Object datum) {
        value = datum;
    }

    /**
     * This method changes the cell to a data cell with value datum. This
     * method useful because changing the value does not affect the value of
     * the reference list.
     *

     * Warning: If the cell is going to be set to a formula, you must
     * use setFormula() because this present method sets the associated formula
     * field, expression, to null.
     *
     * @param datum the new value of cell
     */
    public void setData(Object datum) {
        value = datum;
        expression = null;
    }

    /**
     * This method sets the cell to be a formula cell. It puts the formula
     * object into the expression field. The Table of Cells is responsible
     * for recalculating and setting the appropriate value in the value
     * field of this cell.
     *
     * @param form the internal representation of formula to set this cell to
     */
    public void setFormula(Formula form) {
        expression = form;
    }

    /**
     * Returns true if cell at specified position is empty.
     *
     * @return true if empty, false is not
     */
    public boolean isEmpty() {
        return value.equals("") && expression == null;
    }

    /**
     * This method returns true if there are cells that reference this one.
     *
     * @return true only if there are cells that reference this one
     */
    public boolean hasRefs() {
        return (refs != null && !refs.isEmpty());
    }

    /**
     * This method gets the list of cells that reference this one.
     * This method should be used after the cell's value has been changed
     * to find out which cells need to be updated.
     *
     * @return all cells that reference this cell
     */
    public TreeSet getRefs() {
        return refs;
    }

    /**
     * This method removes a cell from reference list.
     *
     * @param reference the cell to be removed from the reference list
     */
    public void removeRef(CellPoint reference) {
        //	System.out.println("remove ref "+reference+" from "+this);
        if (refs != null) {
            refs.remove(reference);
            if (refs.isEmpty()) refs = null;
        }
    }

    /**
     * This method adds a cell to the dependency list.
     *
     * @param reference a new cell that references this one that needs to be
     *                  added to the reference list
     */
    public void addRef(CellPoint reference) {
        //	System.out.println("add ref "+reference+" to ("+this);
        if (refs == null) {// check if refs is initiated
            refs = new TreeSet();
        }
        refs.add(reference);
    }

    /**
     * This method is useful for determining what information a cell holds. To
     * check if a cell holds a certain type just see if
     * getType() == Cell.CODE where CODE is any of the cell constants.
     *
     * @return the integer code of the type of data this cell holds
     */
    public int getType() {
        if (expression != null) return Cell.FORMULA;
        if (value instanceof Number) return Cell.NUMBER;
        return Cell.TEXT;
    }

    /**
     * This method returns true IFF it is a formula cell
     *
     * @return true iff a formula cell
     */
    public boolean isFormula() {
        return (expression != null);
    }

    /**
     * This method determines a cell is a formula cell that has a error.
     *
     * @return true if cell is an error cell
     */
    public boolean isErrorCell() {
        return ((isFormula()) && (value instanceof ParserException));
    }

    /**
     * This is a method similar to compareTo except that it is not
     * consistent with the equals method. It is used for sorting.
     * Cells are rated in increasing order: blank, error, string,
     * number (including formulas). If two cells are blank or errors
     * then they are "equal" by this compare method. Numbers and
     * strings are compared the usual way.
     *
     * @param x cell to compare this to
     * @return -1 if this < x, 0 if this = x, 1 if this > x
     */
    public int compare(Cell x, boolean ascending) {
        //if this is blank which is lowest value
        if (this.value.equals("")) {
            //x is not blank so this is less than
            if (!x.value.equals("")) {
                if (ascending) {
                    return 1;
                } else {
                    return -1;
                }
            } else {               //otherwise equal
                return 0;
            }
        } else {
            if (x.value.equals("")) {
                if (ascending) {
                    return -1;
                } else {
                    return 1;
                }
            } else {               //both have values
                if (this.isErrorCell()) {
                    if (x.isErrorCell()) {
                        return 0;
                    } else {
                        return -1;
                    }
                } else {
                    if (x.isErrorCell()) {
                        return 1;
                    } else {
                        if (this.getType() == Cell.TEXT) {
                            if (x.getType() == Cell.TEXT) {
                                String temp = (String) this.value;
                                return temp.compareToIgnoreCase((String) x.value);
                            } else {
                                return -1;
                            }
                        } else {
                            if (x.getType() == Cell.TEXT) {
                                return 1;
                            } else {
                                Float first = (Float) this.value;
                                Float second = (Float) x.value;
                                return first.compareTo(second);
                            }
                        }
                    }
                }
            }
        }
    }

    public String toString() {

        if (expression != null)
            return "=" + expression.toString();
        else
            return value.toString();
    }
}


text:
jQuery(function($){
    $('.navbar-default .navbar-nav > li > a').click(function() {
        $('.navbar-default .navbar-collapse').collapse('hide')
    });
});


text:
var OpenAddressingUI = (function() {

})();


text:
from facette.utils import *
import json

GROUP_ENTRY_ORIGIN  = "origin"
GROUP_ENTRY_PATTERN = "pattern"

class GroupEntry:
    def __init__(self, js=""):
        self.entry = {}
        self.origin  = facette_to_json(GROUP_ENTRY_ORIGIN,  js, self.entry)
        self.pattern = facette_to_json(GROUP_ENTRY_PATTERN, js, self.entry)

    def set(self, origin=None, pattern=None):
        self.origin  = facette_set(id, GROUP_ENTRY_ORIGIN,  self.entry)
        self.pattern = facette_set(id, GROUP_ENTRY_PATTERN, self.entry)

    def __str__(self):
        return json.dumps(self.entry)

    def __repr__(self):
        return str(self)


text:
package gwt.material.design.client.ui;

import com.google.gwt.dom.client.Element;
import com.google.gwt.event.logical.shared.AttachEvent;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.ui.Widget;
import gwt.material.design.client.base.HasType;
import gwt.material.design.client.base.MaterialWidget;
import gwt.material.design.client.base.mixin.ColorsMixin;
import gwt.material.design.client.base.mixin.CssTypeMixin;
import gwt.material.design.client.constants.TabType;
import gwt.material.design.client.ui.html.UnorderedList;

//@formatter:off

/**
 * The tabs structure consists of an unordered list of tabs that have hashes corresponding to tab ids. Then when you click on each tab, only the container with the corresponding tab id will become visible.
 *
UiBinder Usage:

 *

 *{@code
<m:MaterialTab ui:field="tab"  backgroundColor="blue">
<m:MaterialTabItem waves="YELLOW" grid="l4"></m:MaterialTabItem>
<m:MaterialTabItem waves="YELLOW" grid="l4"></m:MaterialTabItem>
<m:MaterialTabItem waves="YELLOW" grid="l4"></m:MaterialTabItem>
</m:MaterialTab>

}
 *

 * @see Material Tabs
 * @author kevzlou7979
 * @author Ben Dol
 */
//@formatter:on
public class MaterialTab extends UnorderedList implements HasType<TabType> {

    private int tabIndex;
    private String indicatorColor;

    private MaterialWidget indicator;
    private ColorsMixin<MaterialWidget> indicatorColorMixin;

    private final CssTypeMixin<TabType, MaterialTab> typeMixin = new CssTypeMixin<>(this);

    public MaterialTab() {
        super("tabs");
    }

    @Override
    public void onLoad() {
        super.onLoad();

        initialize();

        indicator = new MaterialWidget(getIndicatorElement(getElement()));
        indicatorColorMixin = new ColorsMixin<>(indicator);

        setIndicatorColor(indicatorColor);
    }

    public int getTabIndex() {
        return tabIndex;
    }

    public void setTabIndex(int tabIndex) {
        this.tabIndex = tabIndex;
        int i = 0;
        for(Widget w : this){
            if(i == tabIndex){
                if(w instanceof MaterialTabItem) {
                    ((MaterialTabItem) w).selectTab();
                    break;
                }
            }
            i++;
        }
    }

    public void setIndicatorColor(String indicatorColor){
        this.indicatorColor = indicatorColor;

        if(indicatorColorMixin != null && indicatorColor != null) {
            indicatorColorMixin.setBackgroundColor(indicatorColor);
        }
    }

    /**
     * Select a given tab by id.
     * @param tabId Tab to selects id.
     */
    public void selectTab(String tabId) {
        selectTab(getElement(), tabId);
    }

    protected void initialize() {
        initialize(getElement());
    }

    private native void initialize(Element e) /*-{
        $wnd.jQuery(document).ready(function(){
            $wnd.jQuery(e).tabs();
            for(var i = 1; i <= $wnd.jQuery(e).find('.indicator').length; i++){
                $wnd.jQuery(e).find('.indicator').eq(i).remove()
            }

        });
    }-*/;

    private native Element getIndicatorElement(Element e)/*-{
        return $wnd.jQuery(e).find(".indicator")[0];
    }-*/;

    private native void selectTab(Element e, String tabId)/*-{
        $wnd.jQuery(e).tabs("select_tab", tabId);
    }-*/;

    @Override
    public void setType(TabType type) {
        typeMixin.setType(type);
    }

    @Override
    public TabType getType() {
        return typeMixin.getType();
    }
}


text:
package com.google.devtools.build.android.desugar.langmodel;

import com.google.common.collect.ConcurrentHashMultiset;

/** The counter used to track a class member use. */
public final class ClassMemberUseCounter implements TypeMappable<ClassMemberUseCounter> {

  /** Tracks a class member with its associated count. */
  private final ConcurrentHashMultiset<ClassMemberUse> memberUseCounter;

  public ClassMemberUseCounter(ConcurrentHashMultiset<ClassMemberUse> memberUseCounter) {
    this.memberUseCounter = memberUseCounter;
  }

  /** Increases the member use count by one when an member access is encountered. */
  public boolean incrementMemberUseCount(ClassMemberUse classMemberUse) {
    return memberUseCounter.add(classMemberUse);
  }

  /** Retrieves the total use count of a given class member. */
  public long getMemberUseCount(ClassMemberUse memberKey) {
    return memberUseCounter.count(memberKey);
  }

  @Override
  public ClassMemberUseCounter acceptTypeMapper(TypeMapper typeMapper) {
    return new ClassMemberUseCounter(typeMapper.map(memberUseCounter));
  }
}


text:
#include "wx/wx.h"
#include "wx/valtext.h"
#include "wx/valgen.h"
#include "wx/statline.h"
#include "wx/msgdlg.h"
#include "Appdefs.h"
#include "Objects.h"
#include "GameLogic.h"
#include "thc.h"
#include "CtrlChessPositionSetup.h"
#include "Book.h"
#include "Repository.h"
#include "PatternDialog.h"
using namespace std;
using namespace thc;

// PatternDialog type definition
IMPLEMENT_CLASS( PatternDialog, wxDialog )

// PatternDialog event table definition
BEGIN_EVENT_TABLE( PatternDialog, wxDialog )
    EVT_BUTTON( ID_PATTERN_CLEAR,PatternDialog::OnClearClick )
    EVT_BUTTON( ID_PATTERN_CURRENT, PatternDialog::OnCurrentClick )
    EVT_BUTTON( ID_PATTERN_RESET, PatternDialog::OnResetClick )
    EVT_BUTTON( wxID_HELP, PatternDialog::OnHelpClick )
    EVT_BUTTON( wxID_OK, PatternDialog::OnOkClick )
END_EVENT_TABLE()

// Constructor
static PatternDialog *singleton;   // for DatabaseSearchVeryUglyTemporaryCallback();
PatternDialog::PatternDialog
(
    PatternParameters *parm, wxWindow* parent,
    const wxString& caption,
    wxWindowID id,
    const wxPoint& pos, const wxSize& size, long style
)
{
    singleton = this;
    bsc = NULL;
    this->parm = parm;
    support_lockdown = (id==ID_MATERIAL_BALANCE_DIALOG);
    offset_persist = 0;

    // pattern
    b_either = !parm->material_balance;
    b_white  = !parm->material_balance;
    b_black  = !parm->material_balance;
    b_dont_allow_more = !parm->material_balance;

    // material balance
    b_piece_map = parm->material_balance;
    b_pawns   = parm->material_balance;
    b_bishops = parm->material_balance;
    b_ply     = parm->material_balance;
    Create(parent, caption, id, pos, size, style);
}

// Dialog create
bool PatternDialog::Create( wxWindow* parent,
  const wxString& caption,
  wxWindowID id,
  const wxPoint& pos, const wxSize& size, long style )
{
    bool okay=true;

    // We have to set extra styles before creating the dialog
    SetExtraStyle( wxWS_EX_BLOCK_EVENTS/*|wxDIALOG_EX_CONTEXTHELP*/ );
    if( !wxDialog::Create( parent, id, caption, pos, size, style ) )
        okay = false;
    else
    {

        CreateControls();
        SetDialogHelp();

        // This fits the dialog to the minimum size dictated by the sizers
        GetSizer()->Fit(this);

        // This ensures that the dialog cannot be sized smaller than the minimum size
        GetSizer()->SetSizeHints(this);

        // Centre the dialog on the parent or (if none) screen
        Centre();
    }
    return okay;
}

// Control creation for PatternDialog
void PatternDialog::CreateControls()
{

    // A top-level sizer
    wxBoxSizer* top_sizer = new wxBoxSizer(wxVERTICAL);
    this->SetSizer(top_sizer);

    // A second box sizer to give more space around the controls
    wxBoxSizer* box_sizer = new wxBoxSizer(wxVERTICAL);
    top_sizer->Add(box_sizer, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);

    // The board setup bitmap
    bsc = new CtrlChessPositionSetup(false,support_lockdown,this);
    bsc->Set( parm->cp, parm->lockdown );

    // Intermediate sizers
    wxBoxSizer* horiz_board = new wxBoxSizer(wxHORIZONTAL);
    wxBoxSizer* horiz_extra = new wxBoxSizer(wxHORIZONTAL);

    wxStaticBox *box = new wxStaticBox(this, wxID_ANY, "&Refine search" );
    wxSizer     *castling_box = new wxStaticBoxSizer(box, wxVERTICAL);
    wxSizer     *who_box = NULL;
    if( b_white )
    {
        wxStaticBox *box2 = new wxStaticBox(this, wxID_ANY, "&Who to move" );
        who_box = new wxStaticBoxSizer(box2, wxVERTICAL);
    }
    //wxStaticBox *box3 = new wxStaticBox(this, wxID_ANY, "&Other details" );
    //wxSizer     *details_box = new wxStaticBoxSizer(box3, wxVERTICAL);
    inc_reflection = new wxCheckBox( this, ID_PATTERN_INC_REFLECTION,
       wxT("&Include reflections"), wxDefaultPosition, wxDefaultSize, 0 );
    inc_reflection->SetValue( parm->include_reflections );
    inc_reverse = new wxCheckBox( this, ID_PATTERN_INC_REVERSE,
       wxT("&Include reversed colours"), wxDefaultPosition, wxDefaultSize, 0 );
    inc_reverse->SetValue( parm->include_reverse_colours );
    if( b_dont_allow_more )
    {
        dont_allow_more = new wxCheckBox( this, ID_PATTERN_DONT_ALLOW_MORE,
           wxT("&Don't allow more pieces"), wxDefaultPosition, wxDefaultSize, 0 );
        dont_allow_more->SetValue( parm->dont_allow_more_pieces );
    }
    if( b_pawns )
    {
        pawns_same_files = new wxCheckBox( this, ID_PATTERN_PAWNS_SAME_FILES,
           wxT("&Pawns must be on same files"), wxDefaultPosition, wxDefaultSize, 0 );
        pawns_same_files->SetValue( parm->pawns_must_be_on_same_files );
    }
    if( b_bishops )
    {
        bishops_same_colour = new wxCheckBox( this, ID_PATTERN_BISHOPS_SAME_COLOUR,
           gbl_spelling_us?"Bishops must be same color":"Bishops must be same colour", wxDefaultPosition, wxDefaultSize, 0 );
        bishops_same_colour->SetValue( parm->bishops_must_be_same_colour );
    }
    if( b_white )
    {
        white_to_move = new wxRadioButton( this, ID_PATTERN_WHITE_TO_MOVE,
           wxT("&White to move"), wxDefaultPosition, wxDefaultSize,  wxRB_GROUP );
        white_to_move->SetValue( parm->either_to_move ? false : parm->white_to_move );
        black_to_move = new wxRadioButton( this, ID_PATTERN_BLACK_TO_MOVE,
           wxT("&Black to move"), wxDefaultPosition, wxDefaultSize, 0 );
        black_to_move->SetValue( parm->either_to_move ? false : !parm->white_to_move );
        either_to_move = new wxRadioButton( this, ID_PATTERN_EITHER_TO_MOVE,
           wxT("&Either to move"), wxDefaultPosition, wxDefaultSize, 0 );
        either_to_move->SetValue( parm->either_to_move );
    }

    // Move count
    wxBoxSizer* move_count_sizer = NULL;;
    if( b_ply )
    {
        move_count_sizer  = new wxBoxSizer(wxHORIZONTAL);
        wxStaticText* move_count_label = new wxStaticText ( this, wxID_STATIC,
            wxT("Balance must persist for at\nleast this many half moves"), wxDefaultPosition, wxDefaultSize, 0 );
        move_count_ctrl = new wxSpinCtrl ( this, ID_PATTERN_MOVE_COUNT,
            wxEmptyString, wxDefaultPosition, wxSize(50, wxDefaultCoord), //wxDefaultSize,
            wxSP_ARROW_KEYS, 1, 500, parm->number_of_ply );
        move_count_sizer->Add(move_count_label, 0, wxBOTTOM|wxALIGN_CENTER_VERTICAL, 10);
        move_count_sizer->Add( 10, 5, 1, wxALL, 0);
        move_count_sizer->Add(move_count_ctrl,  0, wxBOTTOM|wxALIGN_CENTER_VERTICAL, 10);
    }

    castling_box->Add( inc_reflection, 0,
        wxALL, 5);
    castling_box->Add( inc_reverse, 0,
        wxALL, 5);
    if( b_dont_allow_more )
    {
        castling_box->Add( dont_allow_more, 0,
            wxALL, 5);
    }
    if( b_pawns )
    {
        castling_box->Add( pawns_same_files, 0,
            wxALL, 5);
    }
    if( b_bishops )
    {
        castling_box->Add( bishops_same_colour, 0,
            wxALL, 5);
    }
    if( b_ply )
    {
        castling_box->Add(move_count_sizer,
         wxALIGN_LEFT|wxGROW | (wxALL/* & ~wxLEFT */), 5);
         //wxALL, 5);
    }

    if( b_white )
    {
        who_box->Add( white_to_move, 0,
            wxALL, 5);
        who_box->Add( black_to_move, 0,
            wxALL, 5);
        who_box->Add( either_to_move, 0,
            wxALL, 5);
    }

    // A vertical box sizer to contain Reset, Clear, OK, Cancel and Help
    wxBoxSizer* buttons_box = new wxBoxSizer(wxVERTICAL);

    // The Initial button
    wxButton* reset = new wxButton( this, ID_PATTERN_RESET, wxT("&Initial"),
        wxDefaultPosition, wxDefaultSize, 0 );
    buttons_box->Add( reset, 0, wxALL, 5);

    // The Current button
    wxButton* current = new wxButton( this, ID_PATTERN_CURRENT, wxT("&Current"),
        wxDefaultPosition, wxDefaultSize, 0 );
    buttons_box->Add( current, 0, wxALL, 5);

    // The Clear button
    wxButton* clear = new wxButton( this, ID_PATTERN_CLEAR, wxT("&Clear"),
        wxDefaultPosition, wxDefaultSize, 0 );
    buttons_box->Add( clear, 0, wxALL, 5);

    // The OK button
    ok_button = new wxButton ( this, wxID_OK, wxT("&OK"),
        wxDefaultPosition, wxDefaultSize, 0 );
    buttons_box->Add( ok_button, 0, wxALL, 5);

    // The Cancel button
    wxButton* cancel = new wxButton ( this, wxID_CANCEL,
        wxT("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
    buttons_box->Add( cancel, 0, wxALL, 5);

    // The Help button
    wxButton* help = new wxButton( this, wxID_HELP, wxT("&Help"),
        wxDefaultPosition, wxDefaultSize, 0 );
    buttons_box->Add( help, 0, wxALL, 5);

    //box_sizer->Add( buttons_box, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
    horiz_board->Add( bsc, 1, wxALIGN_LEFT|wxALL|wxFIXED_MINSIZE, 5 );
    horiz_board->Add( buttons_box, 0, wxALIGN_LEFT|wxGROW | (wxALL/* & ~wxLEFT */), 5);

    if( b_piece_map )
    {
        wxStaticBox *lockdown = new wxStaticBox(this, wxID_ANY, "&Optionally right click to lock down squares" );
        wxSizer     *lockdown_vert  = new wxStaticBoxSizer(lockdown, wxHORIZONTAL );
        lockdown_text = new wxStaticText(this, wxID_ANY, "Currently there are no locked down squares" );
        wxStaticBox *more_pieces = new wxStaticBox(this, wxID_ANY, "&Optionally allow some extra material" );
        wxSizer     *more_pieces_vert  = new wxStaticBoxSizer(more_pieces, wxVERTICAL );
        wxStaticBox *more_pieces1 = new wxStaticBox(this, wxID_ANY, "&White" );
        wxStaticBox *more_pieces2 = new wxStaticBox(this, wxID_ANY, "&Black" );
        wxSizer     *more_pieces_horiz1 = new wxStaticBoxSizer(more_pieces1,wxHORIZONTAL);
        wxSizer     *more_pieces_horiz2 = new wxStaticBoxSizer(more_pieces2,wxHORIZONTAL);
        more_pieces_vert->Add( more_pieces_horiz1,  0, wxALIGN_LEFT |wxRIGHT, 80 /*spacer*/  );
        more_pieces_vert->Add( more_pieces_horiz2,  0, wxALIGN_LEFT |wxLEFT|wxRIGHT|wxTOP, 0 );
        more_pieces_wq = new wxCheckBox( this, ID_PATTERN_MORE_PIECES_WQ,
           "Q", wxDefaultPosition, wxDefaultSize, 0 );
        more_pieces_wq->SetValue( parm->more_pieces_wq );
        more_pieces_wr = new wxCheckBox( this, ID_PATTERN_MORE_PIECES_WR,
           "R", wxDefaultPosition, wxDefaultSize, 0 );
        more_pieces_wr->SetValue( parm->more_pieces_wr );
        more_pieces_wb = new wxCheckBox( this, ID_PATTERN_MORE_PIECES_WB,
           "B", wxDefaultPosition, wxDefaultSize, 0 );
        more_pieces_wb->SetValue( parm->more_pieces_wb );
        more_pieces_wn = new wxCheckBox( this, ID_PATTERN_MORE_PIECES_WN,
           "N", wxDefaultPosition, wxDefaultSize, 0 );
        more_pieces_wn->SetValue( parm->more_pieces_wn );
        more_pieces_wp = new wxCheckBox( this, ID_PATTERN_MORE_PIECES_WP,
           "P", wxDefaultPosition, wxDefaultSize, 0 );
        more_pieces_wp->SetValue( parm->more_pieces_wp );
        more_pieces_horiz1->Add( more_pieces_wq, 0,
            wxALIGN_CENTER_VERTICAL|wxLEFT, 15);
        more_pieces_horiz1->Add( more_pieces_wr, 0,
            wxALIGN_CENTER_VERTICAL,0);
        more_pieces_horiz1->Add( more_pieces_wb, 0,
            wxALIGN_CENTER_VERTICAL,0);
        more_pieces_horiz1->Add( more_pieces_wn, 0,
            wxALIGN_CENTER_VERTICAL,0);
        more_pieces_horiz1->Add( more_pieces_wp, 0,
            wxALIGN_CENTER_VERTICAL,0);
        more_pieces_bq = new wxCheckBox( this, ID_PATTERN_MORE_PIECES_BQ,
           "Q", wxDefaultPosition, wxDefaultSize, 0 );
        more_pieces_bq->SetValue( parm->more_pieces_bq );
        more_pieces_br = new wxCheckBox( this, ID_PATTERN_MORE_PIECES_BR,
           "R", wxDefaultPosition, wxDefaultSize, 0 );
        more_pieces_br->SetValue( parm->more_pieces_br );
        more_pieces_bb = new wxCheckBox( this, ID_PATTERN_MORE_PIECES_BB,
           "B", wxDefaultPosition, wxDefaultSize, 0 );
        more_pieces_bb->SetValue( parm->more_pieces_bb );
        more_pieces_bn = new wxCheckBox( this, ID_PATTERN_MORE_PIECES_BN,
           "N", wxDefaultPosition, wxDefaultSize, 0 );
        more_pieces_bn->SetValue( parm->more_pieces_bn );
        more_pieces_bp = new wxCheckBox( this, ID_PATTERN_MORE_PIECES_BP,
           "P", wxDefaultPosition, wxDefaultSize, 0 );
        more_pieces_bp->SetValue( parm->more_pieces_bp );
        more_pieces_horiz2->Add( more_pieces_bq, 0,
            wxALIGN_CENTER_VERTICAL|wxLEFT, 15);
        more_pieces_horiz2->Add( more_pieces_br, 0,
            wxALIGN_CENTER_VERTICAL,0);
        more_pieces_horiz2->Add( more_pieces_bb, 0,
            wxALIGN_CENTER_VERTICAL,0);
        more_pieces_horiz2->Add( more_pieces_bn, 0,
            wxALIGN_CENTER_VERTICAL,0);
        more_pieces_horiz2->Add( more_pieces_bp, 0,
            wxALIGN_CENTER_VERTICAL,0);
        lockdown_vert->Add( lockdown_text,  0, wxALIGN_LEFT |wxLEFT|wxTOP, 12 );
        wxBoxSizer* vert_extra  = new wxBoxSizer(wxVERTICAL);
        vert_extra->Add(more_pieces_vert,  1, wxALIGN_LEFT|wxGROW | (wxALL/* & ~wxLEFT */), 5);
        vert_extra->Add(lockdown_vert,  1, wxALIGN_LEFT|wxGROW | (wxALL/* & ~wxLEFT */), 5);
        horiz_extra->Add( vert_extra,  0, wxALIGN_LEFT |wxLEFT|wxRIGHT|wxTOP, 0 );
    }
    if( b_white )
        horiz_extra->Add(who_box,       1, wxALIGN_LEFT|wxGROW | (wxALL/* & ~wxTOP  */), 5);
    horiz_extra->Add(castling_box,  1, wxALIGN_LEFT|wxGROW | (wxALL/* & ~wxLEFT */), 5);
    box_sizer->Add( horiz_board,  0, wxALIGN_LEFT |wxALL, 5 );
    box_sizer->Add( horiz_extra,  0, wxALIGN_LEFT |wxLEFT|wxRIGHT|wxTOP, 5 );
    if( b_piece_map )
        ModifyLockdown( -1 );
    ok_button->SetFocus();
}

// Sets the help text for the dialog controls
void PatternDialog::SetDialogHelp()
{
    wxString initial_help = "Set the standard chess initial pattern";
    FindWindow(ID_PATTERN_RESET)->SetHelpText(initial_help);
    FindWindow(ID_PATTERN_RESET)->SetToolTip(initial_help);
    wxString clear_help = "Clear the board";
    FindWindow(ID_PATTERN_CLEAR)->SetHelpText(clear_help);
    FindWindow(ID_PATTERN_CLEAR)->SetToolTip(clear_help);
    wxString current_help = "Copy from the current main board pattern";
    FindWindow(ID_PATTERN_CURRENT)->SetHelpText(current_help);
    FindWindow(ID_PATTERN_CURRENT)->SetToolTip(current_help);
    wxString help1 = "Set to include mirror images of this pattern in search";
    FindWindow(ID_PATTERN_INC_REFLECTION)->SetHelpText(help1);
    FindWindow(ID_PATTERN_INC_REFLECTION)->SetToolTip(help1);
    wxString help2 = gbl_spelling_us?"Set to include reversed colors form of this pattern in search"
                                    :"Set to include reversed colours form of this pattern in search";
    FindWindow(ID_PATTERN_INC_REVERSE)->SetHelpText(help2);
    FindWindow(ID_PATTERN_INC_REVERSE)->SetToolTip(help2);
    wxString help3 = gbl_spelling_us?"Set to forbid extra pieces - setting this makes pattern search the same as position search (with extra options - eg reversed colors)"
                                    :"Set to forbid extra pieces - setting this makes pattern search the same as position search (with extra options - eg reversed colours)";
    if( b_dont_allow_more )
    {
        FindWindow(ID_PATTERN_DONT_ALLOW_MORE)->SetHelpText(help3);
        FindWindow(ID_PATTERN_DONT_ALLOW_MORE)->SetToolTip(help3);
    }
    if( b_pawns )
    {
        wxString help4 = "Set to specify that games only match if pawns are on the same files as the search pattern";
        FindWindow(ID_PATTERN_PAWNS_SAME_FILES)->SetHelpText(help4);
        FindWindow(ID_PATTERN_PAWNS_SAME_FILES)->SetToolTip(help4);
    }
    if( b_bishops )
    {
        wxString help5 = "Set this if you want light squared and dark squared bishops to be distinct pieces for search purposes";
        FindWindow(ID_PATTERN_BISHOPS_SAME_COLOUR)->SetHelpText(help5);
        FindWindow(ID_PATTERN_BISHOPS_SAME_COLOUR)->SetToolTip(help5);
    }
    if( b_white )
    {
        wxString white_help = "Set to find positions with white to move";
        FindWindow(ID_PATTERN_WHITE_TO_MOVE)->SetHelpText(white_help);
        FindWindow(ID_PATTERN_WHITE_TO_MOVE)->SetToolTip(white_help);
        wxString black_help = "Set to find positions with black to move";
        FindWindow(ID_PATTERN_BLACK_TO_MOVE)->SetHelpText(black_help);
        FindWindow(ID_PATTERN_BLACK_TO_MOVE)->SetToolTip(black_help);
        wxString either_help = "Set if you don't care which side is to move";
        FindWindow(ID_PATTERN_EITHER_TO_MOVE)->SetHelpText(either_help);
        FindWindow(ID_PATTERN_EITHER_TO_MOVE)->SetToolTip(either_help);
    }
    if( b_ply )
    {
        wxString move_count_help = "Games only match if the specified material balance persists for at least this many half moves";
        FindWindow(ID_PATTERN_MOVE_COUNT)->SetHelpText(move_count_help);
        FindWindow(ID_PATTERN_MOVE_COUNT)->SetToolTip(move_count_help);
    }
}

// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_PATTERN_RESET
void PatternDialog::OnResetClick( wxCommandEvent& WXUNUSED(event) )
{
    thc::ChessPosition tmp;
    parm->cp = tmp;
    bsc->Set( parm->cp );
    memset( parm->lockdown, 0, 64 );
    bsc->Set( parm->cp, parm->lockdown );
    if( b_piece_map )
        ModifyLockdown( -1 );
}

// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_PATTERN_CURRENT
void PatternDialog::OnCurrentClick( wxCommandEvent& WXUNUSED(event) )
{
    parm->cp = objs.gl->gd.master_position;
    bsc->Set( parm->cp );
    memset( parm->lockdown, 0, 64 );
    bsc->Set( parm->cp, parm->lockdown );
    if( b_piece_map )
    {
        cprintf( "ModifyLockdown(-1);\n" );
        ModifyLockdown( -1 );
    }
}

// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_PATTERN_CLEAR
void PatternDialog::OnClearClick( wxCommandEvent& WXUNUSED(event) )
{
    thc::ChessPosition tmp;
    parm->cp = tmp;
    memset( parm->cp.squares, ' ', 64 );
    memset( parm->lockdown, 0, 64 );
    bsc->Set( parm->cp, parm->lockdown );
    if( b_piece_map )
    {
        cprintf( "ModifyLockdown(-1);\n" );
        ModifyLockdown( -1 );
    }
}

// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_HELP
void PatternDialog::OnHelpClick( wxCommandEvent& WXUNUSED(event) )
{
    // Normally we would wish to display proper online help.
    // For this example, we're just using a message box.
    /*
    wxGetApp().GetHelpController().DisplaySection(wxT("Personal record dialog"));
     */

    wxString helpText(
      parm->material_balance ?
      "\nUse this panel to search the database for games where a specified material balance occurs at some point. "
      "Put the pieces you want on the board, and the search will locate games where only those pieces remained "
      "on the board at a certain point in the game."
      "\n\n"
      "To make the search (much) more flexible you can refine the search in various ways. "
      "For example, if you put a dark squared bishop on the board, you can insist the search only finds positions with a dark squared bishop (but by "
      "default any bishop will do)."
     :
      "\nUse this panel to search the database for games where a specified pattern (arrangement of some pieces) occurs at some point. "
      "Put the pieces you want on the board, and the search will locate games where those pieces occupied those squares. "
      "The material balance search is also available, and is more flexible (but also more complicated). To make the material balance "
      "search more like the pattern search, lock down the position of pieces you care about with right clicks."
     );
    wxMessageBox(helpText,
      wxT("Pattern Dialog Help"),
      wxOK|wxICON_INFORMATION, this);
}

// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
void PatternDialog::OnOkClick( wxCommandEvent& WXUNUSED(event) )
{
    bool err=false;
    if( bsc )
    {
        parm->cp = bsc->cp;
        memcpy( parm->lockdown, bsc->lockdown, sizeof(parm->lockdown) );
        parm->include_reverse_colours       = inc_reverse->GetValue();
        parm->include_reflections           = inc_reflection->GetValue();
        if( b_piece_map )
        {
            parm->more_pieces_wq = more_pieces_wq->GetValue();
            parm->more_pieces_wr = more_pieces_wr->GetValue();
            parm->more_pieces_wb = more_pieces_wb->GetValue();
            parm->more_pieces_wn = more_pieces_wn->GetValue();
            parm->more_pieces_wp = more_pieces_wp->GetValue();
            parm->more_pieces_bq = more_pieces_bq->GetValue();
            parm->more_pieces_br = more_pieces_br->GetValue();
            parm->more_pieces_bb = more_pieces_bb->GetValue();
            parm->more_pieces_bn = more_pieces_bn->GetValue();
            parm->more_pieces_bp = more_pieces_bp->GetValue();
        }
        if( b_dont_allow_more )
            parm->dont_allow_more_pieces             = dont_allow_more->GetValue();
        if( b_pawns )
            parm->pawns_must_be_on_same_files   = pawns_same_files->GetValue();
        if( b_bishops )
            parm->bishops_must_be_same_colour   = bishops_same_colour->GetValue();
        if( b_ply )
            parm->number_of_ply                 = move_count_ctrl->GetValue();
        if( b_white )
        {
            parm->white_to_move                 = white_to_move->GetValue();
            parm->either_to_move                = either_to_move->GetValue();
        }
        TransferDataToWindow();
    }
    if( !err )
        AcceptAndClose();
}

// Later - learn how to do this by sending an event to parent instead
void DatabaseSearchVeryUglyTemporaryCallback( int offset )
{
    PatternDialog *ptr = singleton;
    if( ptr )
        ptr->ModifyLockdown( offset );
}

void PatternDialog::ModifyLockdown( int offset )
{
    int count=0;
    if( offset == -1 )
        offset = offset_persist;
    for( int i=0; i<64; i++ )
    {
        if( bsc->lockdown[i] )
            count++;
    }
    char buf[1000];
    if( count == 0 )
        sprintf( buf, "There are no locked down squares" );
    else
    {
        if( offset<0 || offset>63 || !bsc->lockdown[offset] )
        {
            for( int i=0; i<64; i++ )
            {
                if( bsc->lockdown[i] )
                {
                    offset = i;
                }
            }
        }
        int file = offset&7;
        int rank = 7 - ((offset>>3)&7);
        char c = bsc->cp.squares[offset];
        const char *s="empty";
        switch( c )
        {
            case 'K': s = "a white king";     break;
            case 'Q': s = "a white queen";    break;
            case 'R': s = "a white rook";     break;
            case 'B': s = "a white bishop";   break;
            case 'N': s = "a white knight";   break;
            case 'P': s = "a white pawn";     break;
            case 'k': s = "a black king";     break;
            case 'q': s = "a black queen";    break;
            case 'r': s = "a black rook";     break;
            case 'b': s = "a black bishop";   break;
            case 'n': s = "a black knight";   break;
            case 'p': s = "a black pawn";     break;
        }
        char buf2[200];
        buf2[0] = '\0';
        if( count-1 > 0 )
            sprintf( buf2, " (and %d other%s...)", count-1, (count-1)>1?"s":"" );
        sprintf( buf, "There %s %d locked down square%s\n %c%c must be %s%s", count>1?"are":"is", count, count>1?"s":"", 'a'+file, '1'+rank, s, buf2 );
    }
    offset_persist = offset;
    lockdown_text->SetLabel( wxString(buf) );
}