text:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text.RegularExpressions;
using FluentAssertions.Execution;

using System.Linq;

namespace FluentAssertions.Primitives
{
    ///
    /// Contains a number of methods to assert that a <see cref="string"/> is in the expected state.
    ///
    [DebuggerNonUserCode]
    public class StringAssertions : ReferenceTypeAssertions<string, StringAssertions>
    {
        ///
        /// Initializes a new instance of the <see cref="T:System.Object" /> class.
        ///
        public StringAssertions(string value)
        {
            Subject = value;
        }

        ///
        /// Asserts that a string is exactly the same as another string, including the casing and any leading or trailing whitespace.
        ///
        /// <param name="expected">The expected string.</param>
        /// <param name="because">
        /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
        /// is needed. If the phrase does not start with the word because, it is prepended automatically.
        /// </param>
        /// <param name="becauseArgs">
        /// Zero or more objects to format using the placeholders in <see cref="because" />.
        /// </param>
        public AndConstraint<StringAssertions> Be(string expected, string because = "", params object[] becauseArgs)
        {
            new StringEqualityValidator(Subject, expected, StringComparison.CurrentCulture, because, becauseArgs).Validate();

            return new AndConstraint<StringAssertions>(this);
        }

        ///
        /// Asserts that the <see cref="string"/> is one of the specified <paramref name="validValues"/>.
        ///
        /// <param name="validValues">
        /// The values that are valid.
        /// </param>
        public AndConstraint<StringAssertions> BeOneOf(params string[] validValues)
        {
            return BeOneOf(validValues, String.Empty);
        }

        ///
        /// Asserts that the <see cref="string"/> is one of the specified <paramref name="validValues"/>.
        ///
        /// <param name="validValues">
        /// The values that are valid.
        /// </param>
        /// <param name="because">
        /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
        /// is needed. If the phrase does not start with the word because, it is prepended automatically.
        /// </param>
        /// <param name="becauseArgs">
        /// Zero or more objects to format using the placeholders in <see cref="because" />.
        /// </param>
        public AndConstraint<StringAssertions> BeOneOf(IEnumerable<string> validValues, string because = "", params object[] becauseArgs)
        {
            Execute.Assertion
                .ForCondition(validValues.Contains(Subject))
                .BecauseOf(because, becauseArgs)
                .FailWith("Expected value to be one of {0}{reason}, but found {1}.", validValues, Subject);

            return new AndConstraint<StringAssertions>(this);
        }

        ///
        /// Asserts that a string is exactly the same as another string, including any leading or trailing whitespace, with
        /// the exception of the casing.
        ///
        /// <param name="expected">
        /// The string that the subject is expected to be equivalent to.
        /// </param>
        /// <param name="because">
        /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
        /// is needed. If the phrase does not start with the word because, it is prepended automatically.
        /// </param>
        /// <param name="becauseArgs">
        /// Zero or more objects to format using the placeholders in <see cref="because" />.
        /// </param>
        public AndConstraint<StringAssertions> BeEquivalentTo(string expected, string because = "",
            params object[] becauseArgs)
        {
            var expectation = new StringEqualityValidator(
                Subject, expected, StringComparison.CurrentCultureIgnoreCase, because, becauseArgs);

            expectation.Validate();

            return new AndConstraint<StringAssertions>(this);
        }

        ///
        /// Asserts that a string is not exactly the same as the specified <paramref name="unexpected"/>,
        /// including any leading or trailing whitespace, with the exception of the casing.
        ///
        /// <param name="unexpected">The string that the subject is not expected to be equivalent to.</param>
        /// <param name="because">
        /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
        /// is needed. If the phrase does not start with the word because, it is prepended automatically.
        /// </param>
        /// <param name="becauseArgs">
        /// Zero or more objects to format using the placeholders in <see cref="because" />.
        /// </param>
        public AndConstraint<StringAssertions> NotBe(string unexpected, string because = "", params object[] becauseArgs)
        {
            Execute.Assertion
                .ForCondition(Subject != unexpected)
                .BecauseOf(because, becauseArgs)
                .FailWith("Expected string not to be {0}{reason}.", unexpected);

            return new AndConstraint<StringAssertions>(this);
        }

        ///
        /// Asserts that a string matches a wildcard pattern.
        ///
        /// <param name="wildcardPattern">
        /// The wildcard pattern with which the subject is matched, where * and ? have special meanings.
        /// </param>
        /// <param name="because">
        /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
        /// is needed. If the phrase does not start with the word because, it is prepended automatically.
        /// </param>
        /// <param name="becauseArgs">
        /// Zero or more objects to format using the placeholders in <see cref="because" />.
        /// </param>
        public AndConstraint<StringAssertions> Match(string wildcardPattern, string because = "", params object[] becauseArgs)
        {
            new StringWildcardMatchingValidator(Subject, wildcardPattern, because, becauseArgs).Validate();

            return new AndConstraint<StringAssertions>(this);
        }

        ///
        /// Asserts that a string does not match a wildcard pattern.
        ///
        /// <param name="wildcardPattern">
        /// The wildcard pattern with which the subject is matched, where * and ? have special meanings.
        /// </param>
        /// <param name="because">
        /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
        /// is needed. If the phrase does not start with the word because, it is prepended automatically.
        /// </param>
        /// <param name="becauseArgs">
        /// Zero or more objects to format using the placeholders in <see cref="because" />.
        /// </param>
        public AndConstraint<StringAssertions> NotMatch(string wildcardPattern, string because = "", params object[] becauseArgs)
        {
            new StringWildcardMatchingValidator(Subject, wildcardPattern, because, becauseArgs)
            {
                Negate = true
            }.Validate();

            return new AndConstraint<StringAssertions>(this);
        }

        ///
        /// Asserts that a string matches a wildcard pattern.
        ///
        /// <param name="wildcardPattern">
        /// The wildcard pattern with which the subject is matched, where * and ? have special meanings.
        /// </param>
        /// <param name="because">
        /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
        /// is needed. If the phrase does not start with the word because, it is prepended automatically.
        /// </param>
        /// <param name="becauseArgs">
        /// Zero or more objects to format using the placeholders in <see cref="because" />.
        /// </param>
        public AndConstraint<StringAssertions> MatchEquivalentOf(string wildcardPattern, string because = "",
            params object[] becauseArgs)
        {
            var validator = new StringWildcardMatchingValidator(Subject, wildcardPattern, because, becauseArgs)
            {
                IgnoreCase = true,
                IgnoreNewLineDifferences = true
            };

            validator.Validate();

            return new AndConstraint<StringAssertions>(this);
        }

        ///
        /// Asserts that a string does not match a wildcard pattern.
        ///
        /// <param name="wildcardPattern">
        /// The wildcard pattern with which the subject is matched, where * and ? have special meanings.
        /// </param>
        /// <param name="because">
        /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
        /// is needed. If the phrase does not start with the word because, it is prepended automatically.
        /// </param>
        /// <param name="becauseArgs">
        /// Zero or more objects to format using the placeholders in <see cref="because" />.
        /// </param>
        public AndConstraint<StringAssertions> NotMatchEquivalentOf(string wildcardPattern, string because = "",
            params object[] becauseArgs)
        {
            var validator = new StringWildcardMatchingValidator(Subject, wildcardPattern, because, becauseArgs)
            {
                IgnoreCase = true,
                IgnoreNewLineDifferences = true,
                Negate = true
            };

            validator.Validate();

            return new AndConstraint<StringAssertions>(this);
        }

