text:
// Copyright (c) Microsoft.  All Rights Reserved.  Licensed under the Apache License, Version 2.0.  See License.txt in the project root for license information.

using System;
using System.Collections.Concurrent;
using System.Diagnostics;
using System.Text;
using Microsoft.CodeAnalysis.Collections;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Utilities;

namespace Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax
{
    /// <summary>
    /// Keeps a sliding buffer over the SourceText of a file for the lexer. Also
    /// provides the lexer with the ability to keep track of a current "lexeme"
    /// by leaving a marker and advancing ahead the offset. The lexer can then
    /// decide to "keep" the lexeme by erasing the marker, or abandon the current
    /// lexeme by moving the offset back to the marker.
    /// </summary>
    internal sealed class SlidingTextWindow : IDisposable
    {
        /// <summary>
        /// In many cases, e.g. PeekChar, we need the ability to indicate that there are
        /// no characters left and we have reached the end of the stream, or some other
        /// invalid or not present character was asked for. Due to perf concerns, things
        /// like nullable or out variables are not viable. Instead we need to choose a
        /// char value which can never be legal.
        ///
        /// In .NET, all characters are represented in 16 bits using the UTF-16 encoding.
        /// Fortunately for us, there are a variety of different bit patterns which
        /// are *not* legal UTF-16 characters. 0xffff (char.MaxValue) is one of these
        /// characters -- a legal Unicode code point, but not a legal UTF-16 bit pattern.
        /// </summary>
        public const char InvalidCharacter = char.MaxValue;

        private const int DefaultWindowLength = 2048;

        private readonly SourceText _text;                 // Source of text to parse.
        private int _basis;                                // Offset of the window relative to the SourceText start.
        private int _offset;                               // Offset from the start of the window.
        private readonly int _textEnd;                     // Absolute end position
        private char[] _characterWindow;                   // Moveable window of chars from source text
        private int _characterWindowCount;                 // # of valid characters in chars buffer

        private int _lexemeStart;                          // Start of current lexeme relative to the window start.

        // Example for the above variables:
        // The text starts at 0.
        // The window onto the text starts at basis.
        // The current character is at (basis + offset), AKA the current "Position".
        // The current lexeme started at (basis + lexemeStart), which is <= (basis + offset)
        // The current lexeme is the characters between the lexemeStart and the offset.

        private readonly StringTable _strings;

        private static readonly ObjectPool<char[]> s_windowPool = new ObjectPool<char[]>(() => new char[DefaultWindowLength]);

        public SlidingTextWindow(SourceText text)
        {
            _text = text;
            _basis = 0;
            _offset = 0;
            _textEnd = text.Length;
            _strings = StringTable.GetInstance();
            _characterWindow = s_windowPool.Allocate();
            _lexemeStart = 0;
        }

        public void Dispose()
        {
            if (_characterWindow != null)
            {
                s_windowPool.Free(_characterWindow);
                _characterWindow = null;
                _strings.Free();
            }
        }

        public SourceText Text
        {
            get
            {
                return _text;
            }
        }

        /// <summary>
        /// The current absolute position in the text file.
        /// </summary>
        public int Position
        {
            get
            {
                return _basis + _offset;
            }
        }

        /// <summary>
        /// The current offset inside the window (relative to the window start).
        /// </summary>
        public int Offset
        {
            get
            {
                return _offset;
            }
        }

        /// <summary>
        /// The buffer backing the current window.
        /// </summary>
        public char[] CharacterWindow
        {
            get
            {
                return _characterWindow;
            }
        }

        /// <summary>
        /// Returns the start of the current lexeme relative to the window start.
        /// </summary>
        public int LexemeRelativeStart
        {
            get
            {
                return _lexemeStart;
            }
        }

        /// <summary>
        /// Number of characters in the character window.
        /// </summary>
        public int CharacterWindowCount
        {
            get
            {
                return _characterWindowCount;
            }
        }

        /// <summary>
        /// The absolute position of the start of the current lexeme in the given
        /// SourceText.
        /// </summary>
        public int LexemeStartPosition
        {
            get
            {
                return _basis + _lexemeStart;
            }
        }

        /// <summary>
        /// The number of characters in the current lexeme.
        /// </summary>
        public int Width
        {
            get
            {
                return _offset - _lexemeStart;
            }
        }

        /// <summary>
        /// Start parsing a new lexeme.
        /// </summary>
        public void Start()
        {
            _lexemeStart = _offset;
        }

        public void Reset(int position)
        {
            // if position is within already read character range then just use what we have
            int relative = position - _basis;
            if (relative >= 0 && relative <= _characterWindowCount)
            {
                _offset = relative;
            }
            else
            {
                // we need to reread text buffer
                int amountToRead = Math.Min(_text.Length, position + _characterWindow.Length) - position;
                amountToRead = Math.Max(amountToRead, 0);
                if (amountToRead > 0)
                {
                    _text.CopyTo(position, _characterWindow, 0, amountToRead);
                }

                _lexemeStart = 0;
                _offset = 0;
                _basis = position;
                _characterWindowCount = amountToRead;
            }
        }

        private bool MoreChars()
        {
            if (_offset >= _characterWindowCount)
            {
                if (this.Position >= _textEnd)
                {
                    return false;
                }

                // if lexeme scanning is sufficiently into the char buffer,
                // then refocus the window onto the lexeme
                if (_lexemeStart > (_characterWindowCount / 4))
                {
                    Array.Copy(_characterWindow,
                        _lexemeStart,
                        _characterWindow,
                        0,
                        _characterWindowCount - _lexemeStart);
                    _characterWindowCount -= _lexemeStart;
                    _offset -= _lexemeStart;
                    _basis += _lexemeStart;
                    _lexemeStart = 0;
                }

                if (_characterWindowCount >= _characterWindow.Length)
                {
                    // grow char array, since we need more contiguous space
                    char[] oldWindow = _characterWindow;
                    char[] newWindow = new char[_characterWindow.Length * 2];
                    Array.Copy(oldWindow, 0, newWindow, 0, _characterWindowCount);
                    s_windowPool.ForgetTrackedObject(oldWindow, newWindow);
                    _characterWindow = newWindow;
                }

                int amountToRead = Math.Min(_textEnd - (_basis + _characterWindowCount),
                    _characterWindow.Length - _characterWindowCount);
                _text.CopyTo(_basis + _characterWindowCount,
                    _characterWindow,
                    _characterWindowCount,
                    amountToRead);
                _characterWindowCount += amountToRead;
                return amountToRead > 0;
            }

            return true;
        }

        /// <summary>
        /// After reading <see cref=" InvalidCharacter"/>, a consumer can determine
        /// if the InvalidCharacter was in the user's source or a sentinel.
        ///
        /// Comments and string literals are allowed to contain any Unicode character.
        /// </summary>
        /// <returns></returns>
        internal bool IsReallyAtEnd()
        {
            return _offset >= _characterWindowCount && Position >= _textEnd;
        }

        /// <summary>
        /// Advance the current position by one. No guarantee that this
        /// position is valid.
        /// </summary>
        public void AdvanceChar()
        {
            _offset++;
        }

        /// <summary>
        /// Advance the current position by n. No guarantee that this position
        /// is valid.
        /// </summary>
        public void AdvanceChar(int n)
        {
            _offset += n;
        }

        /// <summary>
        /// Grab the next character and advance the position.
        /// </summary>
        /// <returns>
        /// The next character, <see cref="InvalidCharacter" /> if there were no characters
        /// remaining.
        /// </returns>
        public char NextChar()
        {
            char c = PeekChar();
            if (c != InvalidCharacter)
            {
                this.AdvanceChar();
            }
            return c;
        }

        /// <summary>
        /// Gets the next character if there are any characters in the
        /// SourceText. May advance the window if we are at the end.
        /// </summary>
        /// <returns>
        /// The next character if any are available. InvalidCharacterSentinal otherwise.
        /// </returns>
        public char PeekChar()
        {
            if (_offset >= _characterWindowCount
                && !MoreChars())
            {
                return InvalidCharacter;
            }

            // N.B. MoreChars may update the offset.
            return _characterWindow[_offset];
        }

        /// <summary>
        /// Gets the character at the given offset to the current position if
        /// the position is valid within the SourceText.
        /// </summary>
        /// <returns>
        /// The next character if any are available. InvalidCharacterSentinal otherwise.
        /// </returns>
        public char PeekChar(int delta)
        {
            int position = this.Position;
            this.AdvanceChar(delta);

            char ch;
            if (_offset >= _characterWindowCount
                && !MoreChars())
            {
                ch = InvalidCharacter;
            }
            else
            {
                // N.B. MoreChars may update the offset.
                ch = _characterWindow[_offset];
            }

            this.Reset(position);
            return ch;
        }

        public bool IsUnicodeEscape()
        {
            if (this.PeekChar() == '\\')
            {
                var ch2 = this.PeekChar(1);
                if (ch2 == 'U' || ch2 == 'u')
                {
                    return true;
                }
            }

            return false;
        }

        public char PeekCharOrUnicodeEscape(out char surrogateCharacter)
        {
            if (this.IsUnicodeEscape())
            {
                return this.PeekUnicodeEscape(out surrogateCharacter);
            }
            else
            {
                surrogateCharacter = InvalidCharacter;
                return this.PeekChar();
            }
        }

        public char PeekUnicodeEscape(out char surrogateCharacter)
        {
            int position = this.Position;

            // if we're peeking, then we don't want to change the position
            SyntaxDiagnosticInfo info;
            var ch = this.ScanUnicodeEscape(peek: true, surrogateCharacter: out surrogateCharacter, info: out info);
            Debug.Assert(info == null, "Never produce a diagnostic while peeking.");
            this.Reset(position);
            return ch;
        }

