text:
/*! drawbit v1.0.0 2013-10-05 */
/*globals console:false */

(function (db) {
	'use strict';

	/**
	 * Represents an Alphabit
	 * @constructor
	 * @param  {Enum} options  - Alphabit options
	 * @return {Object}          Exposed methods
	 */
	db.Alphabit = function Alphabit(options) {

		/**
		 * Layer Canvas Element
		 * @type {HTMLCanvasElement}
		 */
		var canvas,

		/**
		 * Canvas Context
		 * @type {CanvasRenderingContext2D}
		 */
			context,

		/**
		 * Source image
		 * @type {HTMLImage}
		 */
			source,

		/**
		 * Processed letters
		 * @type {Object}
		 */
			letters = {},

		/**
		 * Default Settings
		 * @type {Enum}
		 */
			SETTINGS = {
				padding: 1,
				width: 7,
				height: 7,
				color: '0,0,0,255',
				image: 'img/alphabet.png',
				onComplete: function(){}
			},

		/**
		 * Available letters
		 * @type {Array}
		 */
			LETTERS = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'];

		/**
		 * @construcs db.Alphabit
		 */
		(function() {
			Object.extend(SETTINGS, options);

			canvas = document.createElement('canvas');

			context = canvas.getContext('2d');

			createSpecialCharacter('space');
			createSpecialCharacter('delete');

			addEventListeners();
		}());

		/**
		 * Attach event handlers
		 */
		function addEventListeners() {
			source = document.createElement('img');
			source.addEventListener('load', source_loadHandler);
			source.addEventListener('error', source_errorHandler);
			source.src = SETTINGS.image;
		}

		/**
		 * Add special keys (scape, delete)
		 * @param  {String} key - The special char
		 */
		function createSpecialCharacter(key) {
			var i = 0,
				j = 0,
				colCollection = [],
				rowCollection = [],
				flag = 0;

			for ( ; i < SETTINGS.width; i++ ) {
				colCollection = [];
				for ( j = 0; j < SETTINGS.height; j++ ) {
					colCollection.push(flag);
				}
				rowCollection.push(colCollection);
			}

			letters[key] = rowCollection;
		}

		/**
		 * Process alphabet image
		 */
		function process() {
			var i = 0,
				row = 0,
				col = 0,
				numLetter = 0,
				result = [],
				rowCollection = [],
				dataLength,
				flag = 0;

			canvas.width = source.width;
			canvas.height = source.height;
			// Draw image into canvas
			context.drawImage(source, 0, 0, source.width, source.height);

			var imageData = context.getImageData(0, 0, canvas.width, canvas.height).data;
			dataLength = imageData.length;

			for ( ; i < dataLength; i+=4 ) {
				//	rgba
				flag = ([imageData[i], imageData[i+1], imageData[i+2], imageData[i+3]].toString() === SETTINGS.color) ? 1 : 0;

				//	next col
				rowCollection.push(flag);
				col++;

				//	next row
				if (col % SETTINGS.width === 0) {
					result.push(rowCollection);
					rowCollection = [];
					row++;

					//	next letter
					if (row % (SETTINGS.height+SETTINGS.padding) === 0) {
						letters[LETTERS[numLetter]] = result;
						result = [];
						numLetter++;
					}
				}
			}

			if (typeof SETTINGS.onComplete === 'function') {
				SETTINGS.onComplete();
			}
		}

		/**
		 * Image loaded
		 * @event
		 */
		function source_loadHandler(e) {
			process();
		}

		/**
		 * Image error
		 * @event
		 */
		function source_errorHandler(e) {
			console.log("Error loading alphabet.png");
		}

	//	public methods and properties
		return letters;
	};

}(window.db = window.db || {}));
/*globals console:false */

(function (db) {
	'use strict';

	/**
	 * Represents the configuration
	 * @constructor
	 * @return {Object} Exposed methods
	 */
	db.Config = function(value) {

		/**
		 * Configuration Data
		 * @type {db.gui.Layers}
		 */
		var data;

		/**
		 * @construcs db.Config
		 */
		(function () {
			parseConfig();
		}());

		/**
		 * Parse config JSON file
		 */
		function parseConfig() {
			data = value;

			console.log("data: ", data);
		}

		//	public methods and properties
		return {

		};
	};

}(window.db = window.db || {}));
(function (db) {
	'use strict';

	/**
	 * Represents an Effect
	 * @constructor
	 * @param  {db.Layer} target  - The target Layer
	 * @param  {Enum} options  - effect options
	 * @return {Object}	Exposed methods
	 */
	db.Effect = function(target, options, _time) {

		/**
		 * Tile Identifier
		 * @type {String}
		 */
		var id = 'tile',

		/**
		 * Frame interval
		 */
			requestID,

		/**
		 * Number of tiles finished
		 * @type {Number}
		 */
			completedTiles = 0,

		/**
		 * Tiles to be processed
		 * @type {Array}
		 */
			tiles = [],

		/**
		 * Checks if the all tiles has been completed
		 * @type {Number}
		 */
			isCompleted,

		/**
		 * Transition time
		 * @type {Number} of miliseconds
		 */
			time = _time || 1000;

		/**
		 * @construcs db.Effect
		 */
		(function () {

			var numTiles = target.tiles.length;

			while (numTiles-- > 0) {
				tiles.push(new db.effects[options.type](target.tiles[numTiles], target.context, options, time));
			}

			if (options.delay) {
				setTimeout(start, options.delay);
			} else {
				start();
			}

		}());

		/**
		 * Start transition
		 */
		function start() {
			requestID = window.requestAnimationFrame(render);
		}

		/**
		 * Stop transition
		 * @return {[type]} [description]
		 */
		function stop() {
			requestID = window.cancelAnimationFrame(requestID);
		}

		/**
		 * Update / frame loop
		 */
		function render() {
			next();
			if (requestID && !isCompleted) {
				window.requestAnimationFrame(render);
			}
		}

		/**
		 * Render next frame
		 */
		function next() {
			var numTiles = tiles.length;

			if (completedTiles >= numTiles) {
				isCompleted = true;
			}
			while (numTiles-- > 0) {
				if (tiles[numTiles] && !tiles[numTiles].complete()) {

					tiles[numTiles].update();
					if (tiles[numTiles] && tiles[numTiles].complete()) {
						completedTiles++;
					}
				}
			}

		}

		//	public methods and properties
		return {
			id: id,
			next: next
		};
	};

}(window.db = window.db || {}));
(function (db) {
	'use strict';

	/**
	 * @namespace Effects
	 */
	db.effects = db.effects || {};

	/**
	 * Represents a Fade Effect
	 * @constructor
	 * @param  {db.Tile} Context  - The tile
	 * @param  {CanvasRenderingContext2D} Context  - The tile context (canvas)
	 * @param  {Enum} options  - Tile options
	 * @param  {Number} time  - Transition time
	 *
	 * @return {Object}	Exposed methods
	 */
	db.effects.Fade = function(tile, context, options, time) {

		/**
		 * Frame duration
		 * @type {Float}
		 */
		var	stepSize = 600 / time,

		/**
		 * Transition completed
		 * @type {Boolean}
		 */
			isCompleted,

		/**
		 * Current alpha
		 * @type {Number}
		 */
			alpha = 10;

		/**
		 * @construcs db.Tile
		 */
		(function () {
			reset();
			draw();
		}());

		/**
		 * Reset effect
		 * @private
		 */
		function reset() {
			isCompleted = false;
			alpha = 10;
		}

		/**
		 * Draws a frame
		 */
		function draw() {
			context.clearRect(tile.x, tile.y, tile.width, tile.height);

			context.fillStyle = 'rgba(' + tile.color + ',' + alpha/10 + ')';
			context.fillRect(tile.x, tile.y, tile.width, tile.height);

			if (alpha <= 0) {
				isCompleted = true;
			}

			alpha -= stepSize;
		}

		/**
		 * Effect already completed?
		 * @return {Boolean}
		 */
		function complete() {
			return isCompleted;
		}

		//	public methods and properties
		return {
			update: draw,
			complete: complete
		};
	};

}(window.db = window.db || {}));
(function (db) {
	'use strict';

	/**
	 * @namespace Effects
	 */
	db.effects = db.effects || {};

	/**
	 * Represents a Flip Effect
	 * @constructor
	 * @param  {db.Tile} Context  - The tile
	 * @param  {CanvasRenderingContext2D} Context  - The tile context (canvas)
	 * @param  {Enum} options  - Tile options
	 * @param  {Number} time  - Transition time
	 *
	 * @return {Object} Exposed methods
	 */
	db.effects.Flip = function(tile, context, options, time) {

		/**
		 * Delta
		 * @type {Number}
		 */
		var	delta = 0,

		/**
		 * Previous bounds
		 * @type {Object}
		 */
			initialBounds = {},

		/**
		 * Current bounds
		 * @type {Object}
		 */
			bounds = {},

		/**
		 * Transition Speed
		 * @type {Number}
		 */
			stepSize = 0.5,

		/**
		 * Tile reachs the half transition
		 * @type {Boolean}
		 */
			isFlipped,

		/**
		 * Tile transition completed
		 * @type {Boolean}
		 */
			isCompleted,

		/**
		 * Current tile color
		 * @type {String}
		 */
			currentColor = tile.color,

		/**
		 * flipped
		 * @type {Boolean}
		 */
			isBack = false
		;

		/**
		 * @construcs db.Tile
		 */
		(function () {
			reset();
			draw();

			initialBounds = JSON.stringify(bounds);
		}());

		/**
		 * Reset effect
		 */
		function reset() {
			bounds = {
				t: 0,
				b: 0,
				tl: 0,
				bl: 0,
				tr: 0,
				br: 0
			};

			context.fillStyle = isBack ? options.back : tile.color;

			delta = 0;
			isFlipped = false;
			isCompleted = false;
		}

		/**
		 * Draws a frame
		 * @type {Function} fnHalf - Flip ocurs
		 */
		function draw(fnHalf) {

			context.clearRect(tile.x, tile.y, tile.width, tile.height);
			//	halfway
			if (!isFlipped && bounds.b < bounds.t) {
				if (currentColor === tile.color) {
					currentColor = options.back;
				} else {
					currentColor = tile.color;
				}
				context.fillStyle = currentColor;
				isFlipped = true;
				if (typeof fnHalf === 'function') {
					fnHalf();
				}
			}

			if (!isFlipped) {
				bounds.t = tile.y + delta;
				bounds.b = tile.y + tile.height - delta;
				bounds.tl = tile.x;
				bounds.bl = tile.x + delta;
				bounds.tr = tile.x + tile.width;
				bounds.br = tile.x + tile.width - delta;
			} else {
				bounds.t = tile.y + tile.height - delta;
				bounds.b = tile.y + delta;
				bounds.tl = tile.x + tile.width - delta;
				bounds.bl = tile.x;
				bounds.br = tile.x + tile.width;
				bounds.tr = tile.x + delta;
			}

			context.beginPath();

			context.moveTo(bounds.tl, bounds.t);
			//	left edge
			context.lineTo(bounds.bl, bounds.b);
			//	bottom edge
			context.lineTo(bounds.br, bounds.b);
			//	right edge
			context.lineTo(bounds.tr, bounds.t);
			//	top edge
			context.closePath();
			context.fill();

			if (isFlipped && initialBounds === JSON.stringify(bounds)) {
				isCompleted = true;
				isBack = true;
			}

			delta = delta + stepSize;
		}

		/**
		 * Effect already completed?
		 * @return {Boolean}
		 */
		function complete() {
			return isCompleted;
		}

		//	public methods and properties
		return {
			update: draw,
			complete: complete
		};
	};

}(window.db = window.db || {}));
(function (db) {
	'use strict';

	/**
	 * Represents a canvas grid
	 * @constructor
	 * @param  {String} selector - The HTML selector
	 * @param  {Enum} options  - Grid options
	 * @return {Object}          Exposed methods
	 */
	db.Grid = function(selector, options) {

		/**
		 * Grid HTML Element
		 * @type {HTMLElement}
		 */
		var element,

		/**
		 * Grid Layers
		 * @type {Array}
		 */
			layers = [],

		/**
		 * Grid Width
		 * @type {Number}
		 */
			width = 300,

		/**
		 * Grid Height
		 * @type {Number}
		 */
			height = 300;

		/**
		 * @construcs db.Grid
		 */
		(function () {
			element = document.querySelector(selector);
		}());

		/**
		 * Creates a new layer
		 */
		function addLayer() {
			var layer = new db.Layer('layer_' + layers.length, width, height);
			element.appendChild(layer.element);

			layers.push(layer);

			db.Tools.layer = layer.id;
		}

		/**
		 * Removes a selected layer
		 * @return {[type]} [description]
		 */
		function removeLayer() {

		}

		/**
		 * Gets a selected layer
		 * @param  {String} id - The layer name
		 * @return {db.Layer}
		 */
		function getLayer(id) {
			var layer,
				i = 0,
				numLayers = layers.length;

			while(numLayers-- > 0) {
				if (layers[numLayers].id === id) {
					layer = layers[numLayers];
					break;
				}
			}

			return layer;
		}

		//	public methods and properties
		return {
			element: element,
			addLayer: addLayer,
			getLayer: getLayer,
			width: width,
			height: height
		};
	};

}(window.db = window.db || {}));
(function (db) {
	'use strict';

	/**
	 * @namespace Graphical User Interface
	 */
	db.gui = db.gui || {};

	/**
	 * Represents the Graphical User Interface
	 * @constructor
	 * @return {Object}	Exposed methods
	 */
	db.gui.App = function() {

		/**
		 * App layers
		 * @type {db.gui.Layers}
		 */
		var layers;

		/**
		 * @construcs db.gui.App
		 */
		(function () {
			layers = new db.gui.Layers('.db-layers');
		}());

		//	public methods and properties
		return {
			layers: layers
		};
	};

}(window.db = window.db || {}));
/*globals TouchEvent:false */