        ///
        /// Asserts that a string matches a regular expression.
        ///
        /// <param name="regularExpression">
        /// The regular expression with which the subject is matched.
        /// </param>
        /// <param name="because">
        /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
        /// is needed. If the phrase does not start with the word because, it is prepended automatically.
        /// </param>
        /// <param name="becauseArgs">
        /// Zero or more objects to format using the placeholders in <see cref="because" />.
        /// </param>
        public AndConstraint<StringAssertions> MatchRegex(string regularExpression, string because = "", params object[] becauseArgs)
        {
          if (regularExpression == null)
          {
            throw new NullReferenceException("Cannot match string against <null>.");
          }

          Execute.Assertion
              .ForCondition(!ReferenceEquals(Subject, null))
              .UsingLineBreaks
              .BecauseOf(because, becauseArgs)
              .FailWith("Expected string to match regex {0}{reason}, but it was <null>.", regularExpression);

          bool isMatch;
          try
          {
            isMatch = Regex.IsMatch(Subject, regularExpression);
          }
          catch (ArgumentException)
          {
            throw new ArgumentException(
              string.Format(
                "Cannot match string against \"{0}\" because it is not a valid regular expression.",
                regularExpression));
          }

          Execute.Assertion
              .ForCondition(isMatch)
              .BecauseOf(because, becauseArgs)
              .UsingLineBreaks
              .FailWith("Expected string to match regex {0}{reason}, but {1} does not match.", regularExpression, Subject);

          return new AndConstraint<StringAssertions>(this);
        }

        ///
        /// Asserts that a string does not match a regular expression.
        ///
        /// <param name="regularExpression">
        /// The regular expression with which the subject is matched.
        /// </param>
        /// <param name="because">
        /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
        /// is needed. If the phrase does not start with the word because, it is prepended automatically.
        /// </param>
        /// <param name="becauseArgs">
        /// Zero or more objects to format using the placeholders in <see cref="because" />.
        /// </param>
        public AndConstraint<StringAssertions> NotMatchRegex(string regularExpression, string because = "", params object[] becauseArgs)
        {
          if (regularExpression == null)
          {
            throw new NullReferenceException("Cannot match string against <null>.");
          }

          Execute.Assertion
              .ForCondition(!ReferenceEquals(Subject, null))
              .UsingLineBreaks
              .BecauseOf(because, becauseArgs)
              .FailWith("Expected string to not match regex {0}{reason}, but it was <null>.", regularExpression);

          bool isMatch;
          try
          {
            isMatch = Regex.IsMatch(Subject, regularExpression);
          }
          catch (ArgumentException)
          {
            throw new ArgumentException(
              string.Format(
                "Cannot match string against \"{0}\" because it is not a valid regular expression.",
                regularExpression));
          }

          Execute.Assertion
              .ForCondition(!isMatch)
              .BecauseOf(because, becauseArgs)
              .UsingLineBreaks
              .FailWith("Did not expect string to match regex {0}{reason}, but {1} matches.", regularExpression, Subject);

          return new AndConstraint<StringAssertions>(this);
        }

        ///
        /// Asserts that a string starts exactly with the specified <paramref name="expected"/> value,
        /// including the casing and any leading or trailing whitespace.
        ///
        /// <param name="expected">The string that the subject is expected to start with.</param>
        /// <param name="because">
        /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
        /// is needed. If the phrase does not start with the word because, it is prepended automatically.
        /// </param>
        /// <param name="becauseArgs">
        /// Zero or more objects to format using the placeholders in <see cref="because" />.
        /// </param>
        public AndConstraint<StringAssertions> StartWith(string expected, string because = "", params object[] becauseArgs)
        {
            if (expected == null)
            {
                throw new NullReferenceException("Cannot compare start of string with <null>.");
            }

            if (expected.Length == 0)
            {
                throw new ArgumentException("Cannot compare start of string with empty string.");
            }

            new StringStartValidator(Subject, expected, StringComparison.CurrentCulture, because, becauseArgs).Validate();

            return new AndConstraint<StringAssertions>(this);
        }

        ///
        /// Asserts that a string does not start with the specified <paramref name="unexpected"/> value,
        /// including the casing and any leading or trailing whitespace.
        ///
        /// <param name="unexpected">The string that the subject is not expected to start with.</param>
        /// <param name="because">
        /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
        /// is needed. If the phrase does not start with the word because, it is prepended automatically.
        /// </param>
        /// <param name="becauseArgs">
        /// Zero or more objects to format using the placeholders in <see cref="because" />.
        /// </param>
        public AndConstraint<StringAssertions> NotStartWith(string unexpected, string because = "", params object[] becauseArgs)
        {
            if (unexpected == null)
            {
                throw new NullReferenceException("Cannot compare start of string with <null>.");
            }

            if (unexpected.Length == 0)
            {
                throw new ArgumentException("Cannot compare start of string with empty string.");
            }

            new NegatedStringStartValidator(Subject, unexpected, StringComparison.CurrentCulture, because, becauseArgs).Validate();

            return new AndConstraint<StringAssertions>(this);
        }

        ///
        /// Asserts that a string starts with the specified <paramref name="expected"/>,
        /// including any leading or trailing whitespace, with the exception of the casing.
        ///
        /// <param name="expected">The string that the subject is expected to start with.</param>
        /// <param name="because">
        /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
        /// is needed. If the phrase does not start with the word because, it is prepended automatically.
        /// </param>
        /// <param name="becauseArgs">
        /// Zero or more objects to format using the placeholders in <see cref="because" />.
        /// </param>
        public AndConstraint<StringAssertions> StartWithEquivalent(string expected, string because = "",
            params object[] becauseArgs)
        {
            if (expected == null)
            {
                throw new NullReferenceException("Cannot compare string start equivalence with <null>.");
            }

            if (expected.Length == 0)
            {
                throw new ArgumentException("Cannot compare string start equivalence with empty string.");
            }

            new StringStartValidator(Subject, expected, StringComparison.CurrentCultureIgnoreCase, because, becauseArgs).Validate();

            return new AndConstraint<StringAssertions>(this);
        }

        ///
        /// Asserts that a string does not start with the specified <paramref name="unexpected"/> value,
        /// including any leading or trailing whitespace, with the exception of the casing.
        ///
        /// <param name="unexpected">The string that the subject is not expected to start with.</param>
        /// <param name="because">
        /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
        /// is needed. If the phrase does not start with the word because, it is prepended automatically.
        /// </param>
        /// <param name="becauseArgs">
        /// Zero or more objects to format using the placeholders in <see cref="because" />.
        /// </param>
        public AndConstraint<StringAssertions> NotStartWithEquivalentOf(string unexpected, string because = "", params object[] becauseArgs)
        {
            if (unexpected == null)
            {
                throw new NullReferenceException("Cannot compare start of string with <null>.");
            }

            if (unexpected.Length == 0)
            {
                throw new ArgumentException("Cannot compare start of string with empty string.");
            }

            new NegatedStringStartValidator(Subject, unexpected, StringComparison.CurrentCultureIgnoreCase, because, becauseArgs).Validate();

            return new AndConstraint<StringAssertions>(this);
        }

