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

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>io.permazen.kv.util Class Hierarchy (Permazen 4.1.6 API)</title>
<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

Prev

Next

Frames

No Frames

All Classes

Hierarchy For Package io.permazen.kv.util

Package Hierarchies:

All Packages

Class Hierarchy

java.lang.Object

java.util.AbstractCollection<E> (implements java.util.Collection<E>)

java.util.AbstractSet<E> (implements java.util.Set<E>)

io.permazen.util.AbstractIterationSet<E>

io.permazen.util.AbstractNavigableSet<E> (implements java.util.NavigableSet<E>)

io.permazen.kv.util.AbstractKVNavigableSet<E>

io.permazen.kv.util.KVNavigableSet

io.permazen.kv.util.AbstractKVIterator<E> (implements io.permazen.util.CloseableIterator<E>)

io.permazen.kv.AbstractKVStore (implements io.permazen.kv.KVStore)

io.permazen.kv.util.NavigableMapKVStore (implements java.lang.Cloneable, java.io.Serializable)

java.util.AbstractMap<K,V> (implements java.util.Map<K,V>)

io.permazen.util.AbstractNavigableMap<K,V> (implements java.util.NavigableMap<K,V>)

io.permazen.kv.util.AbstractKVNavigableMap<K,V>

io.permazen.kv.util.KVNavigableMap

io.permazen.util.AbstractXMLStreaming

io.permazen.kv.util.XMLSerializer

io.permazen.kv.util.ForwardingKVStore (implements io.permazen.kv.KVStore)

io.permazen.kv.util.CloseableForwardingKVStore (implements io.permazen.kv.CloseableKVStore)

io.permazen.kv.util.PrefixKVStore

io.permazen.kv.util.PrefixKVTransaction (implements io.permazen.kv.KVTransaction)

io.permazen.kv.util.UnmodifiableKVStore

io.permazen.kv.util.KeyListEncoder

io.permazen.kv.util.KeyWatchTracker (implements java.io.Closeable)

io.permazen.kv.util.PrefixKVDatabase (implements io.permazen.kv.KVDatabase)

Skip navigation links

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

Prev

Next

Frames

No Frames

All Classes

Copyright © 2020. All rights reserved.


text:
<?php

namespace Magento\Payment\Gateway\Command\Result;

use Magento\Payment\Gateway\Command\ResultInterface;

/**
 * Class BoolResult
 */
class BoolResult implements ResultInterface
{
    /**
     * @var array
     */
    private $result;

    /**
     * Constructor
     *
     * @param bool $result
     */
    public function __construct($result = true)
    {
        $this->result = $result;
    }

    /**
     * Returns result interpretation
     *
     * @return mixed
     */
    public function get()
    {
        return (bool) $this->result;
    }
}

redpajama_set_name: RedPajamaGithub


text:
<!DOCTYPE html>

    <meta charset="utf-8">
    <title>Philly Ward Leaders</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">


text:
var util = require('util');

// Create a new custom Error constructor
function AlreadyDenormalizingError(msg) {
    // Pass the constructor to V8's
    // captureStackTrace to clean up the output
    Error.captureStackTrace(this, AlreadyDenormalizingError);

    // If defined, store a custom error message
    if (msg) {
        this.message = msg;
    }
}

// Extend our custom Error from Error
util.inherits(AlreadyDenormalizingError, Error);

// Give our custom error a name property. Helpful for logging the error later.
AlreadyDenormalizingError.prototype.name = AlreadyDenormalizingError.name;

module.exports = AlreadyDenormalizingError;