(function (db) {
	'use strict';

	/**
	 * @namespace Graphical User Interface
	 */
	db.gui = db.gui || {};

	/**
	 * Represents the Layer IDE
	 * @constructor
	 * @param  {String} selector  - The layers DOM selector
	 * @return {Object} Exposed methods
	 */
	db.gui.Layers = function(selector) {

		/**
		 * Layer HTML Element
		 * @type {HTMLElement}
		 */
		var element,

		/**
		 * Current layer
		 * @type {HTMLElement}
		 */
			current,
		/**
		 * Layers collection
		 * @type {Array}
		 */
			items = []
		;

		/**
		 * @construcs db.Layer
		 */
		(function () {
			element = document.querySelector(selector + ' ul');
			current = document.querySelector('h3 strong');
			current.innerHTML = db.Tools.layer;
			items = element.querySelectorAll('li');
		}());

		/**
		 * Adds a new layer
		 * @param {String} label - The layer label
		 */
		function add(label) {
			var hyperlink = document.createElement('a'),
				listItem = document.createElement('li');

			hyperlink.href = '#' + label;
			hyperlink.innerHTML = label;
			listItem.appendChild(hyperlink);

			element.appendChild(listItem);

			update();
		}

		/**
		 * Updates DOM
		 * @private
		 */
		function update() {
			items = element.querySelectorAll('li a');

			var numItems = items.length;

			while (numItems-- > 0) {
				items[numItems].removeEventListener(TouchEvent.CLICK, item_clickHandler);
				items[numItems].addEventListener(TouchEvent.CLICK, item_clickHandler);
			}

			current.innerHTML = db.Tools.layer;
		}

		function item_clickHandler(e) {
			e.preventDefault();

			db.Tools.layer = e.currentTarget.getAttribute('href').replace('#','');

			current.innerHTML = db.Tools.layer;
		}

		//	public methods and properties
		return {
			add: add
		};
	};

}(window.db = window.db || {}));
(function (db) {
	'use strict';

	/**
	 * Represents a Grid Layer
	 * @constructor
	 * @param  {Enum} options  - Tile options
	 * @return {Object}          Exposed methods
	 */
	db.Layer = function(id, width, height) {

		/**
		 * Layer Canvas Element
		 * @type {HTMLCanvasElement}
		 */
		var canvas,

		/**
		 * Canvas Context
		 * @type {CanvasRenderingContext2D}
		 */
			context,
		/**
		 * Tiles collection
		 * @type {Array}
		 */
			tiles = [],

		/**
		 * Current horizontal position
		 * @type {Number}
		 */
			currentX = 0,

		/**
		 * Current vertical position
		 * @type {Number}
		 */
			currentY = 0;

		/**
		 * @construcs db.Layer
		 */
		(function () {
			canvas = document.createElement('canvas');
			canvas.id = id;
			canvas.width = width;
			canvas.height = height;

			context = canvas.getContext('2d');
		}());

		/**
		 * Checks if the ID exists into the tiles collection
		 * @param  {String} id - The tile identifier
		 * @return {Number}    The tile index
		 *
		 * @private
		 */
		function tileExists(id) {
			var tile,
				i = 0,
				numItems = tiles.length;

			while(numItems-- > 0) {
				if (tiles[numItems] && tiles[numItems].id === id) {
					tile = numItems;
					break;
				}
			}

			return tile;
		}

		/**
		 * Draws a tile into the selected position (if it's available)
		 * @param  {Number} x Horizontal position
		 * @param  {Number} y Vertical position
		 */
		function draw(x, y) {
			var exists = tileExists('tile_' + x + '_' + y);

			if (!isNaN(exists)) {
				return;
			}

			var tile = new db.Tile(context, {
				x: x,
				y: y,
				color: db.Tools.color
			});

			tiles.push(tile);
		}

		/**
		 * Draws a set of tiles
		 * @param  {Array} path - The path as a Multi-dimensional array
		 */
		function drawPath(path) {
			var rows = path.length,
				cols = path[0] ? path[0].length : 0,
				currentPos,
				i = 0,
				j = 0,
				numFrame;

			//	loop into rows
			for ( ; i < rows; i++) {
				//	loop into columns
				for (j = 0 ; j < cols; j++) {
					currentPos = path[i][j];
					if (currentPos === 1) {
						//	round num
						numFrame = (0.5 + Math.random()*15) << 0;
						draw(currentX + j, currentY + i);
					}
				}
			}

			currentX += cols;

			//	start new row
			if (currentX + cols > 30) {
				currentY += rows;
				currentX = 0;
			}
		}

		/**
		 * Erase a tile into the selected position
		 * @param  {Number} x Horizontal position
		 * @param  {Number} y Vertical position
		 */
		function erase(x, y) {
			var exists = tileExists('tile_' + x + '_' + y);

			if (typeof exists === 'undefined') {
				return;
			}

			//	clear area
			tiles[exists].dispose();
			//	delete tile
			tiles.splice(exists, 1);
		}

		//	public methods and properties
		return {
			id: id,
			element: canvas,
			context: context,
			draw: draw,
			erase: erase,
			drawPath: drawPath,
			tiles: tiles
		};
	};

}(window.db = window.db || {}));
(function (db) {
	'use strict';

	/**
	 * Represents a Tile
	 * @constructor
	 * @param  {CanvasRenderingContext2D} Context  - The tile context (canvas)
	 * @param  {Enum} options  - Tile options
	 * @return {Object}          Exposed methods
	 */
	db.Tile = function(context, options) {

		/**
		 * Tile Identifier
		 * @type {String}
		 */
		var id = 'tile',

		/**
		 * Tile Width
		 * @type {Number}
		 */
			width = 10,

		/**
		 * Tile height
		 * @type {Number}
		 */
			height = 10,

		/**
		 * Horizontal position
		 * @type {Number}
		 */
			x = 0,

		/**
		 * Vertical position
		 * @type {Number}
		 */
			y = 0,

		/**
		 * Tile padding
		 * @type {Number}
		 */
			padding = 1,

		/**
		 * Background color
		 * @type {String}
		 */
			color = options.color || '200,200,200',

		/**
		 * Background alpha
		 * @type {Float}
		 */
			opacity = 1.0
		;

		/**
		 * @construcs db.Tile
		 */
		(function () {
			id = options.id || 'tile_' + options.x + '_' + options.y;
			x = (options.x * width) + (padding * options.x);
			y = (options.y * height) + (padding * options.y);

			context.fillStyle = 'rgba(' + color + ',' + opacity + ')';
			context.fillRect(x,y,width,height);
		}());

		/**
		 * Clear tile
		 */
		function dispose() {
			context.clearRect(x,y,width,height);
		}

		//	public methods and properties
		return {
			id: id,
			color: color,
			context: context,
			width: width,
			height: height,
			x: x,
			y: y,
			dispose: dispose
		};
	};

}(window.db = window.db || {}));
(function (db) {
	'use strict';

	/**
	 * Represents the Toolbar Persistence Layer
	 * @constructor
	 * @return {Object} Exposed methods
	 */
	db.Tools = (function() {

		/**
		 * Background color
		 * @type {String}
		 */
		var color = '200,200,200',

		/**
		 * Background alpha
		 * @type {Float}
		 */
			opacity = 1.0,

		/**
		 * Eraser enabled?
		 * @type {Boolean}
		 */
			erase = false,

		/**
		 * Current layer
		 * @type {String}
		 */
			layer = 'layer_0'
		;

		/**
		 * @construcs db.Tools
		 */
		(function () {

		}());

		//	public methods and properties
		return {
			color: color,
			erase: erase,
			layer: layer
		};
	}());

}(window.db = window.db || {}));
function round(num) {
	return (0.5 + num) << 0;
}

/**
 * Mouse events mapper
 * @enum {Object.<String>}
 */
var TouchEvent = ('ontouchstart' in document.documentElement) ?
//	touch events
{
	START: 'touchstart',
	MOVE: 'touchmove',
	CLICK: 'touchend',
	END: 'touchend'
} :
//	desktop events
{
	START: 'mousedown',
	MOVE: 'mousemove',
	CLICK: 'click',
	END: 'mouseup'
};

//	handle events invoking directly a method inside the DOM Element
if (!Element.prototype.addEventListener) {
	Element.prototype.addEventListener = function(type, handler, useCapture) {
		if (this.attachEvent) {
			this.attachEvent('on' + type, handler);
		}
		return this;
	};
}

Object.extend = function(destination, source) {
	for (var property in source) {
		destination[property] = source[property];
	}
	return destination;
};


text:
package com.facebook.buck.jvm.kotlin;

import com.facebook.buck.jvm.java.CompileToJarStepFactory;
import com.facebook.buck.jvm.java.DefaultJavaLibrary;
import com.facebook.buck.model.BuildTarget;
import com.facebook.buck.model.Either;
import com.facebook.buck.rules.BuildRule;
import com.facebook.buck.rules.BuildRuleParams;
import com.facebook.buck.rules.SourcePath;
import com.facebook.buck.rules.SourcePathResolver;
import com.facebook.buck.rules.SourcePathRuleFinder;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedSet;

import java.nio.file.Path;
import java.util.Optional;
import java.util.Set;
import java.util.regex.Pattern;

public class DefaultKotlinLibrary extends DefaultJavaLibrary {

  public DefaultKotlinLibrary(
      BuildRuleParams params,
      final SourcePathResolver resolver,
      SourcePathRuleFinder ruleFinder,
      Set<? extends SourcePath> srcs,
      Set<? extends SourcePath> resources,
      Optional<Path> generatedSourceFolder,
      Optional<SourcePath> proguardConfig,
      ImmutableList<String> postprocessClassesCommands,
      ImmutableSortedSet<BuildRule> exportedDeps,
      ImmutableSortedSet<BuildRule> providedDeps,
      BuildTarget abiJar,
      ImmutableSortedSet<SourcePath> abiInputs,
      final boolean trackClassUsage,
      ImmutableSet<Either<SourcePath, Path>> additionalClasspathEntries,
      CompileToJarStepFactory compileStepFactory,
      Optional<Path> resourcesRoot,
      Optional<SourcePath> manifestFile,
      Optional<String> mavenCoords,
      ImmutableSortedSet<BuildTarget> tests,
      ImmutableSet<Pattern> classesToRemoveFromJar) {

    super(
        params,
        resolver,
        ruleFinder,
        srcs,
        resources,
        generatedSourceFolder,
        proguardConfig,
        postprocessClassesCommands,
        exportedDeps,
        providedDeps,
        abiJar,
        abiInputs,
        trackClassUsage,
        additionalClasspathEntries,
        compileStepFactory,
        resourcesRoot,
        manifestFile,
        mavenCoords,
        tests,
        classesToRemoveFromJar);
  }
}