        ///
        /// Asserts that a string ends exactly with the specified <paramref name="expected"/>,
        /// including the casing and any leading or trailing whitespace.
        ///
        /// <param name="expected">The string that the subject is expected to end with.</param>
        /// <param name="because">
        /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
        /// is needed. If the phrase does not start with the word because, it is prepended automatically.
        /// </param>
        /// <param name="becauseArgs">
        /// Zero or more objects to format using the placeholders in <see cref="because" />.
        /// </param>
        public AndConstraint<StringAssertions> EndWith(string expected, string because = "", params object[] becauseArgs)
        {
            if (expected == null)
            {
                throw new NullReferenceException("Cannot compare string end with <null>.");
            }

            if (expected.Length == 0)
            {
                throw new ArgumentException("Cannot compare string end with empty string.");
            }

            if (Subject == null)
            {
                Execute.Assertion
                    .BecauseOf(because, becauseArgs)
                    .FailWith("Expected string {0} to end with {1}{reason}.", Subject, expected);
            }

            if (Subject.Length < expected.Length)
            {
                Execute.Assertion
                    .BecauseOf(because, becauseArgs)
                    .FailWith("Expected string to end with {0}{reason}, but {1} is too short.", expected, Subject);
            }

            Execute.Assertion
                .ForCondition(Subject.EndsWith(expected))
                .BecauseOf(because, becauseArgs)
                .FailWith("Expected string {0} to end with {1}{reason}.", Subject, expected);

            return new AndConstraint<StringAssertions>(this);
        }

        ///
        /// Asserts that a string does not end exactly with the specified <paramref name="unexpected"/>,
        /// including the casing and any leading or trailing whitespace.
        ///
        /// <param name="unexpected">The string that the subject is not expected to end with.</param>
        /// <param name="because">
        /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
        /// is needed. If the phrase does not start with the word because, it is prepended automatically.
        /// </param>
        /// <param name="becauseArgs">
        /// Zero or more objects to format using the placeholders in <see cref="because" />.
        /// </param>
        public AndConstraint<StringAssertions> NotEndWith(string unexpected, string because = "", params object[] becauseArgs)
        {
            if (unexpected == null)
            {
                throw new NullReferenceException("Cannot compare end of string with <null>.");
            }

            if (unexpected.Length == 0)
            {
                throw new ArgumentException("Cannot compare end of string with empty string.");
            }

            if (Subject == null)
            {
                Execute.Assertion
                    .BecauseOf(because, becauseArgs)
                    .FailWith("Expected string that does not end with {1}, but found {0}.", Subject, unexpected);
            }

            Execute.Assertion
                .ForCondition(!Subject.EndsWith(unexpected))
                .BecauseOf(because, becauseArgs)
                .FailWith("Expected string {0} not to end with {1}{reason}.", Subject, unexpected);

            return new AndConstraint<StringAssertions>(this);
        }

        ///
        /// Asserts that a string ends with the specified <paramref name="expected"/>,
        /// including any leading or trailing whitespace, with the exception of the casing.
        ///
        /// <param name="expected">The string that the subject is expected to end with.</param>
        /// <param name="because">
        /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
        /// is needed. If the phrase does not start with the word because, it is prepended automatically.
        /// </param>
        /// <param name="becauseArgs">
        /// Zero or more objects to format using the placeholders in <see cref="because" />.
        /// </param>
        public AndConstraint<StringAssertions> EndWithEquivalent(string expected, string because = "", params object[] becauseArgs)
        {
            if (expected == null)
            {
                throw new NullReferenceException("Cannot compare string end equivalence with <null>.");
            }

            if (expected.Length == 0)
            {
                throw new ArgumentException("Cannot compare string end equivalence with empty string.");
            }

            if (Subject == null)
            {
                Execute.Assertion
                    .BecauseOf(because, becauseArgs)
                    .FailWith("Expected string that ends with equivalent of {0}{reason}, but found {1}.", expected, Subject);
            }

            if (Subject.Length < expected.Length)
            {
                Execute.Assertion
                    .BecauseOf(because, becauseArgs)
                    .FailWith("Expected string to end with equivalent of {0}{reason}, but {1} is too short.", expected, Subject);
            }

            Execute.Assertion
                .ForCondition(Subject.EndsWith(expected, StringComparison.CurrentCultureIgnoreCase))
                .BecauseOf(because, becauseArgs)
                .FailWith("Expected string that ends with equivalent of {0}{reason}, but found {1}.", expected, Subject);

            return new AndConstraint<StringAssertions>(this);
        }

        ///
        /// Asserts that a string does not end with the specified <paramref name="unexpected"/>,
        /// including any leading or trailing whitespace, with the exception of the casing.
        ///
        /// <param name="unexpected">The string that the subject is not expected to end with.</param>
        /// <param name="because">
        /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
        /// is needed. If the phrase does not start with the word because, it is prepended automatically.
        /// </param>
        /// <param name="becauseArgs">
        /// Zero or more objects to format using the placeholders in <see cref="because" />.
        /// </param>
        public AndConstraint<StringAssertions> NotEndWithEquivalentOf(string unexpected, string because = "", params object[] becauseArgs)
        {
            if (unexpected == null)
            {
                throw new NullReferenceException("Cannot compare end of string with <null>.");
            }

            if (unexpected.Length == 0)
            {
                throw new ArgumentException("Cannot compare end of string with empty string.");
            }

            if (Subject == null)
            {
                Execute.Assertion
                    .BecauseOf(because, becauseArgs)
                    .FailWith("Expected string that does not end with equivalent of {0}, but found {1}.", unexpected, Subject);
            }

            Execute.Assertion
                .ForCondition(!Subject.EndsWith(unexpected, StringComparison.CurrentCultureIgnoreCase))
                .BecauseOf(because, becauseArgs)
                .FailWith("Expected string that does not end with equivalent of {0}{reason}, but found {1}.", unexpected, Subject);

            return new AndConstraint<StringAssertions>(this);
        }

        ///
        /// Asserts that a string contains another (fragment of a) string.
        ///
        /// <param name="expected">
        /// The (fragment of a) string that the current string should contain.
        /// </param>
        /// <param name="because">
        /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
        /// is needed. If the phrase does not start with the word because, it is prepended automatically.
        /// </param>
        /// <param name="becauseArgs">
        /// Zero or more objects to format using the placeholders in <see cref="because" />.
        /// </param>
        public AndConstraint<StringAssertions> Contain(string expected, string because = "", params object[] becauseArgs)
        {
            if (expected == null)
            {
                throw new ArgumentException("Cannot assert string containment against <null>.");
            }

            if (expected.Length == 0)
            {
                throw new ArgumentException("Cannot assert string containment against an empty string.");
            }

            Execute.Assertion
                .ForCondition(Contains(Subject, expected, StringComparison.Ordinal))
                .BecauseOf(because, becauseArgs)
                .FailWith("Expected string {0} to contain {1}{reason}.", Subject, expected);

            return new AndConstraint<StringAssertions>(this);
        }