        public char NextCharOrUnicodeEscape(out char surrogateCharacter, out SyntaxDiagnosticInfo info)
        {
            var ch = this.PeekChar();
            Debug.Assert(ch != InvalidCharacter, "Precondition established by all callers; required for correctness of AdvanceChar() call.");
            if (ch == '\\')
            {
                var ch2 = this.PeekChar(1);
                if (ch2 == 'U' || ch2 == 'u')
                {
                    return this.ScanUnicodeEscape(peek: false, surrogateCharacter: out surrogateCharacter, info: out info);
                }
            }

            surrogateCharacter = InvalidCharacter;
            info = null;
            this.AdvanceChar();
            return ch;
        }

        public char NextUnicodeEscape(out char surrogateCharacter, out SyntaxDiagnosticInfo info)
        {
            return ScanUnicodeEscape(peek: false, surrogateCharacter: out surrogateCharacter, info: out info);
        }

        private char ScanUnicodeEscape(bool peek, out char surrogateCharacter, out SyntaxDiagnosticInfo info)
        {
            surrogateCharacter = InvalidCharacter;
            info = null;

            int start = this.Position;
            char character = this.PeekChar();
            Debug.Assert(character == '\\');
            this.AdvanceChar();

            character = this.PeekChar();
            if (character == 'U')
            {
                uint uintChar = 0;

                this.AdvanceChar();
                if (!SyntaxFacts.IsHexDigit(this.PeekChar()))
                {
                    if (!peek)
                    {
                        info = CreateIllegalEscapeDiagnostic(start);
                    }
                }
                else
                {
                    for (int i = 0; i < 8; i++)
                    {
                        character = this.PeekChar();
                        if (!SyntaxFacts.IsHexDigit(character))
                        {
                            if (!peek)
                            {
                                info = CreateIllegalEscapeDiagnostic(start);
                            }

                            break;
                        }

                        uintChar = (uint)((uintChar << 4) + SyntaxFacts.HexValue(character));
                        this.AdvanceChar();
                    }

                    if (uintChar > 0x0010FFFF)
                    {
                        if (!peek)
                        {
                            info = CreateIllegalEscapeDiagnostic(start);
                        }
                    }
                    else
                    {
                        character = GetCharsFromUtf32(uintChar, out surrogateCharacter);
                    }
                }
            }
            else
            {
                Debug.Assert(character == 'u' || character == 'x');

                int intChar = 0;
                this.AdvanceChar();
                if (!SyntaxFacts.IsHexDigit(this.PeekChar()))
                {
                    if (!peek)
                    {
                        info = CreateIllegalEscapeDiagnostic(start);
                    }
                }
                else
                {
                    for (int i = 0; i < 4; i++)
                    {
                        char ch2 = this.PeekChar();
                        if (!SyntaxFacts.IsHexDigit(ch2))
                        {
                            if (character == 'u')
                            {
                                if (!peek)
                                {
                                    info = CreateIllegalEscapeDiagnostic(start);
                                }
                            }

                            break;
                        }

                        intChar = (intChar << 4) + SyntaxFacts.HexValue(ch2);
                        this.AdvanceChar();
                    }

                    character = (char)intChar;
                }
            }

            return character;
        }

        /// <summary>
        /// Given that the next character is an ampersand ('&'), attempt to interpret the
        /// following characters as an XML entity.  On success, populate the out parameters
        /// with the low and high UTF-16 surrogates for the character represented by the
        /// entity.
        /// </summary>
        /// <param name="ch">e.g. '<' for &lt;.</param>
        /// <param name="surrogate">e.g. '\uDC00' for &#x10000; (ch == '\uD800').</param>
        /// <returns>True if a valid XML entity was consumed.</returns>
        /// <remarks>
        /// NOTE: Always advances, even on failure.
        /// </remarks>
        public bool TryScanXmlEntity(out char ch, out char surrogate)
        {
            Debug.Assert(this.PeekChar() == '&');

            ch = '&';
            this.AdvanceChar();

            surrogate = InvalidCharacter;

            switch (this.PeekChar())
            {
                case 'l':
                    if (AdvanceIfMatches("lt;"))
                    {
                        ch = '<';
                        return true;
                    }
                    break;
                case 'g':
                    if (AdvanceIfMatches("gt;"))
                    {
                        ch = '>';
                        return true;
                    }
                    break;
                case 'a':
                    if (AdvanceIfMatches("amp;"))
                    {
                        ch = '&';
                        return true;
                    }
                    else if (AdvanceIfMatches("apos;"))
                    {
                        ch = '\'';
                        return true;
                    }
                    break;
                case 'q':
                    if (AdvanceIfMatches("quot;"))
                    {
                        ch = '"';
                        return true;
                    }
                    break;
                case '#':
                    {
                        this.AdvanceChar(); //#

                        uint uintChar = 0;

                        if (AdvanceIfMatches("x"))
                        {
                            char digit;
                            while (SyntaxFacts.IsHexDigit(digit = this.PeekChar()))
                            {
                                this.AdvanceChar();

                                // disallow overflow
                                if (uintChar <= 0x7FFFFFF)
                                {
                                    uintChar = (uintChar << 4) + (uint)SyntaxFacts.HexValue(digit);
                                }
                                else
                                {
                                    return false;
                                }
                            }
                        }
                        else
                        {
                            char digit;
                            while (SyntaxFacts.IsDecDigit(digit = this.PeekChar()))
                            {
                                this.AdvanceChar();

                                // disallow overflow
                                if (uintChar <= 0x7FFFFFF)
                                {
                                    uintChar = (uintChar << 3) + (uintChar << 1) + (uint)SyntaxFacts.DecValue(digit);
                                }
                                else
                                {
                                    return false;
                                }
                            }
                        }

                        if (AdvanceIfMatches(";"))
                        {
                            ch = GetCharsFromUtf32(uintChar, out surrogate);
                            return true;
                        }

                        break;
                    }
            }

            return false;
        }

        /// <summary>
        /// If the next characters in the window match the given string,
        /// then advance past those characters.  Otherwise, do nothing.
        /// </summary>
        private bool AdvanceIfMatches(string desired)
        {
            int length = desired.Length;

            for (int i = 0; i < length; i++)
            {
                if (PeekChar(i) != desired[i])
                {
                    return false;
                }
            }

            AdvanceChar(length);
            return true;
        }

        private SyntaxDiagnosticInfo CreateIllegalEscapeDiagnostic(int start)
        {
            return new SyntaxDiagnosticInfo(start - this.LexemeStartPosition,
                this.Position - start,
                ErrorCode.ERR_IllegalEscape);
        }

        public string Intern(StringBuilder text)
        {
            return _strings.Add(text);
        }

        public string Intern(char[] array, int start, int length)
        {
            return _strings.Add(array, start, length);
        }

        public string GetInternedText()
        {
            return this.Intern(_characterWindow, _lexemeStart, this.Width);
        }

        public string GetText(bool intern)
        {
            return this.GetText(this.LexemeStartPosition, this.Width, intern);
        }

        public string GetText(int position, int length, bool intern)
        {
            int offset = position - _basis;

            // PERF: Whether interning or not, there are some frequently occurring
            // easy cases we can pick off easily.
            switch (length)
            {
                case 0:
                    return string.Empty;

                case 1:
                    if (_characterWindow[offset] == ' ')
                    {
                        return " ";
                    }
                    break;

                case 2:
                    char firstChar = _characterWindow[offset];
                    if (firstChar == '\r' && _characterWindow[offset + 1] == '\n')
                    {
                        return "\r\n";
                    }
                    if (firstChar == '/' && _characterWindow[offset + 1] == '/')
                    {
                        return "//";
                    }
                    break;

                case 3:
                    if (_characterWindow[offset] == '/' && _characterWindow[offset + 1] == '/' && _characterWindow[offset + 2] == ' ')
                    {
                        return "// ";
                    }
                    break;
            }

            if (intern)
            {
                return this.Intern(_characterWindow, offset, length);
            }
            else
            {
                return new string(_characterWindow, offset, length);
            }
        }

        internal static char GetCharsFromUtf32(uint codepoint, out char lowSurrogate)
        {
            if (codepoint < (uint)0x00010000)
            {
                lowSurrogate = InvalidCharacter;
                return (char)codepoint;
            }
            else
            {
                Debug.Assert(codepoint > 0x0000FFFF && codepoint <= 0x0010FFFF);
                lowSurrogate = (char)((codepoint - 0x00010000) % 0x0400 + 0xDC00);
                return (char)((codepoint - 0x00010000) / 0x0400 + 0xD800);
            }
        }
    }
}


text:
package de.ailis.jollada.model;

/**
 * A light.
 *
 * @author Klaus Reimer (k@ailis.de)
 */

public final class Light extends Element implements Identifiable,
        AssetElement
{
    /** Serial version UID. */
    private static final long serialVersionUID = 1L;

    /** The light name. */
    private String name;

    /** Asset-management information. */
    private Asset asset;

    /** The common technique. */
    private CommonLightTechnique commonTechnique;

    /**
     * Constructor.
     *
     * @param commonTechnique
     *            The common light technique. Must not be null.
     */

    public Light(final CommonLightTechnique commonTechnique)
    {
        setCommonTechnique(commonTechnique);
    }

    /**
     * Returns the id.
     *
     * @return The id. May be null if not set.
     */

    @Override
    public String getId()
    {
        return this.id;
    }

    /**
     * Sets the id.
     *
     * @param id
     *            The id to set. Null to unset.
     */

    @Override
    public void setId(final String id)
    {
        super.updateId(id);
    }

    /**
     * Returns the name.
     *
     * @return The name. May be null if not set.
     */

    public String getName()
    {
        return this.name;
    }

    /**
     * Sets the name.
     *
     * @param name
     *            The name to set. Null to unset.
     */

    public void setName(final String name)
    {
        this.name = name;
    }

    /**
     * Returns the asset-management information.
     *
     * @return The asset-management information. May be null if not set.
     */

    @Override
    public Asset getAsset()
    {
        return this.asset;
    }

    /**
     * Sets the asset-management information.
     *
     * @param asset
     *            The asset-management information to set. Null to unset.
     */

    public void setAsset(final Asset asset)
    {
        this.asset = asset;
    }

    /**
     * Returns the common technique.
     *
     * @return The common technique. Never null.
     */

    public CommonLightTechnique getCommonTechnique()
    {
        return this.commonTechnique;
    }

    /**
     * Sets the common technique.
     *
     * @param commonTechnique
     *            The common technique to set. Must not be null.
     */

    public void setCommonTechnique(final CommonLightTechnique commonTechnique)
    {
        if (commonTechnique == null)
            throw new IllegalArgumentException(
                "commonTechnique must not be null");
        if (commonTechnique != this.commonTechnique)
        {
            if (this.commonTechnique != null)
                removeChild(this.commonTechnique);
            this.commonTechnique = commonTechnique;
            addChild(commonTechnique);
        }
    }
}