redpajama_set_name: RedPajamaGithub


text:
/*
 *  Copyright (C) 1998, University of Adelaide, under its participation
 *  in the Advanced Computational Systems Cooperative Research Centre
 *  Agreement.
 *
 *  THIS SOFTWARE IS MADE AVAILABLE, AS IS, AND THE UNIVERSITY
 *  OF ADELAIDE DOES NOT MAKE ANY WARRANTY ABOUT THE SOFTWARE, ITS
 *  PERFORMANCE, ITS MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR
 *  USE, FREEDOM FROM ANY COMPUTER DISEASES OR ITS CONFORMITY TO ANY
 *  SPECIFICATION. THE ENTIRE RISK AS TO QUALITY AND PERFORMANCE OF
 *  THE SOFTWARE IS WITH THE USER.
 *
 *  Copyright of the software and supporting documentation is owned by the
 *  University of Adelaide, and free access is hereby granted as a license
 *  to use this software, copy this software and prepare derivative works
 *  based upon this software.  However, any distribution of this software
 *  source code or supporting documentation or derivative works (source
 *  code and supporting documentation) must include this copyright notice
 *  and acknowledge the University of Adelaide.
 *
 *
 *  Developed by: Distributed High Performance Computing (DHPC) Group
 *                Department of Computer Science
 *                The University of Adelaide
 *                South Australia 5005
 *                Tel +61 8 8303 4519, Fax +61 8 8303 4366
 *                http://dhpc.adelaide.edu.au
 *  Last Modified: 26 January 1999
 *
 *
 */

import jgfutil.*;

public class JGFMethodSequenceBench2 implements JGFSection1{

	  private static final int INITSIZE = 10000;
	  private static final int MAXSIZE = 1000000000;
	  private static final double TARGETTIME = 10.0;

  static int  k = 0;
  private int k0 = 0;
  private int k1 = 0,  k2 = 0,
  k3 =  0, k4 = 0, k5 = 0, k6 = 0, k7 = 0, k8 = 0,  k9 = 0, k10 = 0,
  k11 =0 , k12 = 0, k13 = 0, k14 = 0;
  public void JGFrun(){

    int i,size;
    double time;

    // Test non empty instance method (increments a variable)
    JGFInstrumentor.addTimer("Section1:Method:Other:Instance", "calls");
    time = 0.0;
    size = INITSIZE;
    MethodSeq_01 a1 = new MethodSeq_01();
//    MethodTester a1 = new MethodTester();
    while (time < TARGETTIME && size < MAXSIZE){
      JGFInstrumentor.resetTimer("Section1:Method:Other:Instance");
      JGFInstrumentor.startTimer("Section1:Method:Other:Instance");
      for (i=0; i<size; i++){
	a1.instance_method();
	a1.instance_method();
	a1.instance_method();
	a1.instance_method();
	a1.instance_method();
	a1.instance_method();
	a1.instance_method();
	a1.instance_method();
	a1.instance_method();
	a1.instance_method();
	a1.instance_method();
	a1.instance_method();
	a1.instance_method();
	a1.instance_method();
	a1.instance_method();
	a1.instance_method();
	a1.instance_method();
      }
      JGFInstrumentor.stopTimer("Section1:Method:Other:Instance");
      time = JGFInstrumentor.readTimer("Section1:Method:Other:Instance");
      JGFInstrumentor.addOpsToTimer("Section1:Method:Other:Instance", (double) 16*size);
      size *=2;
    }
    JGFInstrumentor.printperfTimer("Section1:Method:Other:Instance");

    // Test non empty instance method (increments a variable)
    JGFInstrumentor.addTimer("Section1:Method:Same:Instance2", "calls");
    MethodSeq_02 a2 = new MethodSeq_02();
    time = 0.0;
    size = INITSIZE;
    while (time < TARGETTIME && size < MAXSIZE){
      JGFInstrumentor.resetTimer("Section1:Method:Same:Instance2");
      JGFInstrumentor.startTimer("Section1:Method:Same:Instance2");
      for (i=0; i<size; i++){
    	  a2.instance_method();
    	  a2.instance_method();
    	  a2.instance_method();
    	  a2.instance_method();
    	  a2.instance_method();
    	  a2.instance_method();
    	  a2.instance_method();
    	  a2.instance_method();
    	  a2.instance_method();
    	  a2.instance_method();
    	  a2.instance_method();
    	  a2.instance_method();
    	  a2.instance_method();
    	  a2.instance_method();
    	  a2.instance_method();
    	  a2.instance_method();
    	  a2.instance_method();
      }
      JGFInstrumentor.stopTimer("Section1:Method:Same:Instance2");
      time = JGFInstrumentor.readTimer("Section1:Method:Same:Instance2");
      JGFInstrumentor.addOpsToTimer("Section1:Method:Same:Instance2", (double) 16*size);
      size *=2;
    }
    JGFInstrumentor.printperfTimer("Section1:Method:Same:Instance2");

    // Test non empty instance method (increments a variable)
    JGFInstrumentor.addTimer("Section1:Method:Same:Instance3", "calls");

    MethodSeq_03 a3 = new MethodSeq_03();
    time = 0.0;
    size = INITSIZE;
    while (time < TARGETTIME && size < MAXSIZE){
      JGFInstrumentor.resetTimer("Section1:Method:Same:Instance3");
      JGFInstrumentor.startTimer("Section1:Method:Same:Instance3");
      for (i=0; i<size; i++){
    	  a3.instance_method();
    	  a3.instance_method();
    	  a3.instance_method();
    	  a3.instance_method();
    	  a3.instance_method();
    	  a3.instance_method();
    	  a3.instance_method();
    	  a3.instance_method();
    	  a3.instance_method();
    	  a3.instance_method();
    	  a3.instance_method();
    	  a3.instance_method();
    	  a3.instance_method();
    	  a3.instance_method();
    	  a3.instance_method();
    	  a3.instance_method();
    	  a3.instance_method();
      }
      JGFInstrumentor.stopTimer("Section1:Method:Same:Instance3");
      time = JGFInstrumentor.readTimer("Section1:Method:Same:Instance3");
      JGFInstrumentor.addOpsToTimer("Section1:Method:Same:Instance3", (double) 16*size);
      size *=2;
    }
    JGFInstrumentor.printperfTimer("Section1:Method:Same:Instance3");

    // Test non empty instance method (increments a variable)
    JGFInstrumentor.addTimer("Section1:Method:Same:Instance4", "calls");
    time = 0.0;
    size = INITSIZE;
    MethodSeq_04 a4 = new MethodSeq_04();
    while (time < TARGETTIME && size < MAXSIZE){
      JGFInstrumentor.resetTimer("Section1:Method:Same:Instance4");
      JGFInstrumentor.startTimer("Section1:Method:Same:Instance4");
      for (i=0; i<size; i++){
	a4.instance_method();
	a4.instance_method();
	a4.instance_method();
	a4.instance_method();
	a4.instance_method();
	a4.instance_method();
	a4.instance_method();
	a4.instance_method();
	a4.instance_method();
	a4.instance_method();
	a4.instance_method();
	a4.instance_method();
	a4.instance_method();
	a4.instance_method();
	a4.instance_method();
	a4.instance_method();

      }
      JGFInstrumentor.stopTimer("Section1:Method:Same:Instance4");
      time = JGFInstrumentor.readTimer("Section1:Method:Same:Instance4");
      JGFInstrumentor.addOpsToTimer("Section1:Method:Same:Instance4", (double) 16*size);
      size *=2;
    }
    JGFInstrumentor.printperfTimer("Section1:Method:Same:Instance4");

    // Test non empty instance method (increments a variable)
    MethodSeq_05 a5 = new MethodSeq_05();
    JGFInstrumentor.addTimer("Section1:Method:Same:Instance5", "calls");
    time = 0.0;
    size = INITSIZE;
    while (time < TARGETTIME && size < MAXSIZE){
      JGFInstrumentor.resetTimer("Section1:Method:Same:Instance5");
      JGFInstrumentor.startTimer("Section1:Method:Same:Instance5");
      for (i=0; i<size; i++){
	a5.instance_method();
	a5.instance_method();
	a5.instance_method();
	a5.instance_method();
	a5.instance_method();
	a5.instance_method();
	a5.instance_method();
	a5.instance_method();
	a5.instance_method();
	a5.instance_method();
	a5.instance_method();
	a5.instance_method();
	a5.instance_method();
	a5.instance_method();
	a5.instance_method();
	a5.instance_method();

      }
      JGFInstrumentor.stopTimer("Section1:Method:Same:Instance5");
      time = JGFInstrumentor.readTimer("Section1:Method:Same:Instance5");
      JGFInstrumentor.addOpsToTimer("Section1:Method:Same:Instance5", (double) 16*size);
      size *=2;
    }
    JGFInstrumentor.printperfTimer("Section1:Method:Same:Instance5");

//Test non empty instance method (increments a variable)
    MethodSeq_06 a6 = new MethodSeq_06();
  JGFInstrumentor.addTimer("Section1:Method:Same:Instance6", "calls");
  time = 0.0;
  size = INITSIZE;
  while (time < TARGETTIME && size < MAXSIZE){
    JGFInstrumentor.resetTimer("Section1:Method:Same:Instance6");
    JGFInstrumentor.startTimer("Section1:Method:Same:Instance6");
    for (i=0; i<size; i++){
	a6.instance_method();
	a6.instance_method();
	a6.instance_method();
	a6.instance_method();
	a6.instance_method();
	a6.instance_method();
	a6.instance_method();
	a6.instance_method();
	a6.instance_method();
	a6.instance_method();
	a6.instance_method();
	a6.instance_method();
	a6.instance_method();
	a6.instance_method();
	a6.instance_method();
	a6.instance_method();

    }
    JGFInstrumentor.stopTimer("Section1:Method:Same:Instance6");
    time = JGFInstrumentor.readTimer("Section1:Method:Same:Instance6");
    JGFInstrumentor.addOpsToTimer("Section1:Method:Same:Instance6", (double) 16*size);
    size *=2;
  }
  JGFInstrumentor.printperfTimer("Section1:Method:Same:Instance6");

  MethodSeq_07 a7 = new MethodSeq_07();
//Test non empty instance method (increments a variable)
  JGFInstrumentor.addTimer("Section1:Method:Same:Instance7", "calls");
  time = 0.0;
  size = INITSIZE;
  while (time < TARGETTIME && size < MAXSIZE){
    JGFInstrumentor.resetTimer("Section1:Method:Same:Instance7");
    JGFInstrumentor.startTimer("Section1:Method:Same:Instance7");
    for (i=0; i<size; i++){
	a7.instance_method();
	a7.instance_method();
	a7.instance_method();
	a7.instance_method();
	a7.instance_method();
	a7.instance_method();
	a7.instance_method();
	a7.instance_method();
	a7.instance_method();
	a7.instance_method();
	a7.instance_method();
	a7.instance_method();
	a7.instance_method();
	a7.instance_method();
	a7.instance_method();
	a7.instance_method();

    }
    JGFInstrumentor.stopTimer("Section1:Method:Same:Instance7");
    time = JGFInstrumentor.readTimer("Section1:Method:Same:Instance7");
    JGFInstrumentor.addOpsToTimer("Section1:Method:Same:Instance7", (double) 16*size);
    size *=2;
  }
  JGFInstrumentor.printperfTimer("Section1:Method:Same:Instance7");

  MethodSeq_08 a8 = new MethodSeq_08();
//Test non empty instance method (increments a variable)
  JGFInstrumentor.addTimer("Section1:Method:Same:Instance8", "calls");
  time = 0.0;
  size = INITSIZE;
  while (time < TARGETTIME && size < MAXSIZE){
    JGFInstrumentor.resetTimer("Section1:Method:Same:Instance8");
    JGFInstrumentor.startTimer("Section1:Method:Same:Instance8");
    for (i=0; i<size; i++){
	a8.instance_method();
	a8.instance_method();
	a8.instance_method();
	a8.instance_method();
	a8.instance_method();
	a8.instance_method();
	a8.instance_method();
	a8.instance_method();
	a8.instance_method();
	a8.instance_method();
	a8.instance_method();
	a8.instance_method();
	a8.instance_method();
	a8.instance_method();
	a8.instance_method();
	a8.instance_method();

    }
    JGFInstrumentor.stopTimer("Section1:Method:Same:Instance8");
    time = JGFInstrumentor.readTimer("Section1:Method:Same:Instance8");
    JGFInstrumentor.addOpsToTimer("Section1:Method:Same:Instance8", (double) 16*size);
    size *=2;
  }
  JGFInstrumentor.printperfTimer("Section1:Method:Same:Instance8");

//Test non empty instance method (increments a variable)
  MethodSeq_09 a9 = new MethodSeq_09();
  JGFInstrumentor.addTimer("Section1:Method:Same:Instance9", "calls");
  time = 0.0;
  size = INITSIZE;
  while (time < TARGETTIME && size < MAXSIZE){
    JGFInstrumentor.resetTimer("Section1:Method:Same:Instance9");
    JGFInstrumentor.startTimer("Section1:Method:Same:Instance9");
    for (i=0; i<size; i++){
	a9.instance_method();
	a9.instance_method();
	a9.instance_method();
	a9.instance_method();
	a9.instance_method();
	a9.instance_method();
	a9.instance_method();
	a9.instance_method();
	a9.instance_method();
	a9.instance_method();
	a9.instance_method();
	a9.instance_method();
	a9.instance_method();
	a9.instance_method();
	a9.instance_method();
	a9.instance_method();

    }
    JGFInstrumentor.stopTimer("Section1:Method:Same:Instance9");
    time = JGFInstrumentor.readTimer("Section1:Method:Same:Instance9");
    JGFInstrumentor.addOpsToTimer("Section1:Method:Same:Instance9", (double) 16*size);
    size *=2;
  }
  JGFInstrumentor.printperfTimer("Section1:Method:Same:Instance9");

  MethodSeq_10 a10 = new MethodSeq_10();
//Test non empty instance method (increments a variable)
  JGFInstrumentor.addTimer("Section1:Method:Same:Instance10", "calls");
  time = 0.0;
  size = INITSIZE;
  while (time < TARGETTIME && size < MAXSIZE){
    JGFInstrumentor.resetTimer("Section1:Method:Same:Instance10");
    JGFInstrumentor.startTimer("Section1:Method:Same:Instance10");
    for (i=0; i<size; i++){
	a10.instance_method();
	a10.instance_method();
	a10.instance_method();
	a10.instance_method();
	a10.instance_method();
	a10.instance_method();
	a10.instance_method();
	a10.instance_method();
	a10.instance_method();
	a10.instance_method();
	a10.instance_method();
	a10.instance_method();
	a10.instance_method();
	a10.instance_method();
	a10.instance_method();
	a10.instance_method();

    }
    JGFInstrumentor.stopTimer("Section1:Method:Same:Instance10");
    time = JGFInstrumentor.readTimer("Section1:Method:Same:Instance10");
    JGFInstrumentor.addOpsToTimer("Section1:Method:Same:Instance10", (double) 16*size);
    size *=2;
  }
  JGFInstrumentor.printperfTimer("Section1:Method:Same:Instance10");

  MethodSeq_11 a11 = new MethodSeq_11();
//Test non empty instance method (increments a variable)
  JGFInstrumentor.addTimer("Section1:Method:Same:Instance11", "calls");
  time = 0.0;
  size = INITSIZE;
  while (time < TARGETTIME && size < MAXSIZE){
    JGFInstrumentor.resetTimer("Section1:Method:Same:Instance11");
    JGFInstrumentor.startTimer("Section1:Method:Same:Instance11");
    for (i=0; i<size; i++){
	a11.instance_method();
	a11.instance_method();
	a11.instance_method();
	a11.instance_method();
	a11.instance_method();
	a11.instance_method();
	a11.instance_method();
	a11.instance_method();
	a11.instance_method();
	a11.instance_method();
	a11.instance_method();
	a11.instance_method();
	a11.instance_method();
	a11.instance_method();
	a11.instance_method();
	a11.instance_method();

    }
    JGFInstrumentor.stopTimer("Section1:Method:Same:Instance11");
    time = JGFInstrumentor.readTimer("Section1:Method:Same:Instance11");
    JGFInstrumentor.addOpsToTimer("Section1:Method:Same:Instance11", (double) 16*size);
    size *=2;
  }
  JGFInstrumentor.printperfTimer("Section1:Method:Same:Instance11");
}

