text:
<!DOCTYPE html>

        <title>Lobibox - Responsive jQuery notification plugin</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">

        <link rel="stylesheet" href="font-awesome/css/font-awesome.min.css"/>
        <link rel="stylesheet" href="demo/demo.css"/>

        <link rel="stylesheet" href="dist/css/lobibox.min.css"/>

Examples

                                <fieldset>

                                        <button id="popupYesNoBasic" class="btn btn-primary">Confirm</button>

                                </fieldset>

                                <fieldset>

                                        <button id="popupErrorBasic" class="btn btn-danger">Show Error</button>
                                        <button id="popupSuccessBasic" class="btn btn-success">Show Success</button>
                                        <button id="popupInfoBasic" class="btn btn-info">Show info</button>
                                        <button id="popupWarningBasic" class="btn btn-warning">Show Warning</button>

                                </fieldset>

                                <fieldset>

                                        <button id="popupPromptBasic" class="btn btn-primary">Prompt</button>

                                </fieldset>

                                <fieldset>

                                        <button id="popupProgressBasic" class="btn btn-primary">Progress</button>

                                        <button id="popupProgressBootstrap" class="btn btn-primary">Bootstrap progress</button>

                                </fieldset>

                                <fieldset>

                                        <button id="popupWindowBasic" class="btn btn-primary">Window</button>

                                </fieldset>

Custom buttons

                                    <button id="popupProgressErrorButtons" class="btn btn-danger">Error</button>

Disable icon

                                    <button id="popupConfirmNoIcon" class="btn btn-primary">Button</button>

Advanced usage of Lobibox.window

                                    <button id="popupWindowExample" class="btn btn-primary">Window</button>

Callbacks

All popup boxes have callback option

                                <button id="popupYesNoCallback" class="btn btn-primary">Confirm</button>

Lobibox.confirm({
    msg: "Are you sure you want to delete this user?",
    callback: function ($this, type, ev) {
        //Your code goes here
    }
});

                        <form id="lobibox-popup-demo-form" action>

                                        Popup type
                                        <select class="form-control" name="popupType">
                                            <option value="confirm">Confirm</option>
                                            <option value="alert">Alert</option>
                                            <option value="prompt">Prompt</option>
                                            <option value="progress">Progress</option>
                                        </select>

                                            Common parameters

                                        <fieldset>

                                                        title
                                                        <input type="text" name="title" class="form-control" value=""/>

                                                    Base class (default)
                                                    <input type="text" name="baseClass" class="form-control" value="animated-super-fast"/>

                                                    Show class
                                                    <input type="text" name="showClass" class="form-control" value="zoomIn"/>

                                                    Hide class
                                                    <input type="text" name="hideClass" class="form-control" value="zoomOut"/>

                                                    Message
                                                    <textarea rows="4" class="form-control" name="msg"></textarea>

                                                        Width

                                                            <input type="number" name="width" class="form-control"/>

                                                        Height

                                                            <input type="text" name="height" value="auto" class="form-control"/>

                                                                <input type="checkbox" name="closeButton" checked=""> Close button

                                                                <input type="checkbox" name="draggable"> Draggable

                                                                <input type="checkbox" name="modal" checked=""> Modal

                                                                <input type="checkbox" name="closeOnEsc"> Close on escape

                                        </fieldset>

                                                        Confirm options

                                                    <fieldset class="confirm-fieldset">

                                                                    Icon Class
                                                                    <input type="text" class="form-control" name="iconClass" value="glyphicon glyphicon-question-sign"/>

                                                    </fieldset>

                                                        Alert options

                                                    <fieldset class="alert-fieldset" disabled="">

                                                                    Alert type
                                                                    <select class="form-control" name="type">
                                                                        <option value="success">Success</option>
                                                                        <option value="error">Error</option>
                                                                        <option value="info">Info</option>
                                                                        <option value="warning">Warning</option>
                                                                    </select>

                                                                    Icon Class
                                                                    <input type="text" class="form-control" name="iconClass"/>

                                                    </fieldset>

                                                        Prompt options

                                                    <fieldset class="prompt-fieldset" disabled="">

                                                                    Type
                                                                    <input type="text" class="form-control" name="type" value="text"/>

                                                                    Placeholder
                                                                    <input type="text" class="form-control" name="placeholder" value=""/>

                                                                    Value
                                                                    <input type="text" class="form-control" name="value" value=""/>

                                                                    Label
                                                                    <input type="text" class="form-control" name="label"/>

                                                                            <input type="checkbox" name="multiline"> Multiline

                                                                    Lines (For multiline)
                                                                    <input type="number" class="form-control" name="lines" value=""/>

                                                    </fieldset>

                                                        Progress options

Progress does not update itself.

But you can implement it easily when uploading or waiting something

                                                    <fieldset class="progress-fieldset" disabled="">

                                                                Label
                                                                <input type="text" class="form-control" name="label" value=""/>

                                                                        <input type="checkbox" name="showProgressLabel" checked> Progress label

                                                    </fieldset>

                            <button class="btn btn-primary">Create popup</button>
                        </form>

Examples

                        <fieldset>
                            <legend>Basic notifications Can be closed by clicking on it</legend>

                                <button id="basicDefault" class="btn btn-default">Default</button>
                                <button id="basicInfo" class="btn btn-info">Info</button>
                                <button id="basicWarning" class="btn btn-warning">Warning</button>
                                <button id="basicError" class="btn btn-danger">Error</button>
                                <button id="basicSuccess" class="btn btn-success">Success</button>

                        </fieldset>

                        <fieldset>
                            <legend>With image</legend>

                                <button id="basicDefaultImage" class="btn btn-default">Default</button>
                                <button id="basicInfoImage" class="btn btn-info">Info</button>
                                <button id="basicWarningImage" class="btn btn-warning">Warning</button>
                                <button id="basicErrorImage" class="btn btn-danger">Error</button>
                                <button id="basicSuccessImage" class="btn btn-success">Success</button>

                        </fieldset>

                        <fieldset>
                            <legend>Disable sound</legend>

                                <button id="basicInfoNoSound" class="btn btn-info">Info</button>
                                <button id="basicWarningNoSound" class="btn btn-warning">Warning</button>
                                <button id="basicErrorNoSound" class="btn btn-danger">Error</button>
                                <button id="basicSuccessNoSound" class="btn btn-success">Success</button>

                        </fieldset>

                        <fieldset>
                            <legend>Custom title</legend>

                                <button id="basicDefaultCustomTitle" class="btn btn-default">Default</button>
                                <button id="basicInfoCustomTitle" class="btn btn-info">Info</button>
                                <button id="basicWarningCustomTitle" class="btn btn-warning">Warning</button>
                                <button id="basicErrorCustomTitle" class="btn btn-danger">Error</button>
                                <button id="basicSuccessCustomTitle" class="btn btn-success">Success</button>

                        </fieldset>

                        <fieldset>
                            <legend>Without icon and image</legend>

                                <button id="basicDefaultNoIcon" class="btn btn-default">Default</button>
                                <button id="basicInfoNoIcon" class="btn btn-info">Info</button>
                                <button id="basicWarningNoIcon" class="btn btn-warning">Warning</button>
                                <button id="basicErrorNoIcon" class="btn btn-danger">Error</button>
                                <button id="basicSuccessNoIcon" class="btn btn-success">Success</button>

                        </fieldset>

                        <fieldset>
                            <legend>Increase delay time</legend>

                                <button id="basicDefaultCustomDelay" class="btn btn-default">Default</button>
                                <button id="basicInfoCustomDelay" class="btn btn-info">Info</button>
                                <button id="basicWarningCustomDelay" class="btn btn-warning">Warning</button>
                                <button id="basicErrorCustomDelay" class="btn btn-danger">Error</button>
                                <button id="basicSuccessCustomDelay" class="btn btn-success">Success</button>

                        </fieldset>

                        <fieldset>
                            <legend>Sticky (without delay)</legend>

                                <button id="basicDefaultNoDelay" class="btn btn-default">Default</button>
                                <button id="basicInfoNoDelay" class="btn btn-info">Info</button>
                                <button id="basicWarningNoDelay" class="btn btn-warning">Warning</button>
                                <button id="basicErrorNoDelay" class="btn btn-danger">Error</button>
                                <button id="basicSuccessNoDelay" class="btn btn-success">Success</button>

                        </fieldset>

                        <fieldset>
                            <legend>Alternative position</legend>

                                <button id="basicInfoPosition" class="btn btn-info">Info</button>
                                <button id="basicWarningPosition" class="btn btn-warning">Warning</button>
                                <button id="basicErrorPosition" class="btn btn-danger">Error</button>
                                <button id="basicSuccessPosition" class="btn btn-success">Success</button>

                        </fieldset>

                        <fieldset>
                            <legend>Change width</legend>

                                <button id="basicInfoWidth" class="btn btn-info">Info</button>
                                <button id="basicWarningWidth" class="btn btn-warning">Warning</button>
                                <button id="basicErrorWidth" class="btn btn-danger">Error</button>
                                <button id="basicSuccessWidth" class="btn btn-success">Success</button>

                        </fieldset>

                        <fieldset>
                            <legend>Change Animation</legend>

For animation Lobibox is depended on animate.css. You can use any animate.css classes

By default .animated class is added

                                <button id="basicInfoAnimation" class="btn btn-info">Info</button>
                                <button id="basicWarningAnimation" class="btn btn-warning">Warning</button>
                                <button id="basicErrorAnimation" class="btn btn-danger">Error</button>
                                <button id="basicSuccessAnimation" class="btn btn-success">Success</button>

                        </fieldset>

Large Notifications

                        <fieldset>

Large notifications

are sticky

can be closed only by clicking close button

does not have delay

are larger in width

                                <button id="largeInfoBasic" class="btn btn-info">Info</button>
                                <button id="largeWarningBasic" class="btn btn-warning">Warning</button>
                                <button id="largeErrorBasic" class="btn btn-danger">Error</button>
                                <button id="largeSuccessBasic" class="btn btn-success">Success</button>

                        </fieldset>

                        <fieldset>

With Image

                                <button id="largeInfoImage" class="btn btn-info">Info</button>
                                <button id="largeWarningImage" class="btn btn-warning">Warning</button>
                                <button id="largeErrorImage" class="btn btn-danger">Error</button>
                                <button id="largeSuccessImage" class="btn btn-success">Success</button>

                        </fieldset>

                        <fieldset>
                            <legend>Alternative position</legend>

                                <button id="largeInfoPosition" class="btn btn-info">Info</button>
                                <button id="largeWarningPosition" class="btn btn-warning">Warning</button>
                                <button id="largeErrorPosition" class="btn btn-danger">Error</button>
                                <button id="largeSuccessPosition" class="btn btn-success">Success</button>

                        </fieldset>

                        <fieldset>
                            <legend>Change animation</legend>

                                <button id="largeInfoAnimation" class="btn btn-info">Info</button>
                                <button id="largeWarningAnimation" class="btn btn-warning">Warning</button>
                                <button id="largeErrorAnimation" class="btn btn-danger">Error</button>
                                <button id="largeSuccessAnimation" class="btn btn-success">Success</button>

                        </fieldset>