        ///
        /// Asserts that a string contains the specified <paramref name="expected"/>,
        /// including any leading or trailing whitespace, with the exception of the casing.
        ///
        /// <param name="expected">The string that the subject is expected to contain.</param>
        /// <param name="because">
        /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
        /// is needed. If the phrase does not start with the word because, it is prepended automatically.
        /// </param>
        /// <param name="becauseArgs">
        /// Zero or more objects to format using the placeholders in <see cref="because" />.
        /// </param>
        public AndConstraint<StringAssertions> ContainEquivalentOf(string expected, string because = "", params object[] becauseArgs)
        {
            if (expected == null)
            {
                throw new ArgumentException("Cannot assert string containment against <null>.");
            }

            if (expected.Length == 0)
            {
                throw new ArgumentException("Cannot assert string containment against an empty string.");
            }

            Execute.Assertion
                .ForCondition(Contains(Subject, expected, StringComparison.CurrentCultureIgnoreCase))
                .BecauseOf(because, becauseArgs)
                .FailWith("Expected string to contain equivalent of {0}{reason} but found {1}", expected, Subject);

            return new AndConstraint<StringAssertions>(this);
        }

        ///
        /// Asserts that a string does not contain another (fragment of a) string.
        ///
        /// <param name="expected">
        /// The (fragment of a) string that the current string should not contain.
        /// </param>
        /// <param name="because">
        /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
        /// is needed. If the phrase does not start with the word because, it is prepended automatically.
        /// </param>
        /// <param name="becauseArgs">
        /// Zero or more objects to format using the placeholders in <see cref="because" />.
        /// </param>
        public AndConstraint<StringAssertions> NotContain(string expected, string because = "",
            params object[] becauseArgs)
        {
            if (expected == null)
            {
                throw new ArgumentException("Cannot assert string containment against <null>.");
            }

            if (expected.Length == 0)
            {
                throw new ArgumentException("Cannot assert string containment against an empty string.");
            }

            Execute.Assertion
                .ForCondition(!Contains(Subject, expected, StringComparison.Ordinal))
                .BecauseOf(because, becauseArgs)
                .FailWith("Did not expect string {0} to contain {1}{reason}.", Subject, expected);

            return new AndConstraint<StringAssertions>(this);
        }

        ///
        /// Asserts that a string does not contain the specified <paramref name="unexpected"/> string,
        /// including any leading or trailing whitespace, with the exception of the casing.
        ///
        /// <param name="unexpected">The string that the subject is not expected to contain.</param>
        /// <param name="because">
        /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
        /// is needed. If the phrase does not start with the word because, it is prepended automatically.
        /// </param>
        /// <param name="becauseArgs">
        /// Zero or more objects to format using the placeholders in <see cref="because" />.
        /// </param>
        public AndConstraint<StringAssertions> NotContainEquivalentOf(string unexpected, string because = "",
            params object[] becauseArgs)
        {
            Execute.Assertion
                .ForCondition(!Contains(Subject, unexpected, StringComparison.CurrentCultureIgnoreCase))
                .BecauseOf(because, becauseArgs)
                .FailWith("Did not expect string to contain equivalent of {0}{reason} but found {1}", unexpected, Subject);

            return new AndConstraint<StringAssertions>(this);
        }

        static bool Contains(string actual, string expected, StringComparison comparison)
        {
            return (actual ?? "").IndexOf(expected ?? "", comparison) >= 0;
        }

        ///
        /// Asserts that a string is <see cref="string.Empty"/>.
        ///
        /// <param name="because">
        /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
        /// is needed. If the phrase does not start with the word because, it is prepended automatically.
        /// </param>
        /// <param name="becauseArgs">
        /// Zero or more objects to format using the placeholders in <see cref="because" />.
        /// </param>
        public AndConstraint<StringAssertions> BeEmpty(string because = "", params object[] becauseArgs)
        {
            Execute.Assertion
                .ForCondition((Subject != null) && (Subject.Length == 0))
                .BecauseOf(because, becauseArgs)
                .FailWith("Expected empty string{reason}, but found {0}.", Subject);

            return new AndConstraint<StringAssertions>(this);
        }

        ///
        /// Asserts that a string is not <see cref="string.Empty"/>.
        ///
        /// <param name="because">
        /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
        /// is needed. If the phrase does not start with the word because, it is prepended automatically.
        /// </param>
        /// <param name="becauseArgs">
        /// Zero or more objects to format using the placeholders in <see cref="because" />.
        /// </param>
        public AndConstraint<StringAssertions> NotBeEmpty(string because = "", params object[] becauseArgs)
        {
            Execute.Assertion
                .ForCondition(Subject.Length > 0)
                .BecauseOf(because, becauseArgs)
                .FailWith("Did not expect empty string{reason}.");

            return new AndConstraint<StringAssertions>(this);
        }

        ///
        /// Asserts that a string has the specified <paramref name="expected"/> length.
        ///
        /// <param name="expected">The expected length of the string</param>
        /// <param name="because">
        /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
        /// is needed. If the phrase does not start with the word because, it is prepended automatically.
        /// </param>
        /// <param name="becauseArgs">
        /// Zero or more objects to format using the placeholders in <see cref="because" />.
        /// </param>
        public AndConstraint<StringAssertions> HaveLength(int expected, string because = "", params object[] becauseArgs)
        {
            Execute.Assertion
                .ForCondition(Subject.Length == expected)
                .BecauseOf(because, becauseArgs)
                .FailWith("Expected string with length {0}{reason}, but found string {1} with length {2}.",
                    expected, Subject, Subject.Length);

            return new AndConstraint<StringAssertions>(this);
        }

        ///
        /// Asserts that a string is neither <c>null</c> nor <see cref="string.Empty"/>.
        ///
        /// <param name="because">
        /// A formatted phrase explaining why the assertion should be satisfied. If the phrase does not
        /// start with the word because, it is prepended to the message.
        /// </param>
        /// <param name="becauseArgs">
        /// Zero or more values to use for filling in any <see cref="string.Format(string,object[])" /> compatible placeholders.
        /// </param>
        public AndConstraint<StringAssertions> NotBeNullOrEmpty(string because = "", params object[] becauseArgs)
        {
            Execute.Assertion
                .ForCondition(!string.IsNullOrEmpty(Subject))
                .BecauseOf(because, becauseArgs)
                .FailWith("Expected string not to be <null> or empty{reason}, but found {0}.", Subject);

            return new AndConstraint<StringAssertions>(this);
        }

        ///
        /// Asserts that a string is either <c>null</c> or <see cref="string.Empty"/>.
        ///
        /// <param name="because">
        /// A formatted phrase explaining why the assertion should be satisfied. If the phrase does not
        /// start with the word because, it is prepended to the message.
        /// </param>
        /// <param name="becauseArgs">
        /// Zero or more values to use for filling in any <see cref="string.Format(string,object[])" /> compatible placeholders.
        /// </param>
        public AndConstraint<StringAssertions> BeNullOrEmpty(string because = "", params object[] becauseArgs)
        {
            Execute.Assertion
                .ForCondition(string.IsNullOrEmpty(Subject))
                .BecauseOf(because, becauseArgs)
                .FailWith("Expected string to be <null> or empty{reason}, but found {0}.", Subject);

            return new AndConstraint<StringAssertions>(this);
        }

        ///
        /// Asserts that a string is neither <c>null</c> nor <see cref="string.Empty"/> nor white space
        ///
        /// <param name="because">
        /// A formatted phrase explaining why the assertion should be satisfied. If the phrase does not
        /// start with the word because, it is prepended to the message.
        /// </param>
        /// <param name="becauseArgs">
        /// Zero or more values to use for filling in any <see cref="string.Format(string,object[])" /> compatible placeholders.
        /// </param>
        public AndConstraint<StringAssertions> NotBeNullOrWhiteSpace(string because = "", params object[] becauseArgs)
        {
            Execute.Assertion
                .ForCondition(!IsBlank(Subject))
                .BecauseOf(because, becauseArgs)
                .FailWith("Expected string not to be <null> or whitespace{reason}, but found {0}.", Subject);

            return new AndConstraint<StringAssertions>(this);
        }