redpajama_set_name: RedPajamaGithub


text:
import chai 		= require('chai');
import zip 			= require('../src/ZipCodeValidator');

var assert = chai.assert;
var expect = chai.expect;

describe('ZipCodeValidator#isAcceptable', function(){
	it('five-digit number counts as zip code', function() {
		var v = new zip.ZipCodeValidator();
		expect( v.isAcceptable( "11111" ) ).to.be.equals(true);
	});

	it('four-digit number is not acceptable', function() {
		var v = new zip.ZipCodeValidator();
		expect( v.isAcceptable( "2222" ) ).to.be.equals(false);
	});

	it('letters are not acceptable', function() {
		var v = new zip.ZipCodeValidator();
		expect( v.isAcceptable( "abcde" ) ).to.be.equals(false);
	});
})


text:
package com.genexplain.api.app;

import static org.junit.Assert.*;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import com.genexplain.api.app.test.TestApplicationCommand2;

/**
 * @author pst
 *
 */
public class APIRunnerTest {

    @Rule
    public final ExpectedException exception = ExpectedException.none();

    @Test
    public void printsHelpForNoArgs() throws Exception {
        PrintStream           stdOut  = System.out;
        ByteArrayOutputStream ostream = new ByteArrayOutputStream();
        System.setOut(new PrintStream(ostream));

        try {
            APIRunner.main(new String[]{});
            String out = ostream.toString();
            assertTrue(out.length() > 0);
            assertTrue(out.contains(APIRunner.API_PACKAGE_PROPERTY));
        } finally {
            System.setOut(stdOut);
        }
    }

    @Test
    public void usesDefaultApiPackages() throws Exception {
        System.setProperty(APIRunner.API_PACKAGE_PROPERTY, "");
        APIRunner.main(new String[]{"test-command"});
        assertEquals(TestApplicationCommand.getInstances(),1);
        System.setProperty(APIRunner.API_PACKAGE_PROPERTY, "");
    }

    @Test
    public void canSpecifyApiPackages() throws Exception {
        System.setProperty(APIRunner.API_PACKAGE_PROPERTY, "com.genexplain.api.app.test");
        APIRunner.main(new String[]{"test-command-2"});
        assertEquals(TestApplicationCommand2.getInstances(),1);
        System.setProperty(APIRunner.API_PACKAGE_PROPERTY, "");
    }

    @Test
    public void exceptionForDuplicateCommands() throws Exception {
        try {
            System.setProperty(APIRunner.API_PACKAGE_PROPERTY, "com.genexplain.api:com.genexplain.fail");
            exception.expect(UnsupportedOperationException.class);
            APIRunner.main(new String[]{"test-command"});
        } finally {
            System.setProperty(APIRunner.API_PACKAGE_PROPERTY, "");
        }
    }

    @Test
    public void stdoutAndExceptionForUnknownCommand() throws Exception {
        System.setProperty(APIRunner.API_PACKAGE_PROPERTY, "");
        PrintStream           stdOut  = System.out;
        ByteArrayOutputStream ostream = new ByteArrayOutputStream();
        System.setOut(new PrintStream(ostream));

        try {
            exception.expect(IllegalArgumentException.class);
            APIRunner.main(new String[]{"unknown-test-command"});
            String out = ostream.toString();
            assertTrue(out.length() > 0);
            assertTrue(out.contains(APIRunner.API_PACKAGE_PROPERTY));
        } finally {
            System.setOut(stdOut);
        }
    }

}


text:
package net.roryclaasen.sandbox.RenderEngine;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import net.roryclaasen.sandbox.RenderEngine.entity.EntityRenderer;
import net.roryclaasen.sandbox.RenderEngine.shaddow.ShadowMapMasterRenderer;
import net.roryclaasen.sandbox.RenderEngine.shaders.StaticShader;
import net.roryclaasen.sandbox.RenderEngine.skybox.Skybox;
import net.roryclaasen.sandbox.RenderEngine.skybox.SkyboxRenderer;
import net.roryclaasen.sandbox.RenderEngine.terrain.TerrainRenderer;
import net.roryclaasen.sandbox.RenderEngine.terrain.TerrainShader;
import net.roryclaasen.sandbox.RenderEngine.terrain.water.WaterFrameBuffers;
import net.roryclaasen.sandbox.RenderEngine.terrain.water.WaterRenderer;
import net.roryclaasen.sandbox.RenderEngine.terrain.water.WaterShader;
import net.roryclaasen.sandbox.entities.Camera;
import net.roryclaasen.sandbox.entities.Entity;
import net.roryclaasen.sandbox.entities.EntityManager;
import net.roryclaasen.sandbox.entities.light.Light;
import net.roryclaasen.sandbox.models.TexturedModel;
import net.roryclaasen.sandbox.terrain.Terrain;
import net.roryclaasen.sandbox.terrain.TerrainManager;
import net.roryclaasen.sandbox.util.Loader;
import net.roryclaasen.sandbox.util.config.Config;

import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL13;
import org.lwjgl.util.vector.Matrix4f;
import org.lwjgl.util.vector.Vector3f;
import org.lwjgl.util.vector.Vector4f;

public class MasterRenderer {

	public static final float FOV = Config.fov.get();
	public static final float PLAIN_NEAR = 0.01F;
	public static final float PLAIN_FAR = 1000F;

	private Loader loader;

	private Vector3f fogColour = Skybox.getFogColour();

	private Matrix4f projectionMatrix;

	private StaticShader shader = new StaticShader();
	private EntityRenderer entityRenderer;

	private TerrainShader terrainShader = new TerrainShader();
	private TerrainRenderer terrainRenderer;

	private SkyboxRenderer skyboxRenderer;

	private WaterShader waterShader = new WaterShader();
	private WaterRenderer waterRenderer;

	private ShadowMapMasterRenderer shadowMapRenderer;

	private Map<TexturedModel, List<Entity>> entities = new HashMap<TexturedModel, List<Entity>>();
	private List<Terrain> terrains = new ArrayList<Terrain>();

	public MasterRenderer(Loader loader, Camera camera) {
		this.loader = loader;
		enableCulling();
		createProjectionMatrix();
		entityRenderer = new EntityRenderer(shader, projectionMatrix);
		terrainRenderer = new TerrainRenderer(terrainShader, projectionMatrix);
		skyboxRenderer = new SkyboxRenderer(loader, projectionMatrix);
		shadowMapRenderer = new ShadowMapMasterRenderer(camera);
	}

	public static void enableCulling() {
		GL11.glEnable(GL11.GL_CULL_FACE);
		GL11.glCullFace(GL11.GL_BACK);
	}

	public static void disableCulling() {
		GL11.glDisable(GL11.GL_CULL_FACE);
	}

	public void renderScene(EntityManager entityManager, TerrainManager terrainManager, Camera camera, Vector4f clipPlane) {
		fogColour = Skybox.getFogColour();
		for (Terrain terrain : terrainManager.getTerrains()) {
			processTerrain(terrain);
		}
		entityManager.render(this);

		render(entityManager.getNearestLights(), camera, clipPlane);
	}

	public void setUpWaterRenderer(WaterFrameBuffers buffers) {
		waterRenderer = new WaterRenderer(loader, waterShader, projectionMatrix, buffers);
	}

	public void renderWater(TerrainManager terrainManager, Camera camera, Light sun) {
		waterRenderer.render(terrainManager.getWaters(), camera, sun);
	}

	public void render(List<Light> lights, Camera camera, Vector4f clipPlane) {
		prepare();
		shader.start();
		shader.loadClipPlane(clipPlane);
		shader.loadSkyClourVariable(fogColour.x, fogColour.y, fogColour.z);
		shader.loadLights(lights);
		shader.loadViewMatrix(camera);
		entityRenderer.render(entities, shadowMapRenderer.getToShadowMapSpaceMatrix());
		shader.stop();
		terrainShader.start();
		terrainShader.loadClipPlane(clipPlane);
		terrainShader.loadSkyColorVariable(fogColour.x, fogColour.y, fogColour.z);
		terrainShader.loadLights(lights);
		terrainShader.loadViewMatrix(camera);
		terrainRenderer.render(terrains, shadowMapRenderer.getToShadowMapSpaceMatrix());
		terrainShader.stop();
		skyboxRenderer.render(camera, fogColour.x, fogColour.y, fogColour.z);

		GL11.glShadeModel(GL11.GL_SMOOTH);
		entities.clear();
		terrains.clear();
	}

	public void prepare() {
		GL11.glShadeModel(GL11.GL_FLAT);
		GL11.glEnable(GL11.GL_DEPTH_TEST);
		GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
		GL11.glClearColor(fogColour.x, fogColour.y, fogColour.z, 1);
		GL13.glActiveTexture(GL13.GL_TEXTURE5);
		GL11.glBindTexture(GL11.GL_TEXTURE_2D, getShadowmapTexture());
	}