Mini notifications

For mini notifications icon and image is shown on small size and title is disabled by default. Although you can enable it by giving title parameter when initializing.

                        <fieldset>

                                <button id="miniDefaultAnimation" class="btn btn-default">Default</button>
                                <button id="miniInfoAnimation" class="btn btn-info">Info</button>
                                <button id="miniWarningAnimation" class="btn btn-warning">Warning</button>
                                <button id="miniErrorAnimation" class="btn btn-danger">Error</button>
                                <button id="miniSuccessAnimation" class="btn btn-success">Success</button>

                        </fieldset>

                        <fieldset>

With image

                                <button id="miniDefaultImage" class="btn btn-default">Default</button>
                                <button id="miniInfoImage" class="btn btn-info">Info</button>
                                <button id="miniWarningImage" class="btn btn-warning">Warning</button>
                                <button id="miniErrorImage" class="btn btn-danger">Error</button>
                                <button id="miniSuccessImage" class="btn btn-success">Success</button>

                        </fieldset>

                        <fieldset>

Without icon

                                <button id="miniDefaultNoIcon" class="btn btn-default">Default</button>
                                <button id="miniInfoNoIcon" class="btn btn-info">Info</button>
                                <button id="miniWarningNoIcon" class="btn btn-warning">Warning</button>
                                <button id="miniErrorNoIcon" class="btn btn-danger">Error</button>
                                <button id="miniSuccessNoIcon" class="btn btn-success">Success</button>

                        </fieldset>

                        <fieldset>

With title

                                <button id="miniDefaultTitle" class="btn btn-default">Default</button>
                                <button id="miniInfoTitle" class="btn btn-info">Info</button>
                                <button id="miniWarningTitle" class="btn btn-warning">Warning</button>
                                <button id="miniErrorTitle" class="btn btn-danger">Error</button>
                                <button id="miniSuccessTitle" class="btn btn-success">Success</button>

                        </fieldset>

                        <fieldset>

Rounded corners new

                                <button id="miniDefaultRounded" class="btn btn-default">Default</button>
                                <button id="miniInfoRounded" class="btn btn-info">Info</button>
                                <button id="miniWarningRounded" class="btn btn-warning">Warning</button>
                                <button id="miniErrorRounded" class="btn btn-danger">Error</button>
                                <button id="miniSuccessRounded" class="btn btn-success">Success</button>

                        </fieldset>


text:
namespace boost { namespace text { namespace data { namespace be {

inline string_view standard_collation_tailoring()
{
    return string_view((char const *)
u8R"(
[reorder Cyrl]
&Е<ё<<<Ё
&у<ў<<<Ў
  )");
}

}}}}

#endif

redpajama_set_name: RedPajamaGithub


text:
<!DOCTYPE html>

  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
  <title>The Wedding of Susannah Plaster & Daniel St. Germain - @ViewBag.Title</title>
  <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" />
  <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap-theme.min.css" />
  <link rel="stylesheet" href="script/admin-section.min.css" />


text:
package com.seafile.seadroid2.account;

import com.seafile.seadroid2.util.Utils;
import org.json.JSONException;
import org.json.JSONObject;

/**
 * This class used to manage Account information
 *
 */
public class AccountInfo {
    private static final String DEBUG_TAG = "AccountInfo";

    public static final String SPACE_USAGE_SEPERATOR = " / ";
    private long usage;
    private long total;
    private String email;

    // server doesn`t exist in API JOSN data,
    // it was used together with email to identify the uniqueness
    //  of the AccountInfo instance
    // to assign value to it, explicitly call its setter method.
    private String server;

    public AccountInfo() {}

    public static  AccountInfo fromJson(JSONObject accountInfo) throws JSONException {
        AccountInfo info = new AccountInfo();
        info.usage = accountInfo.getLong("usage");
        info.total = accountInfo.getLong("total");
        info.email = accountInfo.getString("email");

        return info;
    }

    public long getUsage() {
        return usage;
    }

    public void setUsage(long usage) {
        this.usage = usage;
    }

    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getServer() {
        return server;
    }

    public void setServer(String server) {
        this.server = server;
    }

    public String getSpaceUsed() {
        String strUsage = Utils.readableFileSize(usage);
        String strTotal = Utils.readableFileSize(total);
        return strUsage + SPACE_USAGE_SEPERATOR + strTotal;
    }

}


text:
include_recipe "build-essential"

case node['platform_family']
  when 'rhel','fedora'
    package "openssl-devel"
  when 'debian'
    package "libssl-dev"
end

nodejs_tar = "node-v#{node['nodejs']['version']}.tar.gz"
nodejs_tar_path = nodejs_tar
if node['nodejs']['version'].split('.')[1].to_i >= 5
  nodejs_tar_path = "v#{node['nodejs']['version']}/#{nodejs_tar_path}"
end
# Let the user override the source url in the attributes
nodejs_src_url = "#{node['nodejs']['src_url']}/#{nodejs_tar_path}"

remote_file "/usr/local/src/#{nodejs_tar}" do
  source nodejs_src_url
  checksum node['nodejs']['checksum']
  mode 0644
  action :create_if_missing
end

# --no-same-owner required overcome "Cannot change ownership" bug
# on NFS-mounted filesystem
execute "tar --no-same-owner -zxf #{nodejs_tar}" do
  cwd "/usr/local/src"
  creates "/usr/local/src/node-v#{node['nodejs']['version']}"
end

make_threads = node['cpu'] ? node['cpu']['total'].to_i : 2
bash "compile node.js (on #{make_threads} cpu)" do
  # OSX doesn't have the attribute so arbitrarily default 2
  cwd "/usr/local/src/node-v#{node['nodejs']['version']}"
  code <<-EOH
    PATH="/usr/local/bin:$PATH"
    ./configure --prefix=#{node['nodejs']['dir']} && \
    make -j #{make_threads}
  EOH
  creates "/usr/local/src/node-v#{node['nodejs']['version']}/node"
end

execute "nodejs make install" do
  environment({"PATH" => "/usr/local/bin:/usr/bin:/bin:$PATH"})
  command "make install"
  cwd "/usr/local/src/node-v#{node['nodejs']['version']}"
  not_if {File.exists?("#{node['nodejs']['dir']}/bin/node") && `#{node['nodejs']['dir']}/bin/node --version`.chomp == "v#{node['nodejs']['version']}" }
end


text:
[ `uname -s` != "Darwin" ] && return

function tab () {
    local cmd=""
    local cdto="$PWD"
    local args="$@"

    if [ -d "$1" ]; then
        cdto=`cd "$1"; pwd`
        args="${@:2}"
    fi

    if [ -n "$args" ]; then
        cmd="; $args"
    fi

    osascript &>/dev/null <<EOF
        tell application "iTerm"
            tell current window
                set newTab to (create tab with default profile)
                tell newTab
                    tell current session
                        write text "cd \"$cdto\"$cmd"
                    end tell
                end tell
            end tell
        end tell
EOF
}


text:
'use strict'

const stroke = '#00f'
const fill = '#bbd'
const width = 320
const height = 240

module.exports = {stroke, fill, width, height}


text:
<!DOCTYPE HTML>

    <title>Scripts injected via `new Function()` are not allowed with `strict-dynamic` without `unsafe-eval`.</title>

Scripts injected via `new Function()` are not allowed with `strict-dynamic` without `unsafe-eval`.


text:
var express = require('express');
var router = express.Router();

/* GET home page. */
router.get('/', function (req, res) {
  res.render('page-admin', { title: 'Admin Console', displayName: 'Administrator Console' });
});

module.exports = router;


text:
\newcommand{\preamblefolder}{./include}       % Preamble folder location
\input{\preamblefolder/00.main.tex}           % Main packages
\input{\preamblefolder/10.tikz.tex}           % Tikz packages
\input{\preamblefolder/20.commands.tex}       % Functions and commands

\usepackage[enable]{easy-todo}                % enable = todo messages are visible, disable = todo messages are invisible.

%--------------title stuff
\title{MATH 999 -- Assignment 9}
\author{
  Last-Name, First-Name\\
  {\fontfamily{cmtt}\selectfont email@domain.com}
}
%--------------\title stuff

\begin{document}
  %--------------header stuff
  \maketitle
  %--------------\header stuff

    \begin{enumerate}
      %Question 1
      \item[\textbf{1}.]

        \aspace

      \qspace

      %Question 2
      \item[\textbf{2}.]

        \aspace

    \end{enumerate}

  %--------------footer stuff
  \begin{bibdiv}
    \begin{biblist}
    \end{biblist}
  \end{bibdiv}

  \listoftodos
  %--------------\footer stuff

\end{document}


text:
module Null
    ( Null (..)   -- Class with null value
    , EqNull (..) -- Class with null value and test for null value
    ) where

import Data.Word ( Word32, Word64 )

----------------------------------------------------------------------
-- Class having a reasonable null value
----------------------------------------------------------------------

class Null n where
    mkNull :: n     -- Produce a null value

-- Types with equality and null values
class (Eq n, Null n) => EqNull n where
    isNull :: n -> Bool
    isNull = \n -> n == mkNull

instance Null Int where
    mkNull = 0

instance EqNull Int

instance Null Integer where
    mkNull = 0

instance EqNull Integer

instance Null [a] where
    mkNull = []

instance (Eq a) => EqNull [a]

instance Null (Maybe n) where
    mkNull = Nothing

instance (Eq n) => EqNull (Maybe n)

instance Null () where
    mkNull = ()

instance EqNull ()

-- When the codomain of a mapping has a null value, then we can
-- construct a null value for the mapping by associating the null
-- value of the codomain with each domain value.
instance (Null b) => Null (a -> b) where
    mkNull = const mkNull

-- No instance of equality for functions a -> b, so no instance
-- of EqNull for functions a -> b

instance Null Word64 where
    mkNull = 0

instance Null Word32 where
    mkNull = 0


text:
/* sqMemoryAccess.h -- memory accessors (and associated type definitions)
 *
 * Author: Ian.Piumarta@squeakland.org
 *
 * Last edited: 2013-10-14 12:23:39 by eliot on McStalker
 */

/* This file defines the core types for the VM, sqInt, usqInt et al, and
 * the memory asccess API for the Smalltalk heap.  Consequently this file
 * is the minimum required prerequisite for Smalltalk-related code.
 */

