text:
package mainecoon

import scala.annotation.{StaticAnnotation, compileTimeOnly}
import scala.meta._
import Util._

import collection.immutable.Seq

/**
 * auto generates an instance of [[FunctorK]]
 */
@compileTimeOnly("Cannot expand @autoFunctorK")
class autoFunctorK(autoDerivation: Boolean) extends StaticAnnotation {
  inline def apply(defn: Any): Any = meta {
    val autoDerivation: Boolean = this match {
      case q"new $_(${Lit.Boolean(arg)})" => arg
      case q"new $_(autoDerivation = ${Lit.Boolean(arg)})" => arg
      case _  => true
    }
    enrichAlgebra(defn)(a => new CovariantKInstanceGenerator(a, autoDerivation).newDef)
  }
}

abstract class FunctorKInstanceGenerator(ad: AlgDefn) {
  import ad._

  def covariantTransform(resultType: Type, originImpl: Term): (Type, Term) = {
    resultType match {
      case t"${Type.Name(`effectTypeName`)}[$resultTpeArg]" =>
        (t"G[$resultTpeArg]", q"fk($originImpl)")
      case _ => (resultType, originImpl)
    }
  }

  lazy val defWithoutParams: Seq[Stat] =
    fromExistingStats {
      case q"def $methodName[..$mTParams]: $resultType" =>
        val (newResultType, newImpl) = covariantTransform(resultType, q"af.$methodName" )
        q"""def $methodName[..$mTParams]: $newResultType = $newImpl"""
    }
}

class CovariantKInstanceGenerator(algDefn: AlgDefn, autoDerivation: Boolean) extends CovariantKMethodsGenerator(algDefn) {
  import algDefn._
  import cls._
  lazy val instanceDef: Seq[Defn] = {
    Seq(
      companionMapKDef,
      q"""
        implicit def ${Term.Name("functorKFor" + name.value)}[..$extraTParams]: _root_.mainecoon.FunctorK[$typeLambdaVaryingHigherKindedEffect] =
          new _root_.mainecoon.FunctorK[$typeLambdaVaryingHigherKindedEffect] {
            $instanceMapKDef
          }
      """
    )
  }

  lazy val instanceDefFullyRefined: Seq[Defn] = {
    Seq(
      q"""
       object fullyRefined {
         implicit def ${Term.Name("functorKForFullyRefined" + name.value)}[..${fullyRefinedTParams}]: _root_.mainecoon.FunctorK[$typeLambdaVaryingHigherKindedEffectFullyRefined] =
           new _root_.mainecoon.FunctorK[$typeLambdaVaryingHigherKindedEffectFullyRefined] {
             def mapK[F[_], G[_]]($from: ${fullyRefinedTypeSig("F")})(fk: _root_.cats.~>[F, G]):${fullyRefinedTypeSig("G")} =
                ${newInstance(newTypeMemberFullyRefined)}
         }

         object autoDerive {
           @SuppressWarnings(Array("org.wartremover.warts.ImplicitParameter"))
           implicit def fromFunctorK[${effectType}, G[_], ..${fullyRefinedTParams}](
             implicit fk: _root_.cats.~>[${effectTypeArg}, G],
             FK: _root_.mainecoon.FunctorK[$typeLambdaVaryingHigherKindedEffectFullyRefined],
             af: ${fullyRefinedTypeSig()})
             : ${fullyRefinedTypeSig("G")} = FK.mapK(af)(fk)
           }
       }
      """
    )
  }

  lazy val newDef: TypeDefinition = cls.copy(companion = cls.companion.addStats(instanceDef ++ {
    if(autoDerivation)
      Seq(autoDerivationDef)
    else Nil} ++ instanceDefFullyRefined))
}

class CovariantKMethodsGenerator(algDefn: AlgDefn) extends FunctorKInstanceGenerator(algDefn) {
  import algDefn._
  import cls._

  def autoDerivationDef: Defn =
    q"""
      object autoDerive {
        @SuppressWarnings(Array("org.wartremover.warts.ImplicitParameter"))
        implicit def fromFunctorK[${effectType}, G[_], ..${extraTParams}](
          implicit fk: _root_.cats.~>[${effectTypeArg}, G],
          FK: _root_.mainecoon.FunctorK[$typeLambdaVaryingHigherKindedEffect],
          af: ${newTypeSig("F")})
          : ${newTypeSig("G")} = FK.mapK(af)(fk)
      }"""

  def covariantKMethods(from: Term.Name): Seq[Stat] =
    fromExistingStats {
      case q"def $methodName[..$mTParams](..$params): $resultType" =>
        val (newResultType, newImpl) = covariantTransform(resultType, q"$from.$methodName(..${arguments(params)})" )
        q"""def $methodName[..$mTParams](..$params): $newResultType = $newImpl"""
      case q"def $methodName[..$mTParams](..$params)(..$params2): $resultType" =>
        val (newResultType, newImpl) = covariantTransform(resultType, q"$from.$methodName(..${arguments(params)})(..${arguments(params2)})" )
        q"""def $methodName[..$mTParams](..$params)(..$params2): $newResultType = $newImpl"""
    } ++ defWithoutParams

  val from = Term.Name("af")

  def  newInstance(typeMembers: Seq[Defn.Type]): Term.New =
    q"""new ${Ctor.Ref.Name(name.value)}[..${tArgs("G")}] {
          ..$typeMembers
          ..${covariantKMethods(from)}
     }"""

  lazy val companionMapKDef: Defn = {
      q"""
        def mapK[F[_], G[_], ..$extraTParams]($from: ${newTypeSig("F")})(fk: _root_.cats.~>[F, G]): ${dependentRefinedTypeSig("G", from)} =
          ${newInstance(newTypeMember(from))}
      """
  }

  lazy val instanceMapKDef: Defn = {
      q"""
        def mapK[F[_], G[_]]($from: ${newTypeSig("F")})(fk: _root_.cats.~>[F, G]): ${newTypeSig("G")} =
          ${newInstance(newTypeMember(from))}
      """
  }

}


text:
package jp.yuiki.dev.qiita4jv2;

public class QiitaResponse<E> {
    /**
     * The got entity
     */
    private final E entity;

    /**
     * The qiita rate reset time(Epoch)
     */
    private final long rateResetEpochTime;

    /**
     * The qiita rate limit count
     */
    private final long rateLimitCount;

    /**
     * The qiita rate remaining count
     */
    private final long rateRemainingCount;

    public QiitaResponse(E entity, long rateResetEpochTime, long rateLimitCount, long rateRemainingCount) {
        this.entity = entity;
        this.rateResetEpochTime = rateResetEpochTime;
        this.rateLimitCount = rateLimitCount;
        this.rateRemainingCount = rateRemainingCount;
    }

    public E getEntity() {
        return entity;
    }

    public long getRateResetEpochTime() {
        return rateResetEpochTime;
    }

    public long getRateLimitCount() {
        return rateLimitCount;
    }

    public long getRateRemainingCount() {
        return rateRemainingCount;
    }
}

redpajama_set_name: RedPajamaGithub


text:
require 'net/http'

describe "Net::HTTPGenericRequest#body_exist?" do
  it "returns true when the response is expected to have a body" do
    request = Net::HTTPGenericRequest.new("POST", true, true, "/some/path")
    request.body_exist?.should be_true

    request = Net::HTTPGenericRequest.new("POST", true, false, "/some/path")
    request.body_exist?.should be_false
  end

  # TODO: Doesn't work?!
  #
  # describe "when $VERBOSE is true" do
  #   it "emits a warning" do
  #     old_verbose, $VERBOSE = $VERBOSE, true
  #
  #     begin
  #       request = Net::HTTPGenericRequest.new("POST", true, false, "/some/path")
  #       lambda { request.body_exist? }.should complain("")
  #     ensure
  #       $VERBOSE = old_verbose
  #     end
  #   end
  # end
end


text:
<!--
   This file is part of the X12Parser library that provides tools to
   manipulate X12 messages using Ruby native syntax.

   http://x12parser.rubyforge.org

   Copyright (C) 2009 APP Design, Inc.

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with this library; if not, write to the Free Software
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

   $Id: LFH.xml 78 2009-05-12 22:27:26Z ikk $
-->

<Segment name="LFH" comment="To uniquely identify the variable information required by government regulation covering the transportation of hazardous material shipments">
  <Field name="HazardousMaterialShipmentInformationQualifier" min="3" max="3" validation="T808" comment="Qualifier indicating the type of information being passed so that a receiver may format a description of hazardous commodity movements that meets regulatory requirements"/>
  <Field name="HazardousMaterialShipmentInformation1" min="1" max="25" comment="Specific information required by law for hazardous material shipments"/>
  <Field name="HazardousMaterialShipmentInformation2" required="y" min="1" max="25" comment="Specific information required by law for hazardous material shipments"/>
  <Field name="HazardZoneCode" required="y" min="1" max="1" validation="T1023" comment="Code specifying the Department of Transportation assigned zone designating the Inhalation Toxicity Hazard Zone"/>
  <Field name="UnitOrBasisForMeasurementCode" required="y" min="2" max="2" validation="T355" comment="Code specifying the units in which a value is being expressed, or manner in which a measurement has been taken"/>
  <Field name="Quantity1" type="double" required="y" min="1" max="15" comment="Numeric value of quantity"/>
  <Field name="Quantity2" type="double" required="y" min="1" max="15" comment="Numeric value of quantity"/>
</Segment>


text:
namespace ClojSharp.Core.Tests.Forms
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using ClojSharp.Core.Exceptions;
    using ClojSharp.Core.Forms;
    using ClojSharp.Core.Language;
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    [TestClass]
    public class FirstTests
    {
        [TestMethod]
        public void FirstInSimpleList()
        {
            First first = new First();
            Machine machine = new Machine();

            Assert.AreEqual(1, first.Evaluate(machine.RootContext, new object[] { new List(new Symbol("list"), new List(1, null)) }));
        }

        [TestMethod]
        public void FirstToNil()
        {
            First first = new First();
            Assert.IsNull(first.Evaluate(null, new object[] { null }));
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentException))]
        public void RaiseIfArgumentIsNotAnISeq()
        {
            First first = new First();
            first.Evaluate(null, new object[] { 1 });
        }

        [TestMethod]
        [ExpectedException(typeof(ArityException))]
        public void RaiseIfNullArguments()
        {
            First first = new First();
            first.Evaluate(null, null);
        }

        [TestMethod]
        [ExpectedException(typeof(ArityException))]
        public void RaiseIfNoArgument()
        {
            First first = new First();
            first.Evaluate(null, new object[] { });
        }

        [TestMethod]
        [ExpectedException(typeof(ArityException))]
        public void RaiseIfTwoArguments()
        {
            First first = new First();
            first.Evaluate(null, new object[] { 1, 2 });
        }
    }
}


text:
require("../env");
require("../../d3");

var vows = require("vows"),
    assert = require("assert");

var suite = vows.describe("d3.selection");

suite.addBatch({
  "selection": {
    topic: function() {
      return d3.selection();
    },
    "selects the document": function(selection) {
      assert.equal(selection.length, 1);
      assert.equal(selection[0].length, 1);
      assert.equal(selection[0][0], document);
    },
    "is an instanceof d3.selection": function(selection) {
      assert.isTrue(selection instanceof d3.selection);
    },
    "subselections are also instanceof d3.selection": function(selection) {
      assert.isTrue(selection.select("body") instanceof d3.selection);
      assert.isTrue(selection.selectAll("body") instanceof d3.selection);
    },
    "selection prototype can be extended": function(selection) {
      d3.selection.prototype.foo = function(v) { return this.attr("foo", v); };
      selection.select("body").foo(42);
      assert.equal(document.body.getAttribute("foo"), "42");
      delete d3.selection.prototype.foo;
    }
  }
});

suite.export(module);


text:
/**
 * Created by shmn on 10/11/2015.
 */