  public void instance_method(){k0++;}

  public void instance_method2(){
	 k0++; k1++;
  }

  public void instance_method3(){
	  k0++; k1++; k2++;
  }

  public void instance_method4(){
	   k0++; k1++; k2++; k3++;
 }

  public void instance_method5(){
	  k0++; k1++; k2++; k3++;k4++;
}

  public void instance_method6(){
	  k0++; k1++; k2++; k3++;k4++;
	  k5++;
}

  public void instance_method7(){
	  k0++; k1++; k2++; k3++;k4++;
	  k5++; k6++;
}

  public void instance_method8(){
	  k0++; k1++; k2++; k3++;k4++;
	  k5++; k6++; k7++;
}

  public void instance_method9(){
	  k0++; k1++; k2++; k3++;k4++;
	  k5++; k6++; k7++; k8++;
}

  public void instance_method10(){
	  k0++; k1++; k2++; k3++;k4++;
	  k5++; k6++; k7++; k8++;k9++;

}

  public void instance_method11(){
	  k0++; k1++; k2++; k3++;k4++;
	  k5++; k6++; k7++; k8++;k9++;
	  k10++;
}

  public static void main (String argv[]){

    JGFInstrumentor.printHeader(1,0);

    JGFMethodSequenceBench2 mb = new JGFMethodSequenceBench2();
    mb.JGFrun();

  }

}

class MethodSeq_01{
	  static int k = 0;

	  static int k1=0;

	  private int k0 = 0;
	  public void instance_method(){k++;}

	  public static void class_method() {k++;}
}

class MethodSeq_02{
	  static int k = 0;

	  static int k1=0;

	  private int k0 = 0;
	  public void instance_method(){(new MethodSeq_01()).instance_method();};

	  public static void class_method() {k++;}
}
class MethodSeq_03{
	  static int k = 0;

	  static int k1=0;

	  private int k0 = 0;
	  public void instance_method(){(new MethodSeq_02()).instance_method();};

	  public static void class_method() {k++;}
}
class MethodSeq_04{
	  static int k = 0;

	  static int k1=0;

	  private int k0 = 0;
	  public void instance_method(){(new MethodSeq_03()).instance_method();};

	  public static void class_method() {k++;}
}

class MethodSeq_05{
	  static int k = 0;

	  static int k1=0;

	  private int k0 = 0;
	  public void instance_method(){(new MethodSeq_04()).instance_method();};

	  public static void class_method() {k++;}
}

class MethodSeq_06{
	  static int k = 0;

	  static int k1=0;

	  private int k0 = 0;
	  public void instance_method(){(new MethodSeq_05()).instance_method();};

	  public static void class_method() {k++;}
}
class MethodSeq_07{
	  static int k = 0;

	  static int k1=0;

	  private int k0 = 0;
	  public void instance_method(){(new MethodSeq_06()).instance_method();};

	  public static void class_method() {k++;}
}
class MethodSeq_08{
	  static int k = 0;

	  static int k1=0;

	  private int k0 = 0;
	  public void instance_method(){(new MethodSeq_07()).instance_method();};

	  public static void class_method() {k++;}
}

class MethodSeq_09{
	  static int k = 0;

	  static int k1=0;

	  private int k0 = 0;
	  public void instance_method(){(new MethodSeq_08()).instance_method();};

	  public static void class_method() {k++;}
}
class MethodSeq_10{
	  static int k = 0;

	  static int k1=0;

	  private int k0 = 0;
	  public void instance_method(){(new MethodSeq_09()).instance_method();};

	  public static void class_method() {k++;}
}
class MethodSeq_11{
	  static int k = 0;

	  static int k1=0;

	  private int k0 = 0;
	  public void instance_method(){(new MethodSeq_10()).instance_method();};

	  public static void class_method() {k++;}
}


text:
import {Expression, seq, plus} from "../combi";
import {IStatementRunnable} from "../statement_runnable";
import {Source} from "./source";

export class PerformChanging extends Expression {
  public getRunnable(): IStatementRunnable {
    const changing = seq("CHANGING", plus(Source));

    return changing;
  }
}


text:
/** Automatically generated file. DO NOT MODIFY */
package com.gocharm.coimotion.apptemplate;

public final class BuildConfig {
    public final static boolean DEBUG = true;
}


text:
#include <errno.h>
#include <limits.h>
#include <string>

#include "gtest/gtest.h"
#include "geopm_error.h"
#include "geopm/Exception.hpp"

class ExceptionTest: public :: testing :: Test {};

TEST_F(ExceptionTest, hello)
{
    const std::string geopm_tag("<geopm> ");
    std::string what_str;

    geopm::Exception ex0("Hello world", GEOPM_ERROR_NO_AGENT, __FILE__, __LINE__);
    EXPECT_EQ(GEOPM_ERROR_NO_AGENT, ex0.err_value());
    what_str = std::string(ex0.what());
    EXPECT_TRUE(what_str.size() != 0);
    EXPECT_TRUE(what_str.compare(0, geopm_tag.length(), geopm_tag) == 0);
    EXPECT_TRUE(what_str.find("agent") != std::string::npos);
    EXPECT_TRUE(what_str.find("ExceptionTest.cpp") != std::string::npos);
    std::cerr << "Error value = " << ex0.err_value() << std::endl;
    try {
        throw ex0;
    }
    catch (...) {
        int err = geopm::exception_handler(std::current_exception());
        EXPECT_EQ(GEOPM_ERROR_NO_AGENT, err);
    }

    geopm::Exception ex1;
    EXPECT_EQ(GEOPM_ERROR_RUNTIME, ex1.err_value());
    what_str = std::string(ex1.what());
    EXPECT_TRUE(what_str.size() != 0);
    EXPECT_TRUE(what_str.compare(0, geopm_tag.length(), geopm_tag) == 0);
    EXPECT_TRUE(what_str.find("untime") != std::string::npos);
    std::cerr << "Error: " << ex1.what() << std::endl;
}

TEST_F(ExceptionTest, last_message)
{
    char message_cstr[256];
    std::string message;
    std::string expect("<geopm> Invalid argument: ExceptionTest: Detail: at ExceptionTest.cpp:1234");
    try {
        throw geopm::Exception("ExceptionTest: Detail", GEOPM_ERROR_INVALID, "ExceptionTest.cpp", 1234);
    }
    catch (...) {
        geopm::exception_handler(std::current_exception(), false);
    }
    geopm_error_message(GEOPM_ERROR_INVALID, message_cstr, 256);
    message = message_cstr;
    // Check basic use case
    EXPECT_EQ(expect, message);

    // Check that message truncation works
    geopm_error_message(GEOPM_ERROR_INVALID, message_cstr, 8);
    message = message_cstr;
    EXPECT_EQ(expect.substr(0, 7), message);

    // Make sure the message changes when a new exception is handled
    try {
        throw geopm::Exception("ExceptionTest: New message", GEOPM_ERROR_RUNTIME, "ExceptionTest.cpp", 1234);
    }
    catch (...) {
        geopm::exception_handler(std::current_exception(), false);
    }
    geopm_error_message(GEOPM_ERROR_RUNTIME, message_cstr, 256);
    message = message_cstr;
    std::string expect_new("<geopm> Runtime error: ExceptionTest: New message: at ExceptionTest.cpp:1234");
    EXPECT_EQ(expect_new, message);

    // Make sure long exception messages are handled
    std::string too_long(2 * NAME_MAX, 'X');
    try {
        throw geopm::Exception(too_long, GEOPM_ERROR_RUNTIME, "ExceptionTest.cpp", 1234);
    }
    catch (...) {
        geopm::exception_handler(std::current_exception(), false);
    }
    geopm_error_message(GEOPM_ERROR_RUNTIME, message_cstr, 256);
    message = message_cstr;
    std::string expect_long("<geopm> Runtime error: " + too_long.substr(0, 231));
    EXPECT_EQ(expect_long, message);

    // Check that we get the short message when no exception was thrown
    geopm_error_message(GEOPM_ERROR_LOGIC, message_cstr, 256);
    message = message_cstr;
    EXPECT_EQ("<geopm> Logic error", message);
}