/* Systematic use of the macros defined in this file within the Interpreter,
 * ObjectMemory and plugins will permit all four combinations of 32/64-bit
 * image and 32/64-bit host to compile and run correctly.  (Code that uses
 * explicit casts and/or integer constants in arithmetic on object pointers
 * will invariably fail in at least one of the four possible combinations.)
 */

#ifndef __sqMemoryAccess_h
#define __sqMemoryAccess_h

#include "config.h"
#include "interp.h"

#ifndef SIZEOF_LONG
#  if LLP64
#    define SIZEOF_LONG 4
#  else
#    define SIZEOF_LONG SIZEOF_VOID_P /* default is sizeof(long)==sizeof(void *) */
#  endif
#endif

#if (SQ_VI_BYTES_PER_WORD == 4)
# define SQ_IMAGE32 1
# define SQ_IMAGE64 0
#else
# define SQ_IMAGE64 1
# define SQ_IMAGE32 0
#endif

#if (SQ_IMAGE64 || SPURVM)
# define OBJECTS_64BIT_ALIGNED 1
# define OBJECTS_32BIT_ALIGNED 0
#else
# define OBJECTS_32BIT_ALIGNED 1
# define OBJECTS_64BIT_ALIGNED 0
#endif

#if (SIZEOF_VOID_P == 4)
# define SQ_HOST32 1
#elif (SIZEOF_VOID_P == 8)
# define SQ_HOST64 1
#else
# error host is neither 32- nor 64-bit?
#endif

/* sqInt is a signed integer with size adequate for holding an Object Oriented Pointer (or immediate value)
  - that is 32bits long on a 32bits image or 64bits long on a 64bits image
  we could use C99 int32_t and int64_t once retiring legacy compiler support this time has not yet come
  usqInt is the unsigned flavour
  SQABS is a macro for taking absolute value of an sqInt */
#if SQ_IMAGE32
  typedef int		sqInt;
  typedef unsigned int	usqInt;
#define PRIdSQINT "d"
#define PRIuSQINT "u"
#define PRIxSQINT "x"
#define PRIXSQINT "X"
# define SQABS abs
#elif SQ_HOST64 && (SIZEOF_LONG == 8)
  typedef long		sqInt;
  typedef unsigned long	usqInt;
#define PRIdSQINT "ld"
#define PRIuSQINT "lu"
#define PRIxSQINT "lx"
#define PRIXSQINT "lX"
# define SQABS labs
#elif (SIZEOF_LONG_LONG != 8)
#   error long long integers are not 64-bits wide?
#else
  typedef long long		sqInt;
  typedef unsigned long long	usqInt;
#define PRIdSQINT "lld"
#define PRIuSQINT "llu"
#define PRIxSQINT "llx"
#define PRIXSQINT "llX"
# define SQABS llabs
#endif

/* sqLong is a signed integer with at least 64bits on both 32 and 64 bits images
   usqLong is the unsigned flavour
   SQLABS is a macro for taking absolute value of a sqLong */
#if !defined(sqLong)
#  if SIZEOF_LONG == 8
#     define sqLong long
#     define usqLong unsigned long
#     define SQLABS labs
#  elif _MSC_VER
#     define sqLong __int64
#     define usqLong unsigned __int64
#     define SQLABS llabs
#  else
#     define sqLong long long
#     define usqLong unsigned long long
#     define SQLABS llabs
#  endif
#endif /* !defined(sqLong) */

/* sqIntptr_t is a signed integer with enough bits to hold a pointer
   usqIntptr_t is the unsigned flavour
   this is essentially C99 intptr_t and uintptr_t but we support legacy compilers
   the C99 printf formats macros are also defined with SQ prefix */
#if SIZEOF_LONG == SIZEOF_VOID_P
typedef long sqIntptr_t;
typedef unsigned long usqIntptr_t;
#define PRIdSQPTR "ld"
#define PRIuSQPTR "lu"
#define PRIxSQPTR "lx"
#define PRIXSQPTR "lX"
#else
typedef long long sqIntptr_t;
typedef unsigned long long usqIntptr_t;
#define PRIdSQPTR "lld"
#define PRIuSQPTR "llu"
#define PRIxSQPTR "llx"
#define PRIXSQPTR "llX"
#endif

#if SQ_HOST64 && SQ_IMAGE32
  extern char *sqMemoryBase;
# define SQ_FAKE_MEMORY_OFFSET	16 // (1*1024*1024)	/* nonzero to debug addr xlation */
#else
# define sqMemoryBase 0
#endif

#ifdef USE_INLINE_MEMORY_ACCESSORS
  /* Use static inline functions when the compiler produces efficient code for small accessors.
     These are preferred because static type checking will prevent inadvertent confusion of pointers and oops. */
  static inline sqInt byteAtPointer(char *ptr)			{ return (sqInt)(*((unsigned char *)ptr)); }
  static inline sqInt byteAtPointerput(char *ptr, int val)	{ return (sqInt)(*((unsigned char *)ptr)= (unsigned char)val); }
  static inline sqInt shortAtPointer(char *ptr)			{ return (sqInt)(*((short *)ptr)); }
  static inline sqInt shortAtPointerput(char *ptr, int val)	{ return (sqInt)(*((short *)ptr)= (short)val); }
  static inline sqInt intAtPointer(char *ptr)			{ return (sqInt)(*((int *)ptr)); }
  static inline sqInt intAtPointerput(char *ptr, int val)	{ return (sqInt)(*((int *)ptr)= val); }
  static inline sqInt longAtPointer(char *ptr)			{ return *(sqInt *)ptr; }
  static inline sqInt longAtPointerput(char *ptr, sqInt val)	{ return *(sqInt *)ptr= val; }
  static inline sqLong long64AtPointer(char *ptr)			{ return *(sqLong *)ptr; }
  static inline sqLong long64AtPointerput(char *ptr, sqLong val)	{ return *(sqLong *)ptr= val; }
  static inline float singleFloatAtPointer(char *ptr)			{ return *(float *)ptr; }
  static inline float singleFloatAtPointerput(char *ptr, float val)	{ return *(float *)ptr= val; }
  static inline double floatAtPointer(char *ptr)			{ return *(double *)ptr; }
  static inline double floatAtPointerput(char *ptr, double val)	{ return *(double *)ptr= val; }
  static inline sqInt oopAtPointer(char *ptr)			{ return *(sqInt *)ptr; }
  static inline sqInt oopAtPointerput(char *ptr, sqInt val)	{ return (sqInt)(*(sqInt *)ptr= val); }
# if defined(sqMemoryBase) && !sqMemoryBase
  static inline char *pointerForOop(usqInt oop)			{ return (char *)oop; }
  static inline sqInt oopForPointer(void *ptr)			{ return (sqInt)ptr; }
# else
  static inline char *pointerForOop(usqInt oop)			{ return sqMemoryBase + oop; }
  static inline sqInt oopForPointer(void *ptr)			{ return (sqInt)((char *)ptr - sqMemoryBase); }
# endif
  static inline sqInt byteAt(sqInt oop)				{ return byteAtPointer(pointerForOop(oop)); }
  static inline sqInt byteAtput(sqInt oop, int val)		{ return byteAtPointerput(pointerForOop(oop), val); }
  static inline sqInt shortAt(sqInt oop)			{ return shortAtPointer(pointerForOop(oop)); }
  static inline sqInt shortAtput(sqInt oop, int val)		{ return shortAtPointerput(pointerForOop(oop), val); }
  static inline sqInt intAt(sqInt oop)				{ return intAtPointer(pointerForOop(oop)); }
  static inline sqInt intAtput(sqInt oop, int val)		{ return intAtPointerput(pointerForOop(oop), val); }
  static inline sqInt longAt(sqInt oop)				{ return longAtPointer(pointerForOop(oop)); }
  static inline sqInt longAtput(sqInt oop, sqInt val)		{ return longAtPointerput(pointerForOop(oop), val); }
  static inline sqLong long64At(sqInt oop)				{ return long64AtPointer(pointerForOop(oop)); }
  static inline sqLong long64Atput(sqInt oop, sqLong val)		{ return long64AtPointerput(pointerForOop(oop), val); }
  static inline sqInt oopAt(sqInt oop)				{ return oopAtPointer(pointerForOop(oop)); }
  static inline sqInt oopAtput(sqInt oop, sqInt val)		{ return oopAtPointerput(pointerForOop(oop), val); }

  static inline char* pointerAtPointer(char *ptr)			{ return *(char **)ptr; }
  static inline char* pointerAtPointerput(char *ptr, char* val)	{ return *(char **)ptr = val; }

  static inline signed char int8AtPointer(char *ptr)			            { return (*((signed char *)ptr)); }
  static inline signed char int8AtPointerput(char *ptr, signed char val)	{ return (*((signed char *)ptr)= val); }
  static inline unsigned char uint8AtPointer(char *ptr)			            { return (*((unsigned char *)ptr)); }
  static inline unsigned char uint8AtPointerput(char *ptr, unsigned char val)	{ return (*((unsigned char *)ptr)= val); }

  static inline short int16AtPointer(char *ptr)			                    { return (*((short *)ptr)); }
  static inline short int16AtPointerput(char *ptr, short val)	            { return (*((short *)ptr)= val); }
  static inline unsigned short uint16AtPointer(char *ptr)			                    { return (*((unsigned short *)ptr)); }
  static inline unsigned short uint16AtPointerput(char *ptr, unsigned short val)	    { return (*((unsigned short *)ptr)= val); }

  static inline int int32AtPointer(char *ptr)			    { return (*((int *)ptr)); }
  static inline int int32AtPointerput(char *ptr, int val)	{ return (*((int *)ptr)= val); }
  static inline unsigned int uint32AtPointer(char *ptr)			    { return (*((unsigned int *)ptr)); }
  static inline unsigned int uint32AtPointerput(char *ptr, unsigned int val)	{ return (*((unsigned int *)ptr)= val); }

  static inline sqLong int64AtPointer(char *ptr)			    { return (*((sqLong *)ptr)); }
  static inline sqLong int64AtPointerput(char *ptr, int val)	{ return (*((sqLong *)ptr)= val); }
  static inline usqLong uint64AtPointer(char *ptr)			    { return (*((usqLong *)ptr)); }
  static inline usqLong uint64AtPointerput(char *ptr, usqLong val)	{ return (*((usqLong *)ptr)= val); }

#else /* USE_INLINE_MEMORY_ACCESSORS */
  /* Use macros when static inline functions aren't efficient. */