(function(blm){

    'use strict';

    blm.trxSchema = kendo.data.Model.define({
        id : 'TRXID',
        fields : {
            TRXID : {editable: false, nullable: true},
            USERID : {editable: false, nullable: true},
            AMOUNT: { editable: true, nullable: true },
            TRXDATE : {editable: true, nullable: true},
            ITEM : {editable: true, nullable: true},
            ACTIVE : {editable: true, nullable: true},
            TRXTYPE : {editable: true, nullable: true}
        }
    });

    blm.trxModel = new kendo.data.DataSource({
        offlineStorage: 'trxModel',
        traditional: true,
        //autoSync: true, //sync changes with restful API automatically

        transport: {

            read: {
                url: blm.apiserver + "/api/v1/trxs",
                dataType: 'json', //not needed jQuery figures it out, shown to be verbose
                type: 'GET', //defined but, this is the default
                beforeSend: function (xhr) {
                    xhr.setRequestHeader('x-access-token', blm.token);
                },
                complete: function(xhr, textStatus) {

                    var obj = JSON.parse(xhr.responseText);
                    //console.log(obj)
                }

            },

            create : function(options) {

                // use jquery ajax

            },

            update: {
              // use jquery ajax

            },
            destroy: {
              // use jquery ajax
            }

        },

        requestStart: function(e) {
            if (e.type != "read") {
                console.log(kendo.format("Request start ({0})", e.type));
            }
        },
        requestEnd: function(e) {
            if (e.type != "read") {
                console.log(kendo.format("Request end ({0})", e.type));
            }
        },
        batch: true,
        schema: {
            model: blm.trxSchema
        },

        error: function (xhr, error) {

            console.log(xhr);

        }
    });

    //blm.trxModel.read();

    /*
    blm.pollTrx = setInterval(function() {

        $.ajax({
                // use an URL from the same domain to adhere to the same origin policy
                url: blm.apiserver
            })
            .done(function() {
                // the ajax request succeeded - we are probably online.
                blm.trxModel.online(true);
            })
            .fail(function() {
                // the ajax request failed - we are probably offline.
                blm.trxModel.online(false);
                blm.trxModel.read();
            });
    }, 5000);
    */

})(blm); //pass in global namespace

// TODO : masukkan fungsi $.ajax dalam kendo transport untuk menyelesaikan masalah JSON Payload
// tidak dibaca (empty) dalam req.body API


text:
package com.defterp.modules.accounting.queryBuilders;

import com.defterp.modules.commonClasses.QueryWrapper;

public class JournalItemQueryBuilder {

    private static final String FIND_CREDIT_SUM_BY_ACCOUNT = "SELECT SUM(j.credit) FROM JournalItem j WHERE j.account.id = :accountId ";
    private static final String FIND_DEBIT_SUM_BY_ACCOUNT = "SELECT SUM(j.debit) FROM JournalItem j WHERE j.account.id = :accountId";

    public static QueryWrapper getFindCreditSumByAccountQuery(Integer accountId) {

        return new QueryWrapper(FIND_CREDIT_SUM_BY_ACCOUNT)
                   .setParameter("accountId", accountId);
    }

    public static QueryWrapper getFindDebitSumByAccountQuery(Integer accountId) {

        return new QueryWrapper(FIND_DEBIT_SUM_BY_ACCOUNT)
                   .setParameter("accountId", accountId);
    }
}


text:
require 'spec_helper'

describe ActionSlacker do
  it 'has a version number' do
    expect(ActionSlacker::VERSION).not_to be nil
  end
end


text:
from collections import namedtuple
import json
import logging
import pprint
import re

(STATUS_OK, STATUS_ERROR) = xrange(2)

CommandsResponse = namedtuple('CommandsResponse', ['status', 'value'])

LOG = logging.getLogger('bgpspeaker.operator.command')

def default_help_formatter(quick_helps):
    """Apply default formatting for help messages

        :param quick_helps: list of tuples containing help info
     """
    ret = ''
    for line in quick_helps:
        cmd_path, param_hlp, cmd_hlp = line
        ret += ' '.join(cmd_path) + ' '
        if param_hlp:
            ret += param_hlp + ' '
        ret += '- ' + cmd_hlp + '\n'
    return ret

class Command(object):
    """Command class is used as a node in tree of commands.

    Each command can do some action or have some sub-commands, just like in IOS
    Command with it's sub-commands form tree.
    Each command can have one or more parameters. Parameters have to be
    distinguishable from sub-commands.
        One can inject dependency into command Cmd(api=my_object).
    This dependency will be injected to every sub-command. And can be used
    to interact with model/data etc.
        Example of path in command tree `show count all`.
    """

    help_msg = ''
    param_help_msg = None
    command = ''
    cli_resp_line_template = '{0}: {1}\n'

    def __init__(self, api=None, parent=None,
                 help_formatter=default_help_formatter,
                 resp_formatter_name='cli'):
        """:param api: object which is saved as self.api
                 and re-injected to every sub-command. You can use it to
                 manipulate your model from inside Commands'
           :param parent: parent command instance.
           :param help_formatter: function used to format
                output of '?'command. Is re-injected to every
                sub-command as well.
           :param resp_formatter_name: used to select function to format
                output of _action. cli_resp_formatter and json_resp_formatter
                are defined by default, but you can define your own formatters.
                If you use custom formatter(not cli nor json) remember to
                implement it for every sub-command.
        """

        self.resp_formatter_name = resp_formatter_name

        if hasattr(self, resp_formatter_name + '_resp_formatter'):
            self.resp_formatter = \
                getattr(self, resp_formatter_name + '_resp_formatter')
        else:
            self.resp_formatter = self.cli_resp_formatter

        self.api = api
        self.parent_cmd = parent
        self.help_formatter = help_formatter
        if not hasattr(self, 'subcommands'):
            self.subcommands = {}

    def __call__(self, params):
        """You run command by calling it.

        :param params: As params you give list of subcommand names
            and params to final subcommand. Kind of like in
            cisco ios cli, ie. show int eth1 / 1, where show is command,
            int subcommand and eth1 / 1 is param for subcommand.
        :return: returns tuple of CommandsResponse and class of
            sub - command on which _action was called. (last sub - command)
            CommandsResposne.status is action status,
            and CommandsResponse.value is formatted response.
        """
        if len(params) == 0:
            return self._action_wrapper([])

        first_param = params[0]

        if first_param == '?':
            return self.question_mark()

        if first_param in self.subcommands:
            return self._instantiate_subcommand(first_param)(params[1:])

        return self._action_wrapper(params)

    @classmethod
    def cli_resp_formatter(cls, resp):
        """Override this method to provide custom formatting of cli response.
        """
        if not resp.value:
            return ''

        if resp.status == STATUS_OK:

            if type(resp.value) in (str, bool, int, float, unicode):
                return str(resp.value)

            ret = ''
            val = resp.value
            if not isinstance(val, list):
                val = [val]
            for line in val:
                for k, v in line.iteritems():
                    if isinstance(v, dict):
                        ret += cls.cli_resp_line_template.format(
                            k, '\n' + pprint.pformat(v)
                        )
                    else:
                        ret += cls.cli_resp_line_template.format(k, v)
            return ret
        else:
            return "Error: {0}".format(resp.value)

    @classmethod
    def json_resp_formatter(cls, resp):
        """Override this method to provide custom formatting of json response.
        """
        return json.dumps(resp.value)

    @classmethod
    def dict_resp_formatter(cls, resp):
        return resp.value

    def _action_wrapper(self, params):
        filter_params = []
        if '|' in params:
            ind = params.index('|')
            new_params = params[:ind]
            filter_params = params[ind:]
            params = new_params

        action_resp = self.action(params)
        if len(filter_params) > 1:
            # we don't pass '|' around so filter_params[1:]
            action_resp = self.filter_resp(action_resp, filter_params[1:])
        action_resp = CommandsResponse(
            action_resp.status,
            self.resp_formatter(action_resp)
        )
        return action_resp, self.__class__

    def action(self, params):
        """Override this method to define what command should do.

        :param params: list of text parameters applied to this command.
        :return: returns CommandsResponse instance.
                 CommandsResposne.status can be STATUS_OK or STATUS_ERROR
                 CommandsResponse.value should be dict or str
        """
        return CommandsResponse(STATUS_ERROR, 'Not implemented')

    def filter_resp(self, action_resp, filter_params):
        """Filter response of action. Used to make printed results more
        specific

        :param action_resp: named tuple (CommandsResponse)
            containing response from action.
        :param filter_params: params used after '|' specific for given filter
        :return: filtered response.
        """
        if action_resp.status == STATUS_OK:
            try:
                return CommandsResponse(
                    STATUS_OK,
                    TextFilter.filter(action_resp.value, filter_params)
                )
            except FilterError as e:
                return CommandsResponse(STATUS_ERROR, str(e))
        else:
            return action_resp

    def question_mark(self):
        """Shows help for this command and it's sub-commands.
        """
        ret = []
        if self.param_help_msg or len(self.subcommands) == 0:
            ret.append(self._quick_help())

        if len(self.subcommands) > 0:
            for k, _ in sorted(self.subcommands.iteritems()):
                command_path, param_help, cmd_help = \
                    self._instantiate_subcommand(k)._quick_help(nested=True)
                if command_path or param_help or cmd_help:
                    ret.append((command_path, param_help, cmd_help))

        return (
            CommandsResponse(STATUS_OK, self.help_formatter(ret)),
            self.__class__
        )

    def _quick_help(self, nested=False):
        """:param nested: True if help is requested directly for this command
                    and False when help is requested for a list of possible
                    completions.
        """
        if nested:
            return self.command_path(), None, self.help_msg
        else:
            return self.command_path(), self.param_help_msg, self.help_msg

    def command_path(self):
        if self.parent_cmd:
            return self.parent_cmd.command_path() + [self.command]
        else:
            return [self.command]

    def _instantiate_subcommand(self, key):
        return self.subcommands[key](
            api=self.api,
            parent=self,
            help_formatter=self.help_formatter,
            resp_formatter_name=self.resp_formatter_name
        )

class TextFilter(object):

    @classmethod
    def filter(cls, action_resp_value, filter_params):
        try:
            action, expected_value = filter_params
        except ValueError:
            raise FilterError('Wrong number of filter parameters')
        if action == 'regexp':

            if isinstance(action_resp_value, list):
                resp = list(action_resp_value)
                iterator = enumerate(action_resp_value)
            else:
                resp = dict(action_resp_value)
                iterator = action_resp_value.iteritems()

            remove = []

            for key, value in iterator:
                if not re.search(expected_value, str(value)):
                    remove.append(key)

            if isinstance(resp, list):
                resp = [resp[key] for key, value in enumerate(resp)
                        if key not in remove]
            else:
                resp = {key: value for key, value in resp.iteritems()
                        if key not in remove}

            return resp
        else:
            raise FilterError('Unknown filter')

class FilterError(Exception):
    pass


text:
package eu.voho.jhttpmock.model;

import eu.voho.jhttpmock.ResponseStubbing;

import javax.servlet.http.Cookie;
import java.time.Duration;
import java.util.concurrent.ThreadLocalRandom;

public class BehaviourDefiningResponseStubbing implements ResponseStubbing {
    private final ResponseConsumer responseConsumerRoot;
    private final ResponseConsumer responseConsumer;

    public BehaviourDefiningResponseStubbing(final ResponseConsumer responseConsumer) {
        this(responseConsumer, responseConsumer);
    }

    public BehaviourDefiningResponseStubbing(final ResponseConsumer responseConsumerRoot, final ResponseConsumer responseConsumer) {
        this.responseConsumerRoot = responseConsumerRoot;
        this.responseConsumer = responseConsumer;
    }

    @Override
    public ResponseStubbing withRandomDelay(final Duration minDelay, final Duration maxDelay) {
        responseConsumer.setDelayGenerator(() -> {
            final long minMs = minDelay.toMillis();
            final long maxMs = maxDelay.toMillis();
            return Duration.ofMillis(nextRandomLong(minMs, maxMs));
        });

        return this;
    }