        ///
        /// Asserts that a string is either <c>null</c> or <see cref="string.Empty"/> or white space
        ///
        /// <param name="because">
        /// A formatted phrase explaining why the assertion should be satisfied. If the phrase does not
        /// start with the word because, it is prepended to the message.
        /// </param>
        /// <param name="becauseArgs">
        /// Zero or more values to use for filling in any <see cref="string.Format(string,object[])" /> compatible placeholders.
        /// </param>
        public AndConstraint<StringAssertions> BeNullOrWhiteSpace(string because = "", params object[] becauseArgs)
        {
            Execute.Assertion
                .ForCondition(IsBlank(Subject))
                .BecauseOf(because, becauseArgs)
                .FailWith("Expected string to be <null> or whitespace{reason}, but found {0}.", Subject);

            return new AndConstraint<StringAssertions>(this);
        }

        private static bool IsBlank(string value)
        {
            return (value == null) || string.IsNullOrEmpty(value.Trim());
        }

        ///
        /// Returns the type of the subject the assertion applies on.
        ///
        protected override string Context
        {
            get { return "string"; }
        }
    }
}


text:
from django.contrib.auth.models import User
from django.utils.http import urlencode
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect
from django.views.decorators.csrf import csrf_exempt

from openid.consumer.discover import DiscoveryFailure
from openid.consumer import consumer
from openid.extensions.sreg import SRegRequest, SRegResponse
from openid.extensions.ax import FetchRequest, FetchResponse, AttrInfo

from allauth.socialaccount.app_settings import QUERY_EMAIL
from allauth.socialaccount.models import SocialAccount, SocialLogin
from allauth.socialaccount.helpers import render_authentication_error
from allauth.socialaccount.helpers import complete_social_login
from allauth.utils import valid_email_or_none

from utils import DBOpenIDStore
from forms import LoginForm
from provider import OpenIDProvider

class AXAttribute:
    CONTACT_EMAIL = 'http://axschema.org/contact/email'

class SRegField:
    EMAIL = 'email'

def _openid_consumer(request):
    store = DBOpenIDStore()
    client = consumer.Consumer(request.session, store)
    return client

def login(request):
    if request.GET.has_key('openid') or request.method == 'POST':
        form = LoginForm(request.REQUEST)
        if form.is_valid():
            client = _openid_consumer(request)
            try:
                auth_request = client.begin(form.cleaned_data['openid'])
                if QUERY_EMAIL:
                    sreg = SRegRequest()
                    sreg.requestField(field_name=SRegField.EMAIL, required=True)
                    auth_request.addExtension(sreg)
                    ax = FetchRequest()
                    ax.add(AttrInfo(AXAttribute.CONTACT_EMAIL,
                                    required=True))
                    auth_request.addExtension(ax)
                callback_url = reverse(callback)
                state = SocialLogin.marshall_state(request)
                callback_url = callback_url + '?' + urlencode(dict(state=state))
                redirect_url = auth_request.redirectURL(
                    request.build_absolute_uri('/'),
                    request.build_absolute_uri(callback_url))
                return HttpResponseRedirect(redirect_url)
            except DiscoveryFailure, e:
                if request.method == 'POST':
                    form._errors["openid"] = form.error_class([e])
                else:
                    return render_authentication_error(request)
    else:
        form = LoginForm()
    d = dict(form=form)
    return render_to_response('openid/login.html',
                              d, context_instance=RequestContext(request))

def _get_email_from_response(response):
    email = None
    sreg = SRegResponse.fromSuccessResponse(response)
    if sreg:
        email = valid_email_or_none(sreg.get(SRegField.EMAIL))
    if not email:
        ax = FetchResponse.fromSuccessResponse(response)
        if ax:
            try:
                values = ax.get(AXAttribute.CONTACT_EMAIL)
                if values:
                    email = valid_email_or_none(values[0])
            except KeyError:
                pass
    return email

@csrf_exempt
def callback(request):
    client = _openid_consumer(request)
    response = client.complete(
        dict(request.REQUEST.items()),
        request.build_absolute_uri(request.path))
    if response.status == consumer.SUCCESS:
        user = User(email=_get_email_from_response(response))
        account = SocialAccount(uid=response.identity_url,
                                provider=OpenIDProvider.id,
                                user=user,
                                extra_data={})
        login = SocialLogin(account)
        login.state = SocialLogin.unmarshall_state(request.REQUEST.get('state'))
        ret = complete_social_login(request, login)
    elif response.status == consumer.CANCEL:
        ret = HttpResponseRedirect(reverse('socialaccount_login_cancelled'))
    else:
        ret = render_authentication_error(request)
    return ret

redpajama_set_name: RedPajamaGithub


text:
package sla;

/**
 * An abstract class representing a SLA that in any point of time is either fulfilled or not fulfilled.
 * Because of this property one can also ask the percentage that the SLA has been fulfilled between two certain times.
 *
 * @author Wietse Buseyne
 *
 */
public abstract class TimeBoundedSLA {

	/**
	 * Tests whether or not the SLA was fulfilled at the specified step
	 * @param step The step at which the SLA's status should be checked.
	 * @return True if the SLA was fulfilled at the specified step, False otherwise
	 */
	public abstract boolean isFulfilled(long step);

	/**
	 * Requests the average percentage of which the SLA was fulfilled during the period between the given start an end steps.
	 * @param startStep The start of the period
	 * @param endStep The end of the period
	 * @param stepInterval The interval of steps at which the percentage should be checked. If this is 1, all percentages will be checked.
	 * 						Can be increased to increase performance, but comes at the price of lost accuracy.
	 * @return A number between 0 and 100 inclusive that represents the percentage of the time the SLA was in the fulfilled state.
	 */
	public double getPercentage(long startStep, long endStep, long stepInterval){
		double percent = 0;
		int denom = 0;
		for(long i = startStep; i <= endStep; i += stepInterval) {
			denom++;
			if (isFulfilled(i))
				percent++;
		}
		return percent * 100 / denom;
	}

}


text:
#ifndef GrYUVProvider_DEFINED
#define GrYUVProvider_DEFINED

#include "include/core/SkImageInfo.h"
#include "include/core/SkYUVAIndex.h"
#include "include/core/SkYUVASizeInfo.h"
#include "include/gpu/GrTypes.h"
#include "include/private/GrTypesPriv.h"

class GrBackendFormat;
class GrRecordingContext;
struct GrSurfaceDesc;
class GrTexture;
class GrTextureProxy;
class SkCachedData;

/**
 *  There are at least 2 different ways to extract/retrieve YUV planar data...
 *  - SkPixelRef
 *  - SkImageGenerator
 *
 *  To share common functionality around using the planar data, we use this abstract base-class
 *  to represent accessing that data.
 */
class GrYUVProvider {
public:
    virtual ~GrYUVProvider() {}