text:
> An ember-cli-deploy plugin to deploy Ember FastBoot apps that are deployed via [fastboot-app-server](https://github.com/ember-fastboot/fastboot-app-server) to [AWS](https://aws.amazon.com) (S3)

This plugin is not a standalone plugin. You will need to have a zipped fastboot-build available on the deployment context. This plugin works best in combination with [ember-cli-deploy-fastboot-app-server](https://github.com/LevelbossMike/ember-cli-deploy-fastboot-app-server).

## What is an ember-cli-deploy plugin?

A plugin is an addon that can be executed as a part of the ember-cli-deploy pipeline. A plugin will implement one or more of the ember-cli-deploy's pipeline hooks.

For more information on what plugins are and how they work, please refer to the [Plugin Documentation][2].

## Quick Start
To get up and running quickly, do the following:

- Ensure [ember-cli-fastboot](https://github.com/ember-fastboot/ember-cli-fastboot) is installed.
- Ensure [ember-cli-deploy-build][4] is installed and configured.
- Ensure [ember-cli-deploy-revision-data][6] is installed and configured.
- Ensure [ember-cli-deploy-display-revisions](https://github.com/duizendnegen/ember-cli-deploy-display-revisions) is installed and configured.
- Ensure [ember-cli-deploy-fastboot-app-server](https://github.com/levelbossmike/ember-cli-deploy-fastboot-app-server) is installed and configured.

- Install this plugin

```bash
$ ember install ember-cli-deploy-fastboot-app-server-aws
```
- Run the pipeline

```bash
$ ember deploy production
```

## ember-cli-deploy Hooks Implemented

For detailed information on what plugin hooks are and how they work, please refer to the [Plugin Documentation][2].

- `configure`
- `upload`
- `fetchInitialRevisions`
- `fetchRevisions`
- `activate`

## Configuration Options

For detailed information on how configuration of plugins works, please refer to the [Plugin Documentation][2].

### accessKeyId

The AWS access key for the user that has the ability to upload to the `bucket`. If this is left undefined, the normal [AWS SDK credential resolution][7] will take place.

*Default:* `undefined`

### secretAccessKey

The AWS secret for the user that has the ability to upload to the `bucket`. This must be defined when `accessKeyId` is defined.

*Default:* `undefined`

### profile
The AWS profile as defined in ~/.aws/credentials. If this is left undefined, the normal AWS SDK credential resolution will take place.

*Default:* `undefined`

### bucket (`required`)

The AWS bucket that the files will be uploaded to.

*Default:* `undefined`

### region (`required`)

The region your bucket is located in. (e.g. set this to `eu-west-1` if your bucket is located in the 'Ireland' region)

*Default:* `undefined`

### awsPrefix

A optional prefix to add to the uploaded destination of your built fastboot assets. Useful if your app is hosted at a nested path on S3. For example if you set `awsPrefix` to `'blog'`, `fastboot-deploy-info.json` will look something like this:
```json
{
  "bucket": "my-bucket",
  "key": "blog/dist-0.0.0+a3323e2.zip"
}
```
**Note** that a trailing slash is added to the value to separate it from the `archivePrefix` value.

*Default:* `''`

### revisionKey

The unique revision number for the version of the app. By default this option will use either the `revision` passed in from the command line or the `revisionData.revisionKey` property from the deployment context.

*Default:* `context.commandOptions.revision || context.revisionData.revisionKey`

### archivePrefix

The prefix that will be used in combination with a revisionKey to build up the identifier for the revision you are deploying. In the default case this gets added to the deploy context via `ember-cli-deploy-fastboot-app-server`.

*Default:* `context.fastbootArchivePrefix` (added by `ember-cli-deploy-fastboot-app-server`)

### downloaderManifestContent

A function that gets added to the deploy context so that other plugins can update an app-manifest file that is used by [fastboot-app-server notifiers](https://github.com/ember-fastboot/fastboot-app-server#notifiers) and [-downloaders](https://github.com/ember-fastboot/fastboot-app-server#downloaders) to update the FastBoot-app served via `fastboot-app-server`.

*Default:* `context.fastbootDownloaderManifestContent` (added by `ember-cli-deploy-fastboot-app-server`)

## TL;DR

### What does this plugin do exactly?
This plugin is meant to be used in combination with [ember-cli-deploy-fastboot-app-server](https://github.com/levelbossmike/ember-cli-deploy-fastboot-app-server). This plugin will upload the zipped fastboot-build to [S3](https://aws.amazon.com/de/s3/) and can be used to implement the [lightning-strategy](http://ember-cli-deploy.com/docs/v1.0.x/the-lightning-strategy/) that you are used to with `ember-cli-deploy` with FastBoot-applications.

This means you can list available revisions via `ember deploy:list` and switch around the revisions that are served to you users via the `ember deploy:activate`-command.

### How do I activate a revision?

A user can activate a revision by either:

- Passing a command line argument to the `deploy` command:

```bash
$ ember deploy --activate=true
```

- Running the `deploy:activate` command:

```bash
$ ember deploy:activate --revision <revision-key>
```

- Setting the `activateOnDeploy` flag in `deploy.js`

```javascript
ENV.pipeline = {
  activateOnDeploy: true
}
```

### What does activation do?

When *ember-cli-deploy-fastboot-app-server* uploads a zipped FastBoot-build-file to S3, it uploads it under the key defined by a combination of the two config properties `archivePrefix` and `revisionKey`.

So, if the `archivePrefix` was configured to be `dist-` and there had been a few revisons deployed, then your bucket might look something like this:

```bash
$ aws s3 ls s3://<bucket>/
                           PRE assets/
2017-07-15 07:47:42       1207 fastboot-deploy-info.json
2017-07-15 07:25:51       1207 dist-a644ba43cdb987288d646c5a97b1c8a9.zip
2017-07-15 07:20:27       1207 dist-61cfff627b79058277e604686197bbbd.zip
2017-07-15 07:19:11       1207 dist-9dd26dbc8f3f9a8a342d067335315a63.zip
```

To activate a revision the plugin will update the contents of `fastboot-deploy-info.json` to point to the passed revision as the active revision. As soon as manifest-file has been updated an [fastboot-app-server-notifier](https://github.com/ember-fastboot/fastboot-app-server#notifiers) will notice the update and trigger an [fastboot-app-server-downloader](https://github.com/ember-fastboot/fastboot-app-server#downloaders) to update the version of your application served via a [fastboot-app-server](https://github.com/ember-fastboot/fastboot-app-server).

```bash
$ ember deploy:activate --revision a644ba43cdb987288d646c5a97b1c8a9
```

### When does activation occur?

Activation occurs during the `activate` hook of the pipeline. By default, activation is turned off and must be explicitly enabled by one of the 3 methods above.

## Prerequisites

The following properties are expected to be present on the deployment `context` object:

- `distDir`                     (provided by [ember-cli-deploy-build][4])
- `project.name()`              (provided by [ember-cli-deploy][5])
- `revisionKey`                 (provided by [ember-cli-deploy-revision-data][6])
- `commandLineArgs.revisionKey` (provided by [ember-cli-deploy][5])
- `deployEnvironment`           (provided by [ember-cli-deploy][5])

## S3 Permissions
In addition to the same permissions you need to have for uploading files via the  [ember-cli-deploy-s3 plugin](https://github.com/ember-cli-deploy/ember-cli-deploy-s3#deployment-user-and-s3-permissions) you also need permission for the `listBucket` and `listObject` actions for S3. Usually the easiest thing to do when using this plugin is to create a user that has admin-access to the bucket you chose to use for uploading your deployments to.

## Running Tests
You need to have a bucket on S3 setup for the test to complete. Tests expect
specific environment variables to be set so that tests are able to upload to
s3 automatically:

* `AWS_ACCESS_KEY_ID` - to authenticate with AWS
* `AWS_SECRET_ACCESS_KEY` - to authenticate with AWS
* `TEST_BUCKET` - the name of the test bucket
* `TEST_REGION` - the region the test bucket is located in

To run tests:

* `yarn test`

[2]: http://ember-cli.github.io/ember-cli-deploy/plugins "Plugin Documentation"
[4]: https://github.com/ember-cli-deploy/ember-cli-deploy-build "ember-cli-deploy-build"
[5]: https://github.com/ember-cli/ember-cli-deploy "ember-cli-deploy"
[6]: https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data "ember-cli-deploy-revision-data"
[7]: https://docs.aws.amazon.com/AWSJavaScriptSDK/guide/node-configuring.html#Setting_AWS_Credentials "Setting AWS Credentials"


text:
<?php

define('DWOO_DIRECTORY', dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR);

class Dwoo_Core
{
    /**
     * current version number
     *
     * @var string
     */
    const VERSION = '1.2.0';

    /**
     * unique number of this dwoo release
     *
     * this can be used by templates classes to check whether the compiled template
     * has been compiled before this release or not, so that old templates are
     * recompiled automatically when Dwoo is updated
     */
    const RELEASE_TAG = 17;

    /**#@+
     * constants that represents all plugin types
     *
     * these are bitwise-operation-safe values to allow multiple types
     * on a single plugin
     *
     * @var int
     */
    const CLASS_PLUGIN = 1;
    const FUNC_PLUGIN = 2;
    const NATIVE_PLUGIN = 4;
    const BLOCK_PLUGIN = 8;
    const COMPILABLE_PLUGIN = 16;
    const CUSTOM_PLUGIN = 32;
    const SMARTY_MODIFIER = 64;
    const SMARTY_BLOCK = 128;
    const SMARTY_FUNCTION = 256;
    const PROXY_PLUGIN = 512;
    const TEMPLATE_PLUGIN = 1024;
    /**#@-*/

    /**
     * character set of the template, used by string manipulation plugins
     *
     * it must be lowercase, but setCharset() will take care of that
     *
     * @see setCharset
     * @see getCharset
     * @var string
     */
    protected $charset = 'utf-8';

    /**
     * global variables that are accessible through $dwoo.* in the templates
     *
     * default values include:
     *
     * $dwoo.version - current version number
     * $dwoo.ad - a Powered by Dwoo link pointing to dwoo.org
     * $dwoo.now - the current time
     * $dwoo.template - the current template filename
     * $dwoo.charset - the character set used by the template
     *
     * on top of that, foreach and other plugins can store special values in there,
     * see their documentation for more details.
     *
     * @private
     * @var array
     */
    public $globals;

    /**
     * directory where the compiled templates are stored
     *
     * defaults to DWOO_COMPILEDIR (= dwoo_dir/compiled by default)
     *
     * @var string
     */
    protected $compileDir;

    /**
     * directory where the cached templates are stored
     *
     * defaults to DWOO_CACHEDIR (= dwoo_dir/cache by default)
     *
     * @var string
     */
    protected $cacheDir;

    /**
     * defines how long (in seconds) the cached files must remain valid
     *
     * can be overriden on a per-template basis
     *
     * -1 = never delete
     * 0 = disabled
     * >0 = duration in seconds
     *
     * @var int
     */
    protected $cacheTime = 0;

    /**
     * security policy object
     *
     * @var Dwoo_Security_Policy
     */
    protected $securityPolicy = null;

    /**
     * stores the custom plugins callbacks
     *
     * @see addPlugin
     * @see removePlugin
     * @var array
     */
    protected $plugins = array();

    /**
     * stores the filter callbacks
     *
     * @see addFilter
     * @see removeFilter
     * @var array
     */
    protected $filters = array();

    /**
     * stores the resource types and associated
     * classes / compiler classes
     *
     * @var array
     */
    protected $resources = array
    (
        'file'      =>  array
        (
            'class'     =>  'Dwoo_Template_File',
            'compiler'  =>  null
        ),
        'string'    =>  array
        (
            'class'     =>  'Dwoo_Template_String',
            'compiler'  =>  null
        )
    );

    /**
     * the dwoo loader object used to load plugins by this dwoo instance
     *
     * @var Dwoo_ILoader
     */
    protected $loader = null;

    /**
     * currently rendered template, set to null when not-rendering
     *
     * @var Dwoo_ITemplate
     */
    protected $template = null;

    /**
     * stores the instances of the class plugins during template runtime
     *
     * @var array
     */
    protected $runtimePlugins;

    /**
     * stores the returned values during template runtime
     *
     * @var array
     */
    protected $returnData;

    /**
     * stores the data during template runtime
     *
     * @var array
     * @private
     */
    public $data;

    /**
     * stores the current scope during template runtime
     *
     * this should ideally not be accessed directly from outside template code
     *
     * @var mixed
     * @private
     */
    public $scope;

    /**
     * stores the scope tree during template runtime
     *
     * @var array
     */
    protected $scopeTree;

    /**
     * stores the block plugins stack during template runtime
     *
     * @var array
     */
    protected $stack;

    /**
     * stores the current block plugin at the top of the stack during template runtime
     *
     * @var Dwoo_Block_Plugin
     */
    protected $curBlock;

    /**
     * stores the output buffer during template runtime
     *
     * @var string
     */
    protected $buffer;

    /**
     * stores plugin proxy
     *
     * @var Dwoo_IPluginProxy
     */
    protected $pluginProxy;

    /**
     * constructor, sets the cache and compile dir to the default values if not provided
     *
     * @param string $compileDir path to the compiled directory, defaults to lib/compiled
     * @param string $cacheDir path to the cache directory, defaults to lib/cache
     */
    public function __construct($compileDir = null, $cacheDir = null)
    {
        if ($compileDir !== null) {
            $this->setCompileDir($compileDir);
        }
        if ($cacheDir !== null) {
            $this->setCacheDir($cacheDir);
        }
        $this->initGlobals();
    }

    /**
     * resets some runtime variables to allow a cloned object to be used to render sub-templates
     */
    public function __clone()
    {
        $this->template = null;
        unset($this->data);
        unset($this->returnData);
    }

    /**
     * outputs the template instead of returning it, this is basically a shortcut for get(*, *, *, true)
     *
     * @see get
     * @param mixed $tpl template, can either be a Dwoo_ITemplate object (i.e. Dwoo_Template_File), a valid path to a template, or
     *                   a template as a string it is recommended to provide a Dwoo_ITemplate as it will probably make things faster,
     *                   especially if you render a template multiple times
     * @param mixed $data the data to use, can either be a Dwoo_IDataProvider object (i.e. Dwoo_Data) or an associative array. if you're
     *                    rendering the template from cache, it can be left null
     * @param Dwoo_ICompiler $compiler the compiler that must be used to compile the template, if left empty a default
     *                                Dwoo_Compiler will be used.
     * @return string nothing or the template output if $output is true
     */
    public function output($tpl, $data = array(), Dwoo_ICompiler $compiler = null)
    {
        return $this->get($tpl, $data, $compiler, true);
    }

    /**
     * returns the given template rendered using the provided data and optional compiler
     *
     * @param mixed $tpl template, can either be a Dwoo_ITemplate object (i.e. Dwoo_Template_File), a valid path to a template, or
     *                   a template as a string it is recommended to provide a Dwoo_ITemplate as it will probably make things faster,
     *                   especially if you render a template multiple times
     * @param mixed $data the data to use, can either be a Dwoo_IDataProvider object (i.e. Dwoo_Data) or an associative array. if you're
     *                    rendering the template from cache, it can be left null
     * @param Dwoo_ICompiler $compiler the compiler that must be used to compile the template, if left empty a default
     *                                Dwoo_Compiler will be used.
     * @param bool $output flag that defines whether the function returns the output of the template (false, default) or echoes it directly (true)
     * @return string nothing or the template output if $output is false
     */
    public function get($_tpl, $data = array(), $_compiler = null, $_output = false)
    {
        // a render call came from within a template, so we need a new dwoo instance in order to avoid breaking this one
        if ($this->template instanceof Dwoo_ITemplate) {
            $clone = clone $this;
            return $clone->get($_tpl, $data, $_compiler, $_output);
        }

        // auto-create template if required
        if ($_tpl instanceof Dwoo_ITemplate) {
            // valid, skip
        } elseif (is_string($_tpl) && file_exists($_tpl)) {
            $_tpl = new Dwoo_Template_File($_tpl);
        } else {
            throw new Dwoo_Exception('Dwoo->get/Dwoo->output\'s first argument must be a Dwoo_ITemplate (i.e. Dwoo_Template_File) or a valid path to a template file', E_USER_NOTICE);
        }

        // save the current template, enters render mode at the same time
        // if another rendering is requested it will be proxied to a new Dwoo_Core(instance
        $this->template = $_tpl;

        // load data
        if ($data instanceof Dwoo_IDataProvider) {
            $this->data = $data->getData();
        } elseif (is_array($data)) {
            $this->data = $data;
        } elseif ($data instanceof ArrayAccess) {
            $this->data = $data;
        } else {
            throw new Dwoo_Exception('Dwoo->get/Dwoo->output\'s data argument must be a Dwoo_IDataProvider object (i.e. Dwoo_Data) or an associative array', E_USER_NOTICE);
        }

        $this->globals['template'] = $_tpl->getName();
        $this->initRuntimeVars($_tpl);

        // try to get cached template
        $file = $_tpl->getCachedTemplate($this);
        $doCache = $file === true;
        $cacheLoaded = is_string($file);

        if ($cacheLoaded === true) {
            // cache is present, run it
            if ($_output === true) {
                include $file;
                $this->template = null;
            } else {
                ob_start();
                include $file;
                $this->template = null;
                return ob_get_clean();
            }
        } else {
            // no cache present
            if ($doCache === true) {
                $dynamicId = uniqid();
            }

            // render template
            $compiledTemplate = $_tpl->getCompiledTemplate($this, $_compiler);
            $out = include $compiledTemplate;

            // template returned false so it needs to be recompiled
            if ($out === false) {
                $_tpl->forceCompilation();
                $compiledTemplate = $_tpl->getCompiledTemplate($this, $_compiler);
                $out = include $compiledTemplate;
            }

            if ($doCache === true) {
                $out = preg_replace('/(<%|%>|<\?php|<\?|\?>)/', '<?php /*'.$dynamicId.'*/ echo \'$1\'; ?>', $out);
                if (!class_exists('Dwoo_plugin_dynamic', false)) {
                    $this->getLoader()->loadPlugin('dynamic');
                }
                $out = Dwoo_Plugin_dynamic::unescape($out, $dynamicId, $compiledTemplate);
            }

            // process filters
            foreach ($this->filters as $filter) {
                if (is_array($filter) && $filter[0] instanceof Dwoo_Filter) {
                    $out = call_user_func($filter, $out);
                } else {
                    $out = call_user_func($filter, $this, $out);
                }
            }

            if ($doCache === true) {
                // building cache
                $file = $_tpl->cache($this, $out);

                // run it from the cache to be sure dynamics are rendered
                if ($_output === true) {
                    include $file;
                    // exit render mode
                    $this->template = null;
                } else {
                    ob_start();
                    include $file;
                    // exit render mode
                    $this->template = null;
                    return ob_get_clean();
                }
            } else {
                // no need to build cache
                // exit render mode
                $this->template = null;
                // output
                if ($_output === true) {
                    echo $out;
                }
                return $out;
            }
        }
    }

    /**
     * re-initializes the globals array before each template run
     *
     * this method is only callede once when the Dwoo object is created
     */
    protected function initGlobals()
    {
        $this->globals = array
        (
            'version'   =>  self::VERSION,
            'ad'        =>  'Powered by Dwoo',
            'now'       =>  $_SERVER['REQUEST_TIME'],
            'charset'   =>  $this->charset,
        );
    }

    /**
     * re-initializes the runtime variables before each template run
     *
     * override this method to inject data in the globals array if needed, this
     * method is called before each template execution
     *
     * @param Dwoo_ITemplate $tpl the template that is going to be rendered
     */
    protected function initRuntimeVars(Dwoo_ITemplate $tpl)
    {
        $this->runtimePlugins = array();
        $this->scope =& $this->data;
        $this->scopeTree = array();
        $this->stack = array();
        $this->curBlock = null;
        $this->buffer = '';
        $this->returnData = array();
    }

    /*
     * --------- settings functions ---------
     */

    /**
     * adds a custom plugin that is not in one of the plugin directories
     *
     * @param string $name the plugin name to be used in the templates
     * @param callback $callback the plugin callback, either a function name,
     *                           a class name or an array containing an object
     *                           or class name and a method name
     * @param bool $compilable if set to true, the plugin is assumed to be compilable
     */
    public function addPlugin($name, $callback, $compilable = false)
    {
        $compilable = $compilable ? self::COMPILABLE_PLUGIN : 0;
        if (is_array($callback)) {
            if (is_subclass_of(is_object($callback[0]) ? get_class($callback[0]) : $callback[0], 'Dwoo_Block_Plugin')) {
                $this->plugins[$name] = array('type'=>self::BLOCK_PLUGIN | $compilable, 'callback'=>$callback, 'class'=>(is_object($callback[0]) ? get_class($callback[0]) : $callback[0]));
            } else {
                $this->plugins[$name] = array('type'=>self::CLASS_PLUGIN | $compilable, 'callback'=>$callback, 'class'=>(is_object($callback[0]) ? get_class($callback[0]) : $callback[0]), 'function'=>$callback[1]);
            }
        } elseif (class_exists($callback, false)) {
            if (is_subclass_of($callback, 'Dwoo_Block_Plugin')) {
                $this->plugins[$name] = array('type'=>self::BLOCK_PLUGIN | $compilable, 'callback'=>$callback, 'class'=>$callback);
            } else {
                $this->plugins[$name] = array('type'=>self::CLASS_PLUGIN | $compilable, 'callback'=>$callback, 'class'=>$callback, 'function'=>($compilable ? 'compile' : 'process'));
            }
        } elseif (function_exists($callback)) {
            $this->plugins[$name] = array('type'=>self::FUNC_PLUGIN | $compilable, 'callback'=>$callback);
        } else {
            throw new Dwoo_Exception('Callback could not be processed correctly, please check that the function/class you used exists');
        }
    }

    /**
     * removes a custom plugin
     *
     * @param string $name the plugin name
     */
    public function removePlugin($name)
    {
        if (isset($this->plugins[$name])) {
            unset($this->plugins[$name]);
        }
    }

    /**
     * adds a filter to this Dwoo instance, it will be used to filter the output of all the templates rendered by this instance
     *
     * @param mixed $callback a callback or a filter name if it is autoloaded from a plugin directory
     * @param bool $autoload if true, the first parameter must be a filter name from one of the plugin directories
     */
    public function addFilter($callback, $autoload = false)
    {
        if ($autoload) {
            $class = 'Dwoo_Filter_'.$callback;

            if (!class_exists($class, false) && !function_exists($class)) {
                try {
                    $this->getLoader()->loadPlugin($callback);
                } catch (Dwoo_Exception $e) {
                    if (strstr($callback, 'Dwoo_Filter_')) {
                        throw new Dwoo_Exception('Wrong filter name : '.$callback.', the "Dwoo_Filter_" prefix should not be used, please only use "'.str_replace('Dwoo_Filter_', '', $callback).'"');
                    } else {
                        throw new Dwoo_Exception('Wrong filter name : '.$callback.', when using autoload the filter must be in one of your plugin dir as "name.php" containg a class or function named "Dwoo_Filter_name"');
                    }
                }
            }

            if (class_exists($class, false)) {
                $callback = array(new $class($this), 'process');
            } elseif (function_exists($class)) {
                $callback = $class;
            } else {
                throw new Dwoo_Exception('Wrong filter name : '.$callback.', when using autoload the filter must be in one of your plugin dir as "name.php" containg a class or function named "Dwoo_Filter_name"');
            }

            $this->filters[] = $callback;
        } else {
            $this->filters[] = $callback;
        }
    }

    /**
     * removes a filter
     *
     * @param mixed $callback callback or filter name if it was autoloaded
     */
    public function removeFilter($callback)
    {
        if (($index = array_search('Dwoo_Filter_'.$callback, $this->filters, true)) !== false) {
            unset($this->filters[$index]);
        } elseif (($index = array_search($callback, $this->filters, true)) !== false) {
            unset($this->filters[$index]);
        } else  {
            $class = 'Dwoo_Filter_' . $callback;
            foreach ($this->filters as $index=>$filter) {
                if (is_array($filter) && $filter[0] instanceof $class) {
                    unset($this->filters[$index]);
                    break;
                }
            }
        }
    }

    /**
     * adds a resource or overrides a default one
     *
     * @param string $name the resource name
     * @param string $class the resource class (which must implement Dwoo_ITemplate)
     * @param callback $compilerFactory the compiler factory callback, a function that must return a compiler instance used to compile this resource, if none is provided. by default it will produce a Dwoo_Compiler object
     */
    public function addResource($name, $class, $compilerFactory = null)
    {
        if (strlen($name) < 2) {
            throw new Dwoo_Exception('Resource names must be at least two-character long to avoid conflicts with Windows paths');
        }

        if (!class_exists($class)) {
            throw new Dwoo_Exception('Resource class does not exist');
        }

        $interfaces = class_implements($class);
        if (in_array('Dwoo_ITemplate', $interfaces) === false) {
            throw new Dwoo_Exception('Resource class must implement Dwoo_ITemplate');
        }

        $this->resources[$name] = array('class'=>$class, 'compiler'=>$compilerFactory);
    }

    /**
     * removes a custom resource
     *
     * @param string $name the resource name
     */
    public function removeResource($name)
    {
        unset($this->resources[$name]);
        if ($name==='file') {
            $this->resources['file'] = array('class'=>'Dwoo_Template_File', 'compiler'=>null);
        }
    }

    /*
     * --------- getters and setters ---------
     */

    /**
     * sets the loader object to use to load plugins
     *
     * @param Dwoo_ILoader $loader loader object
     */
    public function setLoader(Dwoo_ILoader $loader)
    {
        $this->loader = $loader;
    }

    /**
     * returns the current loader object or a default one if none is currently found
     *
     * @param Dwoo_ILoader
     */
    public function getLoader()
    {
        if ($this->loader === null) {
            $this->loader = new Dwoo_Loader($this->getCompileDir());
        }

        return $this->loader;
    }

    /**
     * returns the custom plugins loaded
     *
     * used by the Dwoo_ITemplate classes to pass the custom plugins to their Dwoo_ICompiler instance
     *
     * @return array
     */
    public function getCustomPlugins()
    {
        return $this->plugins;
    }

    /**
     * returns the cache directory with a trailing DIRECTORY_SEPARATOR
     *
     * @return string
     */
    public function getCacheDir()
    {
        if ($this->cacheDir === null) {
            $this->setCacheDir(DWOO_DIRECTORY.'cache'.DIRECTORY_SEPARATOR);
        }

        return $this->cacheDir;
    }

    /**
     * sets the cache directory and automatically appends a DIRECTORY_SEPARATOR
     *
     * @param string $dir the cache directory
     */
    public function setCacheDir($dir)
    {
        $this->cacheDir = rtrim($dir, '/\\').DIRECTORY_SEPARATOR;
        if (is_writable($this->cacheDir) === false) {
            throw new Dwoo_Exception('The cache directory must be writable, chmod "'.$this->cacheDir.'" to make it writable');
        }
    }

    /**
     * returns the compile directory with a trailing DIRECTORY_SEPARATOR
     *
     * @return string
     */
    public function getCompileDir()
    {
        if ($this->compileDir === null) {
            $this->setCompileDir(DWOO_DIRECTORY.'compiled'.DIRECTORY_SEPARATOR);
        }

        return $this->compileDir;
    }

    /**
     * sets the compile directory and automatically appends a DIRECTORY_SEPARATOR
     *
     * @param string $dir the compile directory
     */
    public function setCompileDir($dir)
    {
        $this->compileDir = rtrim($dir, '/\\').DIRECTORY_SEPARATOR;
        if (is_writable($this->compileDir) === false) {
            throw new Dwoo_Exception('The compile directory must be writable, chmod "'.$this->compileDir.'" to make it writable');
        }
    }

    /**
     * returns the default cache time that is used with templates that do not have a cache time set
     *
     * @return int the duration in seconds
     */
    public function getCacheTime()
    {
        return $this->cacheTime;
    }

    /**
     * sets the default cache time to use with templates that do not have a cache time set
     *
     * @param int $seconds the duration in seconds
     */
    public function setCacheTime($seconds)
    {
        $this->cacheTime = (int) $seconds;
    }

    /**
     * returns the character set used by the string manipulation plugins
     *
     * the charset is automatically lowercased
     *
     * @return string
     */
    public function getCharset()
    {
        return $this->charset;
    }

    /**
     * sets the character set used by the string manipulation plugins
     *
     * the charset will be automatically lowercased
     *
     * @param string $charset the character set
     */
    public function setCharset($charset)
    {
        $this->charset = strtolower((string) $charset);
    }

    /**
     * returns the current template being rendered, when applicable, or null
     *
     * @return Dwoo_ITemplate|null
     */
    public function getTemplate()
    {
        return $this->template;
    }

    /**
     * sets the current template being rendered
     *
     * @param Dwoo_ITemplate $tpl template object
     */
    public function setTemplate(Dwoo_ITemplate $tpl)
    {
        $this->template = $tpl;
    }

    /**
     * sets the default compiler factory function for the given resource name
     *
     * a compiler factory must return a Dwoo_ICompiler object pre-configured to fit your needs
     *
     * @param string $resourceName the resource name (i.e. file, string)
     * @param callback $compilerFactory the compiler factory callback
     */
    public function setDefaultCompilerFactory($resourceName, $compilerFactory)
    {
        $this->resources[$resourceName]['compiler'] = $compilerFactory;
    }

    /**
     * returns the default compiler factory function for the given resource name
     *
     * @param string $resourceName the resource name
     * @return callback the compiler factory callback
     */
    public function getDefaultCompilerFactory($resourceName)
    {
        return $this->resources[$resourceName]['compiler'];
    }

    /**
     * sets the security policy object to enforce some php security settings
     *
     * use this if untrusted persons can modify templates
     *
     * @param Dwoo_Security_Policy $policy the security policy object
     */
    public function setSecurityPolicy(Dwoo_Security_Policy $policy = null)
    {
        $this->securityPolicy = $policy;
    }

    /**
     * returns the current security policy object or null by default
     *
     * @return Dwoo_Security_Policy|null the security policy object if any
     */
    public function getSecurityPolicy()
    {
        return $this->securityPolicy;
    }

    /**
     * sets the object that must be used as a plugin proxy when plugin can't be found
     * by dwoo's loader
     *
     * @param Dwoo_IPluginProxy $pluginProxy the proxy object
     */
    public function setPluginProxy(Dwoo_IPluginProxy $pluginProxy) {
        $this->pluginProxy = $pluginProxy;
    }

    /**
     * returns the current plugin proxy object or null by default
     *
     * @param Dwoo_IPluginProxy|null the proxy object if any
     */
    public function getPluginProxy() {
        return $this->pluginProxy;
    }

    /*
     * --------- util functions ---------
     */

    /**
     * [util function] checks whether the given template is cached or not
     *
     * @param Dwoo_ITemplate $tpl the template object
     * @return bool
     */
    public function isCached(Dwoo_ITemplate $tpl)
    {
        return is_string($tpl->getCachedTemplate($this));
    }

    /**
     * [util function] clears the cached templates if they are older than the given time
     *
     * @param int $olderThan minimum time (in seconds) required for a cached template to be cleared
     * @return int the amount of templates cleared
     */
    public function clearCache($olderThan=-1)
    {
        $cacheDirs = new RecursiveDirectoryIterator($this->getCacheDir());
        $cache = new RecursiveIteratorIterator($cacheDirs);
        $expired = time() - $olderThan;
        $count = 0;
        foreach ($cache as $file) {
            if ($cache->isDot() || $cache->isDir() || substr($file, -5) !== '.html') {
                continue;
            }
            if ($cache->getCTime() < $expired) {
                $count += unlink((string) $file) ? 1 : 0;
            }
        }
        return $count;
    }

    /**
     * [util function] fetches a template object of the given resource
     *
     * @param string $resourceName the resource name (i.e. file, string)
     * @param string $resourceId the resource identifier (i.e. file path)
     * @param int $cacheTime the cache time setting for this resource
     * @param string $cacheId the unique cache identifier
     * @param string $compileId the unique compiler identifier
     * @return Dwoo_ITemplate
     */
    public function templateFactory($resourceName, $resourceId, $cacheTime = null, $cacheId = null, $compileId = null, Dwoo_ITemplate $parentTemplate = null)
    {
        if (isset($this->resources[$resourceName])) {
            // TODO could be changed to $this->resources[$resourceName]['class']::templateFactory(..) in 5.3 maybe
            return call_user_func(array($this->resources[$resourceName]['class'], 'templateFactory'), $this, $resourceId, $cacheTime, $cacheId, $compileId, $parentTemplate);
        } else {
            throw new Dwoo_Exception('Unknown resource type : '.$resourceName);
        }
    }

    /**
     * [util function] checks if the input is an array or arrayaccess object, optionally it can also check if it's empty
     *
     * @param mixed $value the variable to check
     * @param bool $checkIsEmpty if true, the function will also check if the array|arrayaccess is empty,
     *                              and return true only if it's not empty
     * @return int|bool true if it's an array|arrayaccess (or the item count if $checkIsEmpty is true) or false if it's not an array|arrayaccess (or 0 if $checkIsEmpty is true)
     */
    public function isArray($value, $checkIsEmpty=false)
    {
        if (is_array($value) === true || $value instanceof ArrayAccess) {
            if ($checkIsEmpty === false) {
                return true;
            } else {
                return $this->count($value);
            }
        }
    }

    /**
     * [util function] checks if the input is an array or a traversable object, optionally it can also check if it's empty
     *
     * @param mixed $value the variable to check
     * @param bool $checkIsEmpty if true, the function will also check if the array|traversable is empty,
     *                              and return true only if it's not empty
     * @return int|bool true if it's an array|traversable (or the item count if $checkIsEmpty is true) or false if it's not an array|traversable (or 0 if $checkIsEmpty is true)
     */
    public function isTraversable($value, $checkIsEmpty=false)
    {
        if (is_array($value) === true) {
            if ($checkIsEmpty === false) {
                return true;
            } else {
                return count($value) > 0;
            }
        } elseif ($value instanceof Traversable) {
            if ($checkIsEmpty === false) {
                return true;
            } else {
                return $this->count($value);
            }
        }
        return false;
    }

    /**
     * [util function] counts an array or arrayaccess/traversable object
     * @param mixed $value
     * @return int|bool the count for arrays and objects that implement countable, true for other objects that don't, and 0 for empty elements
     */
    public function count($value)
    {
        if (is_array($value) === true || $value instanceof Countable) {
            return count($value);
        } elseif ($value instanceof ArrayAccess) {
            if ($value->offsetExists(0)) {
                return true;
            }
        } elseif ($value instanceof Iterator) {
            $value->rewind();
            if ($value->valid()) {
                return true;
            }
        } elseif ($value instanceof Traversable) {
            foreach ($value as $dummy) {
                return true;
            }
        }
        return 0;
    }

    /**
     * [util function] triggers a dwoo error
     *
     * @param string $message the error message
     * @param int $level the error level, one of the PHP's E_* constants
     */
    public function triggerError($message, $level=E_USER_NOTICE)
    {
        if (!($tplIdentifier = $this->template->getResourceIdentifier())) {
            $tplIdentifier = $this->template->getResourceName();
        }
        trigger_error('Dwoo error (in '.$tplIdentifier.') : '.$message, $level);
    }

    /*
     * --------- runtime functions ---------
     */

    /**
     * [runtime function] adds a block to the block stack
     *
     * @param string $blockName the block name (without Dwoo_Plugin_ prefix)
     * @param array $args the arguments to be passed to the block's init() function
     * @return Dwoo_Block_Plugin the newly created block
     */
    public function addStack($blockName, array $args=array())
    {
        if (isset($this->plugins[$blockName])) {
            $class = $this->plugins[$blockName]['class'];
        } else {
            $class = 'Dwoo_Plugin_'.$blockName;
        }

        if ($this->curBlock !== null) {
            $this->curBlock->buffer(ob_get_contents());
            ob_clean();
        } else {
            $this->buffer .= ob_get_contents();
            ob_clean();
        }

        $block = new $class($this);

        $cnt = count($args);
        if ($cnt===0) {
            $block->init();
        } elseif ($cnt===1) {
            $block->init($args[0]);
        } elseif ($cnt===2) {
            $block->init($args[0], $args[1]);
        } elseif ($cnt===3) {
            $block->init($args[0], $args[1], $args[2]);
        } elseif ($cnt===4) {
            $block->init($args[0], $args[1], $args[2], $args[3]);
        } else {
            call_user_func_array(array($block,'init'), $args);
        }

        $this->stack[] = $this->curBlock = $block;
        return $block;
    }

    /**
     * [runtime function] removes the plugin at the top of the block stack
     *
     * calls the block buffer() function, followed by a call to end()
     * and finally a call to process()
     */
    public function delStack()
    {
        $args = func_get_args();

        $this->curBlock->buffer(ob_get_contents());
        ob_clean();

        $cnt = count($args);
        if ($cnt===0) {
            $this->curBlock->end();
        } elseif ($cnt===1) {
            $this->curBlock->end($args[0]);
        } elseif ($cnt===2) {
            $this->curBlock->end($args[0], $args[1]);
        } elseif ($cnt===3) {
            $this->curBlock->end($args[0], $args[1], $args[2]);
        } elseif ($cnt===4) {
            $this->curBlock->end($args[0], $args[1], $args[2], $args[3]);
        } else {
            call_user_func_array(array($this->curBlock, 'end'), $args);
        }

        $tmp = array_pop($this->stack);

        if (count($this->stack) > 0) {
            $this->curBlock = end($this->stack);
            $this->curBlock->buffer($tmp->process());
        } else {
            $this->curBlock = null;
            echo $tmp->process();
        }

        unset($tmp);
    }

    /**
     * [runtime function] returns the parent block of the given block
     *
     * @param Dwoo_Block_Plugin $block
     * @return Dwoo_Block_Plugin or false if the given block isn't in the stack
     */
    public function getParentBlock(Dwoo_Block_Plugin $block)
    {
        $index = array_search($block, $this->stack, true);
        if ($index !== false && $index > 0) {
            return $this->stack[$index-1];
        }
        return false;
    }

    /**
     * [runtime function] finds the closest block of the given type, starting at the top of the stack
     *
     * @param string $type the type of plugin you want to find
     * @return Dwoo_Block_Plugin or false if no plugin of such type is in the stack
     */
    public function findBlock($type)
    {
        if (isset($this->plugins[$type])) {
            $type = $this->plugins[$type]['class'];
        } else {
            $type = 'Dwoo_Plugin_'.str_replace('Dwoo_Plugin_', '', $type);
        }

        $keys = array_keys($this->stack);
        while (($key = array_pop($keys)) !== false) {
            if ($this->stack[$key] instanceof $type) {
                return $this->stack[$key];
            }
        }
        return false;
    }

    /**
     * [runtime function] returns a Dwoo_Plugin of the given class
     *
     * this is so a single instance of every class plugin is created at each template run,
     * allowing class plugins to have "per-template-run" static variables
     *
     * @private
     * @param string $class the class name
     * @return mixed an object of the given class
     */
    public function getObjectPlugin($class)
    {
        if (isset($this->runtimePlugins[$class])) {
            return $this->runtimePlugins[$class];
        }
        return $this->runtimePlugins[$class] = new $class($this);
    }

    /**
     * [runtime function] calls the process() method of the given class-plugin name
     *
     * @param string $plugName the class plugin name (without Dwoo_Plugin_ prefix)
     * @param array $params an array of parameters to send to the process() method
     * @return string the process() return value
     */
    public function classCall($plugName, array $params = array())
    {
        $class = 'Dwoo_Plugin_'.$plugName;

        $plugin = $this->getObjectPlugin($class);

        $cnt = count($params);
        if ($cnt===0) {
            return $plugin->process();
        } elseif ($cnt===1) {
            return $plugin->process($params[0]);
        } elseif ($cnt===2) {
            return $plugin->process($params[0], $params[1]);
        } elseif ($cnt===3) {
            return $plugin->process($params[0], $params[1], $params[2]);
        } elseif ($cnt===4) {
            return $plugin->process($params[0], $params[1], $params[2], $params[3]);
        } else {
            return call_user_func_array(array($plugin, 'process'), $params);
        }
    }

    /**
     * [runtime function] calls a php function
     *
     * @param string $callback the function to call
     * @param array $params an array of parameters to send to the function
     * @return mixed the return value of the called function
     */
    public function arrayMap($callback, array $params)
    {
        if ($params[0] === $this) {
            $addThis = true;
            array_shift($params);
        }
        if ((is_array($params[0]) || ($params[0] instanceof Iterator && $params[0] instanceof ArrayAccess))) {
            if (empty($params[0])) {
                return $params[0];
            }

            // array map
            $out = array();
            $cnt = count($params);

            if (isset($addThis)) {
                array_unshift($params, $this);
                $items = $params[1];
                $keys = array_keys($items);

                if (is_string($callback) === false) {
                    while (($i = array_shift($keys)) !== null) {
                        $out[] = call_user_func_array($callback, array(1=>$items[$i]) + $params);
                    }
                } elseif ($cnt===1) {
                    while (($i = array_shift($keys)) !== null) {
                        $out[] = $callback($this, $items[$i]);
                    }
                } elseif ($cnt===2) {
                    while (($i = array_shift($keys)) !== null) {
                        $out[] = $callback($this, $items[$i], $params[2]);
                    }
                } elseif ($cnt===3) {
                    while (($i = array_shift($keys)) !== null) {
                        $out[] = $callback($this, $items[$i], $params[2], $params[3]);
                    }
                } else {
                    while (($i = array_shift($keys)) !== null) {
                        $out[] = call_user_func_array($callback, array(1=>$items[$i]) + $params);
                    }
                }
            } else {
                $items = $params[0];
                $keys = array_keys($items);

                if (is_string($callback) === false) {
                    while (($i = array_shift($keys)) !== null) {
                        $out[] = call_user_func_array($callback, array($items[$i]) + $params);
                    }
                } elseif ($cnt===1) {
                    while (($i = array_shift($keys)) !== null) {
                        $out[] = $callback($items[$i]);
                    }
                } elseif ($cnt===2) {
                    while (($i = array_shift($keys)) !== null) {
                        $out[] = $callback($items[$i], $params[1]);
                    }
                } elseif ($cnt===3) {
                    while (($i = array_shift($keys)) !== null) {
                        $out[] = $callback($items[$i], $params[1], $params[2]);
                    }
                } elseif ($cnt===4) {
                    while (($i = array_shift($keys)) !== null) {
                        $out[] = $callback($items[$i], $params[1], $params[2], $params[3]);
                    }
                } else {
                    while (($i = array_shift($keys)) !== null) {
                        $out[] = call_user_func_array($callback, array($items[$i]) + $params);
                    }
                }
            }
            return $out;
        } else {
            return $params[0];
        }
    }

    /**
     * [runtime function] reads a variable into the given data array
     *
     * @param string $varstr the variable string, using dwoo variable syntax (i.e. "var.subvar[subsubvar]->property")
     * @param mixed $data the data array or object to read from
     * @param bool $safeRead if true, the function will check whether the index exists to prevent any notices from being output
     * @return mixed
     */
    public function readVarInto($varstr, $data, $safeRead = false)
    {
        if ($data === null) {
            return null;
        }

        if (is_array($varstr) === false) {
            preg_match_all('#(\[|->|\.)?((?:[^.[\]-]|-(?!>))+)\]?#i', $varstr, $m);
        } else {
            $m = $varstr;
        }
        unset($varstr);

        while (list($k, $sep) = each($m[1])) {
            if ($sep === '.' || $sep === '[' || $sep === '') {
                // strip enclosing quotes if present
                $m[2][$k] = preg_replace('#^(["\']?)(.*?)\1$#', '$2', $m[2][$k]);

                if ((is_array($data) || $data instanceof ArrayAccess) && ($safeRead === false || isset($data[$m[2][$k]]))) {
                    $data = $data[$m[2][$k]];
                } else {
                    return null;
                }
            } else {
                if (is_object($data) && ($safeRead === false || isset($data->$m[2][$k]))) {
                    $data = $data->$m[2][$k];
                } else {
                    return null;
                }
            }
        }

        return $data;
    }

    /**
     * [runtime function] reads a variable into the parent scope
     *
     * @param int $parentLevels the amount of parent levels to go from the current scope
     * @param string $varstr the variable string, using dwoo variable syntax (i.e. "var.subvar[subsubvar]->property")
     * @return mixed
     */
    public function readParentVar($parentLevels, $varstr = null)
    {
        $tree = $this->scopeTree;
        $cur = $this->data;

        while ($parentLevels--!==0) {
            array_pop($tree);
        }

        while (($i = array_shift($tree)) !== null) {
            if (is_object($cur)) {
                $cur = $cur->$i;
            } else {
                $cur = $cur[$i];
            }
        }

        if ($varstr!==null) {
            return $this->readVarInto($varstr, $cur);
        } else {
            return $cur;
        }
    }

    /**
     * [runtime function] reads a variable into the current scope
     *
     * @param string $varstr the variable string, using dwoo variable syntax (i.e. "var.subvar[subsubvar]->property")
     * @return mixed
     */
    public function readVar($varstr)
    {
        if (is_array($varstr)===true) {
            $m = $varstr;
            unset($varstr);
        } else {
            if (strstr($varstr, '.') === false && strstr($varstr, '[') === false && strstr($varstr, '->') === false) {
                if ($varstr === 'dwoo') {
                    return $this->globals;
                } elseif ($varstr === '__' || $varstr === '_root' ) {
                    return $this->data;
                    $varstr = substr($varstr, 6);
                } elseif ($varstr === '_' || $varstr === '_parent') {
                    $varstr = '.'.$varstr;
                    $tree = $this->scopeTree;
                    $cur = $this->data;
                    array_pop($tree);

                    while (($i = array_shift($tree)) !== null) {
                        if (is_object($cur)) {
                            $cur = $cur->$i;
                        } else {
                            $cur = $cur[$i];
                        }
                    }

                    return $cur;
                }

                $cur = $this->scope;

                if (isset($cur[$varstr])) {
                    return $cur[$varstr];
                } else {
                    return null;
                }
            }

            if (substr($varstr, 0, 1) === '.') {
                $varstr = 'dwoo'.$varstr;
            }

            preg_match_all('#(\[|->|\.)?((?:[^.[\]-]|-(?!>))+)\]?#i', $varstr, $m);
        }

        $i = $m[2][0];
        if ($i === 'dwoo') {
            $cur = $this->globals;
            array_shift($m[2]);
            array_shift($m[1]);
            switch ($m[2][0]) {

            case 'get':
                $cur = $_GET;
                break;
            case 'post':
                $cur = $_POST;
                break;
            case 'session':
                $cur = $_SESSION;
                break;
            case 'cookies':
            case 'cookie':
                $cur = $_COOKIE;
                break;
            case 'server':
                $cur = $_SERVER;
                break;
            case 'env':
                $cur = $_ENV;
                break;
            case 'request':
                $cur = $_REQUEST;
                break;
            case 'const':
                array_shift($m[2]);
                if (defined($m[2][0])) {
                    return constant($m[2][0]);
                } else {
                    return null;
                }

            }
            if ($cur !== $this->globals) {
                array_shift($m[2]);
                array_shift($m[1]);
            }
        } elseif ($i === '__' || $i === '_root') {
            $cur = $this->data;
            array_shift($m[2]);
            array_shift($m[1]);
        } elseif ($i === '_' || $i === '_parent') {
            $tree = $this->scopeTree;
            $cur = $this->data;

            while (true) {
                array_pop($tree);
                array_shift($m[2]);
                array_shift($m[1]);
                if (current($m[2]) === '_' || current($m[2]) === '_parent') {
                    continue;
                }

                while (($i = array_shift($tree)) !== null) {
                    if (is_object($cur)) {
                        $cur = $cur->$i;
                    } else {
                        $cur = $cur[$i];
                    }
                }
                break;
            }
        } else {
            $cur = $this->scope;
        }

        while (list($k, $sep) = each($m[1])) {
            if ($sep === '.' || $sep === '[' || $sep === '') {
                if ((is_array($cur) || $cur instanceof ArrayAccess) && isset($cur[$m[2][$k]])) {
                    $cur = $cur[$m[2][$k]];
                } else {
                    return null;
                }
            } elseif ($sep === '->') {
                if (is_object($cur)) {
                    $cur = $cur->$m[2][$k];
                } else {
                    return null;
                }
            } else {
                return null;
            }
        }

        return $cur;
    }

    /**
     * [runtime function] assign the value to the given variable
     *
     * @param mixed $value the value to assign
     * @param string $scope the variable string, using dwoo variable syntax (i.e. "var.subvar[subsubvar]->property")
     * @return bool true if assigned correctly or false if a problem occured while parsing the var string
     */
    public function assignInScope($value, $scope)
    {
        $tree =& $this->scopeTree;
        $data =& $this->data;

        if (!is_string($scope)) {
            return $this->triggerError('Assignments must be done into strings, ('.gettype($scope).') '.var_export($scope, true).' given', E_USER_ERROR);
        }
        if (strstr($scope, '.') === false && strstr($scope, '->') === false) {
            $this->scope[$scope] = $value;
        } else {
            // TODO handle _root/_parent scopes ?
            preg_match_all('#(\[|->|\.)?([^.[\]-]+)\]?#i', $scope, $m);

            $cur =& $this->scope;
            $last = array(array_pop($m[1]), array_pop($m[2]));

            while (list($k, $sep) = each($m[1])) {
                if ($sep === '.' || $sep === '[' || $sep === '') {
                    if (is_array($cur) === false) {
                        $cur = array();
                    }
                    $cur =& $cur[$m[2][$k]];
                } elseif ($sep === '->') {
                    if (is_object($cur) === false) {
                        $cur = new stdClass;
                    }
                    $cur =& $cur->$m[2][$k];
                } else {
                    return false;
                }
            }

            if ($last[0] === '.' || $last[0] === '[' || $last[0] === '') {
                if (is_array($cur) === false) {
                    $cur = array();
                }
                $cur[$last[1]] = $value;
            } elseif ($last[0] === '->') {
                if (is_object($cur) === false) {
                    $cur = new stdClass;
                }
                $cur->$last[1] = $value;
            } else {
                return false;
            }
        }
    }

    /**
     * [runtime function] sets the scope to the given scope string or array
     *
     * @param mixed $scope a string i.e. "level1.level2" or an array i.e. array("level1", "level2")
     * @param bool $absolute if true, the scope is set from the top level scope and not from the current scope
     * @return array the current scope tree
     */
    public function setScope($scope, $absolute = false)
    {
        $old = $this->scopeTree;

        if (is_string($scope)===true) {
            $scope = explode('.', $scope);
        }

        if ($absolute===true) {
            $this->scope =& $this->data;
            $this->scopeTree = array();
        }

        while (($bit = array_shift($scope)) !== null) {
            if ($bit === '_' || $bit === '_parent') {
                array_pop($this->scopeTree);
                $this->scope =& $this->data;
                $cnt = count($this->scopeTree);
                for ($i=0;$i<$cnt;$i++)
                    $this->scope =& $this->scope[$this->scopeTree[$i]];
            } elseif ($bit === '__' || $bit === '_root') {
                $this->scope =& $this->data;
                $this->scopeTree = array();
            } elseif (isset($this->scope[$bit])) {
                if($this->scope instanceof ArrayAccess) {
                    $tmp = $this->scope[$bit];
                    $this->scope =& $tmp;
                } else {
                    $this->scope =& $this->scope[$bit];
                }
                $this->scopeTree[] = $bit;
            } else {
                unset($this->scope);
                $this->scope = null;
            }
        }

        return $old;
    }

    /**
     * [runtime function] returns the entire data array
     *
     * @return array
     */
    public function getData()
    {
        return $this->data;
    }

    /**
     * [runtime function] sets a return value for the currently running template
     *
     * @param string $name var name
     * @param mixed $value var value
     */
    public function setReturnValue($name, $value)
    {
        $this->returnData[$name] = $value;
    }

    /**
     * [runtime function] retrieves the return values set by the template
     *
     * @return array
     */
    public function getReturnValues()
    {
        return $this->returnData;
    }

    /**
     * [runtime function] returns a reference to the current scope
     *
     * @return &mixed
     */
    public function &getScope()
    {
        return $this->scope;
    }

    /**
     * Redirects all calls to unexisting to plugin proxy.
     *
     * @param string Method name
     * @param array  List of arguments
     * @return mixed
     */
    public function __call($method, $args) {
        $proxy = $this->getPluginProxy();
        if (!$proxy) {
            throw new Dwoo_Exception('Call to undefined method '.__CLASS__.'::'.$method.'()');
        }
        return call_user_func_array($proxy->getCallback($method), $args);
    }
}


text:
<?php

/**
 * Handles switching to alternate nicks in cases where the primary nick is
 * not available for use.
 *
 * @category Phergie
 * @package  Phergie_Plugin_AltNick
 * @author   Phergie Development Team <team@phergie.org>
 * @license  http://phergie.org/license New BSD License
 * @link     http://pear.phergie.org/package/Phergie_Plugin_AltNick
 * @uses     extension spl
 */
class Phergie_Plugin_AltNick extends Phergie_Plugin_Abstract
{
    /**
     * Iterator for the alternate nick list
     *
     * @var ArrayIterator
     */
    protected $iterator;

    /**
     * Initializes instance variables.
     *
     * @return void
     */
    public function onConnect()
    {
        if ($this->config['altnick.nicks']) {
            if (is_string($this->config['altnick.nicks'])) {
                $this->config['altnick.nicks']
                    = array($this->config['altnick.nicks']);
            }
            $this->iterator = new ArrayIterator($this->config['altnick.nicks']);
        }
    }

    /**
     * Switches to alternate nicks as needed when nick collisions occur.
     *
     * @return void
     */
    public function onResponse()
    {
        // If no alternate nick list was found, return
        if (empty($this->iterator)) {
            return;
        }

        // If the response event indicates that the nick set is in use...
        $code = $this->getEvent()->getCode();
        if ($code == Phergie_Event_Response::ERR_NICKNAMEINUSE) {

            // Attempt to move to the next nick in the alternate nick list
            $this->iterator->next();

            // If another nick is available...
            if ($this->iterator->valid()) {

                // Switch to the new nick
                $altNick = $this->iterator->current();
                $this->doNick($altNick);

                // Update the connection to reflect the nick change
                $this->getConnection()->setNick($altNick);

            } else {
                // If no other nicks are available...

                // Terminate the connection
                $this->doQuit('All specified alternate nicks are in use');
            }
        }
    }
}


text:
puts __FILE__ if defined?(DEBUG)

require_relative('../base/environment')

NUGET_FILES = FileList.new('**/*.nuspec')

desc 'performs package commands'
task :package do Tasks.execute_task :package; end

class Package < Array
  def update
    update_nuget if Environment.windows?
  end

  def update_nuget
    puts 'Package scanning for nuget files' if Environment.default.debug?
    NUGET_FILES.each do |nuget_file|
      next if nuget_file.include?('/obj/')

      package_commands = Nuget.get_build_commands nuget_file
      next if package_commands.nil?

      package_commands.each do |c|
        add_passive(c)
      end
    end
  end
end


text:
// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: google/cloud/osconfig/v1/os_policy_assignments.proto

package com.google.cloud.osconfig.v1;

public interface OSPolicyAssignmentOperationMetadataOrBuilder
    extends
    // @@protoc_insertion_point(interface_extends:google.cloud.osconfig.v1.OSPolicyAssignmentOperationMetadata)
    com.google.protobuf.MessageOrBuilder {

  /**
   *
   *
   *

   * Reference to the `OSPolicyAssignment` API resource.
   * Format:
   * `projects/{project_number}/locations/{location}/osPolicyAssignments/{os_policy_assignment_id@revision_id}`
   *

   *
   * string os_policy_assignment = 1 [(.google.api.resource_reference) = { ... }
   *
   * @return The osPolicyAssignment.
   */
  java.lang.String getOsPolicyAssignment();
  /**
   *
   *
   *

   * Reference to the `OSPolicyAssignment` API resource.
   * Format:
   * `projects/{project_number}/locations/{location}/osPolicyAssignments/{os_policy_assignment_id@revision_id}`
   *

   *
   * string os_policy_assignment = 1 [(.google.api.resource_reference) = { ... }
   *
   * @return The bytes for osPolicyAssignment.
   */
  com.google.protobuf.ByteString getOsPolicyAssignmentBytes();

  /**
   *
   *
   *

   * The OS policy assignment API method.
   *

   *
   * .google.cloud.osconfig.v1.OSPolicyAssignmentOperationMetadata.APIMethod api_method = 2;
   *
   *
   * @return The enum numeric value on the wire for apiMethod.
   */
  int getApiMethodValue();
  /**
   *
   *
   *

   * The OS policy assignment API method.
   *

   *
   * .google.cloud.osconfig.v1.OSPolicyAssignmentOperationMetadata.APIMethod api_method = 2;
   *
   *
   * @return The apiMethod.
   */
  com.google.cloud.osconfig.v1.OSPolicyAssignmentOperationMetadata.APIMethod getApiMethod();

  /**
   *
   *
   *

   * State of the rollout
   *

   *
   *
   * .google.cloud.osconfig.v1.OSPolicyAssignmentOperationMetadata.RolloutState rollout_state = 3;
   *
   *
   * @return The enum numeric value on the wire for rolloutState.
   */
  int getRolloutStateValue();
  /**
   *
   *
   *

   * State of the rollout
   *

   *
   *
   * .google.cloud.osconfig.v1.OSPolicyAssignmentOperationMetadata.RolloutState rollout_state = 3;
   *
   *
   * @return The rolloutState.
   */
  com.google.cloud.osconfig.v1.OSPolicyAssignmentOperationMetadata.RolloutState getRolloutState();

  /**
   *
   *
   *

   * Rollout start time
   *

   *
   * .google.protobuf.Timestamp rollout_start_time = 4;
   *
   * @return Whether the rolloutStartTime field is set.
   */
  boolean hasRolloutStartTime();
  /**
   *
   *
   *

   * Rollout start time
   *

   *
   * .google.protobuf.Timestamp rollout_start_time = 4;
   *
   * @return The rolloutStartTime.
   */
  com.google.protobuf.Timestamp getRolloutStartTime();
  /**
   *
   *
   *

   * Rollout start time
   *

   *
   * .google.protobuf.Timestamp rollout_start_time = 4;
   */
  com.google.protobuf.TimestampOrBuilder getRolloutStartTimeOrBuilder();

  /**
   *
   *
   *

   * Rollout update time
   *

   *
   * .google.protobuf.Timestamp rollout_update_time = 5;
   *
   * @return Whether the rolloutUpdateTime field is set.
   */
  boolean hasRolloutUpdateTime();
  /**
   *
   *
   *

   * Rollout update time
   *

   *
   * .google.protobuf.Timestamp rollout_update_time = 5;
   *
   * @return The rolloutUpdateTime.
   */
  com.google.protobuf.Timestamp getRolloutUpdateTime();
  /**
   *
   *
   *

   * Rollout update time
   *

   *
   * .google.protobuf.Timestamp rollout_update_time = 5;
   */
  com.google.protobuf.TimestampOrBuilder getRolloutUpdateTimeOrBuilder();
}


text: sudo apt-get install --only-upgrade apport=2.0.1-0ubuntu17.15 -y


text:
  #encoding:utf-8

require 'spec_helper'

describe WashOut::Type do

  it "defines custom type" do

    class Abraka1 < WashOut::Type
      map :test => :string
    end

    class Abraka2 < WashOut::Type
      type_name 'test'
      map :foo => Abraka1
    end

    expect(Abraka1.wash_out_param_name).to eq 'abraka1'
    expect(Abraka1.wash_out_param_map).to eq({:test => :string})

    expect(Abraka2.wash_out_param_name).to eq 'test'
    expect(Abraka2.wash_out_param_map).to eq({:foo => Abraka1})
  end

  it "allows arrays inside custom types" do
    class Abraka1 < WashOut::Type
      map :test => :string
    end
    class Abraka2 < WashOut::Type
      type_name 'test'
      map :foo => [:bar => Abraka1]
    end

    expect(Abraka1.wash_out_param_name).to eq 'abraka1'
    expect(Abraka1.wash_out_param_map).to eq({:test => :string})

    expect(Abraka2.wash_out_param_name).to eq 'test'
    expect(Abraka2.wash_out_param_map).to eq({:foo => [:bar => Abraka1]})
  end

end


text:
using System;
using System.Collections;
using System.Collections.Generic;

namespace Flinq
{

public static class FlinqQueryExtensions_BuildString
{
	public static string BuildString<T>(this FlinqQuery<string> query, string delim)
	{
		var finalList = query.Resolve();

		var builder = FlinqStringBuilderPool.Get();
		int count = finalList.count;
		var array = finalList.array;

		for(int i = 0; i < count; ++i)
		{
			builder.Append(array[i]);

			if(i != count - 1)
				builder.Append(delim);
		}

		var str = builder.ToString();

		FlinqStringBuilderPool.Return(builder);

		FlinqListPool<string>.Return(finalList);

		return str;
	}

	public static string BuildString<T>(this FlinqQuery<string> query)
	{
		var finalList = query.Resolve();

		var builder = FlinqStringBuilderPool.Get();
		int count = finalList.count;
		var array = finalList.array;

		for(int i = 0; i < count; ++i)
		{
			builder.Append(array[i]);
		}

		var str = builder.ToString();

		FlinqStringBuilderPool.Return(builder);

		FlinqListPool<string>.Return(finalList);

		return str;
	}

	public static string BuildString<T>(this FlinqQuery<T> query, Func<T, string> selector, string delim)
	{
		if(selector == null)
			throw new ArgumentNullException("selector");

		var finalList = query.Resolve();

		var builder = FlinqStringBuilderPool.Get();
		int count = finalList.count;
		var array = finalList.array;

		for(int i = 0; i < count; ++i)
		{
			builder.Append(selector(array[i]));

			if(i != count - 1)
				builder.Append(delim);
		}

		var str = builder.ToString();

		FlinqStringBuilderPool.Return(builder);

		FlinqListPool<T>.Return(finalList);

		return str;
	}

	public static string BuildString<T>(this FlinqQuery<T> query, Func<T, string> selector)
	{
		if(selector == null)
			throw new ArgumentNullException("selector");

		var finalList = query.Resolve();

		var builder = FlinqStringBuilderPool.Get();
		int count = finalList.count;
		var array = finalList.array;

		for(int i = 0; i < count; ++i)
		{
			builder.Append(selector(array[i]));
		}

		var str = builder.ToString();

		FlinqStringBuilderPool.Return(builder);

		FlinqListPool<T>.Return(finalList);

		return str;
	}
}

}


text:
[vi](http://www.lagmonster.org/docs/vi.html), [vim](https://vim.rtorr.com/), nano, gedit

##Visual studio code ->
Download

Basic intro

Manage extensions

Basic shortcuts (ctrl+p, ctrl+`, ..)

##Eclipse ->
Installation

Oracle Java setup


text:
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.redkalex.benchmark;

import java.util.Random;
import java.util.concurrent.*;
import javax.annotation.Resource;
import org.redkale.net.http.*;
import org.redkale.service.AbstractService;
import org.redkale.source.*;
import org.redkale.util.Utility;
import org.redkalex.benchmark.CachedWorld.WorldEntityCache;

/**
 *
 * @author zhangjx
 */
@RestService(name = " ", repair = false)
public class BenchmarkService extends AbstractService {

    private static final byte[] helloBytes = "Hello, world!".getBytes();

    @Resource
    private DataSource source;

    @RestMapping(name = "plaintext")
    public byte[] getHelloBytes() {
        return helloBytes;
    }

    @RestMapping(name = "json")
    public Message getHelloMessage() {
        return Message.create("Hello, World!");
    }

    @RestMapping(name = "db")
    public CompletableFuture<World> findWorldAsync() {
        return source.findAsync(World.class, randomId(ThreadLocalRandom.current()));
    }

    @RestMapping(name = "queries")
    public CompletableFuture<World[]> queryWorldAsync(int q) {
        final int size = Math.min(500, Math.max(1, q));
        final Random random = ThreadLocalRandom.current();
        final CompletableFuture<World>[] futures = new CompletableFuture[size];
        for (int i = 0; i < size; i++) {
            futures[i] = source.findAsync(World.class, randomId(random));
        }
        return Utility.allOfFutures(futures, c -> new World[c]);
    }

    @RestMapping(name = "updates")
    public CompletableFuture<World[]> updateWorldAsync(int q) {
        final int size = Math.min(500, Math.max(1, q));
        final Random random = ThreadLocalRandom.current();
        final CompletableFuture<World>[] futures = new CompletableFuture[size];
        for (int i = 0; i < size; i++) {
            futures[i] = source.findAsync(World.class, randomId(random));
        }
        return CompletableFuture.allOf(futures).thenCompose(v -> {
            final Random r = ThreadLocalRandom.current();
            final World[] worlds = new World[size];
            for (int i = 0; i < size; i++) {
                worlds[i] = futures[i].join().randomNumber(randomId(r));
            }
            return source.updateAsync(World.sort(worlds)).thenApply(u -> worlds);
        });
    }

    @RestMapping(name = "fortunes")
    public CompletableFuture<HttpScope> queryFortunes() {
        return source.queryListAsync(Fortune.class).thenApply(fortunes -> {
            fortunes.add(new Fortune(0, "Additional fortune added at request time."));
            return HttpScope.refer("").attr("fortunes", Fortune.sort(fortunes));
        });
    }

    private WorldEntityCache cache;

    @RestMapping(name = "cached-worlds")
    public CachedWorld[] cachedWorlds(int q) {
        if (cache == null) {
            synchronized (this) {
                if (cache == null) cache = new WorldEntityCache(source);
            }
        }
        final int size = Math.min(500, Math.max(1, q));
        return cache.random(ThreadLocalRandom.current(), size);
    }

    protected int randomId(Random rand) {
        long s = rand.nextLong();
        return (int) ((s < 0 ? -s : s) % 10000) + 1;
    }

}


text:
require 'yt/collections/base'
require 'yt/models/content_detail'

module Yt
  module Collections
    # @private
    class ContentDetails < Base

    private

      def attributes_for_new_item(data)
        {data: data['contentDetails']}
      end

      # @return [Hash] the parameters to submit to YouTube to get the
      #   content detail of a resource, for instance a video.
      # @see https://developers.google.com/youtube/v3/docs/videos#resource
      def list_params
        endpoint = @parent.kind.pluralize.camelize :lower
        super.tap do |params|
          params[:params] = content_details_params
          params[:path] = "/youtube/v3/#{endpoint}"
        end
      end

      def content_details_params
        {max_results: 50, part: 'contentDetails', id: @parent.id}
      end
    end
  end
end


text:
define(['core', 'jquery', 'commonUtils', 'module', 'engineConfig', 'logger' ],
	/**
	 * The InputManager handles input events.
	 *
	 *

	 * On initialization, the InputManager also creates the {@link mmir.InputEngine},
	 * and returns it as the second argument of the {@link #init}() function's callback
	 * (or the Promise's triggered callbacks).
	 *
	 * In addition, the InputEngine is exported as module "inputEngine" via
	 * RequireJS' define() function.
	 *
	 * @example
	 * //initialization of inputManager
	 * require('inputManager').init().then( function(inputManagerInstance, inputEngineInstance){
	 * 		//do something
	 * });
	 *
	 *
	 * @name mmir.InputManager
	 * @static
	 * @class
	 *
	 *
     *  @requires jQuery.Deferred
     *  @requires jQuery.extend
	 *
	 */
	function(
		mmir, $, commonUtils,module, engineConfig, Logger
){

	//the next comment enables JSDoc2 to map all functions etc. to the correct class description
	/** @scope mmir.InputManager.prototype */

	/**
	 * @memberOf mmir.InputManager#
	 */
	var _instance = {

		/** @scope mmir.InputManager.prototype */

		/**
		 * @deprecated instead: use mmir.InputManager object directly.
		 *
		 * @memberOf mmir.InputManager.prototype
		 */
		getInstance : function() {
			return this;
		},

		/**
		 * This function raises an event.
		 *
		 * @function
		 * @param {String} eventName
		 * 				The name of the event which is to be raised
		 * @param {Object} [eventData] OPTIONAL
		 * 				Data belonging to the event
		 * @throws {Error} if this function is invoked while the internal
		 * 				   event/state engine (i.e. {@link mmir.InputEngine}
		 * 				   is not initialized yet
		 * @public
		 */
		raise : function(eventName, eventData) {
			//NOTE the functional implementation will be set during initialization (see below #init())
			throw new Error('InputEngine not initialized yet: '
					+'call mmir.InputManager.init(callback) and wait for the callback.'
			);
		}

	};

	return $.extend(true, _instance, {

		/**
		 * @function
		 * @name init
		 * @returns {Deferred}
		 *
		 * @memberOf mmir.InputManager.prototype
		 */
		init : function() {
			delete this.init;

			//"read" settings from requirejs' config (see mainConfig.js):
			var url = module.config().scxmlDoc;
			var mode = module.config().mode;

			//create a SCION engine:
			var engine = engineConfig(url, mode);

			this._log = Logger.create(module);
			engine._log = Logger.create(module.id+'Engine', module.config().logLevel);

//			var _self = this;

			return $.Deferred(function(theDeferredObj) {

				engine.load().done(function(_engine) {

					_instance.raise = function raise(){
						_engine.raise.apply(_engine, arguments);
					};

//					mmir.InputEngine = _engine;
					delete _engine.gen;

					//register the InputEngine with requirejs as module "inputEngine":
					define("inputEngine", function(){
						return _engine;
					});
					//immediately load the module-definition:
					require(['inputEngine'], function(){
						//signal end of initialization process:
						theDeferredObj.resolve(_instance, _engine);
					});

				});

			}).promise();
		}
	});

});


text:
<?php

namespace jc\SlideshowBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use jc\SlideshowBundle\Entity\Slideshow;

class SlideshowFOController extends Controller {

    /**
     * @Route("/ajax/slideshow/{id}", name="jc_slideshow_fo", defaults={"id" = 0})
     */
    public function indexAction($id) {

        $slideshow = $this->getDoctrine()->getManager()->getRepository('jcSlideshowBundle:Slideshow')->find($id);
        return $this->render('jcSlideshowBundle:FO:slideshow.html.twig', array('slideshow' => $slideshow));
    }
}


text:
package com.vmware.vim25;

/**
* @author Steve Jin (http://www.doublecloud.org)
* @version 5.1
*/

@SuppressWarnings("all")
public class VMotionLinkCapacityLow extends VMotionInterfaceIssue {
  public String network;

  public String getNetwork() {
    return this.network;
  }

  public void setNetwork(String network) {
    this.network=network;
  }
}


text:
namespace base {
namespace internal {
namespace {

constexpr int kWarmupRuns = 1;
constexpr TimeDelta kTimeLimit = Seconds(1);
constexpr int kTimeCheckInterval = 100000;

constexpr char kMetricPrefixLock[] = "PartitionLock.";
constexpr char kMetricLockUnlockThroughput[] = "lock_unlock_throughput";
constexpr char kMetricLockUnlockLatency[] = "lock_unlock_latency_ns";
constexpr char kStoryBaseline[] = "baseline_story";
constexpr char kStoryWithCompetingThread[] = "with_competing_thread";

perf_test::PerfResultReporter SetUpReporter(const std::string& story_name) {
  perf_test::PerfResultReporter reporter(kMetricPrefixLock, story_name);
  reporter.RegisterImportantMetric(kMetricLockUnlockThroughput, "runs/s");
  reporter.RegisterImportantMetric(kMetricLockUnlockLatency, "ns");
  return reporter;
}

class Spin : public PlatformThread::Delegate {
 public:
  Spin(MaybeLock<true>* lock, uint32_t* data)
      : lock_(lock), data_(data), should_stop_(false) {}
  ~Spin() override = default;

  void ThreadMain() override {
    started_count_++;
    // Local variable to avoid "cache line ping-pong" from influencing the
    // results.
    uint32_t count = 0;
    while (!should_stop_.load(std::memory_order_relaxed)) {
      lock_->Lock();
      count++;
      lock_->Unlock();
    }

    lock_->Lock();
    (*data_) += count;
    lock_->Unlock();
  }

  // Called from another thread to stop the loop.
  void Stop() { should_stop_ = true; }
  int started_count() const { return started_count_; }

 private:
  MaybeLock<true>* lock_;
  uint32_t* data_ GUARDED_BY(lock_);
  std::atomic<bool> should_stop_;
  std::atomic<int> started_count_{0};
};

}  // namespace

TEST(PartitionLockPerfTest, Simple) {
  LapTimer timer(kWarmupRuns, kTimeLimit, kTimeCheckInterval);
  uint32_t data = 0;

  Lock lock;

  do {
    lock.Acquire();
    data += 1;
    lock.Release();
    timer.NextLap();
  } while (!timer.HasTimeLimitExpired());

  ALLOW_UNUSED_LOCAL(data);
  auto reporter = SetUpReporter(kStoryBaseline);
  reporter.AddResult(kMetricLockUnlockThroughput, timer.LapsPerSecond());
  reporter.AddResult(kMetricLockUnlockLatency, 1e9 / timer.LapsPerSecond());
}

TEST(PartitionLockPerfTest, WithCompetingThreads) {
  uint32_t data = 0;

  MaybeLock<true> lock;

  // Starts a competing thread executing the same loop as this thread.
  Spin thread_main(&lock, &data);
  std::vector<PlatformThreadHandle> thread_handles;
  constexpr int kThreads = 4;

  for (int i = 0; i < kThreads; i++) {
    PlatformThreadHandle thread_handle;
    ASSERT_TRUE(PlatformThread::Create(0, &thread_main, &thread_handle));
    thread_handles.push_back(thread_handle);
  }
  // Wait for all the threads to start.
  while (thread_main.started_count() != kThreads) {
  }

  LapTimer timer(kWarmupRuns, kTimeLimit, kTimeCheckInterval);
  do {
    lock.Lock();
    data += 1;
    lock.Unlock();
    timer.NextLap();
  } while (!timer.HasTimeLimitExpired());

  thread_main.Stop();
  for (int i = 0; i < kThreads; i++) {
    PlatformThread::Join(thread_handles[i]);
  }

  auto reporter = SetUpReporter(kStoryWithCompetingThread);
  reporter.AddResult(kMetricLockUnlockThroughput, timer.LapsPerSecond());
  reporter.AddResult(kMetricLockUnlockLatency, 1e9 / timer.LapsPerSecond());
}

}  // namespace internal
}  // namespace base


text:
package mil.nga.geopackage.test.attributes;

import java.sql.SQLException;

import mil.nga.geopackage.test.CreateGeoPackageTestCase;

import org.junit.Test;

/**
 * Test Attributes from a created database
 *
 * @author osbornb
 */
public class AttributesCreateTest extends CreateGeoPackageTestCase {

	/**
	 * Constructor
	 */
	public AttributesCreateTest() {

	}

	/**
	 * Test reading
	 *
	 * @throws SQLException
	 */
	@Test
	public void testRead() throws SQLException {

		AttributesUtils.testRead(geoPackage);

	}

	/**
	 * Test updating
	 *
	 * @throws SQLException
	 */
	@Test
	public void testUpdate() throws SQLException {

		AttributesUtils.testUpdate(geoPackage);

	}

	/**
	 * Test creating
	 *
	 * @throws SQLException
	 */
	@Test
	public void testCreate() throws SQLException {

		AttributesUtils.testCreate(geoPackage);

	}

	/**
	 * Test deleting
	 *
	 * @throws SQLException
	 */
	@Test
	public void testDelete() throws SQLException {

		AttributesUtils.testDelete(geoPackage);

	}

}


text:
type ViewProps = import('react-native').ViewProps;

export type InterstialEventType = 'adLoaded' | 'adFailedToLoad' | 'adOpened' | 'adClosed' | 'adLeftApplication';

export interface BannerProps extends ViewProps {
    /**
     * DFP iOS library banner size constants
     * (https://developers.google.com/admob/ios/banner)
     * banner (320x50, Standard Banner for Phones and Tablets)
     * largeBanner (320x100, Large Banner for Phones and Tablets)
     * mediumRectangle (300x250, IAB Medium Rectangle for Phones and Tablets)
     * fullBanner (468x60, IAB Full-Size Banner for Tablets)
     * leaderboard (728x90, IAB Leaderboard for Tablets)
     * smartBannerPortrait (Screen width x 32|50|90, Smart Banner for Phones and Tablets)
     * smartBannerLandscape (Screen width x 32|50|90, Smart Banner for Phones and Tablets)
     *
     * banner is default
     */
    adSize?:
        | 'banner'
        | 'largeBanner'
        | 'mediumRectangle'
        | 'fullBanner'
        | 'leaderboard'
        | 'smartBannerPortrait'
        | 'smartBannerLandscape';

    /**
     * Optional array specifying all valid sizes that are appropriate for this slot.
     */
    validAdSizes?: string[];

    /**
     * DFP ad unit ID
     */
    adUnitID?: string;

    /**
     * Array of test devices. Use Banner.simulatorId for the simulator
     */
    testDevices?: string[];
    /**
     * The ad manager targeting
     */
    targeting?: Targeting;
    onSizeChange?: (event: { type: string; width: number; height: number }) => void;
    onAppEvent?: (event: { name: string; info: string }) => void;
    onAdLoaded?: (event: AdLoadedEvent) => void;
    onAdFailedToLoad?: (error: any) => void;
    onAdOpened?: () => void;
    onAdLeftApplication?: () => void;
    onAdClosed?: () => void;
}

export interface AdLoadedEvent {
    type: string;
    gadSize: string;
}

export interface AdFailedToLoadEvent {
    error: {
        message: string;
    };
}

export type Targeting = Partial<{
    /**
     * Arbitrary object of custom targeting information.
     */
    customTargeting: object;

    /**
     * Array of exclusion labels.
     */
    categoryExclusions: string[];

    /**
     * Array of keyword strings.
     */
    keywords: string[];

    /**
     * Applications that monetize content matching a webpage's content may pass
     * a content URL for keyword targeting.
     */
    contentURL: string;

    /**
     * You can set a publisher provided identifier (PPID) for use in frequency
     * capping, audience segmentation and targeting, sequential ad rotation, and
     * other audience-based ad delivery controls across devices.
     */
    publisherProvidedID: string;

    /**
     * The user's current location may be used to deliver more relevant ads.
     */
    location: {
        latitude: number;
        longitude: number;
        accuracy: number;
    };
    correlator: string;
}>;

export {};


text:
package org.apache.camel.processor.aggregator;

import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.processor.aggregate.AggregationStrategy;

/**
 * Unit test for using our own aggregation strategy.
 */
public class CustomAggregationStrategyTest extends ContextTestSupport {

    public void testCustomAggregationStrategy() throws Exception {
        // START SNIPPET: e2
        MockEndpoint result = getMockEndpoint("mock:result");

        // we expect to find the two winners with the highest bid
        result.expectedBodiesReceivedInAnyOrder("200", "150");

        // then we sent all the message at once
        template.sendBodyAndHeader("direct:start", "100", "id", "1");
        template.sendBodyAndHeader("direct:start", "150", "id", "2");
        template.sendBodyAndHeader("direct:start", "130", "id", "2");
        template.sendBodyAndHeader("direct:start", "200", "id", "1");
        template.sendBodyAndHeader("direct:start", "190", "id", "1");

        assertMockEndpointsSatisfied();
        // END SNIPPET: e2
    }

    @Override
    protected RouteBuilder createRouteBuilder() throws Exception {
        return new RouteBuilder() {
            public void configure() throws Exception {
                // START SNIPPET: e1
                // our route is aggregating from the direct queue and sending the response to the mock
                from("direct:start")
                    // aggregated by header id and use our own strategy how to aggregate
                    .aggregate(new MyAggregationStrategy()).header("id")
                    // wait for 1 seconds to aggregate
                    .completionTimeout(1000L)
                    .to("mock:result");
                // END SNIPPET: e1
            }
        };
    }

    // START SNIPPET: e3
    private static class MyAggregationStrategy implements AggregationStrategy {

        public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
            if (oldExchange == null) {
                // the first time we only have the new exchange so it wins the first round
                return newExchange;
            }
            int oldPrice = oldExchange.getIn().getBody(Integer.class);
            int newPrice = newExchange.getIn().getBody(Integer.class);
            // return the "winner" that has the highest price
            return newPrice > oldPrice ? newExchange : oldExchange;
        }
    }
    // END SNIPPET: e3
}


text:
class DnB::Direct::Plus::Mappings::IndustryCode < DnB::Direct::Mapping

  kartograph do
    mapping DnB::Direct::Plus::IndustryCode

    scoped :read do
      property :code
      property :decription
      property :typeDescription
      property :typeDnBCode
      property :priority
    end # scoped :read

  end # kartograph

end # class


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

<title>JRXmlTemplateDigesterFactory (JasperReports 5.6.0 API)</title>
<meta name="date" content="2014-05-27">
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">

JavaScript is disabled on your browser.

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

Prev Class

Next Class

Frames

No Frames

All Classes

Summary:

Nested |

Field |

Constr |

Method

Detail:

Field |

Constr |

Method

net.sf.jasperreports.engine.xml

Class JRXmlTemplateDigesterFactory

java.lang.Object

net.sf.jasperreports.engine.xml.JRXmlTemplateDigesterFactory

All Implemented Interfaces:

org.xml.sax.ErrorHandler

public class JRXmlTemplateDigesterFactory
extends java.lang.Object
implements org.xml.sax.ErrorHandler

Factory for template XML digesters.

Version:

$Id: JRXmlTemplateDigesterFactory.java 5878 2013-01-07 20:23:13Z teodord $

Author:

Lucian Chirita (lucianc@users.sourceforge.net)

See Also:

JRTemplate

Field Summary

Fields

Modifier and Type
Field and Description

protected static java.lang.String
PATTERN_BOX

protected static java.lang.String
PATTERN_BOX_BOTTOM_PEN

protected static java.lang.String
PATTERN_BOX_LEFT_PEN

protected static java.lang.String
PATTERN_BOX_PEN

protected static java.lang.String
PATTERN_BOX_RIGHT_PEN

protected static java.lang.String
PATTERN_BOX_TOP_PEN

protected static java.lang.String
PATTERN_INCLUDED_TEMPLATE

protected static java.lang.String
PATTERN_PARAGRAPH

protected static java.lang.String
PATTERN_ROOT

protected static java.lang.String
PATTERN_STYLE

protected static java.lang.String
PATTERN_STYLE_PEN

protected static java.lang.String
PATTERN_TAB_STOP

Constructor Summary

Constructors

Modifier
Constructor and Description

protected
JRXmlTemplateDigesterFactory()

Method Summary

Methods

Modifier and Type
Method and Description

protected void
configureDigester(org.apache.commons.digester.Digester digester)

Deprecated.

Replaced by configureDigester(JasperReportsContext, Digester).

protected void
configureDigester(JasperReportsContext jasperReportsContext,
                 org.apache.commons.digester.Digester digester)

JRXmlDigester
createDigester()

Deprecated.

Replaced by createDigester(JasperReportsContext).

JRXmlDigester
createDigester(JasperReportsContext jasperReportsContext)

Creates and configures a digester for template XML.

void
error(org.xml.sax.SAXParseException exception)

void
fatalError(org.xml.sax.SAXParseException exception)

static JRXmlTemplateDigesterFactory
instance()

Returns the singleton instance.

protected org.apache.commons.digester.RuleSet
readRuleSet()

void
warning(org.xml.sax.SAXParseException exception)

Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail

PATTERN_ROOT

protected static final java.lang.String PATTERN_ROOT

See Also:

Constant Field Values

PATTERN_INCLUDED_TEMPLATE

protected static final java.lang.String PATTERN_INCLUDED_TEMPLATE

See Also:

Constant Field Values

PATTERN_STYLE

protected static final java.lang.String PATTERN_STYLE

See Also:

Constant Field Values

PATTERN_STYLE_PEN

protected static final java.lang.String PATTERN_STYLE_PEN

See Also:

Constant Field Values

PATTERN_BOX

protected static final java.lang.String PATTERN_BOX

See Also:

Constant Field Values

PATTERN_BOX_PEN

protected static final java.lang.String PATTERN_BOX_PEN

See Also:

Constant Field Values

PATTERN_BOX_TOP_PEN

protected static final java.lang.String PATTERN_BOX_TOP_PEN

See Also:

Constant Field Values

PATTERN_BOX_LEFT_PEN

protected static final java.lang.String PATTERN_BOX_LEFT_PEN

See Also:

Constant Field Values

PATTERN_BOX_BOTTOM_PEN

protected static final java.lang.String PATTERN_BOX_BOTTOM_PEN

See Also:

Constant Field Values

PATTERN_BOX_RIGHT_PEN

protected static final java.lang.String PATTERN_BOX_RIGHT_PEN

See Also:

Constant Field Values

PATTERN_PARAGRAPH

protected static final java.lang.String PATTERN_PARAGRAPH

See Also:

Constant Field Values

PATTERN_TAB_STOP

protected static final java.lang.String PATTERN_TAB_STOP

See Also:

Constant Field Values

Constructor Detail

JRXmlTemplateDigesterFactory

protected JRXmlTemplateDigesterFactory()

Method Detail

instance

public static JRXmlTemplateDigesterFactory instance()

Returns the singleton instance.

Returns:

the singleton instance

readRuleSet

protected org.apache.commons.digester.RuleSet readRuleSet()

createDigester

public JRXmlDigester createDigester(JasperReportsContext jasperReportsContext)

Creates and configures a digester for template XML.

Returns:

a template XML digester

createDigester

public JRXmlDigester createDigester()

Deprecated. Replaced by createDigester(JasperReportsContext).

configureDigester

protected void configureDigester(org.apache.commons.digester.Digester digester)
                          throws org.xml.sax.SAXException,
                                 javax.xml.parsers.ParserConfigurationException

Deprecated. Replaced by configureDigester(JasperReportsContext, Digester).

Throws:

org.xml.sax.SAXException

javax.xml.parsers.ParserConfigurationException

configureDigester

protected void configureDigester(JasperReportsContext jasperReportsContext,
                     org.apache.commons.digester.Digester digester)
                          throws org.xml.sax.SAXException,
                                 javax.xml.parsers.ParserConfigurationException

Throws:

org.xml.sax.SAXException

javax.xml.parsers.ParserConfigurationException

error

public void error(org.xml.sax.SAXParseException exception)
           throws org.xml.sax.SAXException

Specified by:

error in interface org.xml.sax.ErrorHandler

Throws:

org.xml.sax.SAXException

fatalError

public void fatalError(org.xml.sax.SAXParseException exception)
                throws org.xml.sax.SAXException

Specified by:

fatalError in interface org.xml.sax.ErrorHandler

Throws:

org.xml.sax.SAXException

warning

public void warning(org.xml.sax.SAXParseException exception)
             throws org.xml.sax.SAXException

Specified by:

warning in interface org.xml.sax.ErrorHandler

Throws:

org.xml.sax.SAXException

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

Prev Class

Next Class

Frames

No Frames

All Classes

Summary:

Nested |

Field |

Constr |

Method

Detail:

Field |

Constr |

Method

© 2001-2010 Jaspersoft Corporation www.jaspersoft.com