    @Override
    public ResponseStubbing withPoissonRandomDelay(final Duration lambda) {
        responseConsumer.setDelayGenerator(() -> {
            final long lambdaMs = lambda.toMillis();
            final long delayMs = nextPoissonRandomLong(lambdaMs);
            return Duration.ofMillis(delayMs);
        });

        return this;
    }

    @Override
    public ResponseStubbing orRespondWithProbability(final double probability) {
        final ResponseConsumer alternative = new ResponseConsumer();
        responseConsumerRoot.addAlternative(alternative, probability);
        return new BehaviourDefiningResponseStubbing(responseConsumerRoot, alternative);
    }

    @Override
    public ResponseStubbing withHeader(final String name, final Iterable<String> values) {
        responseConsumer.addHeader(name, values);
        return this;
    }

    @Override
    public ResponseStubbing withCookie(final Cookie cookie) {
        responseConsumer.addCookie(cookie);
        return this;
    }

    @Override
    public ResponseStubbing withCode(final int code) {
        responseConsumer.setCode(code);
        return this;
    }

    @Override
    public ResponseStubbing withBody(final String body) {
        responseConsumer.setBody(body.toCharArray());
        return this;
    }

    private long nextPoissonRandomLong(final double lambda) {
        return Math.round(Math.log(1.0 - ThreadLocalRandom.current().nextDouble()) / (-1 / lambda));
    }

    private long nextRandomLong(final long minMs, final long maxMs) {
        if (minMs == maxMs) {
            return minMs;
        }

        return ThreadLocalRandom.current().nextLong(minMs, maxMs + 1);
    }
}


text:
    Aanmelden

	    <form name="signupform" data-ng-submit="signup()" novalidate="true">
			Gebruikersnaam:
			<input type="text" name="username" id="username"  maxlength="50" />

			E-mailadres:
			<input type="text" name="email" id="email"  maxlength="50" />

			Wachtwoord:
			<input type="password" name="password" id="password" maxlength="50" />

			<input type="submit" name="Submit" value="Submit" />
		</form>


text:
<ion-header>
    <ion-toolbar>
        <ion-buttons slot="start">
            <ion-back-button [text]="'core.back' | translate"></ion-back-button>
        </ion-buttons>
        <ion-title>

                <core-format-text *ngIf="h5pActivity" [text]="h5pActivity.name" contextLevel="module"
                    [contextInstanceId]="h5pActivity.coursemodule" [courseId]="courseId">
                </core-format-text>

        </ion-title>
    </ion-toolbar>
</ion-header>
<ion-content>
    <ion-refresher slot="fixed" [disabled]="!loaded" (ionRefresh)="doRefresh($event.target)">
        <ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content>
    </ion-refresher>
    <core-loading [hideUntil]="loaded">
        <ion-list *ngIf="users.length">

            <ion-item class="addon-mod_h5pactivity-table-header font-bold" [detail]="false">
                <ion-label>
                    <ion-row class="ion-align-items-center">
                        <ion-col class="ion-text-center" size="4">{{ 'core.user' | translate }}</ion-col>
                        <ion-col class="ion-text-center" size="4">{{ 'core.date' | translate }}</ion-col>
                        <ion-col class="ion-text-center" size="2">{{ 'addon.mod_h5pactivity.score' | translate }}</ion-col>
                        <ion-col class="ion-text-center" size="2">{{ 'addon.mod_h5pactivity.attempts' | translate }}</ion-col>
                    </ion-row>
                </ion-label>
            </ion-item>

            <ion-item class="ion-text-wrap addon-mod_h5pactivity-table-row" *ngFor="let user of users" detail="true" button
                [attr.aria-label]="'addon.mod_h5pactivity.review_user_attempts' | translate:{$a: user.attempts.length}"
                (click)="openUser(user)">

                <ion-label>
                    <ion-row class="ion-align-items-center">
                        <ion-col class="ion-text-center" size="4">

                                <core-user-avatar [user]="user.user" [courseId]="courseId"></core-user-avatar>

                            {{ user.user.fullname }}
                        </ion-col>
                        <ion-col class="ion-text-center" size="4">

                                {{ user.attempts[user.attempts.length - 1].timemodified | coreFormatDate:'strftimedatetimeshort' }}

                            -
                        </ion-col>
                        <ion-col class="ion-text-center" size="2">

                                {{ 'core.percentagenumber' | translate: {$a: user.score} }}

                            -
                        </ion-col>
                        <ion-col class="ion-text-center" size="2">
                            {{user.attempts.length}}
                        </ion-col>
                    </ion-row>
                </ion-label>
            </ion-item>
        </ion-list>

        <core-empty-box *ngIf="!users.length && !canLoadMore" icon="fas-chart-bar"
            [message]="'addon.mod_h5pactivity.noparticipants' | translate">
        </core-empty-box>

        <core-infinite-loading [enabled]="loaded && canLoadMore" [error]="fetchMoreUsersFailed" (action)="fetchMoreUsers($event)">
        </core-infinite-loading>
    </core-loading>
</ion-content>


text:
namespace crashpad {

size_t c16lcpy(base::char16* destination,
               const base::char16* source,
               size_t length) {
  size_t source_length = base::c16len(source);
  if (source_length < length) {
    base::c16memcpy(destination, source, source_length + 1);
  } else if (length != 0) {
    base::c16memcpy(destination, source, length - 1);
    destination[length - 1] = '\0';
  }
  return source_length;
}

}  // namespace crashpad


text:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Cell_1 = require("./Cell");
var EventEmitter_1 = require("./EventEmitter");
exports.EventEmitter = EventEmitter_1.EventEmitter;
var ObservableMap_1 = require("./collections/ObservableMap");
exports.ObservableMap = ObservableMap_1.ObservableMap;
var ObservableList_1 = require("./collections/ObservableList");
exports.ObservableList = ObservableList_1.ObservableList;
var Cell_2 = require("./Cell");
exports.Cell = Cell_2.Cell;
var WaitError_1 = require("./WaitError");
exports.WaitError = WaitError_1.WaitError;
const hasOwn = Object.prototype.hasOwnProperty;
const slice = Array.prototype.slice;
const global_ = Function('return this;')();
var configuration_1 = require("./configuration");
exports.configure = configuration_1.configure;
exports.KEY_CELLS = Symbol('cells');
function cellx(value, options) {
    if (!options) {
        options = {};
    }
    let initialValue = value;
    let cx = function (value) {
        let context = this;
        if (!context || context == global_) {
            context = cx;
        }
        if (!hasOwn.call(context, exports.KEY_CELLS)) {
            context[exports.KEY_CELLS] = new Map();
        }
        let cell = context[exports.KEY_CELLS].get(cx);
        if (!cell) {
            if (value === 'dispose' && arguments.length >= 2) {
                return;
            }
            cell = new Cell_1.Cell(initialValue, {
                __proto__: options,
                context
            });
            context[exports.KEY_CELLS].set(cx, cell);
        }
        switch (arguments.length) {
            case 0: {
                return cell.get();
            }
            case 1: {
                cell.set(value);
                return value;
            }
        }
        let method = value;
        switch (method) {
            case 'cell': {
                return cell;
            }
            case 'bind': {
                cx = cx.bind(context);
                cx.constructor = cellx;
                return cx;
            }
        }
        let result = Cell_1.Cell.prototype[method].apply(cell, slice.call(arguments, 1));
        return result === cell ? cx : result;
    };
    cx.constructor = cellx;
    if (options.onChange || options.onError) {
        cx.call(options.context || global_);
    }
    return cx;
}
exports.cellx = cellx;
function defineObservableProperty(obj, name, value) {
    let cellName = name + 'Cell';
    Object.defineProperty(obj, cellName, {
        configurable: true,
        enumerable: false,
        writable: true,
        value: value instanceof Cell_1.Cell ? value : new Cell_1.Cell(value, { context: obj })
    });
    Object.defineProperty(obj, name, {
        configurable: true,
        enumerable: true,
        get() {
            return this[cellName].get();
        },
        set(value) {
            this[cellName].set(value);
        }
    });
    return obj;
}
exports.defineObservableProperty = defineObservableProperty;
function defineObservableProperties(obj, props) {
    Object.keys(props).forEach(name => {
        defineObservableProperty(obj, name, props[name]);
    });
    return obj;
}
exports.defineObservableProperties = defineObservableProperties;
function define(obj, name, value) {
    if (typeof name == 'string') {
        defineObservableProperty(obj, name, value);
    }
    else {
        defineObservableProperties(obj, name);
    }
    return obj;
}
exports.define = define;


text:
package org.hyperledger.indy.sdk.wallet;

import org.hyperledger.indy.sdk.SovrinJava;

/**
 * wallet.rs Results
 */
public final class WalletResults {

	private WalletResults() {

	}

	public static class CreateWalletResult extends SovrinJava.Result {

		CreateWalletResult() { }
	}

	public static class OpenWalletResult extends SovrinJava.Result {

		private Wallet wallet;
		OpenWalletResult(Wallet wallet) { this.wallet = wallet; }
		public Wallet getWallet() { return this.wallet; }
	}

	public static class CloseWalletResult extends SovrinJava.Result {

		CloseWalletResult() { }
	}

	public static class DeleteWalletResult extends SovrinJava.Result {

		DeleteWalletResult() { }
	}

	public static class WalletSetSeqNoForValueResult extends SovrinJava.Result {

		WalletSetSeqNoForValueResult() { }
	}
}


text:
import Immutable                              from 'immutable';
import { createReducer }                      from 'redux-immutablejs';

import { UPDATE_HEADERS }                     from 'actions/headers';

import { SIGN_OUT }                           from 'actions/signOut';

const initialState = Immutable.fromJS({});

export default createReducer(initialState, {
  [UPDATE_HEADERS]: (state, { headers }) => state.mergeDeep(headers),

  [SIGN_OUT]: () => initialState
});


text:
namespace doim
{
ProtobufFile::ProtobufFile(const FsDirectorySPtr& directory, const FsFileSPtr& file)
    : Element(directory, file)
{
    ASSERT(directory != nullptr && directory->isUnique());
    ASSERT(file != nullptr && file->isUnique());
}
}