TEST_F(ExceptionTest, check_ronn)
{
    // Make sure output of geopm_print_error --ronn matches what is in
    // geopm_error.3.ronn
    EXPECT_EQ(0, system(
        "./examples/geopm_print_error --ronn > tmp.txt && "
        "diff tmp.txt ronn/geopm_error.3.ronn | grep '^<'; err=$?; "
        "rm -f tmp.txt; if [ \"$err\" -eq 0 ]; then false; else true; fi"));
}


text:
#ifndef ANALYTICS_STRUCTURED_SYSLOG_CONFIG_H_
#define ANALYTICS_STRUCTURED_SYSLOG_CONFIG_H_

#include <map>
#include <tbb/atomic.h>
#include <boost/shared_ptr.hpp>
#include <boost/regex.hpp>
#include <boost/algorithm/string.hpp>
#include "config_client_collector.h"
#include "parser_util.h"

class Options;

class HostnameRecord {
    public:
        explicit HostnameRecord(const std::string &name, const std::string &hostaddr,
        const std::string &tenant, const std::string &location, const std::string &device):
            refreshed_(true), name_(name), hostaddr_(hostaddr), tenant_(tenant),
            location_(location), device_(device) {
        }
        bool operator==(const HostnameRecord &rhs) {
            return rhs.IsMe(name_) &&  rhs.hostaddr() == hostaddr_ &&
            rhs.tenant() == tenant_ && rhs.location() == location_ &&
            rhs.device() == device_;
        }

        const std::string name() { return name_; }
        const std::string hostaddr() const { return hostaddr_; }
        const std::string tenant() const { return tenant_; }
        const std::string location() const { return location_; }
        const std::string device() const { return device_; }

        bool IsMe(const std::string &name) const { return name == name_; }
        void Refresh(const std::string &name, const std::string &hostaddr,
                     const std::string &tenant, const std::string &location,
                     const std::string &device) {
             if (hostaddr_ != hostaddr)
                hostaddr_ = hostaddr;
             if (tenant_ != tenant)
                tenant_ = tenant;
             if (location_ != location)
                location_ = location;
             if (device_ != device)
                device_ = device;

            refreshed_ = true;
        }
        bool GetandClearRefreshed() { bool r = refreshed_; refreshed_ = false; return r;}
    private:
        bool                   refreshed_;
        std::string            name_;
        std::string            hostaddr_;
        std::string            tenant_;
        std::string            location_;
        std::string            device_;
};

class ApplicationRecord {
    public:
        explicit ApplicationRecord(const std::string &name, const std::string &app_category,
        const std::string &app_subcategory, const std::string &app_groups,
        const std::string &app_risk, const std::string &app_service_tags):
            refreshed_(true), name_(name), app_category_(app_category),
            app_subcategory_(app_subcategory), app_groups_(app_groups),
            app_risk_(app_risk), app_service_tags_(app_service_tags) {
        }
        bool operator==(const ApplicationRecord &rhs) {
            return rhs.IsMe(name_) &&  rhs.app_category() == app_category_ &&
            rhs.app_subcategory() == app_subcategory_ &&
            rhs.app_groups() == app_groups_ &&
            rhs.app_risk() == app_risk_ &&
            rhs.app_service_tags() == app_service_tags_;
        }

        const std::string name() { return name_; }
        const std::string app_category() const { return app_category_; }
        const std::string app_subcategory() const { return app_subcategory_; }
        const std::string app_groups() const { return app_groups_; }
        const std::string app_risk() const { return app_risk_; }
        const std::string app_service_tags() const { return app_service_tags_; }

        bool IsMe(const std::string &name) const { return name == name_; }
        void Refresh(const std::string &name, const std::string &app_category,
                     const std::string &app_subcategory, const std::string &app_groups,
                     const std::string &app_risk, const std::string &app_service_tags) {
             if (app_category_ != app_category)
                app_category_ = app_category;
             if (app_subcategory_ != app_subcategory)
                app_subcategory_ = app_subcategory;
             if (app_groups_ != app_groups)
                app_groups_ = app_groups;
             if (app_risk_ != app_risk)
                app_risk_ = app_risk;
             if (app_service_tags_ != app_service_tags)
                app_service_tags_ = app_service_tags;

            refreshed_ = true;
        }
        bool GetandClearRefreshed() { bool r = refreshed_; refreshed_ = false; return r;}
    private:
        bool                   refreshed_;
        std::string            name_;
        std::string            app_category_;
        std::string            app_subcategory_;
        std::string            app_groups_;
        std::string            app_risk_;
        std::string            app_service_tags_;
};

class TenantApplicationRecord {
    public:
        explicit TenantApplicationRecord(const std::string &name, const std::string &tenant_app_category,
        const std::string &tenant_app_subcategory, const std::string &tenant_app_groups,
        const std::string &tenant_app_risk, const std::string &tenant_app_service_tags):
            refreshed_(true), name_(name), tenant_app_category_(tenant_app_category),
            tenant_app_subcategory_(tenant_app_subcategory),
            tenant_app_groups_(tenant_app_groups), tenant_app_risk_(tenant_app_risk),
            tenant_app_service_tags_(tenant_app_service_tags) {
        }
        bool operator==(const TenantApplicationRecord &rhs) {
            return rhs.IsMe(name_) &&  rhs.tenant_app_category() == tenant_app_category_ &&
            rhs.tenant_app_subcategory() == tenant_app_subcategory_ &&
            rhs.tenant_app_groups() == tenant_app_groups_ &&
            rhs.tenant_app_risk() == tenant_app_risk_ &&
            rhs.tenant_app_service_tags() == tenant_app_service_tags_;
        }

        const std::string name() { return name_; }
        const std::string tenant_app_category() const { return tenant_app_category_; }
        const std::string tenant_app_subcategory() const { return tenant_app_subcategory_; }
        const std::string tenant_app_groups() const { return tenant_app_groups_; }
        const std::string tenant_app_risk() const { return tenant_app_risk_; }
        const std::string tenant_app_service_tags() const { return tenant_app_service_tags_; }

        bool IsMe(const std::string &name) const { return name == name_; }
        void Refresh(const std::string &name, const std::string &tenant_app_category,
                     const std::string &tenant_app_subcategory, const std::string &tenant_app_groups,
                     const std::string &tenant_app_risk, const std::string &tenant_app_service_tags) {
             if (tenant_app_category_ != tenant_app_category)
                tenant_app_category_ = tenant_app_category;
             if (tenant_app_subcategory_ != tenant_app_subcategory)
                tenant_app_subcategory_ = tenant_app_subcategory;
             if (tenant_app_groups_ != tenant_app_groups)
                tenant_app_groups_ = tenant_app_groups;
             if (tenant_app_risk_ != tenant_app_risk)
                tenant_app_risk_ = tenant_app_risk;
             if (tenant_app_service_tags_ != tenant_app_service_tags)
                tenant_app_service_tags_ = tenant_app_service_tags;

            refreshed_ = true;
        }
        bool GetandClearRefreshed() { bool r = refreshed_; refreshed_ = false; return r;}
    private:
        bool                   refreshed_;
        std::string            name_;
        std::string            tenant_app_category_;
        std::string            tenant_app_subcategory_;
        std::string            tenant_app_groups_;
        std::string            tenant_app_risk_;
        std::string            tenant_app_service_tags_;
};

class MessageConfig {
    public:
        explicit MessageConfig(const std::string &name, const std::vector< std::string > &tags,
        const std::vector< std::string > &ints, bool process_and_store, bool forward,
        bool process_before_forward, bool process_and_summarize, bool process_and_summarize_user):
            refreshed_(true), name_(name), tags_(tags), ints_(ints), process_and_store_(process_and_store),
            forward_(forward), process_before_forward_(process_before_forward), process_and_summarize_(process_and_summarize),
            process_and_summarize_user_(process_and_summarize_user) {
        }
        bool operator==(const MessageConfig &rhs) {
            return rhs.IsMe(name_) &&  std::equal(rhs.tags().begin(), rhs.tags().end(), tags_.begin()) &&
            std::equal(rhs.ints().begin(), rhs.ints().end(), ints_.begin()) && rhs.forward() == forward_ &&
            rhs.process_and_store() == process_and_store_ &&
            rhs.process_before_forward() == process_before_forward_ &&
            rhs.process_and_summarize() == process_and_summarize_ &&
            rhs.process_and_summarize_user() == process_and_summarize_user_;
        }

        const std::string name() { return name_; }
        const std::vector< std::string > tags() const { return tags_; }
        const std::vector< std::string > ints() const { return ints_; }
        const bool process_and_store() const { return process_and_store_; }
        const bool process_and_summarize() const { return process_and_summarize_; }
        const bool process_and_summarize_user() const { return process_and_summarize_user_; }
        const bool forward() const { return forward_; }
        const bool process_before_forward() const { return process_before_forward_; }
        bool IsMe(const std::string &name) const { return name == name_; }
        void Refresh(const std::string &name, const std::vector< std::string > &tags,
                     const std::vector< std::string > &ints, bool process_and_store,
                     bool forward, bool process_before_forward, bool process_and_summarize,
                     bool process_and_summarize_user) {
             if (tags.size() != tags_.size()) {
                 tags_ = tags;
             } else if (!(std::equal(tags.begin(), tags.end(), tags_.begin()))) {
                tags_ = tags;
             }
             if (ints.size() != ints_.size()) {
                ints_ = ints;
             } else if (!(std::equal(ints.begin(), ints.end(), ints_.begin()))) {
                ints_ = ints;
             }
             if (process_and_store_ != process_and_store)
                process_and_store_ = process_and_store;
             if (process_and_summarize_ != process_and_summarize)
                process_and_summarize_ = process_and_summarize;
             if (process_and_summarize_user_ != process_and_summarize_user)
                process_and_summarize_user_ = process_and_summarize_user;
             if (forward_ != forward)
                forward_ = forward;
             if (process_before_forward_ != process_before_forward)
                process_before_forward_ = process_before_forward;

            refreshed_ = true;
        }
        bool GetandClearRefreshed() { bool r = refreshed_; refreshed_ = false; return r;}
    private:
        bool                        refreshed_;
        std::string                 name_;
        std::vector< std::string >  tags_;
        std::vector< std::string >  ints_;
        bool                        process_and_store_;
        bool                        forward_;
        bool                        process_before_forward_;
        bool                        process_and_summarize_;
        bool                        process_and_summarize_user_;
};

typedef std::map<std::string, boost::shared_ptr<HostnameRecord> > Chr_t;
typedef std::map<std::string, boost::shared_ptr<ApplicationRecord> > Car_t;
typedef std::map<std::string, boost::shared_ptr<TenantApplicationRecord> > Ctar_t;
typedef std::map<std::string, boost::shared_ptr<MessageConfig> > Cmc_t;

class StructuredSyslogConfig {
    public:
        StructuredSyslogConfig(ConfigClientCollector *config_client);
        ~StructuredSyslogConfig();
        void AddHostnameRecord(const std::string &name, const std::string &hostaddr,
                                  const std::string &tenant, const std::string &location,
                                  const std::string &device);
        void AddApplicationRecord(const std::string &name, const std::string &app_category,
                                  const std::string &app_subcategory, const std::string &app_groups,
                                  const std::string &app_risk, const std::string &app_service_tags);
        void AddTenantApplicationRecord(const std::string &name, const std::string &tenant_app_category,
                                  const std::string &tenant_app_subcategory, const std::string &tenant_app_groups,
                                  const std::string &tenant_app_risk, const std::string &tenant_app_service_tags);
        void AddMessageConfig(const std::string &name, const std::vector< std::string > &tags,
                                  const std::vector< std::string > &ints, bool process_and_store,
                                  const std::string &forward, bool process_and_summarize, bool process_and_summarize_user);
        boost::shared_ptr<HostnameRecord> GetHostnameRecord(const std::string &name);
        boost::shared_ptr<ApplicationRecord> GetApplicationRecord(const std::string &name);
        boost::shared_ptr<TenantApplicationRecord> GetTenantApplicationRecord(const std::string &name);
        boost::shared_ptr<MessageConfig> GetMessageConfig(const std::string &name);
        void ReceiveConfig(const contrail_rapidjson::Document &jdoc, bool add_change);
    private:
        void HostnameRecordsHandler(const contrail_rapidjson::Document &jdoc,
                                    bool add_change);
        void ApplicationRecordsHandler(const contrail_rapidjson::Document &jdoc,
                                    bool add_change);
        void MessageConfigsHandler(const contrail_rapidjson::Document &jdoc,
                                    bool add_change);