# define byteAtPointer(ptr)			((sqInt)(*((unsigned char *)(ptr))))
# define byteAtPointerput(ptr,val)	((sqInt)(*((unsigned char *)(ptr))= (unsigned char)(val)))
# define shortAtPointer(ptr)		((sqInt)(*((short *)(ptr))))
# define shortAtPointerput(ptr,val)	((sqInt)(*((short *)(ptr))= (short)(val)))
# define intAtPointer(ptr)			((sqInt)(*((int *)(ptr))))
# define intAtPointerput(ptr,val)	((sqInt)(*((int *)(ptr))= (int)(val)))
# define longAtPointer(ptr)			(*(sqInt *)(ptr))
# define longAtPointerput(ptr,val)	(*(sqInt *)(ptr)= (sqInt)(val))
# define long64AtPointer(ptr)			(*(sqLong *)(ptr))
# define long64AtPointerput(ptr,val)	(*(sqLong *)(ptr)= (sqLong)(val))
# define singleFloatAtPointer(ptr)		(*(float*)(ptr))
# define singleFloatAtPointerput(ptr, val)		(*(float*)(ptr) = val)
# define floatAtPointer(ptr)		        (*(double*)(ptr))
# define floatAtPointerput(ptr, val)		(*(double*)(ptr) = val)
# define pointerAtPointer(ptr)		        (*(char**)(ptr))
# define pointerAtPointerput(ptr, val)		(*(char**)(ptr) = val)
# define oopAtPointer(ptr)			(*(sqInt *)(ptr))
# define oopAtPointerput(ptr,val)	(*(sqInt *)(ptr)= (sqInt)(val))
# if defined(sqMemoryBase) && !sqMemoryBase
#  define pointerForOop(oop)		((char *)(oop))
#  define oopForPointer(ptr)		((sqInt)(ptr))
#  define atPointerArg(oop)			oop
# else
#  define pointerForOop(oop)		((char *)(sqMemoryBase + ((usqInt)(oop))))
#  define oopForPointer(ptr)		((sqInt)(((char *)(ptr)) - (sqMemoryBase)))
#  define atPointerArg(oop)			sqMemoryBase + (usqInt)(oop)
# endif
# define byteAt(oop)				byteAtPointer(atPointerArg(oop))
# define byteAtput(oop,val)			byteAtPointerput(atPointerArg(oop), val)
# define shortAt(oop)				shortAtPointer(atPointerArg(oop))
# define shortAtput(oop,val)		shortAtPointerput(atPointerArg(oop), val)
# define longAt(oop)				longAtPointer(atPointerArg(oop))
# define longAtput(oop,val)			longAtPointerput(atPointerArg(oop), val)
# define long64At(oop)				long64AtPointer(atPointerArg(oop))
# define long64Atput(oop,val)		long64AtPointerput(atPointerArg(oop), val)
# define intAt(oop)					intAtPointer(atPointerArg(oop))
# define intAtput(oop,val)			intAtPointerput(atPointerArg(oop), val)
# define oopAt(oop)					oopAtPointer(atPointerArg(oop))
# define oopAtput(oop,val)			oopAtPointerput(atPointerArg(oop), val)

# define int8AtPointer(ptr)          (*(signed char*)(ptr))
# define int8AtPointerput(ptr, val)  (*(signed char*)(ptr) = val)
# define uint8AtPointer(ptr)          (*(unsigned char*)(ptr))
# define uint8AtPointerput(ptr, val)  (*(unsigned char*)(ptr) = val)

# define int16AtPointer(ptr)          (*(signed short*)(ptr))
# define int16AtPointerput(ptr, val)  (*(signed short*)(ptr) = val)
# define uint16AtPointer(ptr)          (*(unsigned short*)(ptr))
# define uint16AtPointerput(ptr, val)  (*(unsigned short*)(ptr) = val)

# define int32AtPointer(ptr)          (*(signed int*)(ptr))
# define int32AtPointerput(ptr, val)  (*(signed int*)(ptr) = val)
# define uint32AtPointer(ptr)          (*(unsigned int*)(ptr))
# define uint32AtPointerput(ptr, val)  (*(unsigned int*)(ptr) = val)

# define int64AtPointer(ptr)          (*(sqLong*)(ptr))
# define int64AtPointerput(ptr, val)  (*(sqLong*)(ptr) = val)
# define uint64AtPointer(ptr)          (*(usqLong*)(ptr))
# define uint64AtPointerput(ptr, val)  (*(usqLong*)(ptr) = val)
#endif /* USE_INLINE_MEMORY_ACCESSORS */

static inline sqLong asIEEE64BitWord(double val)
{
    /* Use an union here to not violate the strict aliasing rule. */
    union {
        double input;
        sqLong output;
    } data;
    data.input = val;
    return data.output;
}

static inline unsigned int asIEEE32BitWord(float val)
{
    /* Use an union here to not violate the strict aliasing rule. */
    union {
        float input;
        unsigned int output;
    } data;
    data.input = val;
    return data.output;
}

#define long32At	intAt
#define long32Atput	intAtput

/* platform-dependent float conversion macros.
 * Note: Second argument must be a variable name, not an expression!
 * Pre-Cog systems stored floats in Mac PowerPC big-endian format.
 * BigEndianFloats selects this behaviour for backwards-compatibility.
 * RISC systems typically insist on double-word alignment of double-words, but
 * the heap is only word-aligned.  OBJECTS_32BIT_ALIGNED selects word access.
 */
#if BigEndianFloats && !VMBIGENDIAN
/* this is to allow strict aliasing assumption in the optimizer */
typedef union { double d; int i[sizeof(double) / sizeof(int)]; } _swapper;
/* word-based copy with swapping for non-PowerPC order */
# define storeFloatAtPointerfrom(intPointerToFloat, doubleVar) do { \
		*((int *)(intPointerToFloat) + 0) = ((_swapper *)(&doubleVar))->i[1]; \
		*((int *)(intPointerToFloat) + 1) = ((_swapper *)(&doubleVar))->i[0]; \
	} while (0)
# define fetchFloatAtPointerinto(intPointerToFloat, doubleVar) do { \
		((_swapper *)(&doubleVar))->i[1] = *((int *)(intPointerToFloat) + 0); \
		((_swapper *)(&doubleVar))->i[0] = *((int *)(intPointerToFloat) + 1); \
	} while (0)
# else
# define storeFloatAtPointerfrom(intPointerToFloat, doubleVar) \
    memcpy((char *)intPointerToFloat,&doubleVar,sizeof(double));
# define fetchFloatAtPointerinto(intPointerToFloat, doubleVar) \
    memcpy(&doubleVar,(char *)intPointerToFloat,sizeof(double));
#endif /* !(BigEndianFloats && !VMBIGENDIAN) && !OBJECTS_32BIT_ALIGNED */

# define storeSingleFloatAtPointerfrom(intPointerToFloat, floatVar) \
        do {float __f=floatVar; memcpy((char *)intPointerToFloat,&__f,sizeof(float));} while(0)
# define fetchSingleFloatAtPointerinto(intPointerToFloat, floatVar) \
        do {float __f; memcpy(&__f,(char *)intPointerToFloat,sizeof(float)); floatVar=__f;} while(0)

#define storeFloatAtfrom(i, doubleVar)	storeFloatAtPointerfrom(pointerForOop(i), doubleVar)
#define fetchFloatAtinto(i, doubleVar)	fetchFloatAtPointerinto(pointerForOop(i), doubleVar)
#define storeSingleFloatAtfrom(i, floatVar)	storeSingleFloatAtPointerfrom(pointerForOop(i), floatVar)
#define fetchSingleFloatAtinto(i, floatVar)	fetchSingleFloatAtPointerinto(pointerForOop(i), floatVar)

/* These accessors are for accelerating byte swapping
   whenever intrinsics or other fast functions are available */
/* Compatibility with non-clang compilers */
#ifndef __has_builtin
#  define __has_builtin(x) 0
#endif

/*  GCC and Clang recent versions provide intrinsic byte swaps via builtins */
#if (defined(__clang__) && __has_builtin(__builtin_bswap32) && __has_builtin(__builtin_bswap64)) \
  || (defined(__GNUC__ ) && \
  (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)))
#  define SQ_SWAP_4_BYTES(x) __builtin_bswap32(x)
#  define SQ_SWAP_8_BYTES(x) __builtin_bswap64(x)
#elif defined(__linux__)
#  include <byteswap.h>
#  define SQ_SWAP_4_BYTES(x) bswap_32(x)
#  define SQ_SWAP_8_BYTES(x) bswap_64(x)
#elif defined(_MSC_VER)
#  include <stdlib.h>
#  define SQ_SWAP_4_BYTES(x) _byteswap_ulong(x)
#  define SQ_SWAP_8_BYTES(x) _byteswap_uint64(x)
#else
#  define SQ_SWAP_4_BYTES(x) \
	(((unsigned int)(x) << 24) | \
	(((unsigned int)(x) <<  8) & 0xff0000U) | \
	(((unsigned int)(x) >>  8) & 0xff00U) | \
	( (unsigned int)(x) >> 24))
#  define SQ_SWAP_8_BYTES(x) \
	(((unsigned long long)(x) << 56) | \
	(((unsigned long long)(x) << 40) & 0xff000000000000ULL) | \
	(((unsigned long long)(x) << 24) & 0xff0000000000ULL) | \
	(((unsigned long long)(x) << 8)  & 0xff00000000ULL) | \
	(((unsigned long long)(x) >> 8)  & 0xff000000ULL) | \
	(((unsigned long long)(x) >> 24) & 0xff0000ULL) | \
	(((unsigned long long)(x) >> 40) & 0xff00ULL) | \
	( (unsigned long long)(x) >> 56))
#endif

/* Since Large Integers are Bytes Oops allways stored as little endian,
   the following macros are handy to retrieve 4 or 8 byte limbs */
#if VMBIGENDIAN
#  define SQ_SWAP_4_BYTES_IF_BIGENDIAN(x) SQ_SWAP_4_BYTES(x)
#  define SQ_SWAP_8_BYTES_IF_BIGENDIAN(x) SQ_SWAP_8_BYTES(x)
#else
#  define SQ_SWAP_4_BYTES_IF_BIGENDIAN(x) (x)
#  define SQ_SWAP_8_BYTES_IF_BIGENDIAN(x) (x)
#endif

/* This doesn't belong here, but neither do 'self flag: ...'s belong in the
   image. We use a macro, not an inline function; we need no trace of flag.
 */
#define flag(foo) 0

/* heap debugging facilities in sqHeapMap.c */
extern void clearHeapMap(void);
extern int  heapMapAtWord(void *wordPointer);
extern void heapMapAtWordPut(void *wordPointer, int bit);

/* Platform-dependent API to allocate/manage object memory. */