text:
YUI.add('graphics-svg', function(Y) {

var SHAPE = "svgShape",
	Y_LANG = Y.Lang,
	AttributeLite = Y.AttributeLite,
	SVGGraphic,
    SVGShape,
	SVGCircle,
	SVGRect,
	SVGPath,
	SVGEllipse,
    DOCUMENT = Y.config.doc;

function SVGDrawing(){}

SVGDrawing.prototype = {
    /**
     * Draws a bezier curve.
     *
     * @method curveTo
     * @param {Number} cp1x x-coordinate for the first control point.
     * @param {Number} cp1y y-coordinate for the first control point.
     * @param {Number} cp2x x-coordinate for the second control point.
     * @param {Number} cp2y y-coordinate for the second control point.
     * @param {Number} x x-coordinate for the end point.
     * @param {Number} y y-coordinate for the end point.
     */
    curveTo: function(cp1x, cp1y, cp2x, cp2y, x, y) {
        var pathArrayLen,
            currentArray,
            hiX,
            loX,
            hiY,
            loY;
        if(this._pathType !== "C")
        {
            this._pathType = "C";
            currentArray = ["C"];
            this._pathArray.push(currentArray);
        }
        else
        {
            currentArray = this._pathArray[Math.max(0, this._pathArray.length - 1)];
            if(!currentArray)
            {
                currentArray = [];
                this._pathArray.push(currentArray);
            }
        }
        pathArrayLen = this._pathArray.length - 1;
        this._pathArray[pathArrayLen] = this._pathArray[pathArrayLen].concat([Math.round(cp1x), Math.round(cp1y), Math.round(cp2x) , Math.round(cp2y), x, y]);
        hiX = Math.max(x, Math.max(cp1x, cp2x));
        hiY = Math.max(y, Math.max(cp1y, cp2y));
        loX = Math.min(x, Math.min(cp1x, cp2x));
        loY = Math.min(y, Math.min(cp1y, cp2y));
        this._trackSize(hiX, hiY);
        this._trackSize(loX, loY);
    },

    /**
     * Draws a quadratic bezier curve.
     *
     * @method quadraticCurveTo
     * @param {Number} cpx x-coordinate for the control point.
     * @param {Number} cpy y-coordinate for the control point.
     * @param {Number} x x-coordinate for the end point.
     * @param {Number} y y-coordinate for the end point.
     */
    quadraticCurveTo: function(cpx, cpy, x, y) {
        var pathArrayLen,
            currentArray,
            hiX,
            loX,
            hiY,
            loY;
        if(this._pathType !== "Q")
        {
            this._pathType = "Q";
            currentArray = ["Q"];
            this._pathArray.push(currentArray);
        }
        else
        {
            currentArray = this._pathArray[Math.max(0, this._pathArray.length - 1)];
            if(!currentArray)
            {
                currentArray = [];
                this._pathArray.push(currentArray);
            }
        }
        pathArrayLen = this._pathArray.length - 1;
        this._pathArray[pathArrayLen] = this._pathArray[pathArrayLen].concat([Math.round(cpx), Math.round(cpy), Math.round(x), Math.round(y)]);
        hiX = Math.max(x, cpx);
        hiY = Math.max(y, cpy);
        loX = Math.min(x, cpx);
        loY = Math.min(y, cpy);
        this._trackSize(hiX, hiY);
        this._trackSize(loX, loY);
    },

    /**
     * Draws a rectangle.
     *
     * @method drawRect
     * @param {Number} x x-coordinate
     * @param {Number} y y-coordinate
     * @param {Number} w width
     * @param {Number} h height
     */
    drawRect: function(x, y, w, h) {
        this.moveTo(x, y);
        this.lineTo(x + w, y);
        this.lineTo(x + w, y + h);
        this.lineTo(x, y + h);
        this.lineTo(x, y);
    },

    /**
     * Draws a rectangle with rounded corners.
     *
     * @method drawRect
     * @param {Number} x x-coordinate
     * @param {Number} y y-coordinate
     * @param {Number} w width
     * @param {Number} h height
     * @param {Number} ew width of the ellipse used to draw the rounded corners
     * @param {Number} eh height of the ellipse used to draw the rounded corners
     */
    drawRoundRect: function(x, y, w, h, ew, eh) {
        this.moveTo(x, y + eh);
        this.lineTo(x, y + h - eh);
        this.quadraticCurveTo(x, y + h, x + ew, y + h);
        this.lineTo(x + w - ew, y + h);
        this.quadraticCurveTo(x + w, y + h, x + w, y + h - eh);
        this.lineTo(x + w, y + eh);
        this.quadraticCurveTo(x + w, y, x + w - ew, y);
        this.lineTo(x + ew, y);
        this.quadraticCurveTo(x, y, x, y + eh);
	},

    /**
     * Draws a wedge.
     *
     * @param {Number} x			x-coordinate of the wedge's center point
     * @param {Number} y			y-coordinate of the wedge's center point
     * @param {Number} startAngle	starting angle in degrees
     * @param {Number} arc			sweep of the wedge. Negative values draw clockwise.
     * @param {Number} radius		radius of wedge. If [optional] yRadius is defined, then radius is the x radius.
     * @param {Number} yRadius		[optional] y radius for wedge.
     */
    drawWedge: function(x, y, startAngle, arc, radius, yRadius)
    {
        var segs,
            segAngle,
            theta,
            angle,
            angleMid,
            ax,
            ay,
            bx,
            by,
            cx,
            cy,
            i = 0,
            diameter = radius * 2;
        yRadius = yRadius || radius;
        if(this._pathType != "M")
        {
            this._pathType = "M";
            currentArray = ["M"];
            this._pathArray.push(currentArray);
        }
        else
        {
            currentArray = this._getCurrentArray();
        }
        pathArrayLen = this._pathArray.length - 1;
        this._pathArray[pathArrayLen].push(x);
        this._pathArray[pathArrayLen].push(x);

        // limit sweep to reasonable numbers
        if(Math.abs(arc) > 360)
        {
            arc = 360;
        }

        // First we calculate how many segments are needed
        // for a smooth arc.
        segs = Math.ceil(Math.abs(arc) / 45);

        // Now calculate the sweep of each segment.
        segAngle = arc / segs;

        // The math requires radians rather than degrees. To convert from degrees
        // use the formula (degrees/180)*Math.PI to get radians.
        theta = -(segAngle / 180) * Math.PI;

        // convert angle startAngle to radians
        angle = (startAngle / 180) * Math.PI;
        if(segs > 0)
        {
            // draw a line from the center to the start of the curve
            ax = x + Math.cos(startAngle / 180 * Math.PI) * radius;
            ay = y + Math.sin(startAngle / 180 * Math.PI) * yRadius;
            this._pathType = "L";
            pathArrayLen++;
            this._pathArray[pathArrayLen] = ["L"];
            this._pathArray[pathArrayLen].push(Math.round(ax));
            this._pathArray[pathArrayLen].push(Math.round(ay));
            pathArrayLen++;
            this._pathType = "Q";
            this._pathArray[pathArrayLen] = ["Q"];
            for(; i < segs; ++i)
            {
                angle += theta;
                angleMid = angle - (theta / 2);
                bx = x + Math.cos(angle) * radius;
                by = y + Math.sin(angle) * yRadius;
                cx = x + Math.cos(angleMid) * (radius / Math.cos(theta / 2));
                cy = y + Math.sin(angleMid) * (yRadius / Math.cos(theta / 2));
                this._pathArray[pathArrayLen].push(Math.round(cx));
                this._pathArray[pathArrayLen].push(Math.round(cy));
                this._pathArray[pathArrayLen].push(Math.round(bx));
                this._pathArray[pathArrayLen].push(Math.round(by));
            }
        }
        this._trackSize(diameter, diameter);
        return this;
    },

    /**
     * Draws a line segment using the current line style from the current drawing position to the specified x and y coordinates.
     *
     * @method lineTo
     * @param {Number} point1 x-coordinate for the end point.
     * @param {Number} point2 y-coordinate for the end point.
     */
    lineTo: function(point1, point2, etc) {
        var args = arguments,
            i,
            len,
            pathArrayLen,
            currentArray;
        this._pathArray = this._pathArray || [];
        if (typeof point1 === 'string' || typeof point1 === 'number') {
            args = [[point1, point2]];
        }
        len = args.length;
        this._shapeType = "path";
        if(this._pathType !== "L")
        {
            this._pathType = "L";
            currentArray = ['L'];
            this._pathArray.push(currentArray);
        }
        else
        {
            currentArray = this._getCurrentArray();
        }
        pathArrayLen = this._pathArray.length - 1;
        for (i = 0; i < len; ++i) {
            this._pathArray[pathArrayLen].push(args[i][0]);
            this._pathArray[pathArrayLen].push(args[i][1]);
            this._trackSize.apply(this, args[i]);
        }
    },

    _getCurrentArray: function()
    {
        var currentArray = this._pathArray[Math.max(0, this._pathArray.length - 1)];
        if(!currentArray)
        {
            currentArray = [];
            this._pathArray.push(currentArray);
        }
        return currentArray;
    },

    /**
     * Moves the current drawing position to specified x and y coordinates.
     *
     * @method moveTo
     * @param {Number} x x-coordinate for the end point.
     * @param {Number} y y-coordinate for the end point.
     */
    moveTo: function(x, y) {
        var pathArrayLen,
            currentArray;
        this._pathArray = this._pathArray || [];
        if(this._pathType != "M")
        {
            this._pathType = "M";
            currentArray = ["M"];
            this._pathArray.push(currentArray);
        }
        else
        {
            currentArray = this._getCurrentArray();
        }
        pathArrayLen = this._pathArray.length - 1;
        this._pathArray[pathArrayLen] = this._pathArray[pathArrayLen].concat([x, y]);
        this._trackSize(x, y);
    },

    /**
     * Completes a drawing operation.
     *
     * @method end
     */
    end: function() {
        this._draw();
    },

    /**
     * Updates the size of the graphics object
     *
     * @method _trackSize
     * @param {Number} w width
     * @param {Number} h height
     * @private
     */
    _trackSize: function(w, h) {
        if (w > this._right) {
            this._right = w;
        }
        if(w < this._left)
        {
            this._left = w;
        }
        if (h < this._top)
        {
            this._top = h;
        }
        if (h > this._bottom)
        {
            this._bottom = h;
        }
        this._width = this._right - this._left;
        this._height = this._bottom - this._top;
    }
};
Y.SVGDrawing = SVGDrawing;
/**
 * Base class for creating shapes.
 *
 * @class SVGShape
 */
SVGShape = function(cfg)
{
    SVGShape.superclass.constructor.apply(this, arguments);
};

SVGShape.NAME = "svgShape";

Y.extend(SVGShape, Y.BaseGraphic, {
    /**
     * @private
     */
	init: function()
	{
		this.initializer.apply(this, arguments);
	},

	/**
	 * Initializes the shape
	 *
	 * @private
	 * @method _initialize
	 */
	initializer: function(cfg)
	{
		var host = this;
		host.createNode();
		host._graphic = cfg.graphic;
		host._updateHandler();
	},

	/**
	 * Add a class name to each node.
	 *
	 * @method addClass
	 * @param {String} className the class name to add to the node's class attribute
	 */
	addClass: function(className)
	{
		var node = this.node;
		node.className.baseVal = Y_LANG.trim([node.className.baseVal, className].join(' '));
	},

	/**
	 * Removes a class name from each node.
	 *
	 * @method removeClass
	 * @param {String} className the class name to remove from the node's class attribute
	 */
	removeClass: function(className)
	{
		var node = this.node,
			classString = node.className.baseVal;
		classString = classString.replace(new RegExp(className + ' '), className).replace(new RegExp(className), '');
		node.className.baseVal = classString;
	},

	/**
	 * Gets the current position of the node in page coordinates.
	 *
	 * @method getXY
	 * @return Array The XY position of the shape.
	 */
	getXY: function()
	{
		var graphic = this._graphic,
			parentXY = graphic.getXY(),
			x = this.get("x"),
			y = this.get("y");
		return [parentXY[0] + x, parentXY[1] + y];
	},

	/**
	 * Set the position of the shape in page coordinates, regardless of how the node is positioned.
	 *
	 * @method setXY
	 * @param {Array} Contains X & Y values for new position (coordinates are page-based)
	 */
	setXY: function(xy)
	{
		var graphic = this._graphic,
			parentXY = graphic.getXY();
		this.set("x", xy[0] - parentXY[0]);
		this.set("y", xy[1] - parentXY[1]);
	},

	/**
	 * Determines whether the node is an ancestor of another HTML element in the DOM hierarchy.
	 *
	 * @method contains
	 * @param {SVGShape | HTMLElement} needle The possible node or descendent
	 * @return Boolean Whether or not this shape is the needle or its ancestor.
	 */
	contains: function(needle)
	{
		return needle === Y.one(this.node);
	},

	/**
	 * Compares nodes to determine if they match.
	 * Node instances can be compared to each other and/or HTMLElements.
	 * @method compareTo
	 * @param {HTMLElement | Node} refNode The reference node to compare to the node.
	 * @return {Boolean} True if the nodes match, false if they do not.
	 */
	compareTo: function(refNode) {
		var node = this.node;

		return node === refNode;
	},

	/**
	 * Test if the supplied node matches the supplied selector.
	 *
	 * @method test
	 * @param {String} selector The CSS selector to test against.
	 * @return Boolean Wheter or not the shape matches the selector.
	 */
	test: function(selector)
	{
		return Y.Selector.test(this.node, selector);
	},

	/**
	 * Value function for fill attribute
	 *
	 * @private
	 * @method _getDefaultFill
	 * @return Object
	 */
	_getDefaultFill: function() {
		return {
			type: "solid",
			opacity: 1,
			cx: 0.5,
			cy: 0.5,
			fx: 0.5,
			fy: 0.5,
			r: 0.5
		};
	},

	/**
	 * Value function for stroke attribute
	 *
	 * @private
	 * @method _getDefaultStroke
	 * @return Object
	 */
	_getDefaultStroke: function()
	{
		return {
			weight: 1,
			dashstyle: "none",
			color: "#000",
			opacity: 1.0
		};
	},

	/**
	 * Creates the dom node for the shape.
	 *
	 * @private
	 * @return HTMLElement
	 */
	createNode: function()
	{
		var node = document.createElementNS("http://www.w3.org/2000/svg", "svg:" + this._type),
			id = this.get("id"),
			pointerEvents = this.get("pointerEvents");
		this.node = node;
		this.addClass("yui3-" + SHAPE + " yui3-" + this.name);
		if(id)
		{
			node.setAttribute("id", id);
		}
		if(pointerEvents)
		{
			node.setAttribute("pointer-events", pointerEvents);
		}
	},

	/**
	 * @private
	 */
	isMouseEvent: function(type)
	{
		if(type.indexOf('mouse') > -1 || type.indexOf('click') > -1)
		{
			return true;
		}
		return false;
	},

	/**
	 * @private
	 */
	before: function(type, fn)
	{
		if(this.isMouseEvent(type))
		{
			return Y.before(type, fn, "#" +  this.get("id"));
		}
		return Y.on.apply(this, arguments);
	},

	/**
	 * @private
	 */
	on: function(type, fn)
	{
		if(this.isMouseEvent(type))
		{
			return Y.on(type, fn, "#" +  this.get("id"));
		}
		return Y.on.apply(this, arguments);
	},

	/**
	 * @private
	 */
	after: function(type, fn)
	{
		if(this.isMouseEvent(type))
		{
			return Y.after(type, fn, "#" +  this.get("id"));
		}
		return Y.on.apply(this, arguments);
	},

	/**
	 * Adds a stroke to the shape node.
	 *
	 * @method _strokeChangeHandler
	 * @private
	 */
	_strokeChangeHandler: function(e)
	{
		var node = this.node,
			stroke = this.get("stroke"),
			strokeOpacity,
			dashstyle,
			dash,
			linejoin;
		if(stroke && stroke.weight && stroke.weight > 0)
		{
			linejoin = stroke.linejoin || "round";
			strokeOpacity = parseFloat(stroke.opacity);
			dashstyle = stroke.dashstyle || "none";
			dash = Y_LANG.isArray(dashstyle) ? dashstyle.toString() : dashstyle;
			stroke.color = stroke.color || "#000000";
			stroke.weight = stroke.weight || 1;
			stroke.opacity = Y_LANG.isNumber(strokeOpacity) ? strokeOpacity : 1;
			stroke.linecap = stroke.linecap || "butt";
			node.setAttribute("stroke-dasharray", dash);
			node.setAttribute("stroke", stroke.color);
			node.setAttribute("stroke-linecap", stroke.linecap);
			node.setAttribute("stroke-width",  stroke.weight);
			node.setAttribute("stroke-opacity", stroke.opacity);
			if(linejoin == "round" || linejoin == "bevel")
			{
				node.setAttribute("stroke-linejoin", linejoin);
			}
			else
			{
				linejoin = parseInt(linejoin, 10);
				if(Y_LANG.isNumber(linejoin))
				{
					node.setAttribute("stroke-miterlimit",  Math.max(linejoin, 1));
					node.setAttribute("stroke-linejoin", "miter");
				}
			}
		}
		else
		{
			node.setAttribute("stroke", "none");
		}
	},

	/**
	 * Adds a fill to the shape node.
	 *
	 * @method _fillChangeHandler
	 * @private
	 */
	_fillChangeHandler: function(e)
	{
		var node = this.node,
			fill = this.get("fill"),
			fillOpacity,
			type;
		if(fill)
		{
			type = fill.type;
			if(type == "linear" || type == "radial")
			{
				this._setGradientFill(fill);
				node.setAttribute("fill", "url(#grad" + this.get("id") + ")");
			}
			else if(!fill.color)
			{
				node.setAttribute("fill", "none");
			}
			else
			{
                fillOpacity = parseFloat(fill.opacity);
				fillOpacity = Y_LANG.isNumber(fillOpacity) ? fillOpacity : 1;
				node.setAttribute("fill", fill.color);
				node.setAttribute("fill-opacity", fillOpacity);
			}
		}
		else
		{
			node.setAttribute("fill", "none");
		}
	},

	/**
	 * Returns a linear gradient fill
	 *
	 * @method _getLinearGradient
	 * @param {String} type gradient type
	 * @private
	 */
	_setGradientFill: function(fill) {
		var offset,
			opacity,
			color,
			stopNode,
			isNumber = Y_LANG.isNumber,
			graphic = this._graphic,
			type = fill.type,
			gradientNode = graphic.getGradientNode("grad" + this.get("id"), type),
			stops = fill.stops,
			w = this.get("width"),
			h = this.get("height"),
			rotation = fill.rotation,
			i,
			len,
			def,
			stop,
			x1 = "0%",
			x2 = "100%",
			y1 = "50%",
			y2 = "50%",
			cx = fill.cx,
			cy = fill.cy,
			fx = fill.fx,
			fy = fill.fy,
			r = fill.r;
		if(type == "linear")
		{
			gradientNode.setAttribute("gradientTransform", "rotate(" + rotation + "," + (w/2) + ", " + (h/2) + ")");
			gradientNode.setAttribute("width", w);
			gradientNode.setAttribute("height", h);
			gradientNode.setAttribute("x1", x1);
			gradientNode.setAttribute("y1", y1);
			gradientNode.setAttribute("x2", x2);
			gradientNode.setAttribute("y2", y2);
			gradientNode.setAttribute("gradientUnits", "userSpaceOnUse");
		}
		else
		{
			gradientNode.setAttribute("cx", (cx * 100) + "%");
			gradientNode.setAttribute("cy", (cy * 100) + "%");
			gradientNode.setAttribute("fx", (fx * 100) + "%");
			gradientNode.setAttribute("fy", (fy * 100) + "%");
			gradientNode.setAttribute("r", (r * 100) + "%");
		}

		len = stops.length;
		def = 0;
		for(i = 0; i < len; ++i)
		{
			stop = stops[i];
			opacity = stop.opacity;
			color = stop.color;
			offset = stop.offset || i/(len - 1);
			offset = Math.round(offset * 100) + "%";
			opacity = isNumber(opacity) ? opacity : 1;
			opacity = Math.max(0, Math.min(1, opacity));
			def = (i + 1) / len;
			stopNode = graphic._createGraphicNode("stop");
			stopNode.setAttribute("offset", offset);
			stopNode.setAttribute("stop-color", color);
			stopNode.setAttribute("stop-opacity", opacity);
			gradientNode.appendChild(stopNode);
		}
	},

	/**
	 * @private
	 */
	set: function()
	{
		var host = this;
		AttributeLite.prototype.set.apply(host, arguments);
		if(host.initialized)
		{
			host._updateHandler();
		}
	},

	/**
	 * Applies translate transformation.
	 *
	 * @method translate
	 * @param {Number} x The x-coordinate
	 * @param {Number} y The y-coordinate
	 */
	translate: function(x, y)
	{
		this._translateX = x;
		this._translateY = y;
		this._translate.apply(this, arguments);
	},

	/**
	 * Applies translate transformation.
	 *
	 * @method translate
	 * @param {Number} x The x-coordinate
	 * @param {Number} y The y-coordinate
	 * @protected
	 */
	_translate: function(x, y)
	{
		this._addTransform("translate", arguments);
	},

	/**
	 * Applies a skew to the x-coordinate
	 *
	 * @method skewX
	 * @param {Number} x x-coordinate
	 */
	 skewX: function(x)
	 {
		this._addTransform("skewX", arguments);
	 },

	/**
	 * Applies a skew to the x-coordinate
	 *
	 * @method skewX
	 * @param {Number} x x-coordinate
	 */
	 skewY: function(y)
	 {
		this._addTransform("skewY", arguments);
	 },

	/**
	 * @private
	 */
	 _rotation: 0,

	 /**
	  * Applies a rotation.
	  *
	  * @method rotate
	  * @param
	  */
	 rotate: function(deg)
	 {
		this._rotation = deg;
		this._addTransform("rotate", arguments);
	 },

	/**
	 * Applies a scale transform
	 *
	 * @method scale
	 * @param {Number} val
	 */
	scale: function(val)
	{
		this._addTransform("scale", arguments);
	},

	/**
	 * Applies a matrix transformation
	 *
	 * @method matrix
	 */
	matrix: function(a, b, c, d, e, f)
	{
		this._addTransform("matrix", arguments);
	},

	/**
	 * @private
	 */
	_addTransform: function(type, args)
	{
		if(!this._transformArgs)
		{
			this._transformArgs = {};
		}
		this._transformArgs[type] = Array.prototype.slice.call(args, 0);
		this._updateTransform();
	},

	/**
	 * @private
	 */
	_updateTransform: function()
	{
		var node = this.node,
			key,
			args,
			val,
			transform = node.getAttribute("transform"),
			test,
			transformOrigin;
		if(this._transformArgs)
		{
			if(this._transformArgs.hasOwnProperty("rotate"))
			{
				transformOrigin = this.get("transformOrigin");
				args = this._transformArgs.rotate;
				args[1] = this.get("x") + (this.get("width") * transformOrigin[0]);
				args[2] = this.get("y") + (this.get("height") * transformOrigin[1]);
			}
		}
		for(key in this._transformArgs)
		{
			if(key && this._transformArgs.hasOwnProperty(key))
			{
				val = key + "(" + this._transformArgs[key].toString() + ")";
				if(transform && transform.length > 0)
				{
					test = new RegExp(key + '(.*)');
					if(transform.indexOf(key) > -1)
					{
						transform = transform.replace(test, val);
					}
					else
					{
						transform += " " + val;
					}
				}
				else
				{
					transform = val;
				}
			}
		}
        this._graphic.addToRedrawQueue(this);
		if(transform)
		{
			node.setAttribute("transform", transform);
		}
	},

	/**
	 * Updates the shape.
	 *
	 * @method _draw
	 * @private
	 */
	_draw: function()
	{
		var node = this.node;
		node.setAttribute("width", this.get("width"));
		node.setAttribute("height", this.get("height"));
		node.setAttribute("x", this.get("x"));
		node.setAttribute("y", this.get("y"));
		node.style.left = this.get("x") + "px";
		node.style.top = this.get("y") + "px";
		this._fillChangeHandler();
		this._strokeChangeHandler();
		this._updateTransform();
	},

	/**
	 * Change event listener
	 *
	 * @private
	 * @method _updateHandler
	 */
	_updateHandler: function(e)
	{
		this._draw();
	},

	/**
	 * Storage for translateX
	 *
	 * @private
	 */
	_translateX: 0,

	/**
	 * Storage for translateY
	 *
	 * @private
	 */
	_translateY: 0,

	/**
	 * Returns the bounds for a shape.
	 *
	 * @method getBounds
	 * @return Object
	 */
	getBounds: function()
	{
		var rotation = this.get("rotation"),
			radCon = Math.PI/180,
			sinRadians = parseFloat(parseFloat(Math.sin(rotation * radCon)).toFixed(8)),
			cosRadians = parseFloat(parseFloat(Math.cos(rotation * radCon)).toFixed(8)),
			w = this.get("width"),
			h = this.get("height"),
			stroke = this.get("stroke"),
			x = this.get("x"),
			y = this.get("y"),
            right = x + w,
            bottom = y + h,
            tlx,
            tly,
            blx,
            bly,
            brx,
            bry,
            trx,
            trY,
            wt = 0,
			tx = this.get("translateX"),
			ty = this.get("translateY"),
			bounds = {},
			transformOrigin = this.get("transformOrigin"),
			tox = transformOrigin[0],
			toy = transformOrigin[1];
		if(stroke && stroke.weight)
		{
			wt = stroke.weight;
		}
		if(rotation !== 0)
		{
            tox = x + (tox * w);
            toy = y + (toy * h);
            tlx = this._getRotatedCornerX(x, y, tox, toy, cosRadians, sinRadians);
            tly = this._getRotatedCornerY(x, y, tox, toy, cosRadians, sinRadians);
            blx = this._getRotatedCornerX(x, bottom, tox, toy, cosRadians, sinRadians);
            bly = this._getRotatedCornerY(x, bottom, tox, toy, cosRadians, sinRadians);
            brx = this._getRotatedCornerX(right, bottom, tox, toy, cosRadians, sinRadians);
            bry = this._getRotatedCornerY(right, bottom, tox, toy, cosRadians, sinRadians);
            trx = this._getRotatedCornerX(right, y, tox, toy, cosRadians, sinRadians);
            trY = this._getRotatedCornerY(right, y, tox, toy, cosRadians, sinRadians);
            bounds.left = Math.min(tlx, Math.min(blx, Math.min(brx, trx)));
            bounds.right = Math.max(tlx, Math.max(blx, Math.max(brx, trx)));
            bounds.top = Math.min(tly, Math.min(bly, Math.min(bry, trY)));
            bounds.bottom = Math.max(tly, Math.max(bly, Math.max(bry, trY)));
		}
        else
        {
            bounds.left = x - wt + tx;
            bounds.top = y - wt + ty;
            bounds.right = x + w + wt + tx;
            bounds.bottom = y + h + wt + ty;
        }
		return bounds;
	},

    /**
     * Returns the x coordinate for a bounding box's corner based on the corner's original x/y coordinates, rotation and transform origin of the rotation.
     *
     * @method _getRotatedCornerX
     * @param {Number} x original x-coordinate of corner
     * @param {Number} y original y-coordinate of corner
     * @param {Number} tox transform origin x-coordinate of rotation
     * @param {Number} toy transform origin y-coordinate of rotation
     * @param {Number} cosRadians cosine (in radians) of rotation
     * @param {Number} sinRadians sin (in radians) or rotation
     * @return Number
     * @private
     */
    _getRotatedCornerX: function(x, y, tox, toy, cosRadians, sinRadians)
    {
        return (tox + (x - tox) * cosRadians + (y - toy) * sinRadians);
    },

    /**
     * Returns the y coordinate for a bounding box's corner based on the corner's original x/y coordinates, rotation and transform origin of the rotation.
     *
     * @method _getRotatedCornerY
     * @param {Number} x original x-coordinate of corner
     * @param {Number} y original y-coordinate of corner
     * @param {Number} tox transform origin x-coordinate of rotation
     * @param {Number} toy transform origin y-coordinate of rotation
     * @param {Number} cosRadians cosine (in radians) of rotation
     * @param {Number} sinRadians sin (in radians) or rotation
     * @return Number
     * @private
     */
    _getRotatedCornerY: function(x, y, tox, toy, cosRadians, sinRadians)
    {
        return (toy - (x - tox) * sinRadians + (y - toy) * cosRadians);
    },

    destroy: function()
    {
        if(this._graphic && this._graphic._contentNode)
        {
            this._graphic._contentNode.removeChild(this.node);
        }
    }
 });

SVGShape.ATTRS = {
	/**
	 * An array of x, y values which indicates the transformOrigin in which to rotate the shape. Valid values range between 0 and 1 representing a
	 * fraction of the shape's corresponding bounding box dimension. The default value is [0.5, 0.5].
	 *
	 * @attribute transformOrigin
	 * @type Array
	 */
	transformOrigin: {
		valueFn: function()
		{
			return [0.5, 0.5];
		}
	},

	/**
	 * The rotation (in degrees) of the shape.
	 *
	 * @attribute rotation
	 * @type Number
	 */
	rotation: {
		setter: function(val)
		{
			this.rotate(val);
		},

		getter: function()
		{
			return this._rotation;
		}
	},

	/**
	 * Unique id for class instance.
	 *
	 * @attribute id
	 * @type String
	 */
	id: {
		valueFn: function()
		{
			return Y.guid();
		},

		setter: function(val)
		{
			var node = this.node;
			if(node)
			{
				node.setAttribute("id", val);
			}
			return val;
		}
	},

	/**
	 * Indicates the x position of shape.
	 *
	 * @attribute x
	 * @type Number
	 */
	x: {
		value: 0
	},

	/**
	 * Indicates the y position of shape.
	 *
	 * @attribute y
	 * @type Number
	 */
	y: {
		value: 0
	},

	/**
	 * Indicates the width of the shape
	 *
	 * @attribute width
	 * @type Number
	 */
	width: {
        value: 0
    },

	/**
	 * Indicates the height of the shape
	 *
	 * @attribute height
	 * @type Number
	 */
	height: {
        value: 0
    },

	/**
	 * Indicates whether the shape is visible.
	 *
	 * @attribute visible
	 * @type Boolean
	 */
	visible: {
		value: true,

		setter: function(val){
			var visibility = val ? "visible" : "hidden";
			this.node.style.visibility = visibility;
			return val;
		}
	},

	/**
	 * Contains information about the fill of the shape.
	 *  <dl>
	 *      <dt>color</dt><dd>The color of the fill.</dd>
	 *      <dt>opacity</dt><dd>Number between 0 and 1 that indicates the opacity of the fill. The default value is 1.</dd>
	 *      <dt>type</dt><dd>Type of fill.
	 *          <dl>
	 *              <dt>solid</dt><dd>Solid single color fill. (default)</dd>
	 *              <dt>linear</dt><dd>Linear gradient fill.</dd>
	 *              <dt>radial</dt><dd>Radial gradient fill.</dd>
	 *          </dl>
	 *      </dd>
	 *  </dl>
	 *
	 *  <p>If a gradient (linear or radial) is specified as the fill type. The following properties are used:
	 *  <dl>
	 *      <dt>stops</dt><dd>An array of objects containing the following properties:
	 *          <dl>
	 *              <dt>color</dt><dd>The color of the stop.</dd>
	 *              <dt>opacity</dt><dd>Number between 0 and 1 that indicates the opacity of the stop. The default value is 1. Note: No effect for IE <= 8</dd>
	 *              <dt>offset</dt><dd>Number between 0 and 1 indicating where the color stop is positioned.</dd>
	 *          </dl>
	 *      </dd>
	 *      <dt></dt><dd></dd>
	 *      <dt></dt><dd></dd>
	 *      <dt></dt><dd></dd>
	 *  </dl>
	 *  </p>
	 *
	 * @attribute fill
	 * @type Object
	 */
	fill: {
		valueFn: "_getDefaultFill",

		setter: function(val)
		{
			var fill,
				tmpl = this.get("fill") || this._getDefaultFill();
			fill = (val) ? Y.merge(tmpl, val) : null;
			if(fill && fill.color)
			{
				if(fill.color === undefined || fill.color == "none")
				{
					fill.color = null;
				}
			}
			return fill;
		}
	},

	/**
	 * Contains information about the stroke of the shape.
	 *  <dl>
	 *      <dt>color</dt><dd>The color of the stroke.</dd>
	 *      <dt>weight</dt><dd>Number that indicates the width of the stroke.</dd>
	 *      <dt>opacity</dt><dd>Number between 0 and 1 that indicates the opacity of the stroke. The default value is 1.</dd>
	 *      <dt>dashstyle</dt>Indicates whether to draw a dashed stroke. When set to "none", a solid stroke is drawn. When set to an array, the first index indicates the
	 *      length of the dash. The second index indicates the length of gap.
	 *  </dl>
	 *
	 * @attribute stroke
	 * @type Object
	 */
	stroke: {
		valueFn: "_getDefaultStroke",

		setter: function(val)
		{
			var tmpl = this.get("stroke") || this._getDefaultStroke();
			return (val) ? Y.merge(tmpl, val) : null;
		}
	},

	/**
	 * Indicates whether or not the instance will size itself based on its contents.
	 *
	 * @attribute autoSize
	 * @type Boolean
	 */
	autoSize: {
		value: false
	},

	/**
	 * Determines whether the instance will receive mouse events.
	 *
	 * @attribute pointerEvents
	 * @type string
	 */
	pointerEvents: {
		valueFn: function()
		{
			var val = "visiblePainted",
				node = this.node;
			if(node)
			{
				node.setAttribute("pointer-events", val);
			}
			return val;
		},

		setter: function(val)
		{
			var node = this.node;
			if(node)
			{
				node.setAttribute("pointer-events", val);
			}
			return val;
		}
	},

	/**
	 * Performs a translate on the x-coordinate. When translating x and y coordinates,
	 * use the <code>translate</code> method.
	 *
	 * @attribute translateX
	 * @type Number
	 */
	translateX: {
		getter: function()
		{
			return this._translateX;
		},

		setter: function(val)
		{
			this._translateX = val;
			this._translate(val, this._translateY);
			return val;
		}
	},

	/**
	 * Performs a translate on the y-coordinate. When translating x and y coordinates,
	 * use the <code>translate</code> method.
	 *
	 * @attribute translateX
	 * @type Number
	 */
	translateY: {
		getter: function()
		{
			return this._translateY;
		},

		setter: function(val)
		{
			this._translateY = val;
			this._translate(this._translateX, val);
			return val;
		}
	},

	/**
	 * The node used for gradient fills.
	 *
	 * @attribute gradientNode
	 * @type HTMLElement
	 */
	gradientNode: {
		setter: function(val)
		{
			if(Y_LANG.isString(val))
			{
				val = this._graphic.getGradientNode("linear", val);
			}
			return val;
		}
	},

	/**
	 * Indicates whether to automatically refresh.
	 *
	 * @attribute autoDraw
	 * @type Boolean
	 * @readOnly
	 */
	autoDraw: {
		getter: function()
		{
			return this._graphic.autoDraw;
		}
	},

	/**
	 * Dom node for the shape.
	 *
	 * @attribute node
	 * @type HTMLElement
	 * @readOnly
	 */
	node: {
		readOnly: true,

		getter: function()
		{
			return this.node;
		}
	},

	/**
	 * Reference to the parent graphic instance
	 *
	 * @graphic
	 * @type SVGGraphic
	 * @readOnly
	 */
	graphic: {
		readOnly: true,

		getter: function()
		{
			return this._graphic;
		}
	}
};
Y.SVGShape = SVGShape;

/**
 * The SVGPath class creates a shape through the use of drawing methods.
 *
 * @class SVGPath
 * @extends SVGShape
 */
SVGPath = function(cfg)
{
	SVGPath.superclass.constructor.apply(this, arguments);
};
SVGPath.NAME = "svgPath";
Y.extend(SVGPath, Y.SVGShape, Y.merge(Y.SVGDrawing.prototype, {
    /**
     * Left edge of the path
     *
     * @private
     * @property _left
     */
    _left: 0,

    /**
     * Right edge of the path
     *
     * @private
     * @property _right
     */
    _right: 0,

    /**
     * Top edge of the path
     *
     * @private
     * @property _top
     */
    _top: 0,

    /**
     * Bottom edge of the path
     *
     * @private
     * @property _bottom
     */
    _bottom: 0,

    /**
     * Indicates the type of shape
     *
     * @private
     * @property _type
     * @readOnly
     * @type String
     */
    _type: "path",

    /**
     * Draws the path.
     *
     * @method _draw
     * @private
     */
    _draw: function()
    {
        var pathArray,
            segmentArray,
            pathType,
            len,
            val,
            val2,
            i,
            path = "",
            node = this.node,
            tx = this.get("translateX"),
            ty = this.get("translateY"),
            left = this._left,
            top = this._top,
            fill = this.get("fill");
        if(this._pathArray)
        {
            pathArray = this._pathArray.concat();
            while(pathArray && pathArray.length > 0)
            {
                segmentArray = pathArray.shift();
                len = segmentArray.length;
                pathType = segmentArray[0];
                path += " " + pathType + (segmentArray[1] - left);
                switch(pathType)
                {
                    case "L" :
                    case "M" :
                    case "Q" :
                        for(i = 2; i < len; ++i)
                        {
                            val = (i % 2 === 0) ? top : left;
                            val = segmentArray[i] - val;
                            path += ", " + val;
                        }
                    break;
                    case "C" :
                        for(i = 2; i < len; ++i)
                        {
                            val = (i % 2 === 0) ? top : left;
                            val2 = segmentArray[i];
                            val2 -= val;
                            path += " " + val2;
                        }
                    break;

                }
            }
            if(fill && fill.color)
            {
                path += 'z';
            }
            if(path)
            {
                node.setAttribute("d", path);
            }
            //Use transform to handle positioning.
            this._transformArgs = this._transformArgs || {};
            this._transformArgs.translate = [left + tx, top + ty];

            this._path = path;
            this._fillChangeHandler();
            this._strokeChangeHandler();
            this._updateTransform();
        }
    },

    /**
     * Applies translate transformation.
     *
     * @method translate
     * @param {Number} x The x-coordinate
     * @param {Number} y The y-coordinate
     */
    translate: function(x, y)
    {
        x = parseInt(x, 10);
        y = parseInt(y, 10);
        this._translateX = x;
        this._translateY = y;
        this._translate(this._left + x, this._top + y);
    },

	/**
	 * @private
	 */
	_updateHandler: function()
	{
		//do nothing
	},

    /**
     * Completes a drawing operation.
     *
     * @method end
     */
    end: function()
    {
        this._draw();
        this._graphic.addToRedrawQueue(this);
    },

    /**
     * Clears the path.
     *
     * @method clear
     */
    clear: function()
    {
        this._left = 0;
        this._right = 0;
        this._top = 0;
        this._bottom = 0;
        this._pathArray = [];
        this._path = "";
    },

    /**
     * Returns the bounds for a shape.
     *
     * @method getBounds
     * @return Object
     */
    getBounds: function()
    {
        var wt = 0,
            bounds = {},
            stroke = this.get("stroke"),
            tx = this.get("translateX"),
            ty = this.get("translateY");
        if(stroke && stroke.weight)
        {
            wt = stroke.weight;
        }
        bounds.left = this._left - wt + tx;
        bounds.top = this._top - wt + ty;
        bounds.right = (this._right - this._left) + wt + tx;
        bounds.bottom = (this._bottom - this._top) + wt + ty;
        return bounds;
    },

	_path: ""
}));

SVGPath.ATTRS = Y.merge(Y.SVGShape.ATTRS, {
	/**
	 * Path string of the shape
	 *
	 * @attribute path
	 * @type String
	 */
	path: {
		readOnly: true,

		getter: function()
		{
			return this._path;
		}
	},

	/**
	 * Indicates the height of the shape
	 *
	 * @attribute height
	 * @type Number
	 */
	width: {
		getter: function()
		{
			var val = Math.max(this._right - this._left, 0);
			return val;
		}
	},

	/**
	 * Indicates the height of the shape
	 *
	 * @attribute height
	 * @type Number
	 */
	height: {
		getter: function()
		{
			return Math.max(this._bottom - this._top, 0);
		}
	}
});
Y.SVGPath = SVGPath;
/**
 * Draws rectangles
 */
SVGRect = function()
{
	SVGRect.superclass.constructor.apply(this, arguments);
};
SVGRect.NAME = "svgRect";
Y.extend(SVGRect, Y.SVGShape, {
    /**
     * Indicates the type of shape
     *
     * @property _type
     * @readOnly
     * @type String
     */
    _type: "rect"
 });
SVGRect.ATTRS = Y.SVGShape.ATTRS;
Y.SVGRect = SVGRect;
/**
 * Draws an ellipse
 */
SVGEllipse = function(cfg)
{
	SVGEllipse.superclass.constructor.apply(this, arguments);
};

SVGEllipse.NAME = "svgEllipse";

Y.extend(SVGEllipse, SVGShape, {
	/**
	 * Indicates the type of shape
	 *
	 * @property _type
	 * @readOnly
	 * @type String
	 */
	_type: "ellipse",

	/**
	 * Updates the shape.
	 *
	 * @method _draw
	 * @private
	 */
	_draw: function()
	{
		var node = this.node,
			w = this.get("width"),
			h = this.get("height"),
			x = this.get("x"),
			y = this.get("y"),
			xRadius = w * 0.5,
			yRadius = h * 0.5,
			cx = x + xRadius,
			cy = y + yRadius;
		node.setAttribute("rx", xRadius);
		node.setAttribute("ry", yRadius);
		node.setAttribute("cx", cx);
		node.setAttribute("cy", cy);
		this._fillChangeHandler();
		this._strokeChangeHandler();
		this._updateTransform();
	}
});

SVGEllipse.ATTRS = Y.merge(SVGShape.ATTRS, {
	/**
	 * Horizontal radius for the ellipse.
	 *
	 * @attribute xRadius
	 * @type Number
	 * @readOnly
	 */
	xRadius: {
		setter: function(val)
		{
			this.set("width", val/2);
		},

		getter: function()
		{
			var val = this.get("width");
			if(val)
			{
				val *= 0.5;
			}
			return val;
		}
	},

	/**
	 * Vertical radius for the ellipse.
	 *
	 * @attribute yRadius
	 * @type Number
	 * @readOnly
	 */
	yRadius: {
		setter: function(val)
		{
			this.set("height", val/2);
		},

		getter: function()
		{
			var val = this.get("height");
			if(val)
			{
				val *= 0.5;
			}
			return val;
		}
	}
});
Y.SVGEllipse = SVGEllipse;
/**
 * Draws an circle
 */
 SVGCircle = function(cfg)
 {
    SVGCircle.superclass.constructor.apply(this, arguments);
 };

 SVGCircle.NAME = "svgCircle";

 Y.extend(SVGCircle, Y.SVGShape, {

    /**
     * Indicates the type of shape
     *
     * @property _type
     * @readOnly
     * @type String
     */
    _type: "circle",

    /**
     * Updates the shape.
     *
     * @method _draw
     * @private
     */
    _draw: function()
    {
        var node = this.node,
            x = this.get("x"),
            y = this.get("y"),
            radius = this.get("radius"),
            cx = x + radius,
            cy = y + radius;
        node.setAttribute("r", radius);
        node.setAttribute("cx", cx);
        node.setAttribute("cy", cy);
        this._fillChangeHandler();
        this._strokeChangeHandler();
        this._updateTransform();
    }
 });

SVGCircle.ATTRS = Y.merge(Y.SVGShape.ATTRS, {
	/**
	 * Indicates the width of the shape
	 *
	 * @attribute width
	 * @type Number
	 */
    width: {
        setter: function(val)
        {
            this.set("radius", val/2);
            return val;
        },

        getter: function()
        {
            return this.get("radius") * 2;
        }
    },

	/**
	 * Indicates the height of the shape
	 *
	 * @attribute height
	 * @type Number
	 */
    height: {
        setter: function(val)
        {
            this.set("radius", val/2);
            return val;
        },

        getter: function()
        {
            return this.get("radius") * 2;
        }
    },

    /**
     * Radius of the circle
     *
     * @attribute radius
     * @type Number
     */
    radius: {
        value: 0
    }
});
Y.SVGCircle = SVGCircle;
/**
 * Draws pie slices
 */
SVGPieSlice = function()
{
	SVGPieSlice.superclass.constructor.apply(this, arguments);
};
SVGPieSlice.NAME = "svgPieSlice";
Y.extend(SVGPieSlice, Y.SVGPath, {
    /**
     * Indicates the type of shape
     *
     * @property _type
     * @readOnly
     * @type String
     */
    _type: "path",

	/**
	 * Change event listener
	 *
	 * @private
	 * @method _updateHandler
	 */
	_updateHandler: function(e)
	{
        var x = this.get("cx"),
            y = this.get("cy"),
            startAngle = this.get("startAngle"),
            arc = this.get("arc"),
            radius = this.get("radius");
        this.clear();
        this.drawWedge(x, y, startAngle, arc, radius)
		this._draw();
	}
 });
SVGPieSlice.ATTRS = Y.mix(Y.SVGPath.ATTRS, {
    cx: {
        value: 0
    },

    cy: {
        value: 0
    },
    /**
     * Starting angle in relation to a circle in which to begin the pie slice drawing.
     *
     * @attribute startAngle
     * @type Number
     */
    startAngle: {
        value: 0
    },

    /**
     * Arc of the slice.
     *
     * @attribute arc
     * @type Number
     */
    arc: {
        value: 0
    },

    /**
     * Radius of the circle in which the pie slice is drawn
     *
     * @attribute radius
     * @type Number
     */
    radius: {
        value: 0
    }
});
Y.SVGPieSlice = SVGPieSlice;
/**
 * Graphic is a simple drawing api that allows for basic drawing operations.
 *
 * @class Graphic
 * @constructor
 */
SVGGraphic = function(cfg) {
    SVGGraphic.superclass.constructor.apply(this, arguments);
};

SVGGraphic.NAME = "svgGraphic";

SVGGraphic.ATTRS = {
    render: {},

    /**
	 * Unique id for class instance.
	 *
	 * @attribute id
	 * @type String
	 */
	id: {
		valueFn: function()
		{
			return Y.guid();
		},

		setter: function(val)
		{
			var node = this._node;
			if(node)
			{
				node.setAttribute("id", val);
			}
			return val;
		}
	},

    /**
     * Key value pairs in which a shape instance is associated with its id.
     *
     *  @attribute shapes
     *  @type Object
     *  @readOnly
     */
    shapes: {
        readOnly: true,

        getter: function()
        {
            return this._shapes;
        }
    },

    /**
     *  Object containing size and coordinate data for the content of a Graphic in relation to the coordSpace node.
     *
     *  @attribute contentBounds
     *  @type Object
     *  @readOnly
     */
    contentBounds: {
        readOnly: true,

        getter: function()
        {
            return this._contentBounds;
        }
    },

    /**
     *  The html element that represents to coordinate system of the Graphic instance.
     *
     *  @attribute node
     *  @type HTMLElement
     *  @readOnly
     */
    node: {
        readOnly: true,

        getter: function()
        {
            return this._node;
        }
    },

    width: {
        setter: function(val)
        {
            if(this._node)
            {
                this._node.style.width = val + "px";
            }
            return val;
        }
    },

    height: {
        setter: function(val)
        {
            if(this._node)
            {
                this._node.style.height = val  + "px";
            }
            return val;
        }
    },

    /**
     *  Determines how the size of instance is calculated. If true, the width and height are determined by the size of the contents.
     *  If false, the width and height values are either explicitly set or determined by the size of the parent node's dimensions.
     *
     *  @attribute autoSize
     *  @type Boolean
     *  @default false
     */
    autoSize: {
        value: false
    },

    /**
     * When overflow is set to true, by default, the viewBox will resize to greater values but not values. (for performance)
     * When resizing the viewBox down is desirable, set the resizeDown value to true.
     *
     * @attribute resizeDown
     * @type Boolean
     */
    resizeDown: {
        getter: function()
        {
            return this._resizeDown;
        },

        setter: function(val)
        {
            this._resizeDown = val;
            this._redraw();
            return val;
        }
    },

	/**
	 * Indicates the x-coordinate for the instance.
	 *
	 * @attribute x
	 * @type Number
	 */
    x: {
        getter: function()
        {
            return this._x;
        },

        setter: function(val)
        {
            this._x = val;
            if(this._node)
            {
                this._node.style.left = val + "px";
            }
            return val;
        }
    },

	/**
	 * Indicates the y-coordinate for the instance.
	 *
	 * @attribute y
	 * @type Number
	 */
    y: {
        getter: function()
        {
            return this._y;
        },

        setter: function(val)
        {
            this._y = val;
            if(this._node)
            {
                this._node.style.top = val + "px";
            }
            return val;
        }
    },

    /**
     * Indicates whether or not the instance will automatically redraw after a change is made to a shape.
     * This property will get set to false when batching operations.
     *
     * @attribute autoDraw
     * @type Boolean
     * @default true
     * @private
     */
    autoDraw: {
        value: true
    },

    visible: {
        value: true,

        setter: function(val)
        {
            this._toggleVisible(val);
            return val;
        }
    },

    /**
     *  Indicates the pointer-events setting for the svg:svg element.
     *
     *  @attribute pointerEvents
     *  @type String
     */
    pointerEvents: {
        value: "none"
    }
};

Y.extend(SVGGraphic, Y.BaseGraphic, {
    /**
     * @private
     */
    _x: 0,

    /**
     * @private
     */
    _y: 0,

    /**
     * Gets the current position of the graphic instance in page coordinates.
     *
     * @method getXY
     * @return Array The XY position of the shape.
     */
    getXY: function()
    {
        var node = Y.one(this._node),
            xy;
        if(node)
        {
            xy = node.getXY();
        }
        return xy;
    },

    /**
     * @private
     * @property _resizeDown
     * @type Boolean
     */
    _resizeDown: false,

    /**
     * Initializes the class.
     *
     * @method initializer
     * @private
     */
    initializer: function() {
        var render = this.get("render");
        this._shapes = {};
		this._contentBounds = {
            left: 0,
            top: 0,
            right: 0,
            bottom: 0
        };
        this._gradients = {};
        this._node = DOCUMENT.createElement('div');
        this._node.style.position = "absolute";
        this._node.style.left = this.get("x") + "px";
        this._node.style.top = this.get("y") + "px";
        this._contentNode = this._createGraphics();
        this._contentNode.setAttribute("id", this.get("id"));
        this._node.appendChild(this._contentNode);
        if(render)
        {
            this.render(render);
        }
    },

    /**
     * Adds the graphics node to the dom.
     *
     * @method render
     * @param {HTMLElement} parentNode node in which to render the graphics node into.
     */
    render: function(render) {
        var parentNode = Y.one(render),
            w = this.get("width") || parseInt(parentNode.getComputedStyle("width"), 10),
            h = this.get("height") || parseInt(parentNode.getComputedStyle("height"), 10);
        parentNode = parentNode || DOCUMENT.body;
        parentNode.appendChild(this._node);
        this.parentNode = parentNode;
        this.set("width", w);
        this.set("height", h);
        this.parentNode = parentNode;
        return this;
    },

    /**
     * Removes all nodes.
     *
     * @method destroy
     */
    destroy: function()
    {
        this.removeAllShapes();
        this._removeChildren(this._node);
        if(this._node && this._node.parentNode)
        {
            this._node.parentNode.removeChild(this._node);
        }
    },

    /**
     * Generates a shape instance by type.
     *
     * @method getShape
     * @param {String} type type of shape to generate.
     * @param {Object} cfg attributes for the shape
     * @return Shape
     */
    getShape: function(cfg)
    {
        cfg.graphic = this;
        var shape = new this._shapeClass[cfg.type](cfg);
        this.addShape(shape);
        return shape;
    },

    /**
     * Adds a shape instance to the graphic instance.
     *
     * @method addShape
     * @param {Shape} shape The shape instance to be added to the graphic.
     */
    addShape: function(shape)
    {
        var node = shape.node,
            parentNode = this._frag || this._contentNode;
        if(this.get("autoDraw"))
        {
            parentNode.appendChild(node);
        }
        else
        {
            this._getDocFrag().appendChild(node);
        }
    },

    /**
     * Removes a shape instance from from the graphic instance.
     *
     * @method removeShape
     * @param {Shape|String}
     */
    removeShape: function(shape)
    {
        if(!(shape instanceof SVGShape))
        {
            if(Y_LANG.isString(shape))
            {
                shape = this._shapes[shape];
            }
        }
        if(shape && shape instanceof SVGShape)
        {
            shape.destroy();
            delete this._shapes[shape.get("id")];
        }
        if(this.get("autoDraw"))
        {
            this._redraw();
        }
        return shape;
    },

    /**
     * Removes all shape instances from the dom.
     *
     * @method removeAllShapes
     */
    removeAllShapes: function()
    {
        var shapes = this._shapes,
            i;
        for(i in shapes)
        {
            if(shapes.hasOwnProperty(i))
            {
                shapes[i].destroy();
            }
        }
        this._shapes = {};
    },

    /**
     * Removes all child nodes.
     *
     * @method _removeChildren
     * @param {HTMLElement} node
     * @private
     */
    _removeChildren: function(node)
    {
        if(node.hasChildNodes())
        {
            var child;
            while(node.firstChild)
            {
                child = node.firstChild;
                this._removeChildren(child);
                node.removeChild(child);
            }
        }
    },

    /**
     * Clears the graphics object.
     *
     * @method clear
     */
    clear: function() {
        this.removeAllShapes();
    },

    /**
     * Toggles visibility
     *
     * @method _toggleVisible
     * @param {Boolean} val indicates visibilitye
     * @private
     */
    _toggleVisible: function(val)
    {
        var i,
            shapes = this._shapes,
            visibility = val ? "visible" : "hidden";
        if(shapes)
        {
            for(i in shapes)
            {
                if(shapes.hasOwnProperty(i))
                {
                    shapes[i].set("visible", val);
                }
            }
        }
        this._contentNode.style.visibility = visibility;
        this._node.style.visibility = visibility;
    },

    /**
     * @private
     */
    _shapeClass: {
        circle: Y.SVGCircle,
        rect: Y.SVGRect,
        path: Y.SVGPath,
        ellipse: Y.SVGEllipse,
        pieslice: Y.SVGPieSlice
    },

    /**
     * Returns a shape based on the id of its dom node.
     *
     * @method getShapeById
     * @param {String} id Dom id of the shape's node attribute.
     * @return Shape
     */
    getShapeById: function(id)
    {
        var shape = this._shapes[id];
        return shape;
    },

	/**
	 * Allows for creating multiple shapes in order to batch appending and redraw operations.
	 *
	 * @method batch
	 * @param {Function} method Method to execute.
	 */
    batch: function(method)
    {
        var autoDraw = this.get("autoDraw");
        this.set("autoDraw", false);
        method();
        this._redraw();
        this.set("autoDraw", autoDraw);
    },

    _getDocFrag: function()
    {
        if(!this._frag)
        {
            this._frag = document.createDocumentFragment();
        }
        return this._frag;
    },

    _redraw: function()
    {
        var box = this.get("resizeDown") ? this._getUpdatedContentBounds() : this._contentBounds;
        this._contentNode.style.left = box.left + "px";
        this._contentNode.style.top = box.top + "px";
        this._contentNode.setAttribute("width", box.width);
        this._contentNode.setAttribute("height", box.height);
        this._contentNode.style.width = box.width + "px";
        this._contentNode.style.height = box.height + "px";
        this._contentNode.setAttribute("viewBox", "" + box.left + " " + box.top + " " + box.width + " " + box.height + "");
        if(this.get("autoSize"))
        {
            this.set("width", box.right);
            this.set("height", box.bottom);
        }
        if(this._frag)
        {
            this._contentNode.appendChild(this._frag);
            this._frag = null;
        }
    },

    /**
     * Adds a shape to the redraw queue and calculates the contentBounds.
     *
     * @method addToRedrawQueue
     * @param shape {SVGShape}
     */
    addToRedrawQueue: function(shape)
    {
        var shapeBox,
            box;
        this._shapes[shape.get("id")] = shape;
        if(!this.get("resizeDown"))
        {
            shapeBox = shape.getBounds();
            box = this._contentBounds;
            box.left = box.left < shapeBox.left ? box.left : shapeBox.left;
            box.top = box.top < shapeBox.top ? box.top : shapeBox.top;
            box.right = box.right > shapeBox.right ? box.right : shapeBox.right;
            box.bottom = box.bottom > shapeBox.bottom ? box.bottom : shapeBox.bottom;
            box.width = box.right - box.left;
            box.height = box.bottom - box.top;
            this._contentBounds = box;
        }
        if(this.get("autoDraw"))
        {
            this._redraw();
        }
    },

    _getUpdatedContentBounds: function()
    {
        var bounds,
            i,
            shape,
            queue = this._shapes,
            box = {
                left: 0,
                top: 0,
                right: 0,
                bottom: 0
            };
        for(i in queue)
        {
            if(queue.hasOwnProperty(i))
            {
                shape = queue[i];
                bounds = shape.getBounds();
                box.left = Math.min(box.left, bounds.left);
                box.top = Math.min(box.top, bounds.top);
                box.right = Math.max(box.right, bounds.right);
                box.bottom = Math.max(box.bottom, bounds.bottom);
            }
        }
        box.width = box.right - box.left;
        box.height = box.bottom - box.top;
        this._contentBounds = box;
        return box;
    },

    /**
     * Creates a contentNode element
     *
     * @method _createGraphics
     * @private
     */
    _createGraphics: function() {
        var contentNode = this._createGraphicNode("svg"),
            pointerEvents = this.get("pointerEvents");
        contentNode.style.position = "absolute";
        contentNode.style.top = "px";
        contentNode.style.left = "0px";
        contentNode.style.overflow = "auto";
        contentNode.setAttribute("overflow", "auto");
        contentNode.setAttribute("pointer-events", pointerEvents);
        return contentNode;
    },

    /**
     * Creates a graphic node
     *
     * @method _createGraphicNode
     * @param {String} type node type to create
     * @param {String} pe specified pointer-events value
     * @return HTMLElement
     * @private
     */
    _createGraphicNode: function(type, pe)
    {
        var node = document.createElementNS("http://www.w3.org/2000/svg", "svg:" + type),
            v = pe || "none";
        if(type !== "defs" && type !== "stop" && type !== "linearGradient" && type != "radialGradient")
        {
            node.setAttribute("pointer-events", v);
        }
        return node;
    },

    /**
     * Returns a reference to a gradient definition based on an id and type.
     *
     * @method getGradientNode
     * @key {String} id that references the gradient definition
     * @type {String} description of the gradient type
     * @return HTMLElement
     */
    getGradientNode: function(key, type)
    {
        var gradients = this._gradients,
            gradient,
            nodeType = type + "Gradient";
        if(gradients.hasOwnProperty(key) && gradients[key].tagName.indexOf(type) > -1)
        {
            gradient = this._gradients[key];
        }
        else
        {
            gradient = this._createGraphicNode(nodeType);
            if(!this._defs)
            {
                this._defs = this._createGraphicNode("defs");
                this._contentNode.appendChild(this._defs);
            }
            this._defs.appendChild(gradient);
            key = key || "gradient" + Math.round(100000 * Math.random());
            gradient.setAttribute("id", key);
            if(gradients.hasOwnProperty(key))
            {
                this._defs.removeChild(gradients[key]);
            }
            gradients[key] = gradient;
        }
        return gradient;
    }

});

Y.SVGGraphic = SVGGraphic;

}, '@VERSION@' ,{requires:['graphics'], skinnable:false});


text:
package com.kasabi.data.movies.youtube;

import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.zip.GZIPOutputStream;

import com.kasabi.data.movies.Crawler;
import com.kasabi.data.movies.MoviesCommon;
import com.kasabi.data.movies.Scraper;

public class YouTubeCrawler {

	public static void main(String[] args) throws IOException {
		OutputStream out = new BufferedOutputStream ( new GZIPOutputStream( new FileOutputStream ( "youtube.nt.gz") ) );
		Scraper scraper = new YouTubeVideoScraper(MoviesCommon.YOUTUBE_NS, out);
		Crawler crawler = new Crawler(MoviesCommon.YOUTUBE_NS, "/user/" + MoviesCommon.YOUTUBE_CHANNEL + "/videos?sort=dd&view=0&page=1", "h3.video-title", "a[href^=/watch]", "a:matches(Next)", scraper);
		crawler.setRetrieveAll(false);
		crawler.crawl();
		out.flush();
		out.close();
	}

}