	public void createProjectionMatrix() {
		projectionMatrix = new Matrix4f();
		float aspectRatio = (float) Display.getWidth() / (float) Display.getHeight();
		float y_scale = (float) ((1f / Math.tan(Math.toRadians(FOV / 2f))));
		float x_scale = y_scale / aspectRatio;
		float frustum_length = PLAIN_FAR - PLAIN_NEAR;

		projectionMatrix.m00 = x_scale;
		projectionMatrix.m11 = y_scale;
		projectionMatrix.m22 = -((PLAIN_FAR + PLAIN_NEAR) / frustum_length);
		projectionMatrix.m23 = -1;
		projectionMatrix.m32 = -((2 * PLAIN_NEAR * PLAIN_FAR) / frustum_length);
		projectionMatrix.m33 = 0;
	}

	public Matrix4f getProjectionMatrix() {
		return projectionMatrix;
	}

	public void processTerrain(Terrain terrain) {
		terrains.add(terrain);
	}

	public void renderShadowMap(List<Entity> entityList, Light sun) {
		for (Entity entity : entityList) {
			processEntity(entity);
		}
		shadowMapRenderer.render(entities, sun);
		entities.clear();
	}

	public int getShadowmapTexture() {
		return shadowMapRenderer.getShadowMap();
	}

	public void processEntity(Entity entity) {
		TexturedModel entityModel = entity.getModel();
		List<Entity> batch = entities.get(entityModel);
		if (batch != null) batch.add(entity);
		else {
			List<Entity> newBatch = new ArrayList<Entity>();
			newBatch.add(entity);
			entities.put(entityModel, newBatch);
		}
	}

	public void cleanUp() {
		shader.cleanUp();
		terrainShader.cleanUp();
		waterShader.cleanUp();
		shadowMapRenderer.cleanUp();
	}

}


text:
namespace XHTMLClassLibrary.BaseElements.InlineElements.TextBasedElements
{
    /// <summary>
    /// The em element is used to indicate emphasis.
    /// </summary>
    [HTMLItemAttribute(ElementName = "em", SupportedStandards = HTMLElementType.HTML5 |  HTMLElementType.XHTML5 | HTMLElementType.XHTML11 | HTMLElementType.Transitional | HTMLElementType.Strict | HTMLElementType.FrameSet)]
    public class EmphasisedText : TextBasedElement
    {
        public EmphasisedText(HTMLElementType htmlStandard) : base(htmlStandard)
        {
        }
    }
}


text:
package guru.nidi.ramltester.core;

/**
 *
 */
class IllegalVariablePatternException extends RuntimeException {
    private final String pattern;

    public IllegalVariablePatternException(String message, String pattern) {
        super(message);
        this.pattern = pattern;
    }

    public String getPattern() {
        return pattern;
    }
}


text:
#pragma once

#include <wtf/text/AtomicString.h>

#if ENABLE(VIEW_MODE_CSS_MEDIA)
#define CSS_MEDIAQUERY_VIEW_MODE(macro) macro(viewMode, "-webkit-view-mode")
#else
#define CSS_MEDIAQUERY_VIEW_MODE(macro)
#endif

#define CSS_MEDIAQUERY_NAMES_FOR_EACH_MEDIAFEATURE(macro) \
    macro(animation, "-webkit-animation") \
    macro(anyHover, "any-hover") \
    macro(anyPointer, "any-pointer") \
    macro(aspectRatio, "aspect-ratio") \
    macro(color, "color") \
    macro(colorGamut, "color-gamut") \
    macro(colorIndex, "color-index") \
    macro(deviceAspectRatio, "device-aspect-ratio") \
    macro(deviceHeight, "device-height") \
    macro(devicePixelRatio, "-webkit-device-pixel-ratio") \
    macro(deviceWidth, "device-width") \
    macro(grid, "grid") \
    macro(height, "height") \
    macro(hover, "hover") \
    macro(invertedColors, "inverted-colors") \
    macro(maxAspectRatio, "max-aspect-ratio") \
    macro(maxColor, "max-color") \
    macro(maxColorIndex, "max-color-index") \
    macro(maxDeviceAspectRatio, "max-device-aspect-ratio") \
    macro(maxDeviceHeight, "max-device-height") \
    macro(maxDevicePixelRatio, "-webkit-max-device-pixel-ratio") \
    macro(maxDeviceWidth, "max-device-width") \
    macro(maxHeight, "max-height") \
    macro(maxMonochrome, "max-monochrome") \
    macro(maxResolution, "max-resolution") \
    macro(maxWidth, "max-width") \
    macro(minAspectRatio, "min-aspect-ratio") \
    macro(minColor, "min-color") \
    macro(minColorIndex, "min-color-index") \
    macro(minDeviceAspectRatio, "min-device-aspect-ratio") \
    macro(minDeviceHeight, "min-device-height") \
    macro(minDevicePixelRatio, "-webkit-min-device-pixel-ratio") \
    macro(minDeviceWidth, "min-device-width") \
    macro(minHeight, "min-height") \
    macro(minMonochrome, "min-monochrome") \
    macro(minResolution, "min-resolution") \
    macro(minWidth, "min-width") \
    macro(monochrome, "monochrome") \
    macro(orientation, "orientation") \
    macro(pointer, "pointer") \
    macro(resolution, "resolution") \
    macro(transform2d, "-webkit-transform-2d") \
    macro(transform3d, "-webkit-transform-3d") \
    macro(transition, "-webkit-transition") \
    macro(videoPlayableInline, "-webkit-video-playable-inline") \
    macro(width, "width") \
    CSS_MEDIAQUERY_VIEW_MODE(macro)

// end of macro

namespace WebCore {
namespace MediaFeatureNames {

#ifndef CSS_MEDIAQUERY_NAMES_HIDE_GLOBALS
#define CSS_MEDIAQUERY_NAMES_DECLARE(name, string) extern const AtomicString name;
    CSS_MEDIAQUERY_NAMES_FOR_EACH_MEDIAFEATURE(CSS_MEDIAQUERY_NAMES_DECLARE)
#undef CSS_MEDIAQUERY_NAMES_DECLARE
#endif

    void init();

} // namespace MediaFeatureNames
} // namespace WebCore


text:
<?php

namespace Kazoo\Api\Entity;

class MyList extends AbstractEntity
{
    /**
     * Automagic used to determine the URL snippet.
     * This should be implemented in the entity class if
     * it is an exception to the standard naming.
     *
     */
/*    protected function getUriSnippet() {
        $entityIdName = $this->getEntityIdName();
        return "/lists/"."{{$entityIdName}}";
    } */

}