#if SPURVM
/* Spur is an improved object representation/garbage collector/heap manager that
 * replaces the original BttF "V3" Memory Manager (so called because Spur came
 * after Squeak V3).  Spur offers considerable performance improvements but is
 * not backwards-compatible with V3, and requires different internal plumbing.
 * Unlike the V3 memory manager, Spur manages old space heap memory in segments,
 * and is able to release memry back to the OS when the heap shrinks.
 */

/* Allocate a region of memory of al least sz bytes, at or above minAddr.
 * If the attempt fails, answer null.  If the attempt succeeds, answer the
 * start of the region and assign its size through asp.
 */
extern void *sqAllocateMemorySegmentOfSizeAboveAllocatedSizeInto(sqInt sz, void *minAddr, sqInt *asp);
extern void sqDeallocateMemorySegmentAtOfSize(void *addr, sqInt sz);

#else /* SPURVM */

/* Note: The grow/shrink macros assume that the object memory can be extended
   continuously at its prior end. The garbage collector cannot deal with
   'holes' in the object memory so the support code needs to reserve the
   virtual maximum of pages that can be allocated beforehand. The amount of
   'extra' memory should describe the amount of memory that can be allocated
   from the OS (including swap space if the flag is set to true) and must not
   exceed the prior reserved memory.
   In other words: don't you dare to report more free space then you can
   actually allocate.
   The default implementation assumes a fixed size memory allocated at startup.
*/
# define sqAllocateMemory(minHeapSize, desiredHeapSize)  malloc(desiredHeapSize)
# define sqGrowMemoryBy(oldLimit, delta)			oldLimit
# define sqShrinkMemoryBy(oldLimit, delta)		oldLimit
# define sqMemoryExtraBytesLeft(includingSwap)	0
#endif /* SPURVM */

#if COGVM
/* Cog is a JIT extension for the VM. It still relies on the Interpreter (called
 * the CoInterpreter because it sits alongside the "Cogit") for primitives,
 * for executing methods the frst time, and to fall back on in exceptional
 * circumstances.  COGVM implies STACKVM.  See STACKVM below.
 */
extern void sqMakeMemoryExecutableFromToCodeToDataDelta(usqInt, usqInt, sqInt*);
extern void sqMakeMemoryNotExecutableFromTo(usqInt, usqInt);
#endif

/* Platform-dependent memory size adjustment macro. */

/* Note: This macro can be redefined to allows platforms with a
   fixed application memory partition (notably, the Macintosh)
   to reserve extra C heap memory for special applications that need
   it (e.g., for a 3D graphics library). Since most platforms can
   extend their application memory partition at run time if needed,
   this macro is defined as a noop here and redefined if necessary
   in sqPlatformSpecific.h.
*/

#define reserveExtraCHeapBytes(origHeapSize, bytesToReserve) origHeapSize

/* Pluggable primitives macros. */

/* Note: All pluggable primitives are defined as
	EXPORT(int) somePrimitive(void)
   All non-static variables in the VM and plugins are declared as
	VM_EXPORT type var
   If the platform requires special declaration modifiers, the EXPORT and
   VM_EXPORT macros can be redefined.
*/
#if !defined(EXPORT)
# define EXPORT(returnType) returnType
#endif
#if !defined(VM_EXPORT)
# define VM_EXPORT
#endif
#if !defined(VM_FUNCTION_EXPORT)
# define VM_FUNCTION_EXPORT(returnType) returnType
#endif

/* sqPlatformSpecific.h serves a couple of contradictory purposes. One is to
 * define platforms-specific implementations of facilities such as the EXPORT
 * macros.  Another is to define platform-specific implementations of support
 * functions, such as allocating memory, opening files, etc. This file needs
 * the EXPORT macros, but defines the types needed to define the support APIs.
 * So there is a circular dependency.  To solve ths sqPlatformSpecific.h only
 * defines the support APIs if __sqMemoryAccess_h is defined, and this file
 * arranges to include sqPlatformSpecific.h a second time to allow it to
 * declare the support funciton API.
 */
#if defined(_SQ_PLATFORM_SPECIFIC_H)
# undef _SQ_PLATFORM_SPECIFIC_H
# include "sqPlatformSpecific.h"
#endif
#endif /* __sqMemoryAccess_h */


text:
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.Reflection;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("xunit.performance Core")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyCulture("")]


text:
SYNONYM

#### According to
The Catalogue of Life, 3rd January 2011

#### Published in
Medical mycology. Fungous diseases of men and other mammals 523 (1935)

#### Original name
Trichophyton violaceum Sabour. ex E. Bodin

### Remarks
null


text:
package fixtures.bodynumber;

/**
 * The interface for AutoRestNumberTestService class.
 */
public interface AutoRestNumberTestService {
    /**
     * The default base URL.
     */
    String DEFAULT_BASE_URL = "https://localhost";

    /**
     * Gets the Numbers object to access its operations.
     * @return the Numbers object.
     */
    Numbers numbers();

}


text:
@interface ExamplesStub_ArgumentMatchers : ExampleTestCase @end
@implementation ExamplesStub_ArgumentMatchers {
    NSMutableArray *mockArray;
    NSMutableString *mockString;
    __block BOOL actionWasCalled;
}

#pragma mark - Setup

- (void)setUp {
    // we'll use these objects in the examples
    mockArray = mock([NSMutableArray class]);
    mockString = mock([NSMutableString class]);
}

#pragma mark - Default Matching

- (void)testByDefaultArgumentsAreMatchedByEquality
{
    // when you stub a method that has object arguments it will match equal arguments
    //  * isEqual: is used to compare for objects

    stub ([mockArray addObject:@"Hello World"]) with {
        actionWasCalled = YES;
    };

    // call it with the correct argument and the action is executed
    actionWasCalled = NO;
    [mockArray addObject:@"Hello World"];

    expect(actionWasCalled).to.beTruthy();

    // but not if the wrong argument is passed
    actionWasCalled = NO;
    [mockArray addObject:@"Goodbye World"];

    expect(actionWasCalled).to.beFalsy();
}

- (void)testDefaultMatchingWorksTheSameForPrimitivesLikeStructs
{
    // when you stub a method that has primitive arguments it will match same arguments
    //  * -[NSNumber isEqual:] is used for scalars
    //  * -[NSValue isEqual:] is used for other primitive types

    stub ([mockArray subarrayWithRange:NSMakeRange(0, 10)]) with {
        actionWasCalled = YES;
        return nil;
    };

    // call it with the correct argument and the action is executed
    actionWasCalled = NO;
    [mockArray subarrayWithRange:NSMakeRange(0, 10)];

    expect(actionWasCalled).to.beTruthy();

    // but not if the wrong argument is passed
    actionWasCalled = NO;
    [mockArray subarrayWithRange:NSMakeRange(10, 20)];

    expect(actionWasCalled).to.beFalsy();
}

#pragma mark - Matching Arguments Using Argument Matchers

- (void)testYouCanUseArgumentMatchersToControlHowArgumentsMatch
{
    // if you pass argument matchers, the matcher is used to check passed arguments

    // e.g. the any(T) matcher will accept any argument of the given type T
    stub ([mockArray addObject:any(id)]) with {
        actionWasCalled = YES;
    };

    // any value will match
    actionWasCalled = NO;
    [mockArray addObject:@"Some Object"];

    expect(actionWasCalled).to.beTruthy();

    // also nil matches
    actionWasCalled = NO;
    [mockArray addObject:nil];

    expect(actionWasCalled).to.beTruthy();
}

- (void)testYouCanUseArgumentMatchersAlsoForPrimitiveTypes
{
    // argument matchers also work for primitive types

    stub ([mockArray removeObjectAtIndex:any(NSUInteger)]) with {
        actionWasCalled = YES;
    };

    // any value will match
    actionWasCalled = NO;
    [mockArray removeObjectAtIndex:0];

    expect(actionWasCalled).to.beTruthy();

    actionWasCalled = NO;
    [mockArray removeObjectAtIndex:NSUIntegerMax];

    expect(actionWasCalled).to.beTruthy();
}

- (void)testYouCanUseArgumentMatchersEvenForStructs
{
    // matching struct arguments is supported too

    stub ([mockArray subarrayWithRange:any(NSRange)]) with {
        actionWasCalled = YES;
        return nil;
    };

    // any value will match
    actionWasCalled = NO;
    [mockArray subarrayWithRange:NSMakeRange(0, 10)];

    expect(actionWasCalled).to.beTruthy();

    actionWasCalled = NO;
    [mockArray subarrayWithRange:NSMakeRange(0, 0)];

    expect(actionWasCalled).to.beTruthy();
}

@end


text:
package io.realm.entities;

import io.realm.RealmList;
import io.realm.RealmObject;

public class CyclicType extends RealmObject {

    private String name;
    private CyclicType object;
    private RealmList<CyclicType> objects;

    public CyclicType() {
    }