    /**
     *  On success, this returns a texture proxy that has converted the YUV data from the provider
     *  into a form that is supported by the GPU (typically transformed into RGB). The texture will
     *  automatically have a key added, so it can be retrieved from the cache (assuming it is
     *  requested by a provider w/ the same genID). If srcColorSpace and dstColorSpace are
     *  specified, then a color conversion from src to dst will be applied to the pixels.
     *
     *  On failure (e.g. the provider had no data), this returns NULL.
     */
    sk_sp<GrTextureProxy> refAsTextureProxy(GrRecordingContext*,
                                            const GrSurfaceDesc&,
                                            GrColorType colorType,
                                            SkColorSpace* srcColorSpace,
                                            SkColorSpace* dstColorSpace);

    sk_sp<SkCachedData> getPlanes(SkYUVASizeInfo*, SkYUVAIndex[SkYUVAIndex::kIndexCount],
                                  SkYUVColorSpace*, const void* planes[SkYUVASizeInfo::kMaxCount]);

private:
    virtual uint32_t onGetID() const = 0;

    // These are not meant to be called by a client, only by the implementation

    /**
     *  If decoding to YUV is supported, this returns true.  Otherwise, this
     *  returns false and does not modify any of the parameters.
     *
     *  @param sizeInfo    Output parameter indicating the sizes and required
     *                     allocation widths of the Y, U, V, and A planes.
     *  @param yuvaIndices How the YUVA planes are used/organized
     *  @param colorSpace  Output parameter.
     */
    virtual bool onQueryYUVA8(SkYUVASizeInfo* sizeInfo,
                              SkYUVAIndex yuvaIndices[SkYUVAIndex::kIndexCount],
                              SkYUVColorSpace* colorSpace) const = 0;

    /**
     *  Returns true on success and false on failure.
     *  This always attempts to perform a full decode.  If the client only
     *  wants size, it should call onQueryYUVA8().
     *
     *  @param sizeInfo    Needs to exactly match the values returned by the
     *                     query, except the WidthBytes may be larger than the
     *                     recommendation (but not smaller).
     *  @param yuvaIndices How the YUVA planes are used/organized
     *  @param planes      Memory for each of the Y, U, V, and A planes.
     */
    virtual bool onGetYUVA8Planes(const SkYUVASizeInfo& sizeInfo,
                                  const SkYUVAIndex yuvaIndices[SkYUVAIndex::kIndexCount],
                                  void* planes[]) = 0;

    // This is used as release callback for the YUV data that we capture in an SkImage when
    // uploading to a gpu. When the upload is complete and we release the SkImage this callback will
    // release the underlying data.
    static void YUVGen_DataReleaseProc(const void*, void* data);
};

#endif


text:
<?php

namespace Google\Service\Sheets;

class TextFormat extends \Google\Model
{
  /**
   * @var bool
   */
  public $bold;
  /**
   * @var string
   */
  public $fontFamily;
  /**
   * @var int
   */
  public $fontSize;
  protected $foregroundColorType = Color::class;
  protected $foregroundColorDataType = '';
  protected $foregroundColorStyleType = ColorStyle::class;
  protected $foregroundColorStyleDataType = '';
  /**
   * @var bool
   */
  public $italic;
  protected $linkType = Link::class;
  protected $linkDataType = '';
  /**
   * @var bool
   */
  public $strikethrough;
  /**
   * @var bool
   */
  public $underline;

  /**
   * @param bool
   */
  public function setBold($bold)
  {
    $this->bold = $bold;
  }
  /**
   * @return bool
   */
  public function getBold()
  {
    return $this->bold;
  }
  /**
   * @param string
   */
  public function setFontFamily($fontFamily)
  {
    $this->fontFamily = $fontFamily;
  }
  /**
   * @return string
   */
  public function getFontFamily()
  {
    return $this->fontFamily;
  }
  /**
   * @param int
   */
  public function setFontSize($fontSize)
  {
    $this->fontSize = $fontSize;
  }
  /**
   * @return int
   */
  public function getFontSize()
  {
    return $this->fontSize;
  }
  /**
   * @param Color
   */
  public function setForegroundColor(Color $foregroundColor)
  {
    $this->foregroundColor = $foregroundColor;
  }
  /**
   * @return Color
   */
  public function getForegroundColor()
  {
    return $this->foregroundColor;
  }
  /**
   * @param ColorStyle
   */
  public function setForegroundColorStyle(ColorStyle $foregroundColorStyle)
  {
    $this->foregroundColorStyle = $foregroundColorStyle;
  }
  /**
   * @return ColorStyle
   */
  public function getForegroundColorStyle()
  {
    return $this->foregroundColorStyle;
  }
  /**
   * @param bool
   */
  public function setItalic($italic)
  {
    $this->italic = $italic;
  }
  /**
   * @return bool
   */
  public function getItalic()
  {
    return $this->italic;
  }
  /**
   * @param Link
   */
  public function setLink(Link $link)
  {
    $this->link = $link;
  }
  /**
   * @return Link
   */
  public function getLink()
  {
    return $this->link;
  }
  /**
   * @param bool
   */
  public function setStrikethrough($strikethrough)
  {
    $this->strikethrough = $strikethrough;
  }
  /**
   * @return bool
   */
  public function getStrikethrough()
  {
    return $this->strikethrough;
  }
  /**
   * @param bool
   */
  public function setUnderline($underline)
  {
    $this->underline = $underline;
  }
  /**
   * @return bool
   */
  public function getUnderline()
  {
    return $this->underline;
  }
}

// Adding a class alias for backwards compatibility with the previous class name.
class_alias(TextFormat::class, 'Google_Service_Sheets_TextFormat');


text:
"use strict";
function $__interopRequire(id) {
  id = require(id);
  return id && id.__esModule && id || {default: id};
}
Object.defineProperties(module.exports, {
  __esModule: {value: true},
  PropertyNameShorthandTransformer: {
    enumerable: true,
    get: function() {
      return PropertyNameShorthandTransformer;
    }
  }
});
var $__superConstructor = $__interopRequire("traceur/dist/commonjs/runtime/modules/superConstructor.js").default;
var $__createClass = $__interopRequire("traceur/dist/commonjs/runtime/modules/createClass.js").default;
var $__3 = require("../syntax/trees/ParseTrees.js"),
    IdentifierExpression = $__3.IdentifierExpression,
    LiteralPropertyName = $__3.LiteralPropertyName,
    PropertyNameAssignment = $__3.PropertyNameAssignment;
var ParseTreeTransformer = require("./ParseTreeTransformer.js").ParseTreeTransformer;
var PropertyNameShorthandTransformer = function($__super) {
  function PropertyNameShorthandTransformer() {
    $__superConstructor(PropertyNameShorthandTransformer).apply(this, arguments);
  }
  return ($__createClass)(PropertyNameShorthandTransformer, {transformPropertyNameShorthand: function(tree) {
      return new PropertyNameAssignment(tree.location, new LiteralPropertyName(tree.location, tree.name), new IdentifierExpression(tree.location, tree.name));
    }}, {}, $__super);
}(ParseTreeTransformer);


text:
using System;
using Server;
using Server.Items;