        Chr_t hostname_records_;
        Car_t application_records_;
        Ctar_t tenant_application_records_;
        Cmc_t message_configs_;
};

#endif


text:
package alec_wam.CrystalMod.tiles.machine.fluidManager;

import alec_wam.CrystalMod.tiles.TileEntityIOSides;
import alec_wam.CrystalMod.util.ItemNBTHelper;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.fluids.capability.IFluidTankProperties;

public class TileEntityFluidManager extends TileEntityIOSides {

	public static enum OutputMode{
		NONE, CHECK, ALLWAYS;
	}

	public static final int[] capacities = {Fluid.BUCKET_VOLUME, 16*Fluid.BUCKET_VOLUME, 32*Fluid.BUCKET_VOLUME, 48*Fluid.BUCKET_VOLUME, 64*Fluid.BUCKET_VOLUME};

	public FluidTank tank;
	protected int lastUpdateLevel = -1;
	private boolean tankDirty = false;
	private Fluid lastFluid = null;
	byte outputTracker;
	boolean cached = false;

	public OutputMode oMode;
	public int outputAmt;

	public TileEntityFluidManager(){
		this(0);
	}

	public TileEntityFluidManager(int meta){
		tank = new FluidTank(capacities[meta % capacities.length]);
		oMode = OutputMode.NONE;
		outputAmt = 0;
	}

	@Override
	public void writeCustomNBT(NBTTagCompound nbtRoot) {
		super.writeCustomNBT(nbtRoot);
		nbtRoot.setInteger("Type", this.getBlockMetadata());
		nbtRoot.setByte("OMode", (byte)oMode.ordinal());
		nbtRoot.setInteger("OAmt", outputAmt);
    	if(tank.getFluidAmount() > 0) {
	    	NBTTagCompound fluidRoot = new NBTTagCompound();
	      	tank.getFluid().writeToNBT(fluidRoot);
	      	nbtRoot.setTag("tankContents", fluidRoot);
    	}
	}

	@Override
  	public void readCustomNBT(NBTTagCompound nbtRoot) {
		super.readCustomNBT(nbtRoot);
    	tank = new FluidTank(capacities[nbtRoot.getInteger("Type") % capacities.length]);
    	oMode = OutputMode.values()[nbtRoot.getByte("OMode")];
    	outputAmt = nbtRoot.getInteger("OAmt");
    	if(nbtRoot.hasKey("tankContents")) {
    	FluidStack fl = FluidStack.loadFluidStackFromNBT((NBTTagCompound) nbtRoot.getTag("tankContents"));
      	tank.setFluid(fl);
    	} else {
    	tank.setFluid(null);
    	}
  	}

	public void incrsAmt(int incrs){
		outputAmt += incrs;

		if(outputAmt < 0){
			outputAmt = this.tank.getCapacity();
		}
		if(outputAmt > this.tank.getCapacity()){
			outputAmt = 0;
		}

		NBTTagCompound nbt = new NBTTagCompound();
		nbt.setInteger("OAmt", incrs);
		markDirty();
	}

	@Override
	public void update(){
		super.update();
		if(!getWorld().isRemote){
			/*int filledLevel = getFilledLevel();
		    if(lastUpdateLevel != filledLevel) {
		      lastUpdateLevel = filledLevel;
		      tankDirty = false;
		      return;
		    }*/

		    if (this.tank !=null)
		    {
		      for (int i = this.outputTracker; (i < 6) && (this.tank.getFluidAmount() > 0); i++) {
		        transferFluid(EnumFacing.getFront(i));
		      }
		      this.outputTracker = ((byte)(this.outputTracker + 1));
		      this.outputTracker = ((byte)(this.outputTracker % 6));
		    }

		    if(tankDirty && shouldDoWorkThisTick(10)) {
		    	this.markDirty();
		    	Fluid held = tank.getFluid() == null ? null : tank.getFluid().getFluid();
		    	if(lastFluid != held) {
		    		lastFluid = held;
		    	}
		    	tankDirty = false;
	      }
		}
	}

	protected void transferFluid(EnumFacing face)
	{
		if (this.getIO(face) !=IOType.OUT || this.oMode == OutputMode.NONE) {
			return;
		}

		TileEntity tile = getWorld().getTileEntity(getPos().offset(face));

		if(tile == null || !isFluidHandler(tile, face))return;

		IFluidHandler fHandler = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, face.getOpposite());

		int out = this.outputAmt;
		if(this.oMode == OutputMode.CHECK){
			IFluidTankProperties[] infoArray = fHandler.getTankProperties();
			for(int t = 0; t < infoArray.length; t++){
				IFluidTankProperties info = infoArray[t];
				if(info.getContents() !=null){
					if(info.getContents().amount >= this.outputAmt){
						return;
					}else{
						out-=info.getContents().amount;
						break;
					}
				}
			}
		}
		FluidStack copy = tank.getFluid().copy();
		copy.amount = Math.min(tank.getFluidAmount(), out);
		if(tank.getFluidAmount() == 0)return;
		this.drainInternal(fHandler.fill(copy, true), true);
		this.tankDirty = true;
	}

	public static boolean isFluidHandler(TileEntity tile, EnumFacing face) {
		return tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, face.getOpposite()) !=null;
	}

	//@Override
	public int fill(EnumFacing from, FluidStack resource, boolean doFill) {
		return fillInternal(resource, doFill);
	}

	int fillInternal(FluidStack resource, boolean doFill) {
		int res = tank.fill(resource, doFill);
		if(res > 0 && doFill) {
			tankDirty = true;
		}
		return res;
	}

	FluidStack drainInternal(FluidStack resource, boolean doDrain) {
		if(resource == null)return null;
		FluidStack res = tank.drain(resource.amount, doDrain);
		if(res != null && res.amount > 0 && doDrain) {
			tankDirty = true;
		}
		return res;
	}

	FluidStack drainInternal(int maxDrain, boolean doDrain) {
		FluidStack res = tank.drain(maxDrain, doDrain);
		if(res != null && res.amount > 0 && doDrain) {
			tankDirty = true;
		}
		return res;
	}

	@Override
    public boolean hasCapability(Capability<?> capability, EnumFacing facingIn) {
      return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY || super.hasCapability(capability, facingIn);
    }

    @SuppressWarnings("unchecked")
	@Override
    public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
        if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY && getIO(facing) == IOType.IN) {
            //noinspection unchecked
            return (T) new IFluidHandler() {

            	public FluidTank getTank(){
            		return tank;
            	}

            	@Override
				public int fill(FluidStack resource, boolean doFill) {
                    return getTank().fill(resource, doFill);
                }

                @Override
				public FluidStack drain(int maxEmpty, boolean doDrain) {
                	return null;
                }

                @Override
				public FluidStack drain(FluidStack resource, boolean doDrain) {
                    return drain(resource.amount, doDrain);
                }

				@Override
				public IFluidTankProperties[] getTankProperties() {
					return getTank().getTankProperties();
				}

            };
        }
        return super.getCapability(capability, facing);
    }

	/*@Override
	public boolean canFill(EnumFacing from, Fluid fluid) {
		return getIO(from) == IOType.IN && (tank.getFluid() == null || tank.getFluid().getFluid().equals(fluid));
	}*/

	/*private int getFilledLevel() {
		int level = (int) Math.floor(16 * tank.getFilledRatio());
		if(level == 0 && tank.getFluidAmount() > 0) {
			level = 1;
		}
		return level;
	}*/

	/*public int getComparatorOutput() {
		FluidTankInfo info = getTankInfo(null)[0];
		return info == null || info.fluid == null ? 0 : (int) (((double) info.fluid.amount / (double) info.capacity) * 15);
	}*/

	public void writeToStack(ItemStack stack){
		NBTTagCompound nbt = ItemNBTHelper.getCompound(stack);
		nbt.setByte("OMode", (byte)oMode.ordinal());
		nbt.setInteger("OAmt", outputAmt);
    	if(tank.getFluidAmount() > 0) {
	    	NBTTagCompound fluidRoot = new NBTTagCompound();
	      	tank.getFluid().writeToNBT(fluidRoot);
	      	nbt.setTag("tankContents", fluidRoot);
    	}
	}

	public void readFromStack(ItemStack stack){
		NBTTagCompound nbt = ItemNBTHelper.getCompound(stack);
		tank = new FluidTank(capacities[nbt.getInteger("Type") % capacities.length]);
		oMode = OutputMode.values()[nbt.getByte("OMode")];
		outputAmt = nbt.getInteger("OAmt");
		if(nbt.hasKey("tankContents")) {
			FluidStack fl = FluidStack.loadFluidStackFromNBT((NBTTagCompound) nbt.getTag("tankContents"));
	  		tank.setFluid(fl);
		} else {
			tank.setFluid(null);
		}
	}

}


text:
package com.facebook.buck.java;

/**
 * Facilitates creating a fake {@link JavaPackageFinder} for unit tests.
 */
public class FakeJavaPackageFinder implements JavaPackageFinder {
  @Override
  public String findJavaPackageFolderForPath(String pathRelativeToProjectRoot) {
    return null;
  }

  @Override
  public String findJavaPackageForPath(String pathRelativeToProjectRoot) {
    return null;
  }
}


text:
package VMOMI::DatastoreOption;
use parent 'VMOMI::DynamicData';

use strict;
use warnings;

our @class_ancestors = (
    'DynamicData',
);

our @class_members = (
    ['unsupportedVolumes', 'VirtualMachineDatastoreVolumeOption', 1, 1],
);

sub get_class_ancestors {
    return @class_ancestors;
}

sub get_class_members {
    my $class = shift;
    my @super_members = $class->SUPER::get_class_members();
    return (@super_members, @class_members);
}

1;


text:
import { UniversalAdId } from '../../../src/core/universal-ad-id'

describe('UniversalAdId', () => {
  const createInstance = () => {
    const inst = new UniversalAdId()
    return inst
  }

  describe('#idRegistry', () => {
    it('checks default value', () => {
      const inst = createInstance()
      expect(inst.idRegistry).to.equal('unknown')
    })

    it('sets idRegistry', () => {
      const inst = createInstance()
      const value = 'https://example.com/registry'
      inst.idRegistry = value
      expect(inst.idRegistry).to.equal(value)
    })
  })

  describe('#idValue', () => {
    it('checks default value', () => {
      const inst = createInstance()
      expect(inst.idValue).to.equal('unknown')
    })

    it('sets idValue', () => {
      const inst = createInstance()
      const value = 'creative-id'
      inst.idValue = value
      expect(inst.idValue).to.equal(value)
    })
  })

  describe('#creativeIdentifier', () => {
    it('sets creativeIdentifier', () => {
      const inst = createInstance()
      const value = 'creative-id'
      inst.creativeIdentifier = value
      expect(inst.creativeIdentifier).to.equal(value)
    })
  })

  describe('#$type', () => {
    it('is UniversalAdId', () => {
      const inst = createInstance()
      expect(inst.$type).to.equal('UniversalAdId')
    })
  })
})


text:
import os

class FolderFileProcessor(object):
    def __init__(self, files_folder=""):
        self.files_folder = files_folder

    # noinspection PyMethodMayBeStatic
    def is_process_needed(self, file_path):
        return not ("~" in file_path)

    def process_file(self, full_path):
        self.filter_item(full_path)

    def process_files(self):
        cur_path = os.getcwd()
        data_dir = os.path.join(cur_path, self.files_folder)
        for file_path in os.listdir(data_dir):
            if self.is_process_needed(file_path):
                full_path = os.path.join(data_dir, file_path)
                if os.path.isfile(full_path):
                    print "processing:", full_path
                    self.process_file(full_path)