    public CyclicType(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

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

    public CyclicType getObject() {
        return object;
    }

    public void setObject(CyclicType object) {
        this.object = object;
    }

    public RealmList<CyclicType> getObjects() {
        return objects;
    }

    public void setObjects(RealmList<CyclicType> objects) {
        this.objects = objects;
    }
}


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<title>Uses of Interface org.springframework.ui.context.ThemeSource (Spring Framework 5.1.18.RELEASE API)</title>
<meta name="date" content="2020-09-15">
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">

JavaScript is disabled on your browser.

Skip navigation links

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

Spring Framework

Prev

Next

Frames

No Frames

All Classes

Uses of Interface
org.springframework.ui.context.ThemeSource

Packages that use ThemeSource

Package
Description

org.springframework.ui.context

Contains classes defining the application context subinterface
 for UI applications.

org.springframework.ui.context.support

Classes supporting the org.springframework.ui.context package.

org.springframework.web.context.support

Classes supporting the org.springframework.web.context package,
 such as WebApplicationContext implementations and various utility classes.

org.springframework.web.servlet

Provides servlets that integrate with the application context
 infrastructure, and the core interfaces and classes for the
 Spring web MVC framework.

org.springframework.web.servlet.support

Support classes for Spring's web MVC framework.

Uses of ThemeSource in org.springframework.ui.context

Subinterfaces of ThemeSource in org.springframework.ui.context

Modifier and Type
Interface and Description

interface
HierarchicalThemeSource

Sub-interface of ThemeSource to be implemented by objects that
 can resolve theme messages hierarchically.

Methods in org.springframework.ui.context that return ThemeSource

Modifier and Type
Method and Description

ThemeSource
HierarchicalThemeSource.getParentThemeSource()

Return the parent of this ThemeSource, or null if none.

Methods in org.springframework.ui.context with parameters of type ThemeSource

Modifier and Type
Method and Description

void
HierarchicalThemeSource.setParentThemeSource(ThemeSource parent)

Set the parent that will be used to try to resolve theme messages
 that this object can't resolve.

Uses of ThemeSource in org.springframework.ui.context.support

Classes in org.springframework.ui.context.support that implement ThemeSource

Modifier and Type
Class and Description

class
DelegatingThemeSource

Empty ThemeSource that delegates all calls to the parent ThemeSource.

class
ResourceBundleThemeSource

ThemeSource implementation that looks up an individual
 ResourceBundle per theme.

Methods in org.springframework.ui.context.support that return ThemeSource

Modifier and Type
Method and Description

ThemeSource
DelegatingThemeSource.getParentThemeSource()

ThemeSource
ResourceBundleThemeSource.getParentThemeSource()

static ThemeSource
UiApplicationContextUtils.initThemeSource(ApplicationContext context)

Initialize the ThemeSource for the given application context,
 autodetecting a bean with the name "themeSource".

Methods in org.springframework.ui.context.support with parameters of type ThemeSource

Modifier and Type
Method and Description

void
DelegatingThemeSource.setParentThemeSource(ThemeSource parentThemeSource)

void
ResourceBundleThemeSource.setParentThemeSource(ThemeSource parent)

Uses of ThemeSource in org.springframework.web.context.support

Classes in org.springframework.web.context.support that implement ThemeSource

Modifier and Type
Class and Description

class
AbstractRefreshableWebApplicationContext

AbstractRefreshableApplicationContext
 subclass which implements the
 ConfigurableWebApplicationContext
 interface for web environments.

class
AnnotationConfigWebApplicationContext

WebApplicationContext
 implementation which accepts component classes as input — in particular
 @Configuration-annotated
 classes, but also plain @Component
 classes and JSR-330 compliant classes using javax.inject annotations.

class
GenericWebApplicationContext

Subclass of GenericApplicationContext, suitable for web environments.

class
GroovyWebApplicationContext

WebApplicationContext implementation which takes
 its configuration from Groovy bean definition scripts and/or XML files, as understood by
 a GroovyBeanDefinitionReader.

class
StaticWebApplicationContext

Static WebApplicationContext
 implementation for testing.

class
XmlWebApplicationContext

WebApplicationContext implementation
 which takes its configuration from XML documents, understood by an
 XmlBeanDefinitionReader.

Uses of ThemeSource in org.springframework.web.servlet

Methods in org.springframework.web.servlet that return ThemeSource

Modifier and Type
Method and Description

ThemeSource
DispatcherServlet.getThemeSource()

Return this servlet's ThemeSource, if any; else return null.

Uses of ThemeSource in org.springframework.web.servlet.support

Methods in org.springframework.web.servlet.support that return ThemeSource

Modifier and Type
Method and Description

static ThemeSource
RequestContextUtils.getThemeSource(HttpServletRequest request)

Return the ThemeSource that has been bound to the request by the
 DispatcherServlet.

Skip navigation links

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

Spring Framework

Prev

Next

Frames

No Frames

All Classes


text:
<?php

namespace backend\models\search;

use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\Customer as CustomerModel;

/**
 * Customer represents the model behind the search form about `common\models\Customer`.
 */
class Customer extends CustomerModel
{
    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['id', 'type', 'exhibition_id', 'sex', 'company_type_id', 'country', 'province', 'city', 'district', 'from', 'status'], 'integer'],
            [['name', 'mobile', 'email', 'company_name', 'position', 'department', 'phone', 'fax', 'url', 'remark', 'address', 'created_at', 'updated_at', 'rejected_reason'], 'safe'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function scenarios()
    {
        // bypass scenarios() implementation in the parent class
        return Model::scenarios();
    }

    /**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     *
     * @return ActiveDataProvider
     */
    public function search($params)
    {
        $query = CustomerModel::find();

        // add conditions that should always apply here

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);

        $this->load($params);

        if (!$this->validate()) {
            // uncomment the following line if you do not want to return any records when validation fails
            // $query->where('0=1');
            return $dataProvider;
        }

        // grid filtering conditions
        $query->andFilterWhere([
            'id' => $this->id,
            'type' => $this->type,
            'exhibition_id' => $this->exhibition_id,
            'sex' => $this->sex,
            'company_type_id' => $this->company_type_id,
            'country' => $this->country,
            'province' => $this->province,
            'city' => $this->city,
            'district' => $this->district,
            'created_at' => $this->created_at,
            'updated_at' => $this->updated_at,
            'from' => $this->from,
            'status' => $this->status,
        ]);

        $query->andFilterWhere(['like', 'name', $this->name])
            ->andFilterWhere(['like', 'mobile', $this->mobile])
            ->andFilterWhere(['like', 'email', $this->email])
            ->andFilterWhere(['like', 'company_name', $this->company_name])
            ->andFilterWhere(['like', 'position', $this->position])
            ->andFilterWhere(['like', 'department', $this->department])
            ->andFilterWhere(['like', 'phone', $this->phone])
            ->andFilterWhere(['like', 'fax', $this->fax])
            ->andFilterWhere(['like', 'url', $this->url])
            ->andFilterWhere(['like', 'remark', $this->remark])
            ->andFilterWhere(['like', 'address', $this->address])
            ->andFilterWhere(['like', 'rejected_reason', $this->rejected_reason]);

        return $dataProvider;
    }
}


text:
package com.htm.taskinstance;

import java.sql.Timestamp;

import com.htm.ITaskClientInterface;
import com.htm.dm.IDataModelElement;

/**
 * This interface contains the methods that have to be implemented by
 * a valid attachment model.

 * Attachments contain additional data that are assigned to task instances
 * by a particular user.
 *
 * @author Sebastian Wagner
 * @author Tobias Unger
 */
public interface IAttachment extends IDataModelElement {

    /**
     * This attachment type indicates that the content is held within the
     * attachment.
 The concrete type of the attachment content can be
     * obtained by the method {@link IAttachment#getContentType()}.
     *
     * @see IAttachment#ACCESS_TYPE_REFERENCE Attachment content as reference
     */
    public static final String ACCESS_TYPE_INLINE = "inline";

    /**
     * This attachment type indicates that the content of the attachment is an
     * url the points on to an external location where the attachment can be
     * obtained from.
     *
     * @see IAttachment#ACCESS_TYPE_INLINE Inline attachment content
     */
    public static final String ACCESS_TYPE_REFERENCE = "reference";

    /**
     * Contains the valid access types.
     */
    public static final String[] ACCESS_TYPES = new String[]{
            ACCESS_TYPE_INLINE, ACCESS_TYPE_REFERENCE};

    /**
     * @return The name of the attachment.
     */
    public String getName();

    /**
     * @return The access type of the attachment.
     * @see IAttachment#ACCESS_TYPES
     */
    public String getAccessType();

    /**
     * @return The data type of the content simply identified by a string.
     */
    public String getContentType();

    /**
     * @return The actual attachment content as byte array.
     */
    public byte[] getContent();

    /**
     * @return The time that indicates when the attachment was added to a task
     *         instance.
     */
    public Timestamp getAttachedAt();

    /**
     * @return The user that has assigned the attachment to the task instance.
     *
 Note: There is no equivalent setter method.
 The
     *         association of the user with the attachment is implicitly done by
     *         the
     *         {@link ITaskClientInterface#addAttachment(String, String, IAttachment)}
     */
    public IAssignedUser getAttachedBy();

    /**
     * Sets the time when the attachment was assigned to the task instance.
     *
     * @param attachedAt
     */
    public void setAttachedAt(Timestamp attachedAt);

    /**
     * Sets the attachment content.
     *
     * @param content
     */
    public void setContent(byte[] content);

    /**
     * Sets the name of the attachment
     *
     * @param name
     */
    public void setName(String name);

    /**
     * Sets the access type of the attachment.
     *
     * @param accessType
     * @see IAttachment#ACCESS_TYPES
     */
    public void setAccessType(String accessType);

    /**
     * Sets the identifier for the data type of the attachment content.
     *
     * @param contentType
     */
    public void setContentType(String contentType);

}


text:
import { take, orderBy } from 'lodash';
import React from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';

import {
  IfPermission,
} from '@folio/stripes/core';
import {
  Button,
  Col,
  Modal,
  Row,
} from '@folio/stripes/components';

import css from './PatronBlockModal.css';

const PatronBlockModal = ({
  open,
  onOverride,
  onClose,
  patronBlocks,
  viewUserPath,
}) => {
  const blocks = take(orderBy(patronBlocks, ['metadata.updatedDate'], ['desc']), 3);
  const renderBlocks = blocks.map(block => {
    return (
      <Row key={block.id || block.patronBlockConditionId}>
        <Col xs>
          {block.desc || block.message || ''}
        </Col>
      </Row>
    );
  });

  return (
    <Modal
      data-test-patron-block-modal
      open={open}
      onClose={onClose}
      label={

          {' '}
          <FormattedMessage id="ui-users.blocks.modal.header" />
          {' '}
        }
      dismissible
    >
      <Row>
        <Col xs>
          <FormattedMessage id="ui-users.blocks.reason" />
        </Col>
      </Row>
      {renderBlocks}

      <Row>
        <Col xs={6}>{(patronBlocks.length > 3) && <FormattedMessage id="ui-users.blocks.additionalReasons" />}</Col>
        <Col xs={6}>
          <Row end="xs">
            <Col>
              <IfPermission perm="ui-users.overridePatronBlock">
                <Button
                  data-test-open-override-modal
                  onClick={() => {
                    onClose();
                    onOverride();
                  }}
                >
                  <FormattedMessage id="ui-users.blocks.overrideButton" />
                </Button>
              </IfPermission>
              <Button
                id="patron-block-close-modal"
                onClick={onClose}
              >
                <FormattedMessage id="ui-users.blocks.closeButton" />
              </Button>
              <Button
                id="patron-block-details-modal"
                className={css.detailsButton}
                buttonStyle="primary"
                to={viewUserPath}
              >
                <FormattedMessage id="ui-users.blocks.detailsButton" />
              </Button>
            </Col>
          </Row>
        </Col>
      </Row>
    </Modal>
  );
};

PatronBlockModal.propTypes = {
  open: PropTypes.bool,
  onOverride: PropTypes.func.isRequired,
  onClose: PropTypes.func,
  patronBlocks: PropTypes.arrayOf(PropTypes.object),
  viewUserPath: PropTypes.string,
};

export default PatronBlockModal;


text:
export default class DatagridService {
  constructor() {
    this.datagrids = {};
  }

  registerDatagrid(datagridController) {
    const datagridId = datagridController.id;

    if (this.datagrids[datagridId]) {
      throw new Error(`Duplicated datagrid: id="${datagridId}".`);
    }

    if (datagridId) {
      this.datagrids[datagridId] = datagridController;
    }
  }