namespace Server.Mobiles
{
	[CorpseName( "a Grobu corpse" )]
	public class Grobu : BlackBear
	{
		[Constructable]
		public Grobu()
		{
			IsParagon = true;

			Name = "Grobu";
			Hue = 0x455;

			AI = AIType.AI_Melee;
			FightMode = FightMode.Closest;

			SetStr( 192, 210 );
			SetDex( 132, 150 );
			SetInt( 50, 52 );

			SetHits( 1235, 1299 );
			SetStam( 132, 150 );
			SetMana( 9 );

			SetDamage( 15, 18 );

			SetDamageType( ResistanceType.Physical, 100 );

			SetResistance( ResistanceType.Physical, 40, 45 );
			SetResistance( ResistanceType.Fire, 20, 40 );
			SetResistance( ResistanceType.Cold, 32, 35 );
			SetResistance( ResistanceType.Poison, 25, 30 );
			SetResistance( ResistanceType.Energy, 22, 34 );

			SetSkill( SkillName.Wrestling, 96.4, 119.0 );
			SetSkill( SkillName.Tactics, 96.2, 116.5 );
			SetSkill( SkillName.MagicResist, 66.2, 83.7 );

			Fame = 1000;
			Karma = 1000;
		}

		public override void GenerateLoot()
		{
			AddLoot( LootPack.FilthyRich, 2 );
		}

		public override void OnDeath( Container c )
		{
			base.OnDeath( c );

			c.DropItem( new GrobusFur() );
		}

		public override bool GivesMLMinorArtifact{ get{ return true; } }

		public Grobu( Serial serial )
			: base( serial )
		{
		}

		public override void Serialize( GenericWriter writer )
		{
			base.Serialize( writer );

			writer.Write( (int) 0 ); // version
		}

		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );

			int version = reader.ReadInt();
		}
	}
}


text:
function sfWebDebugGetElementsByClassName(strClass, strTag, objContElm)
{
  // http://muffinresearch.co.uk/archives/2006/04/29/getelementsbyclassname-deluxe-edition/
  strTag = strTag || "*";
  objContElm = objContElm || document;
  var objColl = (strTag == '*' && document.all) ? document.all : objContElm.getElementsByTagName(strTag);
  var arr = new Array();
  var delim = strClass.indexOf('|') != -1  ? '|' : ' ';
  var arrClass = strClass.split(delim);
  var j = objColl.length;
  for (var i = 0; i < j; i++) {
    if(objColl[i].className == undefined) continue;
    var arrObjClass = objColl[i].className.split(' ');
    if (delim == ' ' && arrClass.length > arrObjClass.length) continue;
    var c = 0;
    comparisonLoop:
    {
      var l = arrObjClass.length;
      for (var k = 0; k < l; k++) {
        var n = arrClass.length;
        for (var m = 0; m < n; m++) {
          if (arrClass[m] == arrObjClass[k]) c++;
          if (( delim == '|' && c == 1) || (delim == ' ' && c == arrClass.length)) {
            arr.push(objColl[i]);
            break comparisonLoop;
          }
        }
      }
    }
  }
  return arr;
}

function sfWebDebugToggleMenu()
{
  var element = document.getElementById('sfWebDebugDetails');

  var cacheElements = sfWebDebugGetElementsByClassName('sfWebDebugCache');
  var mainCacheElements = sfWebDebugGetElementsByClassName('sfWebDebugActionCache');

  if (element.style.display != 'none')
  {
    document.getElementById('sfWebDebugLog').style.display = 'none';
    document.getElementById('sfWebDebugConfig').style.display = 'none';
    document.getElementById('sfWebDebugDatabaseDetails').style.display = 'none';
    document.getElementById('sfWebDebugTimeDetails').style.display = 'none';

    // hide all cache information
    for (var i = 0; i < cacheElements.length; ++i)
    {
      cacheElements[i].style.display = 'none';
    }
    for (var i = 0; i < mainCacheElements.length; ++i)
    {
      mainCacheElements[i].style.border = 'none';
    }
  }
  else
  {
    for (var i = 0; i < cacheElements.length; ++i)
    {
      cacheElements[i].style.display = '';
    }
    for (var i = 0; i < mainCacheElements.length; ++i)
    {
      mainCacheElements[i].style.border = '1px solid #f00';
    }
  }

  sfWebDebugToggle('sfWebDebugDetails');
  sfWebDebugToggle('sfWebDebugShowMenu');
  sfWebDebugToggle('sfWebDebugHideMenu');
}

function sfWebDebugShowDetailsFor(element)
{
  if (element != 'sfWebDebugLog') document.getElementById('sfWebDebugLog').style.display='none';
  if (element != 'sfWebDebugConfig') document.getElementById('sfWebDebugConfig').style.display='none';
  if (element != 'sfWebDebugDatabaseDetails') document.getElementById('sfWebDebugDatabaseDetails').style.display='none';
  if (element != 'sfWebDebugTimeDetails') document.getElementById('sfWebDebugTimeDetails').style.display='none';

  sfWebDebugToggle(element);
}

function sfWebDebugToggle(element)
{
  if (typeof element == 'string')
    element = document.getElementById(element);

  if (element)
    element.style.display = element.style.display == 'none' ? '' : 'none';
}

function sfWebDebugToggleMessages(klass)
{
  var elements = sfWebDebugGetElementsByClassName(klass);

  var x = elements.length;
  for (var i = 0; i < x; ++i)
  {
    sfWebDebugToggle(elements[i]);
  }
}

function sfWebDebugToggleAllLogLines(show, klass)
{
  var elements = sfWebDebugGetElementsByClassName(klass);
  var x = elements.length;
  for (var i = 0; i < x; ++i)
  {
    elements[i].style.display = show ? '' : 'none';
  }
}

function sfWebDebugShowOnlyLogLines(type)
{
  var types = new Array();
  types[0] = 'info';
  types[1] = 'warning';
  types[2] = 'error';
  for (klass in types)
  {
    var elements = sfWebDebugGetElementsByClassName('sfWebDebug' + types[klass].substring(0, 1).toUpperCase() + types[klass].substring(1, types[klass].length));
    var x = elements.length;
    for (var i = 0; i < x; ++i)
    {
      if ('tr' == elements[i].tagName.toLowerCase())
      {
        elements[i].style.display = (type == types[klass]) ? '' : 'none';
      }
    }
  }
}


text:
Editing Course

<?php echo render(Controller_Base::get_prefix() . 'course/_form'); ?>

	<?php echo Html::anchor(Controller_Base::get_prefix() . 'course/view/'.$course->id, 'View'); ?> |
	<?php echo Html::anchor(Controller_Base::get_prefix() . 'course', 'Back'); ?>


text:
package com.centurylink.mdw.util.log;

import com.centurylink.mdw.activity.types.ActivityCategory;
import com.centurylink.mdw.app.ApplicationContext;
import com.centurylink.mdw.config.PropertyManager;
import com.centurylink.mdw.config.YamlProperties;
import com.centurylink.mdw.util.log.log4j.Log4JStandardLoggerImpl;
import com.centurylink.mdw.util.log.slf4j.Slf4JStandardLoggerImpl;
import org.slf4j.helpers.Util;

import java.io.File;
import java.io.IOException;
import java.io.Serializable;

public class LoggerUtil implements Serializable {

    public static final String MDW_LOGGER_IMPL = "mdw.logger.impl";

    private static LoggerUtil util = new LoggerUtil();

    private LoggerUtil() {
    }

    public static LoggerUtil getInstance() {
        return util;
    }

    private static boolean accessed;