text:
module Griffin.Yo.Net {

    /**
     * Our wrapper around AJAX focused on loading resources and data from the server.
     */
    export class Http {
        private static cache: any = {};

        /**
         * Whether HTTP caching ('If-Modified-Since' and 'Last-Modified') can be used.
         */
        static useCaching = true;

        /**
         * Get a resource from the server.
         * @param url Server to fetch from
         * @param callback Invoked once the response is received from the server (or when something fails).
         * @param contentType Content type for the request.
         */
        static get(url: string, callback: (name: XMLHttpRequest, success: boolean) => void, contentType: string = "application/json"): void {
            var request = new XMLHttpRequest();
            request.open("GET", url, true);
            if (typeof this.cache[url] !== "undefined") {
                var cache: any = this.cache[url];
                request.setRequestHeader("If-Modified-Since", cache.modifiedAt);
            }
            request.setRequestHeader("Content-Type", contentType);
            request.onload = () => {
                if (request.status >= 200 && request.status < 400) {
                    if (request.status === 304) {
                        request.responseText = this.cache[url].content;
                    } else {
                        const header: string = request.getResponseHeader("Last-Modified");
                        if (header) {
                            this.cache[url] = {
                                content: request.responseText,
                                modifiedAt: header
                            };
                        }
                    }

                    if (contentType === "application/json") {
                        request.responseBody = JSON.parse(request.responseText);

                        //for browser that locks well defined objects
                        //(like IE)
                        var tempFix:any = request;
                        tempFix["responseJson"] = JSON.parse(request.responseText);
                    }
                    callback(request, true);
                } else {
                    callback(request, false);
                }
            };

            request.onerror = () => {
                callback(request, false);
            };
            request.send();
        }

        /**
         * POST a resource to the server
         * @param url Server resource to post to
         * @param callback Invoked once the response is received from the server (or when something fails).
         * @param options Additional configuration
         */
        static post(url: string, data: any, callback: (name: XMLHttpRequest, success: boolean) => void, options?: IHttpOptions): void {
            if (!data) {
                throw new Error("You must specify a body when using POST.");
            }
            Http.invokeRequest('POST', url, data, callback, options);
        }

        /**
         * PUT a resource to the server
         * @param url Server resource to post to
         * @param callback Invoked once the response is received from the server (or when something fails).
         * @param options Additional configuration
         */
        static put(url: string, data: any, callback: (name: XMLHttpRequest, success: boolean) => void, options?: IHttpOptions): void {
            if (!data) {
                throw new Error("You must specify a body when using PUT.");
            }
            Http.invokeRequest('PUT', url, data, callback, options);
        }

        /**
         * DELETE a resource on the server
         * @param url Server resource to post to
         * @param callback Invoked once the response is received from the server (or when something fails).
         * @param options Additional configuration
         */
        static delete(url: string, callback: (name: XMLHttpRequest, success: boolean) => void, options?: IHttpOptions): void {
            Http.invokeRequest('DELETE', url, null, callback, options);
        }

        /**
         * Make an HTTP request
         * @param verb HTTP verb
         * @param url Server resource to make a request to
         * @param data null if no body should be sent
         * @param callback Invoked once the response is received from the server (or when something fails).
         * @param options Additional configuration
         */
        static invokeRequest(verb: string, url: string, data: any, callback: (name: XMLHttpRequest, success: boolean) => void, options?: IHttpOptions): void {
            if (!verb) {
                throw new Error("You must specify a HTTP verb");
            }

            if (options && options.userName && !options.password) {
                throw new Error("You must provide password when username has been specified.");
            }

            var request: XMLHttpRequest = new XMLHttpRequest();
            if (options && options.userName) {
                request.open(verb, url, true, options.userName, options.password);
            } else {
                request.open(verb, url, true);
            }

            var requestContentType: string = "application/json";
            if (options && options.contentType) {
                requestContentType = options.contentType;
            }

            if (options && options.headers) {
                for (let key in options.headers) {
                    request.setRequestHeader(key, options.headers[key]);
                }
            }

            request.onload = () => {
                if (request.status >= 200 && request.status < 400) {
                    var contentType = request.getResponseHeader("content-type").toLocaleLowerCase();
                    if (contentType === "application/json") {
                        //this doesn't work in IE
                        request.responseBody = JSON.parse(request.responseText);

                        //for IE
                        var temp = <any>request;
                        temp["responseJson"] = JSON.parse(request.responseText);
                    }
                    callback(request, true);
                } else {
                    callback(request, false);
                }
            };

            request.onerror = () => {
                callback(request, false);
            };

            if (typeof data !== "undefined" && data !== null) {
                request.setRequestHeader("Content-Type", requestContentType);
                if (requestContentType === "application/json" && typeof (data) !== "string") {
                    data = JSON.stringify(data);
                }
                request.send(data);
            } else {
                request.send();
            }

        }
    }

    /** Options for requests */
    export interface IHttpOptions {

        /** Can contain headers (key: value) */
        headers?: any;

        /** Content type if something other than application/json */
        contentType?: string;

        /** User name if authentication should be used */
        userName?: string;

        /** Required when userName is specified */
        password?: string;
    }
}


text:
package de.zib.gndms.taskflows.failure.server;

import de.zib.gndms.kit.config.MapConfig;
import de.zib.gndms.logic.model.gorfx.TaskFlowAction;
import de.zib.gndms.model.gorfx.types.DelegatingOrder;
import de.zib.gndms.model.gorfx.types.TaskState;
import de.zib.gndms.neomodel.common.Dao;
import de.zib.gndms.neomodel.common.Session;
import de.zib.gndms.neomodel.gorfx.Taskling;
import de.zib.gndms.taskflows.failure.client.FailureTaskFlowMeta;
import de.zib.gndms.taskflows.failure.client.model.FailureOrder;
import de.zib.gndms.taskflows.failure.client.model.FailureTaskFlowResult;
import de.zib.gndms.taskflows.failure.server.utils.ExceptionFactory;
import org.jetbrains.annotations.NotNull;

import javax.persistence.EntityManager;

/**
 * @author bachmann@zib.de
 * @date 14.02.11  17:53
 * @brief The action of the dummy task flow.
 *
 * @see FailureOrder
 */
public class FailureTFAction extends TaskFlowAction< FailureOrder > {

    @Override
    public Class< FailureOrder > getOrderBeanClass( ) {
        return FailureOrder.class;
    }

    public FailureTFAction() {
        super( FailureTaskFlowMeta.TASK_FLOW_TYPE_KEY );
    }

    public FailureTFAction(@NotNull EntityManager em, @NotNull Dao dao, @NotNull Taskling model) {

        super( FailureTaskFlowMeta.TASK_FLOW_TYPE_KEY, em, dao, model );
    }

    @Override
    protected void onCreated(@NotNull String wid,
                             @NotNull TaskState state, boolean isRestartedTask, boolean altTaskState)
            throws Exception
    {
        ensureOrder();
        FailureOrder order = getOrder().getOrderBean();

        handle(FailureOrder.FailurePlace.CREATED, true);
        super.onCreated( wid, state, isRestartedTask, altTaskState );
        handle( FailureOrder.FailurePlace.CREATED, false );
    }

    @Override
    protected void onInitialized(@NotNull String wid,
                                 @NotNull TaskState state, boolean isRestartedTask, boolean altTaskState)
            throws Exception {
        ensureOrder();
        FailureOrder order = getOrder().getOrderBean();

        handle( FailureOrder.FailurePlace.INITIALIZED, true );
        super.onInitialized(wid, state, isRestartedTask, altTaskState);
        handle(FailureOrder.FailurePlace.INITIALIZED, false);
    }

    @Override
    protected void onInProgress(@NotNull String wid,
                                @NotNull TaskState state, boolean isRestartedTask, boolean altTaskState)
            throws Exception {
        ensureOrder();
        FailureOrder order = getOrder().getOrderBean();

        handle(FailureOrder.FailurePlace.INPROGRESS, true);
        super.onInProgress(wid, state, isRestartedTask, altTaskState);
        handle( FailureOrder.FailurePlace.INPROGRESS, false );

        transitWithPayload( new FailureTaskFlowResult(), TaskState.FINISHED );
    }

    @Override
    protected void onFinished(@NotNull String wid,
                              @NotNull TaskState state, boolean isRestartedTask, boolean altTaskState)
            throws Exception {
        ensureOrder();
        FailureOrder order = getOrder().getOrderBean();

        handle( FailureOrder.FailurePlace.FINISHED, true );
        super.onFinished(wid, state, isRestartedTask, altTaskState);
        handle(FailureOrder.FailurePlace.FINISHED, false);
    }

    @Override
    protected void onFailed(@NotNull String wid,
                            @NotNull TaskState state, boolean isRestartedTask, boolean altTaskState) throws Exception {
        ensureOrder();
        FailureOrder order = getOrder().getOrderBean();

        handle( FailureOrder.FailurePlace.FAILED, true );
        super.onFailed(wid, state, isRestartedTask, altTaskState);
        handle( FailureOrder.FailurePlace.FAILED, false );
    }

    private void handle( FailureOrder.FailurePlace where, boolean beforeSuper ) throws InterruptedException {
        ensureOrder();
        FailureOrder order = getOrder().getOrderBean();

        if( beforeSuper )
            Thread.sleep( order.getSleepBeforeSuper( where ) );
        else
            Thread.sleep( order.getSleepAfterSuper( where ) );

        if( where.equals( order.getWhere() ) && beforeSuper == order.isBeforeSuper() ) {
            if( order.isThrowInSession() ) {
                final Session session = getDao().beginSession();
                try {
                    ExceptionFactory.throwUncheked(
                            ExceptionFactory.createException( order.getException(), order.getMessage() )
                    );
                    session.success();
                }
                finally { session.finish(); }
            }
            else
                ExceptionFactory.throwUncheked(
                        ExceptionFactory.createException( order.getException(), order.getMessage() )
                );
        }
    }

    protected @NotNull
    MapConfig getOfferTypeConfig() {
        return new MapConfig( getTaskFlowTypeConfigMapData() );
    }

    @Override
    public DelegatingOrder<FailureOrder> getOrder() {

        DelegatingOrder< FailureOrder > order = null;

        final Session session = getDao().beginSession();
        try {
            order = ( DelegatingOrder< FailureOrder > ) getTask( session ).getOrder( );
            session.success();
        }
        finally { session.finish(); }

        return order;
    }
}


text:
<?php
/**
 * ResourceParams
 *
 * PHP version 5
 *
 * @category Class
 * @package  Voximplant
 * @author   http://github.com/swagger-api/swagger-codegen
 * @license  http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2
 * @link     https://github.com/swagger-api/swagger-codegen
 */

/**
 * Voximplant HTTP API
 *
 * Voximplant HTTP API description
 *
 * OpenAPI spec version: 1.0.0
 * Contact: info@voximplant.com
 * Generated by: https://github.com/swagger-api/swagger-codegen.git
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * NOTE: This class is auto generated by the swagger code generator program.
 * https://github.com/swagger-api/swagger-codegen
 * Do not edit the class manually.
 */

namespace Voximplant\Model;

use \ArrayAccess;

/**
 * ResourceParams Class Doc Comment
 *
 * @category    Class */
 // @description The available resource parameters.
/**
 * @package     Voximplant
 * @author      http://github.com/swagger-api/swagger-codegen
 * @license     http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2
 * @link        https://github.com/swagger-api/swagger-codegen
 */
class ResourceParams implements ArrayAccess
{
    /**
      * The original name of the model.
      * @var string
      */
    protected static $swaggerModelName = 'ResourceParams';

    /**
      * Array of property to type mappings. Used for (de)serialization
      * @var string[]
      */
    protected static $swaggerTypes = array(
        'allowed' => 'string[]',
        'forbidden' => 'string[]',
        'requested' => 'string[]'
    );

    public static function swaggerTypes()
    {
        return self::$swaggerTypes;
    }