  unregisterDatagrid(datagridId) {
    delete this.datagrids[datagridId];
  }

  /**
   * Refresh the content of a datagrid that has a specific `id`.
   * @param  string  datagridId  the `id` of the datagrid
   * @param  boolean showSpinner if you want to show the spinner
   * while `rows-loader` is executed (like a first load)
   */
  refresh(datagridId, showSpinner) {
    const datagridController = this.datagrids[datagridId];

    if (datagridController) {
      datagridController.refreshData(false, false, !showSpinner, true);
    }
  }
}


text:
package org.eclipse.ceylon.langtools.tools.javac.util;

import java.util.HashSet;
import java.util.Set;

import org.eclipse.ceylon.javax.tools.JavaFileObject;
import org.eclipse.ceylon.langtools.tools.javac.code.Lint.LintCategory;
import org.eclipse.ceylon.langtools.tools.javac.util.JCDiagnostic.DiagnosticPosition;

/**
 * A handler to process mandatory warnings, setting up a deferred diagnostic
 * to be printed at the end of the compilation if some warnings get suppressed
 * because too many warnings have already been generated.
 *
 * Note that the SuppressWarnings annotation can be used to suppress warnings
 * about conditions that would otherwise merit a warning. Such processing
 * is done when the condition is detected, and in those cases, no call is
 * made on any API to generate a warning at all. In consequence, this handler only
 * gets to handle those warnings that JLS says must be generated.
 *
 *
This is NOT part of any supported API.
 *  If you write code that depends on this, you do so at your own risk.
 *  This code and its internal interfaces are subject to change or
 *  deletion without notice.
 */
public class MandatoryWarningHandler {

    /**
     * The kinds of different deferred diagnostics that might be generated
     * if a mandatory warning is suppressed because too many warnings have
     * already been output.
     *
     * The parameter is a fragment used to build an I18N message key for Log.
     */
    private enum DeferredDiagnosticKind {
        /**
         * This kind is used when a single specific file is found to have warnings
         * and no similar warnings have already been given.
         * It generates a message like:
         *      FILE has ISSUES
         */
        IN_FILE(".filename"),
        /**
         * This kind is used when a single specific file is found to have warnings
         * and when similar warnings have already been reported for the file.
         * It generates a message like:
         *      FILE has additional ISSUES
         */
        ADDITIONAL_IN_FILE(".filename.additional"),
        /**
         * This kind is used when multiple files have been found to have warnings,
         * and none of them have had any similar warnings.
         * It generates a message like:
         *      Some files have ISSUES
         */
        IN_FILES(".plural"),
        /**
         * This kind is used when multiple files have been found to have warnings,
         * and some of them have had already had specific similar warnings.
         * It generates a message like:
         *      Some files have additional ISSUES
         */
        ADDITIONAL_IN_FILES(".plural.additional");

        DeferredDiagnosticKind(String v) { value = v; }
        String getKey(String prefix) { return prefix + value; }

        private final String value;
    }

    /**
     * Create a handler for mandatory warnings.
     * @param log     The log on which to generate any diagnostics
     * @param verbose Specify whether or not detailed messages about
     *                individual instances should be given, or whether an aggregate
     *                message should be generated at the end of the compilation.
     *                Typically set via  -Xlint:option.
     * @param enforceMandatory
     *                True if mandatory warnings and notes are being enforced.
     * @param prefix  A common prefix for the set of message keys for
     *                the messages that may be generated.
     * @param lc      An associated lint category for the warnings, or null if none.
     */
    public MandatoryWarningHandler(Log log, boolean verbose,
                                   boolean enforceMandatory, String prefix,
                                   LintCategory lc) {
        this.log = log;
        this.verbose = verbose;
        this.prefix = prefix;
        this.enforceMandatory = enforceMandatory;
        this.lintCategory = lc;
    }

    /**
     * Report a mandatory warning.
     */
    public void report(DiagnosticPosition pos, String msg, Object... args) {
        JavaFileObject currentSource = log.currentSourceFile();

        if (verbose) {
            if (sourcesWithReportedWarnings == null)
                sourcesWithReportedWarnings = new HashSet<JavaFileObject>();

            if (log.nwarnings < log.MaxWarnings) {
                // generate message and remember the source file
                logMandatoryWarning(pos, msg, args);
                sourcesWithReportedWarnings.add(currentSource);
            } else if (deferredDiagnosticKind == null) {
                // set up deferred message
                if (sourcesWithReportedWarnings.contains(currentSource)) {
                    // more errors in a file that already has reported warnings
                    deferredDiagnosticKind = DeferredDiagnosticKind.ADDITIONAL_IN_FILE;
                } else {
                    // warnings in a new source file
                    deferredDiagnosticKind = DeferredDiagnosticKind.IN_FILE;
                }
                deferredDiagnosticSource = currentSource;
                deferredDiagnosticArg = currentSource;
            } else if ((deferredDiagnosticKind == DeferredDiagnosticKind.IN_FILE
                        || deferredDiagnosticKind == DeferredDiagnosticKind.ADDITIONAL_IN_FILE)
                       && !equal(deferredDiagnosticSource, currentSource)) {
                // additional errors in more than one source file
                deferredDiagnosticKind = DeferredDiagnosticKind.ADDITIONAL_IN_FILES;
                deferredDiagnosticArg = null;
            }
        } else {
            if (deferredDiagnosticKind == null) {
                // warnings in a single source
                deferredDiagnosticKind = DeferredDiagnosticKind.IN_FILE;
                deferredDiagnosticSource = currentSource;
                deferredDiagnosticArg = currentSource;
            }  else if (deferredDiagnosticKind == DeferredDiagnosticKind.IN_FILE &&
                        !equal(deferredDiagnosticSource, currentSource)) {
                // warnings in multiple source files
                deferredDiagnosticKind = DeferredDiagnosticKind.IN_FILES;
                deferredDiagnosticArg = null;
            }
        }
    }

    /**
     * Report any diagnostic that might have been deferred by previous calls of report().
     */
    public void reportDeferredDiagnostic() {
        if (deferredDiagnosticKind != null) {
            if (deferredDiagnosticArg == null)
                logMandatoryNote(deferredDiagnosticSource, deferredDiagnosticKind.getKey(prefix));
            else
                logMandatoryNote(deferredDiagnosticSource, deferredDiagnosticKind.getKey(prefix), deferredDiagnosticArg);

            if (!verbose)
                logMandatoryNote(deferredDiagnosticSource, prefix + ".recompile");
        }
    }

    /**
     * Check two objects, each possibly null, are either both null or are equal.
     */
    private static boolean equal(Object o1, Object o2) {
        return ((o1 == null || o2 == null) ? (o1 == o2) : o1.equals(o2));
    }

    /**
     * The log to which to report warnings.
     */
    private Log log;

    /**
     * Whether or not to report individual warnings, or simply to report a
     * single aggregate warning at the end of the compilation.
     */
    private boolean verbose;

    /**
     * The common prefix for all I18N message keys generated by this handler.
     */
    private String prefix;

    /**
     * A set containing the names of the source files for which specific
     * warnings have been generated -- i.e. in verbose mode.  If a source name
     * appears in this list, then deferred diagnostics will be phrased to
     * include "additionally"...
     */
    private Set<JavaFileObject> sourcesWithReportedWarnings;

    /**
     * A variable indicating the latest best guess at what the final
     * deferred diagnostic will be. Initially as specific and helpful
     * as possible, as more warnings are reported, the scope of the
     * diagnostic will be broadened.
     */
    private DeferredDiagnosticKind deferredDiagnosticKind;

    /**
     * If deferredDiagnosticKind is IN_FILE or ADDITIONAL_IN_FILE, this variable
     * gives the value of log.currentSource() for the file in question.
     */
    private JavaFileObject deferredDiagnosticSource;

    /**
     * An optional argument to be used when constructing the
     * deferred diagnostic message, based on deferredDiagnosticKind.
     * This variable should normally be set/updated whenever
     * deferredDiagnosticKind is updated.
     */
    private Object deferredDiagnosticArg;

    /**
     * True if mandatory warnings and notes are being enforced.
     */
    private final boolean enforceMandatory;

    /**
     * A LintCategory to be included in point-of-use diagnostics to indicate
     * how messages might be suppressed (i.e. with @SuppressWarnings).
     */
    private final LintCategory lintCategory;

    /**
     * Reports a mandatory warning to the log.  If mandatory warnings
     * are not being enforced, treat this as an ordinary warning.
     */
    private void logMandatoryWarning(DiagnosticPosition pos, String msg,
                                     Object... args) {
        // Note: the following log methods are safe if lintCategory is null.
        if (enforceMandatory)
            log.mandatoryWarning(lintCategory, pos, msg, args);
        else
            log.warning(lintCategory, pos, msg, args);
    }

    /**
     * Reports a mandatory note to the log.  If mandatory notes are
     * not being enforced, treat this as an ordinary note.
     */
    private void logMandatoryNote(JavaFileObject file, String msg, Object... args) {
        if (enforceMandatory)
            log.mandatoryNote(file, msg, args);
        else
            log.note(file, msg, args);
    }
}


text:
/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.grinder.plugin.http.tcpproxyfilter;

import net.grinder.tools.tcpproxy.ConnectionDetails;
import net.grinder.util.NoOp;

import org.picocontainer.Disposable;

/**
 * {@link HTTPFilterEventListener} impl which is aware of connection filtering.
 *
 * @author JunHo Yoon
 * @since 1.0
 */
public class ConnectedHostHTTPFilterEventListener implements HTTPFilterEventListener, Disposable {
	private final ConnectionFilter connectionFilter;
	private final HTTPFilterEventListener connectionCache;

	/**
	 * Constructor.
	 *
	 * @param connectionFilter
	 *            connection filter
	 * @param connectionCache
	 *            {@link HTTPFilterEventListener} which will be delegated to
	 */
	public ConnectedHostHTTPFilterEventListener(ConnectionFilter connectionFilter, ConnectionCache connectionCache) {
		this.connectionFilter = connectionFilter;
		this.connectionCache = connectionCache;
	}

	@Override
	public void dispose() {
		if (this.connectionCache instanceof Disposable) {
			((Disposable) connectionCache).dispose();
		}
	}

	@Override
	public void open(ConnectionDetails connectionDetails) {
		if (connectionFilter.addConnectionDetails(connectionDetails, true)) {
			return;
		}
		try {
			connectionCache.open(connectionDetails);
		} catch (IllegalArgumentException e) {
			NoOp.noOp();
		}
	}