text:
.btn-default,
.btn-primary,
.btn-success,
.btn-info,
.btn-warning,
.btn-danger {
  text-shadow: 0 -1px 0 rgba(0, 0, 0, .2);
  -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .15), 0 1px 1px rgba(0, 0, 0, .075);
          box-shadow: inset 0 1px 0 rgba(255, 255, 255, .15), 0 1px 1px rgba(0, 0, 0, .075);
}
.btn-default:active,
.btn-primary:active,
.btn-success:active,
.btn-info:active,
.btn-warning:active,
.btn-danger:active,
.btn-default.active,
.btn-primary.active,
.btn-success.active,
.btn-info.active,
.btn-warning.active,
.btn-danger.active {
  -webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);
          box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);
}
.btn:active,
.btn.active {
  background-image: none;
}
.btn-default {
  text-shadow: 0 1px 0 #fff;
  background-image: -webkit-linear-gradient(top, #fff 0%, #e0e0e0 100%);
  background-image:         linear-gradient(to bottom, #fff 0%, #e0e0e0 100%);
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffe0e0e0', GradientType=0);
  filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
  background-repeat: repeat-x;
  border-color: #dbdbdb;
  border-color: #ccc;
}
.btn-default:hover,
.btn-default:focus {
  background-color: #e0e0e0;
  background-position: 0 -15px;
}
.btn-default:active,
.btn-default.active {
  background-color: #e0e0e0;
  border-color: #dbdbdb;
}
.btn-primary {
  background-image: -webkit-linear-gradient(top, #428bca 0%, #2d6ca2 100%);
  background-image:         linear-gradient(to bottom, #428bca 0%, #2d6ca2 100%);
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff428bca', endColorstr='#ff2d6ca2', GradientType=0);
  filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
  background-repeat: repeat-x;
  border-color: #2b669a;
}
.btn-primary:hover,
.btn-primary:focus {
  background-color: #2d6ca2;
  background-position: 0 -15px;
}
.btn-primary:active,
.btn-primary.active {
  background-color: #2d6ca2;
  border-color: #2b669a;
}
.btn-success {
  background-image: -webkit-linear-gradient(top, #79db32 0%, #5cb11f 100%);
  background-image:         linear-gradient(to bottom, #79db32 0%, #5cb11f 100%);
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff79db32', endColorstr='#ff5cb11f', GradientType=0);
  filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
  background-repeat: repeat-x;
  border-color: #58a81e;
}
.btn-success:hover,
.btn-success:focus {
  background-color: #5cb11f;
  background-position: 0 -15px;
}
.btn-success:active,
.btn-success.active {
  background-color: #5cb11f;
  border-color: #58a81e;
}
.btn-info {
  background-image: -webkit-linear-gradient(top, #a07cbc 0%, #8255a6 100%);
  background-image:         linear-gradient(to bottom, #a07cbc 0%, #8255a6 100%);
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffa07cbc', endColorstr='#ff8255a6', GradientType=0);
  filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
  background-repeat: repeat-x;
  border-color: #7d519f;
}
.btn-info:hover,
.btn-info:focus {
  background-color: #8255a6;
  background-position: 0 -15px;
}
.btn-info:active,
.btn-info.active {
  background-color: #8255a6;
  border-color: #7d519f;
}
.btn-warning {
  background-image: -webkit-linear-gradient(top, #e59728 0%, #b97616 100%);
  background-image:         linear-gradient(to bottom, #e59728 0%, #b97616 100%);
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffe59728', endColorstr='#ffb97616', GradientType=0);
  filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
  background-repeat: repeat-x;
  border-color: #b07015;
}
.btn-warning:hover,
.btn-warning:focus {
  background-color: #b97616;
  background-position: 0 -15px;
}
.btn-warning:active,
.btn-warning.active {
  background-color: #b97616;
  border-color: #b07015;
}
.btn-danger {
  background-image: -webkit-linear-gradient(top, #db3279 0%, #b11f5c 100%);
  background-image:         linear-gradient(to bottom, #db3279 0%, #b11f5c 100%);
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffdb3279', endColorstr='#ffb11f5c', GradientType=0);
  filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
  background-repeat: repeat-x;
  border-color: #a81e58;
}
.btn-danger:hover,
.btn-danger:focus {
  background-color: #b11f5c;
  background-position: 0 -15px;
}
.btn-danger:active,
.btn-danger.active {
  background-color: #b11f5c;
  border-color: #a81e58;
}
.thumbnail,
.img-thumbnail {
  -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, .075);
          box-shadow: 0 1px 2px rgba(0, 0, 0, .075);
}
.dropdown-menu > li > a:hover,
.dropdown-menu > li > a:focus {
  background-color: #e8e8e8;
  background-image: -webkit-linear-gradient(top, #f5f5f5 0%, #e8e8e8 100%);
  background-image:         linear-gradient(to bottom, #f5f5f5 0%, #e8e8e8 100%);
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff5f5f5', endColorstr='#ffe8e8e8', GradientType=0);
  background-repeat: repeat-x;
}
.dropdown-menu > .active > a,
.dropdown-menu > .active > a:hover,
.dropdown-menu > .active > a:focus {
  background-color: #357ebd;
  background-image: -webkit-linear-gradient(top, #428bca 0%, #357ebd 100%);
  background-image:         linear-gradient(to bottom, #428bca 0%, #357ebd 100%);
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff428bca', endColorstr='#ff357ebd', GradientType=0);
  background-repeat: repeat-x;
}
.navbar-default {
  background-image: -webkit-linear-gradient(top, #fff 0%, #f8f8f8 100%);
  background-image:         linear-gradient(to bottom, #fff 0%, #f8f8f8 100%);
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#fff8f8f8', GradientType=0);
  filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
  background-repeat: repeat-x;
  border-radius: 4px;
  -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .15), 0 1px 5px rgba(0, 0, 0, .075);
          box-shadow: inset 0 1px 0 rgba(255, 255, 255, .15), 0 1px 5px rgba(0, 0, 0, .075);
}
.navbar-default .navbar-nav > .active > a {
  background-image: -webkit-linear-gradient(top, #ebebeb 0%, #f3f3f3 100%);
  background-image:         linear-gradient(to bottom, #ebebeb 0%, #f3f3f3 100%);
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffebebeb', endColorstr='#fff3f3f3', GradientType=0);
  background-repeat: repeat-x;
  -webkit-box-shadow: inset 0 3px 9px rgba(0, 0, 0, .075);
          box-shadow: inset 0 3px 9px rgba(0, 0, 0, .075);
}
.navbar-brand,
.navbar-nav > li > a {
  text-shadow: 0 1px 0 rgba(255, 255, 255, .25);
}
.navbar-inverse {
  background-image: -webkit-linear-gradient(top, #365698 0%, #294172 100%);
  background-image:         linear-gradient(to bottom, #365698 0%, #294172 100%);
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff365698', endColorstr='#ff294172', GradientType=0);
  filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
  background-repeat: repeat-x;
}
.navbar-inverse .navbar-nav > .active > a {
  background-image: -webkit-linear-gradient(top, #294172 0%, #2c467b 100%);
  background-image:         linear-gradient(to bottom, #294172 0%, #2c467b 100%);
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff294172', endColorstr='#ff2c467b', GradientType=0);
  background-repeat: repeat-x;
  -webkit-box-shadow: inset 0 3px 9px rgba(0, 0, 0, .25);
          box-shadow: inset 0 3px 9px rgba(0, 0, 0, .25);
}
.navbar-inverse .navbar-brand,
.navbar-inverse .navbar-nav > li > a {
  text-shadow: 0 -1px 0 rgba(0, 0, 0, .25);
}
.navbar-static-top,
.navbar-fixed-top,
.navbar-fixed-bottom {
  border-radius: 0;
}
.alert {
  text-shadow: 0 1px 0 rgba(255, 255, 255, .2);
  -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 2px rgba(0, 0, 0, .05);
          box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 2px rgba(0, 0, 0, .05);
}
.alert-success {
  background-image: -webkit-linear-gradient(top, #dcf6ca 0%, #c7f0a9 100%);
  background-image:         linear-gradient(to bottom, #dcf6ca 0%, #c7f0a9 100%);
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffdcf6ca', endColorstr='#ffc7f0a9', GradientType=0);
  background-repeat: repeat-x;
  border-color: #b2ea89;
}
.alert-info {
  background-image: -webkit-linear-gradient(top, #f6f2f8 0%, #e3d9eb 100%);
  background-image:         linear-gradient(to bottom, #f6f2f8 0%, #e3d9eb 100%);
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff6f2f8', endColorstr='#ffe3d9eb', GradientType=0);
  background-repeat: repeat-x;
  border-color: #d1bfdf;
}
.alert-warning {
  background-image: -webkit-linear-gradient(top, #f8e4c7 0%, #f4d4a5 100%);
  background-image:         linear-gradient(to bottom, #f8e4c7 0%, #f4d4a5 100%);
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff8e4c7', endColorstr='#fff4d4a5', GradientType=0);
  background-repeat: repeat-x;
  border-color: #f0c383;
}
.alert-danger {
  background-image: -webkit-linear-gradient(top, #f6cadc 0%, #f0a9c7 100%);
  background-image:         linear-gradient(to bottom, #f6cadc 0%, #f0a9c7 100%);
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff6cadc', endColorstr='#fff0a9c7', GradientType=0);
  background-repeat: repeat-x;
  border-color: #ea89b2;
}
.progress {
  background-image: -webkit-linear-gradient(top, #ebebeb 0%, #f5f5f5 100%);
  background-image:         linear-gradient(to bottom, #ebebeb 0%, #f5f5f5 100%);
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffebebeb', endColorstr='#fff5f5f5', GradientType=0);
  background-repeat: repeat-x;
}
.progress-bar {
  background-image: -webkit-linear-gradient(top, #428bca 0%, #3071a9 100%);
  background-image:         linear-gradient(to bottom, #428bca 0%, #3071a9 100%);
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff428bca', endColorstr='#ff3071a9', GradientType=0);
  background-repeat: repeat-x;
}
.progress-bar-success {
  background-image: -webkit-linear-gradient(top, #79db32 0%, #61b921 100%);
  background-image:         linear-gradient(to bottom, #79db32 0%, #61b921 100%);
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff79db32', endColorstr='#ff61b921', GradientType=0);
  background-repeat: repeat-x;
}
.progress-bar-info {
  background-image: -webkit-linear-gradient(top, #a07cbc 0%, #885aab 100%);
  background-image:         linear-gradient(to bottom, #a07cbc 0%, #885aab 100%);
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffa07cbc', endColorstr='#ff885aab', GradientType=0);
  background-repeat: repeat-x;
}
.progress-bar-warning {
  background-image: -webkit-linear-gradient(top, #e59728 0%, #c27c18 100%);
  background-image:         linear-gradient(to bottom, #e59728 0%, #c27c18 100%);
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffe59728', endColorstr='#ffc27c18', GradientType=0);
  background-repeat: repeat-x;
}
.progress-bar-danger {
  background-image: -webkit-linear-gradient(top, #db3279 0%, #b92161 100%);
  background-image:         linear-gradient(to bottom, #db3279 0%, #b92161 100%);
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffdb3279', endColorstr='#ffb92161', GradientType=0);
  background-repeat: repeat-x;
}
.list-group {
  border-radius: 4px;
  -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, .075);
          box-shadow: 0 1px 2px rgba(0, 0, 0, .075);
}
.list-group-item.active,
.list-group-item.active:hover,
.list-group-item.active:focus {
  text-shadow: 0 -1px 0 #3071a9;
  background-image: -webkit-linear-gradient(top, #428bca 0%, #3278b3 100%);
  background-image:         linear-gradient(to bottom, #428bca 0%, #3278b3 100%);
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff428bca', endColorstr='#ff3278b3', GradientType=0);
  background-repeat: repeat-x;
  border-color: #3278b3;
}
.panel {
  -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
          box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
}
.panel-default > .panel-heading {
  background-image: -webkit-linear-gradient(top, #f5f5f5 0%, #e8e8e8 100%);
  background-image:         linear-gradient(to bottom, #f5f5f5 0%, #e8e8e8 100%);
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff5f5f5', endColorstr='#ffe8e8e8', GradientType=0);
  background-repeat: repeat-x;
}
.panel-primary > .panel-heading {
  background-image: -webkit-linear-gradient(top, #428bca 0%, #357ebd 100%);
  background-image:         linear-gradient(to bottom, #428bca 0%, #357ebd 100%);
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff428bca', endColorstr='#ff357ebd', GradientType=0);
  background-repeat: repeat-x;
}
.panel-success > .panel-heading {
  background-image: -webkit-linear-gradient(top, #dcf6ca 0%, #cef2b4 100%);
  background-image:         linear-gradient(to bottom, #dcf6ca 0%, #cef2b4 100%);
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffdcf6ca', endColorstr='#ffcef2b4', GradientType=0);
  background-repeat: repeat-x;
}
.panel-info > .panel-heading {
  background-image: -webkit-linear-gradient(top, #f6f2f8 0%, #e9e1f0 100%);
  background-image:         linear-gradient(to bottom, #f6f2f8 0%, #e9e1f0 100%);
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff6f2f8', endColorstr='#ffe9e1f0', GradientType=0);
  background-repeat: repeat-x;
}
.panel-warning > .panel-heading {
  background-image: -webkit-linear-gradient(top, #f8e4c7 0%, #f6d9b0 100%);
  background-image:         linear-gradient(to bottom, #f8e4c7 0%, #f6d9b0 100%);
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff8e4c7', endColorstr='#fff6d9b0', GradientType=0);
  background-repeat: repeat-x;
}
.panel-danger > .panel-heading {
  background-image: -webkit-linear-gradient(top, #f6cadc 0%, #f2b4ce 100%);
  background-image:         linear-gradient(to bottom, #f6cadc 0%, #f2b4ce 100%);
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff6cadc', endColorstr='#fff2b4ce', GradientType=0);
  background-repeat: repeat-x;
}
.well {
  background-image: -webkit-linear-gradient(top, #e8e8e8 0%, #f5f5f5 100%);
  background-image:         linear-gradient(to bottom, #e8e8e8 0%, #f5f5f5 100%);
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffe8e8e8', endColorstr='#fff5f5f5', GradientType=0);
  background-repeat: repeat-x;
  border-color: #dcdcdc;
  -webkit-box-shadow: inset 0 1px 3px rgba(0, 0, 0, .05), 0 1px 0 rgba(255, 255, 255, .1);
          box-shadow: inset 0 1px 3px rgba(0, 0, 0, .05), 0 1px 0 rgba(255, 255, 255, .1);
}
/*# sourceMappingURL=bootstrap-theme.css.map */


text:
package cz.metacentrum.perun.webgui.tabs.groupstabs;

import com.google.gwt.cell.client.FieldUpdater;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.resources.client.ImageResource;
import com.google.gwt.user.cellview.client.CellTable;
import com.google.gwt.user.client.ui.*;
import cz.metacentrum.perun.webgui.client.PerunWebSession;
import cz.metacentrum.perun.webgui.client.UiElements;
import cz.metacentrum.perun.webgui.client.localization.ButtonTranslation;
import cz.metacentrum.perun.webgui.client.localization.WidgetTranslation;
import cz.metacentrum.perun.webgui.client.mainmenu.MainMenu;
import cz.metacentrum.perun.webgui.client.resources.*;
import cz.metacentrum.perun.webgui.json.GetEntityById;
import cz.metacentrum.perun.webgui.json.JsonCallbackEvents;
import cz.metacentrum.perun.webgui.json.JsonUtils;
import cz.metacentrum.perun.webgui.json.groupsManager.GetGroupMembersCount;
import cz.metacentrum.perun.webgui.json.groupsManager.RemoveMember;
import cz.metacentrum.perun.webgui.json.membersManager.FindCompleteRichMembers;
import cz.metacentrum.perun.webgui.json.membersManager.GetCompleteRichMembers;
import cz.metacentrum.perun.webgui.model.BasicOverlayType;
import cz.metacentrum.perun.webgui.model.Group;
import cz.metacentrum.perun.webgui.model.PerunError;
import cz.metacentrum.perun.webgui.model.RichMember;
import cz.metacentrum.perun.webgui.tabs.GroupsTabs;
import cz.metacentrum.perun.webgui.tabs.TabItem;
import cz.metacentrum.perun.webgui.tabs.TabItemWithUrl;
import cz.metacentrum.perun.webgui.tabs.UrlMapper;
import cz.metacentrum.perun.webgui.tabs.memberstabs.AddMemberToGroupTabItem;
import cz.metacentrum.perun.webgui.tabs.memberstabs.MemberDetailTabItem;
import cz.metacentrum.perun.webgui.tabs.userstabs.InviteUserTabItem;
import cz.metacentrum.perun.webgui.widgets.AjaxLoaderImage;
import cz.metacentrum.perun.webgui.widgets.CustomButton;
import cz.metacentrum.perun.webgui.widgets.ExtendedTextBox;
import cz.metacentrum.perun.webgui.widgets.TabMenu;

import java.util.ArrayList;
import java.util.Map;

/**
 * Displays a group members
 *
 * @author Vaclav Mach <374430@mail.muni.cz>
 * @author Pavel Zlamal <256627@mail.muni.cz>
 */
public class GroupMembersTabItem implements TabItem, TabItemWithUrl {

	/**
	 * Perun web session
	 */
	private PerunWebSession session = PerunWebSession.getInstance();

	/**
	 * Content widget - should be simple panel
	 */
	private SimplePanel contentWidget = new SimplePanel();

	/**
	 * Title widget
	 */
	private Label titleWidget = new Label("Loading Group members");

	// when searching
	private String searchString = "";
	private boolean search = false;
	private boolean wasDisabled = false;
	private CellTable<RichMember> table;
	private boolean onceAsked = false;
	private Widget tableWidget;

	/**
	 * Group
	 */
	private Group group;
	private int groupId;

	/**
	 * Creates a tab instance
	 *
	 * @param group
	 */
	public GroupMembersTabItem(Group group){
		this.group = group;
		this.groupId = group.getId();
	}

	/**
	 * Creates a tab instance
	 *
	 * @param groupId
	 */
	public GroupMembersTabItem(int groupId){
		this.groupId = groupId;
		JsonCallbackEvents events = new JsonCallbackEvents(){
			public void onFinished(JavaScriptObject jso) {
				group = jso.cast();
			}
		};
		new GetEntityById(PerunEntity.GROUP, groupId, events).retrieveData();
	}

	public boolean isPrepared(){
		return !(group == null);
	}

	public Widget draw() {

		// SET TAB NAME
		titleWidget.setText(Utils.getStrippedStringWithEllipsis(group.getName()) + ": members");

		// MAIN PANEL
		final VerticalPanel firstTabPanel = new VerticalPanel();
		firstTabPanel.setSize("100%", "100%");

		// MENU
		final TabMenu tabMenu = new TabMenu();
		firstTabPanel.add(tabMenu);
		firstTabPanel.setCellHeight(tabMenu, "30px");

		// DISABLED CHECKBOX
		final CheckBox disabled = new CheckBox(WidgetTranslation.INSTANCE.showDisabledMembers());
		disabled.setTitle(WidgetTranslation.INSTANCE.showDisabledMembersTitle());
		disabled.setValue(wasDisabled);

		// CALLBACKS
		final GetCompleteRichMembers members = new GetCompleteRichMembers(PerunEntity.GROUP, groupId, null);
		final FindCompleteRichMembers findMembers = new FindCompleteRichMembers(PerunEntity.GROUP, groupId, "", null);
		members.excludeDisabled(!wasDisabled);

		final CustomButton searchButton = TabMenu.getPredefinedButton(ButtonType.SEARCH, ButtonTranslation.INSTANCE.searchMemberInGroup());
		final CustomButton listAllButton = TabMenu.getPredefinedButton(ButtonType.LIST_ALL_MEMBERS, ButtonTranslation.INSTANCE.listAllMembersInGroup());
		if ((!session.isVoAdmin(group.getVoId()) && !session.isGroupAdmin(groupId)) || group.isCoreGroup()) {
			findMembers.setCheckable(false);
		}

		table = findMembers.getEmptyTable(new FieldUpdater<RichMember, RichMember>() {
			// when user click on a row -> open new tab
			public void update(int index, RichMember object, RichMember value) {
				session.getTabManager().addTab(new MemberDetailTabItem(object.getId(), groupId));
			}
		});

		tableWidget = table.getEmptyTableWidget();

		// refresh
		tabMenu.addWidget(UiElements.getRefreshButton(this));

		// ADD
		CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addMemberToGroup(), new ClickHandler() {
			public void onClick(ClickEvent event) {
				session.getTabManager().addTabToCurrentTab(new AddMemberToGroupTabItem(groupId), true);
			}
		});
		if (!session.isGroupAdmin(groupId) && !session.isVoAdmin(group.getVoId())) addButton.setEnabled(false);

		CustomButton inviteButton = new CustomButton("Invite member…", SmallIcons.INSTANCE.emailAddIcon(), new ClickHandler() {
			@Override
			public void onClick(ClickEvent event) {
				session.getTabManager().addTabToCurrentTab(new InviteUserTabItem(group.getVoId(), group));
			}
		});
		if (!session.isGroupAdmin(groupId) && !session.isVoAdmin(group.getVoId())) inviteButton.setEnabled(false);

		// REMOVE
		final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeMemberFromGroup());
		if (!session.isGroupAdmin(groupId) && !session.isVoAdmin(group.getVoId())) removeButton.setEnabled(false);
		if (!group.isCoreGroup()) {
			tabMenu.addWidget(addButton);
			tabMenu.addWidget(inviteButton);
			tabMenu.addWidget(removeButton);
		}

		// refreshMembers
		final JsonCallbackEvents refreshEvent = new JsonCallbackEvents() {
			@Override
			public void onFinished(JavaScriptObject jso) {
				if (search) {
					findMembers.searchFor(searchString);
				} else {
					findMembers.clearTable();
					members.retrieveData();
				}
			}
		};

		// add click handler for remove button
		removeButton.addClickHandler(new ClickHandler() {
			@Override
			public void onClick(ClickEvent event) {

				// state specific events
				final ArrayList<RichMember> membersForRemoving = findMembers.getTableSelectedList();
				String text = "Following members will be removed from group. They will lose access to resources provided by this group.";
				UiElements.showDeleteConfirm(membersForRemoving, text, new ClickHandler() {
					@Override
					public void onClick(ClickEvent clickEvent) {
						// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
						for (int i = 0; i < membersForRemoving.size(); i++) {
							RemoveMember request;
							if (i == membersForRemoving.size() - 1) {
								request = new RemoveMember(JsonCallbackEvents.disableButtonEvents(removeButton, refreshEvent));
							} else {
								request = new RemoveMember(JsonCallbackEvents.disableButtonEvents(removeButton));
							}
							request.removeMemberFromGroup(group, membersForRemoving.get(i));
						}
					}
				});
			}
		});

		final ExtendedTextBox searchBox = tabMenu.addSearchWidget(new PerunSearchEvent() {
			public void searchFor(String text) {
				table.setEmptyTableWidget(tableWidget);
				searchString = text;
				search = true;
				findMembers.searchFor(text);
			}
		}, searchButton);
		searchBox.getTextBox().setText(searchString);

		// checkbox click handler
		disabled.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
			@Override
			public void onValueChange(ValueChangeEvent<Boolean> event) {
				wasDisabled = disabled.getValue();
				if (search) {
					// case when update but not triggered by button
					searchString = searchBox.getTextBox().getText();
					members.excludeDisabled(!disabled.getValue());
				} else {
					members.excludeDisabled(!disabled.getValue());
					members.retrieveData();
				}
			}
		});

		findMembers.setEvents(JsonCallbackEvents.mergeEvents(JsonCallbackEvents.disableButtonEvents(searchButton, JsonCallbackEvents.disableCheckboxEvents(disabled)),
				new JsonCallbackEvents() {
					@Override
					public void onFinished(JavaScriptObject jso) {
						searchBox.getTextBox().setEnabled(true);
						listAllButton.setEnabled(true);
					}

					@Override
					public void onError(PerunError error) {
						searchBox.getTextBox().setEnabled(true);
						listAllButton.setEnabled(true);
					}

					@Override
					public void onLoadingStart() {
						searchBox.getTextBox().setEnabled(false);
						listAllButton.setEnabled(false);
						disabled.setVisible(false);
					}
				}
		));

		members.setEvents(JsonCallbackEvents.mergeEvents(JsonCallbackEvents.disableButtonEvents(listAllButton, JsonCallbackEvents.disableCheckboxEvents(disabled)),
				new JsonCallbackEvents() {
					@Override
					public void onFinished(JavaScriptObject jso) {
						// pass data to table handling callback
						findMembers.onFinished(jso);
						((AjaxLoaderImage) table.getEmptyTableWidget()).setEmptyResultMessage("Group has no members.");
						searchBox.getTextBox().setEnabled(true);
						searchButton.setEnabled(true);
					}

					@Override
					public void onError(PerunError error) {
						// pass data to table handling callback
						findMembers.onError(error);
						searchBox.getTextBox().setEnabled(true);
						searchButton.setEnabled(true);
					}

					@Override
					public void onLoadingStart() {
						table.setEmptyTableWidget(tableWidget);
						searchBox.getTextBox().setEnabled(false);
						searchButton.setEnabled(false);
						disabled.setVisible(true);
						// to show progress when reloading
						((AjaxLoaderImage)table.getEmptyTableWidget()).loadingStart();
					}
				}
		));

		// LIST ALL BUTTON
		listAllButton.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				table.setEmptyTableWidget(tableWidget);
				search = false;
				searchString = "";
				searchBox.getTextBox().setText("");
				findMembers.clearTable();
				members.retrieveData();
			}
		});
		tabMenu.addWidget(listAllButton);

		tabMenu.addWidget(disabled);

		/* WHEN TAB RELOADS, CHECK THE STATE */
		if (search) {

			findMembers.searchFor(searchString);

		} else {

			GetGroupMembersCount count = new GetGroupMembersCount(groupId, new JsonCallbackEvents() {
				@Override
				public void onFinished(JavaScriptObject jso) {

					int membersCount = ((BasicOverlayType)jso.cast()).getInt();
					if (membersCount > 1000) {

						FlexTable panel = new FlexTable();
						panel.setSize("100%", "150px");
						HTML label = new HTML();
						label.setHTML("
Group has "+membersCount+" members. We suggest you to use search instead.

You can search member by name, login, email or click List all to see all members.
");

						panel.setWidget(0, 0, label);
						panel.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
						table.setEmptyTableWidget(panel);

					} else {

						// load all members
						members.excludeDisabled(!disabled.getValue());
						members.retrieveData();

					}
					onceAsked=true;

				}
				@Override
				public void onError(PerunError error) {
					// load all members
					members.excludeDisabled(!disabled.getValue());
					members.retrieveData();
				}
				@Override
				public void onLoadingStart() {
				}
			});

			if (!onceAsked) {
				count.retrieveData();
			} else {
				// load all members
				members.excludeDisabled(!disabled.getValue());
				members.retrieveData();
			}

		}

		ScrollPanel tableWrapper = new ScrollPanel();
		table.addStyleName("perun-table");
		tableWrapper.setWidget(table);
		tableWrapper.addStyleName("perun-tableScrollPanel");

		session.getUiElements().resizePerunTable(tableWrapper, 350, this);

		// add menu and the table to the main panel
		firstTabPanel.add(tableWrapper);

		removeButton.setEnabled(false);
		JsonUtils.addTableManagedButton(findMembers, table, removeButton);

		this.contentWidget.setWidget(firstTabPanel);
		return getWidget();

	}

	public Widget getWidget() {
		return this.contentWidget;
	}

	public Widget getTitle() {
		return this.titleWidget;
	}

	public ImageResource getIcon() {
		return SmallIcons.INSTANCE.userGreenIcon();
	}

	@Override
	public int hashCode() {
		final int prime = 827;
		int result = 1;
		result = prime * result + groupId;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;

		GroupMembersTabItem create = (GroupMembersTabItem) obj;

		if (groupId != create.groupId){
			return false;
		}

		return true;
	}

	public boolean multipleInstancesEnabled() {
		return false;
	}

	public void open() {
		session.getUiElements().getMenu().openMenu(MainMenu.GROUP_ADMIN);
		session.getUiElements().getBreadcrumbs().setLocation(group, "Members", getUrlWithParameters());
		if(group != null){
			session.setActiveGroup(group);
			return;
		}
		session.setActiveGroupId(groupId);
	}

	public boolean isAuthorized() {
		if (session.isVoAdmin(group.getVoId()) || session.isVoObserver(group.getVoId()) || session.isGroupAdmin(groupId)) {
			return true;
		} else {
			return false;
		}
	}

	public final static String URL = "members";

	public String getUrl()
	{
		return URL;
	}

	public String getUrlWithParameters() {
		return GroupsTabs.URL + UrlMapper.TAB_NAME_SEPARATOR + getUrl() + "?id=" + groupId;
	}

	static public GroupMembersTabItem load(Map<String, String> parameters) {
		int gid = Integer.parseInt(parameters.get("id"));
		return new GroupMembersTabItem(gid);
	}

}


text:
package com.relay.relay.viewsAndViewAdapters;

/**
 * Created by omer on 26/04/2017.
 */

import android.app.Activity;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.relay.relay.R;

import java.util.List;

import static com.relay.relay.viewsAndViewAdapters.StatusBar.FLAG_ADVERTISEMENT;
import static com.relay.relay.viewsAndViewAdapters.StatusBar.FLAG_CONNECTING;
import static com.relay.relay.viewsAndViewAdapters.StatusBar.FLAG_ERROR;
import static com.relay.relay.viewsAndViewAdapters.StatusBar.FLAG_HANDSHAKE;
import static com.relay.relay.viewsAndViewAdapters.StatusBar.FLAG_NO_CHANGE;
import static com.relay.relay.viewsAndViewAdapters.StatusBar.FLAG_SEARCH;

public class BlConnectionLoggerListArrayAdapter extends RecyclerView.Adapter<BlConnectionLoggerListArrayAdapter.ViewHolder> {

    private final List<BluetoothConnectionLogger> list;
    private final Activity context;

    public BlConnectionLoggerListArrayAdapter(Activity context, List<BluetoothConnectionLogger> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.item_log, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {

        holder.msg.setText(list.get(position).getTimeWithMsg());
        final int code = list.get(position).getFlagCode();
        switch(code){
            case FLAG_ADVERTISEMENT:
                holder.flag.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_flag_advertise));
                break;
            case FLAG_SEARCH:
                holder.flag.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_flag_search));
                break;
            case FLAG_CONNECTING:
                holder.flag.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_flag_connecting));
                break;
            case FLAG_HANDSHAKE:
                holder.flag.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_flag_handshake));
                break;
            case FLAG_ERROR:
                holder.flag.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_flag_error));
                break;
            case FLAG_NO_CHANGE:
                holder.flag.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_flag_ble_info));
                break;
            default:
                holder.flag.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_flag_idle));
                break;
        }

    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder{
        public ImageView flag;
        public TextView msg;

        public ViewHolder(View view) {
            super(view);
            msg = (TextView) view.findViewById(R.id.log_msg);
            flag = (ImageView) view.findViewById(R.id.flag);
        }
    }
}


text:
//
//  Family.m
//  TTShow
//
//  Created by xh on 15/3/12.
//  Copyright (c) 2015年 twb. All rights reserved.
//

#import "Family.h"

@implementation Family

- (id)initWithAttributes:(NSDictionary *)attributes {
    self = [super init];
    if (!self) {
        return nil;
    }

    /*
     @property (nonatomic, assign) NSUInteger bean_count;
     @property (nonatomic, assign) NSUInteger bean_count_total;
     @property (nonatomic, assign) NSUInteger coin_count;
     @property (nonatomic, assign) NSUInteger coin_spend_total;
     @property (nonatomic, assign) NSUInteger spend_star_level;
     @property (nonatomic, assign) NSInteger feather_count;
     @property (nonatomic, assign) long long int feather_last;
     @property (nonatomic, assign) long long int feather_send_total;
     */

    self.family_id = [[attributes valueForKey:@"family_id"] integerValue];
    self.family_priv = [[attributes valueForKey:@"family_priv"] integerValue];
    self.timestamp = [[attributes valueForKey:@"timestamp"] longLongValue];
    self.family_name = [attributes valueForKey:@"family_name"];
    self.badge_name = [attributes valueForKey:@"badge_name"];

    return self;
}

@end


text:
package com.wallace.tools.mvp;

import android.view.View;

/**
 *
 */

public interface BaseView<T> {

    void initViews(View view);

    void setPresenter(T presenter);

}


text:
- Brian Koffler
- Colin Gallagher
- Nikos Bentenitis

## Updates and Action Items

1. Nikos Bentenitis will be in Amsterdam for the Foundation's Bitcoin conference. Any questions that you may have for the Board. Brian suggested that Nikos should be present during the Foundation's Board meetings. Nikos will bring the suggestion to the board during the Amsterdam conference.

2. Brian Koffler will create a proposal on Github for the Unicode symbol for bitcoin, the currency. He will also bring up the issue with the Foundation's general counsel, Patrick Murck.

3. The next committee meeting will be at 10 pm EST on May 27 because Nikos will be absent.


text:
/* global test */
import assert from 'proclaim';

const lib = '../../lib/';

const Document = require(lib + 'Document');
const NodeList = require(lib + 'NodeList');

test('NodeList items', () => {
    const document = new Document();
    const div = document.createElement('div');

    const nodeList = new NodeList();

    assert.strictEqual(nodeList.length, 0);
    nodeList._push(div);
    assert.strictEqual(nodeList.length, 1);

    assert.strictEqual(nodeList[0], div);
    assert.strictEqual(nodeList[1], undefined);

    assert.strictEqual(nodeList.item(0), div);
    assert.strictEqual(nodeList.item(1), null);
});

test('NodeList iterator', () => {
    const document = new Document();
    const div1 = document.createElement('div');
    const div2 = document.createElement('div');

    const nodeList = new NodeList();

    nodeList._push(div1);
    nodeList._push(div2);

    assert.strictEqual(nodeList[0], div1);
    assert.strictEqual(nodeList[1], div2);

    let index = 0;
    for (let item of nodeList) {
        if (index++ == 0) {
            assert.strictEqual(item, div1);
        } else {
            assert.strictEqual(item, div2);
        }
    }

    assert.strictEqual(index, 2);
});


text:
"""Manage site and releases.

Usage:
  manage.py release [<branch>]
  manage.py site
"""

from __future__ import print_function
import datetime, docopt, fileinput, json, os
import re, requests, shutil, sys, tempfile
from contextlib import contextmanager
from distutils.version import LooseVersion
from subprocess import check_call

class Git:
    def __init__(self, dir):
        self.dir = dir

    def call(self, method, args, **kwargs):
        return check_call(['git', method] + list(args), **kwargs)

    def add(self, *args):
        return self.call('add', args, cwd=self.dir)

    def checkout(self, *args):
        return self.call('checkout', args, cwd=self.dir)

    def clean(self, *args):
        return self.call('clean', args, cwd=self.dir)

    def clone(self, *args):
        return self.call('clone', list(args) + [self.dir])

    def commit(self, *args):
        return self.call('commit', args, cwd=self.dir)

    def pull(self, *args):
        return self.call('pull', args, cwd=self.dir)

    def push(self, *args):
        return self.call('push', args, cwd=self.dir)

    def reset(self, *args):
        return self.call('reset', args, cwd=self.dir)

    def update(self, *args):
        clone = not os.path.exists(self.dir)
        if clone:
            self.clone(*args)
        return clone

def clean_checkout(repo, branch):
    repo.clean('-f', '-d')
    repo.reset('--hard')
    repo.checkout(branch)

class Runner:
    def __init__(self, cwd):
        self.cwd = cwd

    def __call__(self, *args, **kwargs):
        kwargs['cwd'] = kwargs.get('cwd', self.cwd)
        check_call(args, **kwargs)

def create_build_env():
    """Create a build environment."""
    class Env:
        pass
    env = Env()

    # Import the documentation build module.
    env.fmt_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    sys.path.insert(0, os.path.join(env.fmt_dir, 'doc'))
    import build

    env.build_dir = 'build'

    # Virtualenv and repos are cached to speed up builds.
    build.create_build_env(os.path.join(env.build_dir, 'virtualenv'))

    env.fmt_repo = Git(os.path.join(env.build_dir, 'fmt'))
    return env

@contextmanager
def rewrite(filename):
    class Buffer:
        pass
    buffer = Buffer()
    if not os.path.exists(filename):
        buffer.data = ''
        yield buffer
        return
    with open(filename) as f:
        buffer.data = f.read()
    yield buffer
    with open(filename, 'w') as f:
        f.write(buffer.data)

fmt_repo_url = 'git@github.com:fmtlib/fmt'

def update_site(env):
    env.fmt_repo.update(fmt_repo_url)

    doc_repo = Git(os.path.join(env.build_dir, 'fmtlib.github.io'))
    doc_repo.update('git@github.com:fmtlib/fmtlib.github.io')

    for version in ['1.0.0', '1.1.0', '2.0.0', '3.0.0']:
        clean_checkout(env.fmt_repo, version)
        target_doc_dir = os.path.join(env.fmt_repo.dir, 'doc')
        # Remove the old theme.
        for entry in os.listdir(target_doc_dir):
            path = os.path.join(target_doc_dir, entry)
            if os.path.isdir(path):
                shutil.rmtree(path)
        # Copy the new theme.
        for entry in ['_static', '_templates', 'basic-bootstrap', 'bootstrap',
                      'conf.py', 'fmt.less']:
            src = os.path.join(env.fmt_dir, 'doc', entry)
            dst = os.path.join(target_doc_dir, entry)
            copy = shutil.copytree if os.path.isdir(src) else shutil.copyfile
            copy(src, dst)
        # Rename index to contents.
        contents = os.path.join(target_doc_dir, 'contents.rst')
        if not os.path.exists(contents):
            os.rename(os.path.join(target_doc_dir, 'index.rst'), contents)
        # Fix issues in reference.rst/api.rst.
        for filename in ['reference.rst', 'api.rst']:
            pattern = re.compile('doxygenfunction.. (bin|oct|hexu|hex)$', re.M)
            with rewrite(os.path.join(target_doc_dir, filename)) as b:
                b.data = b.data.replace('std::ostream &', 'std::ostream&')
                b.data = re.sub(pattern, r'doxygenfunction:: \1(int)', b.data)
                b.data = b.data.replace('std::FILE*', 'std::FILE *')
                b.data = b.data.replace('unsigned int', 'unsigned')
        # Fix a broken link in index.rst.
        index = os.path.join(target_doc_dir, 'index.rst')
        with rewrite(index) as b:
            b.data = b.data.replace(
                'doc/latest/index.html#format-string-syntax', 'syntax.html')
        # Build the docs.
        html_dir = os.path.join(env.build_dir, 'html')
        if os.path.exists(html_dir):
            shutil.rmtree(html_dir)
        include_dir = env.fmt_repo.dir
        if LooseVersion(version) >= LooseVersion('3.0.0'):
            include_dir = os.path.join(include_dir, 'fmt')
        import build
        build.build_docs(version, doc_dir=target_doc_dir,
                         include_dir=include_dir, work_dir=env.build_dir)
        shutil.rmtree(os.path.join(html_dir, '.doctrees'))
        # Create symlinks for older versions.
        for link, target in {'index': 'contents', 'api': 'reference'}.items():
            link = os.path.join(html_dir, link) + '.html'
            target += '.html'
            if os.path.exists(os.path.join(html_dir, target)) and \
               not os.path.exists(link):
                os.symlink(target, link)
        # Copy docs to the website.
        version_doc_dir = os.path.join(doc_repo.dir, version)
        shutil.rmtree(version_doc_dir)
        shutil.move(html_dir, version_doc_dir)

def release(args):
    env = create_build_env()
    fmt_repo = env.fmt_repo

    branch = args.get('<branch>')
    if branch is None:
        branch = 'master'
    if not fmt_repo.update('-b', branch, fmt_repo_url):
        clean_checkout(fmt_repo, branch)

    # Convert changelog from RST to GitHub-flavored Markdown and get the
    # version.
    changelog = 'ChangeLog.rst'
    changelog_path = os.path.join(fmt_repo.dir, changelog)
    import rst2md
    changes, version = rst2md.convert(changelog_path)
    cmakelists = 'CMakeLists.txt'
    for line in fileinput.input(os.path.join(fmt_repo.dir, cmakelists),
                                inplace=True):
        prefix = 'set(FMT_VERSION '
        if line.startswith(prefix):
            line = prefix + version + ')\n'
        sys.stdout.write(line)

    # Update the version in the changelog.
    title_len = 0
    for line in fileinput.input(changelog_path, inplace=True):
        if line.decode('utf-8').startswith(version + ' - TBD'):
            line = version + ' - ' + datetime.date.today().isoformat()
            title_len = len(line)
            line += '\n'
        elif title_len:
            line = '-' * title_len + '\n'
            title_len = 0
        sys.stdout.write(line)
    # TODO: add new version to manage.py
    fmt_repo.checkout('-B', 'release')
    fmt_repo.add(changelog, cmakelists)
    fmt_repo.commit('-m', 'Update version')

    # Build the docs and package.
    run = Runner(fmt_repo.dir)
    run('cmake', '.')
    run('make', 'doc', 'package_source')

    update_site(env)

    # Create a release on GitHub.
    fmt_repo.push('origin', 'release')
    r = requests.post('https://api.github.com/repos/fmtlib/fmt/releases',
                      params={'access_token': os.getenv('FMT_TOKEN')},
                      data=json.dumps({'tag_name': version,
                                       'target_commitish': 'release',
                                       'body': changes, 'draft': True}))
    if r.status_code != 201:
        raise Exception('Failed to create a release ' + str(r))

if __name__ == '__main__':
    args = docopt.docopt(__doc__)
    if args.get('release'):
        release(args)
    elif args.get('site'):
        update_site(create_build_env())