    /**
     * Array of attributes where the key is the local name, and the value is the original name
     * @var string[]
     */
    protected static $attributeMap = array(
        'allowed' => 'allowed',
        'forbidden' => 'forbidden',
        'requested' => 'requested'
    );

    public static function attributeMap()
    {
        return self::$attributeMap;
    }

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     * @var string[]
     */
    protected static $setters = array(
        'allowed' => 'setAllowed',
        'forbidden' => 'setForbidden',
        'requested' => 'setRequested'
    );

    public static function setters()
    {
        return self::$setters;
    }

    /**
     * Array of attributes to getter functions (for serialization of requests)
     * @var string[]
     */
    protected static $getters = array(
        'allowed' => 'getAllowed',
        'forbidden' => 'getForbidden',
        'requested' => 'getRequested'
    );

    public static function getters()
    {
        return self::$getters;
    }

    /**
     * Associative array for storing property values
     * @var mixed[]
     */
    protected $container = array();

    /**
     * Constructor
     * @param mixed[] $data Associated array of property value initalizing the model
     */
    public function __construct(array $data = null)
    {
        $this->container['allowed'] = isset($data['allowed']) ? $data['allowed'] : null;
        $this->container['forbidden'] = isset($data['forbidden']) ? $data['forbidden'] : null;
        $this->container['requested'] = isset($data['requested']) ? $data['requested'] : null;
    }

    /**
     * show all the invalid properties with reasons.
     *
     * @return array invalid properties with reasons
     */
    public function listInvalidProperties()
    {
        $invalid_properties = array();
        return $invalid_properties;
    }

    /**
     * validate all the properties in the model
     * return true if all passed
     *
     * @return bool True if all properteis are valid
     */
    public function valid()
    {
        return true;
    }

    /**
     * Gets allowed
     * @return string[]
     */
    public function getAllowed()
    {
        return $this->container['allowed'];
    }

    /**
     * Sets allowed
     * @param string[] $allowed
     * @return $this
     */
    public function setAllowed($allowed)
    {
        $this->container['allowed'] = $allowed;

        return $this;
    }

    /**
     * Gets forbidden
     * @return string[]
     */
    public function getForbidden()
    {
        return $this->container['forbidden'];
    }

    /**
     * Sets forbidden
     * @param string[] $forbidden
     * @return $this
     */
    public function setForbidden($forbidden)
    {
        $this->container['forbidden'] = $forbidden;

        return $this;
    }

    /**
     * Gets requested
     * @return string[]
     */
    public function getRequested()
    {
        return $this->container['requested'];
    }

    /**
     * Sets requested
     * @param string[] $requested
     * @return $this
     */
    public function setRequested($requested)
    {
        $this->container['requested'] = $requested;

        return $this;
    }
    /**
     * Returns true if offset exists. False otherwise.
     * @param  integer $offset Offset
     * @return boolean
     */
    public function offsetExists($offset)
    {
        return isset($this->container[$offset]);
    }

    /**
     * Gets offset.
     * @param  integer $offset Offset
     * @return mixed
     */
    public function offsetGet($offset)
    {
        return isset($this->container[$offset]) ? $this->container[$offset] : null;
    }

    /**
     * Sets value based on offset.
     * @param  integer $offset Offset
     * @param  mixed   $value  Value to be set
     * @return void
     */
    public function offsetSet($offset, $value)
    {
        if (is_null($offset)) {
            $this->container[] = $value;
        } else {
            $this->container[$offset] = $value;
        }
    }

    /**
     * Unsets offset.
     * @param  integer $offset Offset
     * @return void
     */
    public function offsetUnset($offset)
    {
        unset($this->container[$offset]);
    }

    /**
     * Gets the string presentation of the object
     * @return string
     */
    public function __toString()
    {
        if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print
            return json_encode(\Voximplant\ObjectSerializer::sanitizeForSerialization($this), JSON_PRETTY_PRINT);
        }

        return json_encode(\Voximplant\ObjectSerializer::sanitizeForSerialization($this));
    }
}


text:
using System.ServiceModel.Channels;
using System.ServiceModel.Dispatcher;
using System.Runtime.Serialization;
using System.Collections.Generic;
using System.Xml;

namespace System.ServiceModel.Description
{
    public class DataContractSerializerOperationBehavior : IOperationBehavior
    {
        private readonly bool _builtInOperationBehavior;

        private OperationDescription _operation;
        private DataContractFormatAttribute _dataContractFormatAttribute;
        internal bool ignoreExtensionDataObject = DataContractSerializerDefaults.IgnoreExtensionDataObject;
        private bool _ignoreExtensionDataObjectSetExplicit;
        internal int maxItemsInObjectGraph = DataContractSerializerDefaults.MaxItemsInObjectGraph;
        private bool _maxItemsInObjectGraphSetExplicit;
        private DataContractResolver _dataContractResolver;

        public DataContractFormatAttribute DataContractFormatAttribute
        {
            get { return _dataContractFormatAttribute; }
        }

        public DataContractSerializerOperationBehavior(OperationDescription operation)
            : this(operation, null)
        {
        }

        public DataContractSerializerOperationBehavior(OperationDescription operation, DataContractFormatAttribute dataContractFormatAttribute)
        {
            _dataContractFormatAttribute = dataContractFormatAttribute ?? new DataContractFormatAttribute();
            _operation = operation;
        }

        internal DataContractSerializerOperationBehavior(OperationDescription operation,
            DataContractFormatAttribute dataContractFormatAttribute, bool builtInOperationBehavior)
            : this(operation, dataContractFormatAttribute)
        {
            _builtInOperationBehavior = builtInOperationBehavior;
        }

        internal bool IsBuiltInOperationBehavior
        {
            get { return _builtInOperationBehavior; }
        }

        public int MaxItemsInObjectGraph
        {
            get { return maxItemsInObjectGraph; }
            set
            {
                maxItemsInObjectGraph = value;
                _maxItemsInObjectGraphSetExplicit = true;
            }
        }

        internal bool MaxItemsInObjectGraphSetExplicit
        {
            get { return _maxItemsInObjectGraphSetExplicit; }
            set { _maxItemsInObjectGraphSetExplicit = value; }
        }

        public bool IgnoreExtensionDataObject
        {
            get { return ignoreExtensionDataObject; }
            set
            {
                ignoreExtensionDataObject = value;
                _ignoreExtensionDataObjectSetExplicit = true;
            }
        }

        internal bool IgnoreExtensionDataObjectSetExplicit
        {
            get { return _ignoreExtensionDataObjectSetExplicit; }
            set { _ignoreExtensionDataObjectSetExplicit = value; }
        }

        public DataContractResolver DataContractResolver
        {
            get { return _dataContractResolver; }
            set { _dataContractResolver = value; }
        }

        public virtual XmlObjectSerializer CreateSerializer(Type type, string name, string ns, IList<Type> knownTypes)
        {
            XmlDictionary dictionary = new XmlDictionary(2);
            DataContractSerializerSettings settings = new DataContractSerializerSettings();
            settings.RootName = dictionary.Add(name);
            settings.RootNamespace = dictionary.Add(ns);
            settings.KnownTypes = knownTypes;
            settings.MaxItemsInObjectGraph = MaxItemsInObjectGraph;
            settings.DataContractResolver = DataContractResolver;
            return new DataContractSerializer(type, settings);
        }

        public virtual XmlObjectSerializer CreateSerializer(Type type, XmlDictionaryString name, XmlDictionaryString ns, IList<Type> knownTypes)
        {
            DataContractSerializerSettings settings = new DataContractSerializerSettings();
            settings.RootName = name;
            settings.RootNamespace = ns;
            settings.KnownTypes = knownTypes;
            settings.MaxItemsInObjectGraph = MaxItemsInObjectGraph;
            settings.DataContractResolver = DataContractResolver;
            return new DataContractSerializer(type, settings);
        }

        internal object GetFormatter(OperationDescription operation, out bool formatRequest, out bool formatReply, bool isProxy)
        {
            MessageDescription request = operation.Messages[0];
            MessageDescription response = null;
            if (operation.Messages.Count == 2)
                response = operation.Messages[1];

            formatRequest = (request != null) && !request.IsUntypedMessage;
            formatReply = (response != null) && !response.IsUntypedMessage;

            if (formatRequest || formatReply)
            {
                if (PrimitiveOperationFormatter.IsContractSupported(operation))
                    return new PrimitiveOperationFormatter(operation, _dataContractFormatAttribute.Style == OperationFormatStyle.Rpc);
                else
                    return new DataContractSerializerOperationFormatter(operation, _dataContractFormatAttribute, this);
            }

            return null;
        }

        void IOperationBehavior.Validate(OperationDescription description)
        {
        }

        void IOperationBehavior.AddBindingParameters(OperationDescription description, BindingParameterCollection parameters)
        {
        }

        void IOperationBehavior.ApplyDispatchBehavior(OperationDescription description, DispatchOperation dispatch)
        {
            if (description == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("description");

            if (dispatch == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("dispatch");

            if (dispatch.Formatter != null)
                return;

            bool formatRequest;
            bool formatReply;
            dispatch.Formatter = (IDispatchMessageFormatter)GetFormatter(description, out formatRequest, out formatReply, false);
            dispatch.DeserializeRequest = formatRequest;
            dispatch.SerializeReply = formatReply;
        }

        void IOperationBehavior.ApplyClientBehavior(OperationDescription description, ClientOperation proxy)
        {
            if (description == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("description");

            if (proxy == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("proxy");

            if (proxy.Formatter != null)
                return;

            bool formatRequest;
            bool formatReply;
            proxy.Formatter = (IClientMessageFormatter)GetFormatter(description, out formatRequest, out formatReply, true);
            proxy.SerializeRequest = formatRequest;
            proxy.DeserializeReply = formatReply;
        }
    }
}


text:
package com.opengamma.analytics.financial.provider.calculator.blackforex;

import com.opengamma.analytics.financial.forex.derivative.ForexOptionVanilla;
import com.opengamma.analytics.financial.forex.method.PresentValueForexBlackVolatilitySensitivity;
import com.opengamma.analytics.financial.forex.provider.ForexOptionVanillaBlackFlatMethod;
import com.opengamma.analytics.financial.interestrate.InstrumentDerivativeVisitorAdapter;
import com.opengamma.analytics.financial.provider.description.forex.BlackForexFlatProviderInterface;

/**
 * Calculates the sensitivity of the present value to the implied volatility used in pricing. The underlying pricing
 * model is a Black model without smile.
 */
public final class PresentValueForexVolatilitySensitivityForexBlackFlatCalculator extends
    InstrumentDerivativeVisitorAdapter<BlackForexFlatProviderInterface, PresentValueForexBlackVolatilitySensitivity> {

  /**
   * The unique instance of the calculator.
   */
  private static final PresentValueForexVolatilitySensitivityForexBlackFlatCalculator INSTANCE =
      new PresentValueForexVolatilitySensitivityForexBlackFlatCalculator();

  /**
   * Constructor.
   */
  private PresentValueForexVolatilitySensitivityForexBlackFlatCalculator() {
  }

  /**
   * Gets the calculator instance.
   * @return The calculator.
   */
  public static PresentValueForexVolatilitySensitivityForexBlackFlatCalculator getInstance() {
    return INSTANCE;
  }

  @Override
  public PresentValueForexBlackVolatilitySensitivity visitForexOptionVanilla(final ForexOptionVanilla option,
      final BlackForexFlatProviderInterface blackSmile) {
    return ForexOptionVanillaBlackFlatMethod.getInstance().presentValueBlackVolatilitySensitivity(option, blackSmile);
  }

}


text:
package org.durid.sql.ast.statement;

import org.durid.sql.ast.SQLName;
import org.durid.sql.ast.SQLObjectImpl;
import org.durid.sql.visitor.SQLASTVisitor;

public class SQLAlterTableDropIndex extends SQLObjectImpl implements SQLAlterTableItem {

    private static final long serialVersionUID = 1L;

    private SQLName           indexName;

    public SQLName getIndexName() {
        return indexName;
    }

    public void setIndexName(SQLName indexName) {
        this.indexName = indexName;
    }

    @Override
    protected void accept0(SQLASTVisitor visitor) {
        if (visitor.visit(this)) {
            acceptChild(visitor, indexName);
        }
        visitor.endVisit(this);
    }

}