    /**
     * For Spring Boot with slf4j SimpleLogger, an opportunity to initialize logging before Spring starts logging.
     * Otherwise for slf4j, properties have already been defaulted before we have a chance to set them.
     *
     * See mdw-spring-boot AutoConfig for initialization of logback for pure Spring Boot apps.
     */
    public static String initializeLogging() throws IOException {
        System.setProperty("org.slf4j.simpleLogger.logFile", "System.out");
        System.setProperty("org.slf4j.simpleLogger.showDateTime", "true");
        System.setProperty("org.slf4j.simpleLogger.dateTimeFormat", "yyyyMMdd.HH:mm:ss.SSS");
        // Peek at mdw.yaml to find default logging level, but do not initialize PropertyManager
        // which could initialize slf4j prematurely.  (Works only with yaml config file).
        String mdwLogLevel = null;
        File mdwYaml = getConfigurationFile("mdw.yaml");
        if (mdwYaml.exists()) {
            YamlProperties yamlProps = new YamlProperties("mdw", mdwYaml);
            mdwLogLevel = yamlProps.getString("mdw.logging.level");
            if (mdwLogLevel != null) {
                if (mdwLogLevel.equals("MDW_DEBUG"))
                    mdwLogLevel = "TRACE";
                System.setProperty("org.slf4j.simpleLogger.log.com.centurylink.mdw", mdwLogLevel.toLowerCase());
            }
        }
        return mdwLogLevel;
    }

    public static StandardLogger getStandardLogger() {
        String loggerImplClass = System.getProperty(MDW_LOGGER_IMPL);
        if (!accessed && loggerImplClass != null) {
            System.out.println("\nUsing Logger Impl: " + loggerImplClass);
            accessed = true;
        }
        Class<?> callingClass = Util.getCallingClass();
        StandardLogger logger;
        // avoid reflection for known impls
        if (loggerImplClass == null) {
            logger = new Slf4JStandardLoggerImpl(callingClass.getName());
        }
        else if (SimpleLogger.class.getName().equals(loggerImplClass)) {
            logger = SimpleLogger.getSingleton();
        }
        else if (Log4JStandardLoggerImpl.class.getName().equals(loggerImplClass) || org.apache.log4j.Logger.class.getName().equals(loggerImplClass)) {
            logger = new Log4JStandardLoggerImpl();
        }
        else if (Slf4JStandardLoggerImpl.class.getName().equals(loggerImplClass) || org.slf4j.Logger.class.getName().equals(loggerImplClass)) {
            logger = new Slf4JStandardLoggerImpl(callingClass.getName());
        }
        else {
            try {
                logger = Class.forName(loggerImplClass).asSubclass(StandardLogger.class).newInstance();
            }
            catch (Exception ex) {
                ex.printStackTrace();  // logging isn't working
                return null;
            }
        }
        checkWarnActivityLogging(logger, callingClass);
        return logger;
    }

    private static void checkWarnActivityLogging(StandardLogger logger, Class<?> callingClass) {
        String warn = null;
        if (ActivityCategory.class.isAssignableFrom(callingClass) &&
                !callingClass.getName().equals("com.centurylink.mdw.services.process.BaseActivity")) {
            String docUrl = ApplicationContext.getDocsUrl() + "/help/implementor.html#logging";
            warn = "Activity logging bypassed by: " + callingClass.getName() + " (see " + docUrl + ")";
        }
        else if (callingClass.getName().matches(".*_A\\d*")) {
            // dynamic java
            String docUrl = ApplicationContext.getDocsUrl() + "/help/dynamicJavaActivity.html#logging";
            warn = "Activity logging bypassed by dynamic Java: " + callingClass.getName() + " (see " + docUrl + ")";
        }
        if (warn != null) {
            // this will become a stack trace in a future build
            logger.warn("*** WARNING *** " + warn);
        }
    }

    /**
     * Get a standard logger based on a class name.
     */
    public static StandardLogger getStandardLogger(String className) {
        String loggerImplClass = System.getProperty(MDW_LOGGER_IMPL);
        if (!accessed && loggerImplClass != null) {
            System.out.println("\nUsing Logger Impl: " + loggerImplClass);
            accessed = true;
        }
        // avoid reflection for known impls
        if (className == null) {
            return getStandardLogger();
        }
        else if (loggerImplClass == null || Slf4JStandardLoggerImpl.class.getName().equals(loggerImplClass) || org.slf4j.Logger.class.getName().equals(loggerImplClass)) {
            return new Slf4JStandardLoggerImpl(className);
        }
        else if (SimpleLogger.class.getName().equals(loggerImplClass)) {
            return SimpleLogger.getSingleton();
        }
        else if (Log4JStandardLoggerImpl.class.getName().equals(loggerImplClass) || org.apache.log4j.Logger.class.getName().equals(loggerImplClass)) {
            return new Log4JStandardLoggerImpl(className);
        }
        else {
            try {
                Class<? extends StandardLogger> loggerClass = Class.forName(loggerImplClass).asSubclass(StandardLogger.class);
                return loggerClass.getConstructor(String.class).newInstance(className);
            }
            catch (Exception ex) {
                ex.printStackTrace();  // logging isn't working
                return null;
            }
        }
    }

    public static File getConfigurationFile(String filepath) {
        String configDir = System.getProperty(PropertyManager.MDW_CONFIG_LOCATION);
        if (configDir == null)
            return new File(filepath);
        else if (configDir.endsWith("/"))
            return new File(configDir + filepath);
        else
            return new File(configDir + "/" + filepath);
    }

}


text:
package org.springframework.transaction;

/**
 * Exception to be thrown when a transaction has timed out.
 *
 *
Thrown by Spring's local transaction strategies if the deadline
 * for a transaction has been reached when an operation is attempted,
 * according to the timeout specified for the given transaction.
 *
 *
Beyond such checks before each transactional operation, Spring's
 * local transaction strategies will also pass appropriate timeout values
 * to resource operations (for example to JDBC Statements, letting the JDBC
 * driver respect the timeout). Such operations will usually throw native
 * resource exceptions (for example, JDBC SQLExceptions) if their operation
 * timeout has been exceeded, to be converted to Spring's DataAccessException
 * in the respective DAO (which might use Spring's JdbcTemplate, for example).
 *
 *
In a JTA environment, it is up to the JTA transaction coordinator
 * to apply transaction timeouts. Usually, the corresponding JTA-aware
 * connection pool will perform timeout checks and throw corresponding
 * native resource exceptions (for example, JDBC SQLExceptions).
 *
 * @author Juergen Hoeller
 * @since 1.1.5
 * @see org.springframework.transaction.support.ResourceHolderSupport#getTimeToLiveInMillis
 * @see java.sql.Statement#setQueryTimeout
 * @see java.sql.SQLException
 */
@SuppressWarnings("serial")
public class TransactionTimedOutException extends TransactionException {

	/**
	 * Constructor for TransactionTimedOutException.
	 * @param msg the detail message
	 */
	public TransactionTimedOutException(String msg) {
		super(msg);
	}

	/**
	 * Constructor for TransactionTimedOutException.
	 * @param msg the detail message
	 * @param cause the root cause from the transaction API in use
	 */
	public TransactionTimedOutException(String msg, Throwable cause) {
		super(msg, cause);
	}

}


text:
<?php
/**
 * Created by PhpStorm.
 * User: wamobi10
 * Date: 26/01/17
 * Time: 09:29
 */

namespace AppBundle\Event;

class VisitEvents
{
    //liste des events de cette famille
    const CONTACT = 'app.events.visit';
    // autre ex
    //const PRODUCT = 'app.events.visit.product';
}