	@Override
	public void request(ConnectionDetails connectionDetails, byte[] buffer, int bytesRead) {
		if (connectionFilter.isFiltered(connectionDetails.getRemoteEndPoint())) {
			return;
		}
		try {
			connectionCache.request(connectionDetails, buffer, bytesRead);
		} catch (IllegalArgumentException e) {
			NoOp.noOp();
		}
	}

	@Override
	public void response(ConnectionDetails connectionDetails, byte[] buffer, int bytesRead) {
		if (connectionFilter.isFiltered(connectionDetails.getRemoteEndPoint())) {
			return;
		}
		try {
			connectionCache.response(connectionDetails, buffer, bytesRead);
		} catch (IllegalArgumentException e) {
			NoOp.noOp();
		}
	}

	@Override
	public void close(ConnectionDetails connectionDetails) {
		if (connectionFilter.isFiltered(connectionDetails.getRemoteEndPoint())) {
			return;
		}
		try {
			connectionCache.close(connectionDetails);
		} catch (IllegalArgumentException e) {
			NoOp.noOp();
		}
	}
}


text:
oneTimeSetUp() {
   TEST_SUITE_CACHE="$(mktemp -d ${SHUNIT_TMPDIR}/test_suite_cache.XXXX)"
   BUILDPACK_HOME=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
   # jq isn't in the docker image, so need to do this the hard way
   DEFAULT_GO_VERSION=$(head < $BUILDPACK_HOME/data.json | grep DefaultVersion | cut -d : -f 2 | cut -d , -f 1 | sed -e s:\"::g -e s:\ ::g)
   export GO_BUCKET_URL="file://${BUILDPACK_HOME}/test/assets"
}

oneTimeTearDown() {
  rm -rf ${TEST_SUITE_CACHE}
}

setUp() {
  OUTPUT_DIR="$(mktemp -d ${SHUNIT_TMPDIR}/output.XXXX)"
  STD_OUT="${OUTPUT_DIR}/stdout"
  STD_ERR="${OUTPUT_DIR}/stderr"
  BUILD_DIR="${OUTPUT_DIR}/build"
  CACHE_DIR="${OUTPUT_DIR}/cache"
  ENV_DIR="${OUTPUT_DIR}/env"
  mkdir -p ${OUTPUT_DIR}
  mkdir -p ${BUILD_DIR}
  mkdir -p ${CACHE_DIR}
  mkdir -p ${ENV_DIR}

}

tearDown() {
  rm -rf ${OUTPUT_DIR}
}

##############
## Helpers
##

capture() {
  resetCapture

  LAST_COMMAND="$@"

  $@ >${STD_OUT} 2>${STD_ERR}
  RETURN=$?
  rtrn=${RETURN} # deprecated
}

continue_capture() {
  LAST_COMMAND="$@"

  $@ >>${STD_OUT} 2>>${STD_ERR}
  local cr=$?
  if [ "$RETURN" = "0" ]; then
    RETURN=$cr
  fi
  rtrn=${RETURN} # deprecated
}

resetCapture() {
  if [ -f ${STD_OUT} ]; then
    rm ${STD_OUT}
  fi

  if [ -f "${STD_OUT}_no_color" ]; then
    rm "${STD_OUT}_no_color"
  fi

  if [ -f ${STD_ERR} ]; then
    rm ${STD_ERR}
  fi

  unset LAST_COMMAND
  unset RETURN
  unset rtrn # deprecated
}

fixture() {
  local fixture="${1}"
  echo "* fixture: ${fixture}"
  local fp="${BUILDPACK_HOME}/test/fixtures/${fixture}"
  tar -cf - -C $fp . | tar -x -C ${BUILD_DIR}
}

env() {
  local var="${1}"
  local val="${2}"
  if [ -z "${var}" ]; then
    fail "set env var w/o specifying name"
    exit 1
  fi
  echo -n "${val}" > "${ENV_DIR}/${var}"
}

detect() {
  echo "* detect"
  capture ${BUILDPACK_HOME}/bin/detect ${BUILD_DIR}
}

assertDetected() {
  detect
  assertCaptured "Go"
  assertCapturedSuccess
}

compile() {
  echo "* compile"
  capture ${BUILDPACK_HOME}/bin/compile ${BUILD_DIR} ${CACHE_DIR} ${ENV_DIR}
}

dotest() {
  # On Heroku CI, test-compile and test are run in such a way that the
  # provided BUILD_DIR is the same as HOME. Simulate that here to get
  # better fidelity. For example, this ensures that the default GOPATH of
  # $HOME/go doesn't cause issues.
  echo "* test-compile"
  HOME="${BUILD_DIR}" capture "${BUILDPACK_HOME}/bin/test-compile" "${BUILD_DIR}" "${CACHE_DIR}" "${ENV_DIR}"
  echo "* test"
  HOME="${BUILD_DIR}" continue_capture "${BUILDPACK_HOME}/bin/test" "${BUILD_DIR}" "${ENV_DIR}"
}

release() {
  capture ${BUILDPACK_HOME}/bin/release ${BUILD_DIR}
}

assertFile() {
  local content="${1}"
  local name="${2}"
  local tgt="${BUILD_DIR}/${name}"
  assertEquals "${content}" "$(cat ${tgt})"
}

assertBuildDirFileDoesNotExist() {
  local name="${1}"
  local tgt="${BUILD_DIR}/${name}"
  assertTrue "File ${name} exists" "[ ! -f ${tgt} ]"
}

assertBuildDirFileExists() {
  local name="${1}"
  local tgt="${BUILD_DIR}/${name}"
  assertTrue "File ${name} does not exist" "[ -f ${tgt} ]"
}

assertFileExists() {
  local name="${1}"
  assertTrue "File ${name} does not exist" "[ -f ${name} ]"
}

assertDirExists() {
  local path="${1}"
  assertTrue "Dir ${path} does not exist" "[ -d ${path} ]"
}

assertDirDoesNotExist() {
  local path="${1}"
  assertTrue "Dir ${path} exists" "[ ! -d ${path} ]"
}

assertCompiledBinaryExists() {
  local name="${1:-fixture}"
  local tgt="${BUILD_DIR}/bin/${name}"
  assertTrue "Compiled binary (${tgt}) exists" "[ -x ${tgt} ]"
}

assertCompiledBinaryOutputs() {
  local name="${1}"
  local output="${2}"
  capture "${BUILD_DIR}/bin/${name}"
}

assertCapturedEquals() {
  assertEquals "$@" "$(cat ${STD_OUT})"
}

assertCapturedNotEquals() {
  assertNotEquals "$@" "$(cat ${STD_OUT})"
}

assertCaptured() {
  assertFileContains "$@" "${STD_OUT}"
}

assertNotCaptured() {
  assertFileNotContains "$@" "${STD_OUT}"
}

assertCapturedSuccess() {
  assertEquals "Expected captured exit code to be 0; was <${RETURN}>" "0" "${RETURN}"
  assertEquals "Expected STD_ERR to be empty; was <$(cat ${STD_ERR})>" "" "$(cat ${STD_ERR})"
}

assertCapturedExitSuccess() {
  assertEquals "Expected captured exit code to be 0; was <${RETURN}>" "0" "${RETURN}"
}

# assertCapturedError [[expectedErrorCode] expectedErrorMsg]
assertCapturedError() {
  if [ $# -gt 1 ]; then
    local expectedErrorCode="${1}"
    shift
  fi

  local expectedErrorMsg="${1:-""}"

  if [ -z ${expectedErrorCode} ]; then
    assertTrue "Expected captured exit code to be greater than 0; was <${RETURN}>" "[ ${RETURN} -gt 0 ]"
  else
    assertTrue "Expected captured exit code to be <${expectedErrorCode}>; was <${RETURN}>" "[ ${RETURN} -eq ${expectedErrorCode} ]"
  fi

  if [ "${expectedErrorMsg}" != "" ]; then
    assertFileContains "Expected STD_ERR to contain error <${expectedErrorMsg}>" "${expectedErrorMsg}" "${STD_ERR}"
  fi
}

_assertContains() {
  if [ 5 -eq $# ]; then
    local msg="${1}"
    shift
  elif [ ! 4 -eq $# ]; then
    fail "Expected 4 or 5 parameters; Receieved $# parameters"
  fi

  local needle=$1
  local haystack=$2
  local expectation=$3
  local haystack_type=$4

  case "${haystack_type}" in
    "file")
      local haystack_no_color="${haystack}_no_color"
      if [ ! -e ${haystack_no_color} ]; then
        sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" < ${haystack} > ${haystack_no_color}
      fi
      ## echo grep -q -F -e "${needle}" ${haystack_no_color}
      grep -q -F -e "${needle}" ${haystack_no_color} ;;
    "text") echo "${haystack}" | grep -q -F -e "${needle}" ;;
  esac

  if [ "${expectation}" != "$?" ]; then
    case "${expectation}" in
      0) default_msg="Expected <${haystack}> to contain <${needle}>" ;;
      1) default_msg="Did not expect <${haystack}> to contain <${needle}>" ;;
    esac

    fail "${msg:-${default_msg}}"
  fi
}

assertContains() {
  _assertContains "$@" 0 "text"
}

assertNotContains() {
  _assertContains "$@" 1 "text"
}

assertFileContains() {
  _assertContains "$@" 0 "file"
}

assertFileNotContains() {
  _assertContains "$@" 1 "file"
}

command_exists () {
    type "$1" > /dev/null 2>&1 ;
}

assertFileMD5() {
  expectedHash=$1
  filename=$2

  if command_exists "md5sum"; then
    md5_cmd="md5sum ${filename}"
    expected_md5_cmd_output="${expectedHash}  ${filename}"
  elif command_exists "md5"; then
    md5_cmd="md5 ${filename}"
    expected_md5_cmd_output="MD5 (${filename}) = ${expectedHash}"
  else
    fail "no suitable MD5 hashing command found on this system"
  fi

  assertEquals "${expected_md5_cmd_output}" "`${md5_cmd}`"
}

assertModulesBoilerplateCaptured() {
  assertCaptured "Detected go modules via go.mod"
  assertCaptured "Detected Module Name: github.com/heroku/fixture"
  assertCaptured "Determining packages to install"
}

assertGoInstallOnlyFixturePackageCaptured(){
  assertCaptured "Running: go install -v -tags heroku github.com/heroku/fixture
github.com/heroku/fixture"
}

assertInstalledFixtureBinary() {
  assertCaptured "Installed the following binaries:
./bin/fixture"
  assertCompiledBinaryExists fixture
}

assertGoInstallCaptured() {
  local go_ver=${1:-${DEFAULT_GO_VERSION}}
  assertCaptured "Installing ${go_ver}
Fetching ${go_ver}.linux-amd64.tar.gz... done"
}