text:
package ru.wordmetrix.webcrawler

import java.net.URI

import akka.actor.{Actor, ActorRef, Props, actorRef2Scala}
import ru.wordmetrix.smartfile.SmartFile.fromFile
import ru.wordmetrix.utils.impl.URIEx
import ru.wordmetrix.utils.{CFG, CFGAware}

object WebGet {

  abstract sealed trait WebGetMessage

  case class WebGetRequest(seed: URI, gather: ActorRef) extends WebGetMessage

  def props(cfg: CFG): Props =
    Props(new WebGet()(cfg))
}

/*
 * WebGet gets an information from web pages
 */
class WebGet()(implicit cfg: CFG)
  extends Actor with CFGAware {
  override val name = "WebGet"

  import Gather._
  import SeedQueue._
  import WebGet._

  def receive(): Receive = {
    case WebGetRequest(seed, gather) => {
      //log("Getting a page %s ", seed)
      try {
        val page = (cfg.cache / seed.toFilename).readLines.mkString("")
        log("Getting from caches %s ", seed)
        gather ! GatherPage(seed, page)

      } catch {
        case x: Throwable =>
          if (cfg.isdebug) log("Getting from source %s ", seed)

          time(s"Getting from source $seed") {
            try {
              val connection = seed.toURL.openConnection()
              connection.getContentType().split(";").head match {
                case "text/html" => {
                  val text = io.Source.fromInputStream(
                    connection.getInputStream()).
                    getLines().mkString("\n")
                  (cfg.cache / seed.toFilename).write(text)

                  gather ! GatherPage(seed, text)
                }
                case _ => None
              }
            } catch {
              case x: Throwable =>
                this.log("Download fault %s because %s", seed, x)
            }
          }
      }
      sender ! SeedQueueGet
    }

    case SeedQueueEmpty =>
      context.stop(self)
  }
}


text:
<?php

namespace Brickrouge;

/**
 * Brickrouge helpers.
 *
 * The following helpers are patchable:
 *
 * - {@link check_session()}
 * - {@link format()}
 * - {@link format_size()}
 * - {@link get_accessible_file()}
 * - {@link get_document()}
 * - {@link normalize()}
 * - {@link render_exception()}
 * - {@link retrieve_form()}
 * - {@link retrieve_form_errors()}
 * - {@link store_form()}
 * - {@link store_form_errors()}
 * - {@link t()}
 *
 * @method void check_session() check_session()
 * @method string format() format(string $str, array $args=[])
 * @method string format_size() format_size(number $size)
 * @method string get_accessible_file() get_accessible_file(string $path, $suffix=null)
 * @method Document get_document() get_document()
 * @method string normalize() normalize(string $str)
 * @method string render_exception() render_exception(\Exception $exception)
 * @method Form retrieve_form() retrieve_form(string $name)
 * @method \ICanboogie\Errors retrieve_form_errors() retrieve_form_errors(string $name)
 * @method string store_form() store_form(Form $form)
 * @method void store_form_errors() store_form_errors(string $name, \ICanBoogie\Errors $errors)
 * @method string t() t(string $str, array $args=[], array $options=[])
 */
class Helpers
{
	static private $jumptable = [

		'check_session'        => [ __CLASS__, 'check_session' ],
		'format'               => [ __CLASS__, 'format' ],
		'format_size'          => [ __CLASS__, 'format_size' ],
		'get_accessible_file'  => [ __CLASS__, 'get_accessible_file' ],
		'get_document'         => [ __CLASS__, 'get_document' ],
		'normalize'            => [ __CLASS__, 'normalize' ],
		'render_exception'     => [ __CLASS__, 'render_exception' ],
		'retrieve_form'        => [ __CLASS__, 'retrieve_form' ],
		'retrieve_form_errors' => [ __CLASS__, 'retrieve_form_errors' ],
		'store_form'           => [ __CLASS__, 'store_form' ],
		'store_form_errors'    => [ __CLASS__, 'store_form_errors' ],
		't'                    => [ __CLASS__, 't' ]

	];

	/**
	 * Calls the callback of a patchable function.
	 *
	 * @param string $name Name of the function.
	 * @param array $arguments Arguments.
	 *
	 * @return mixed
	 */
	static public function __callstatic($name, array $arguments)
	{
		return call_user_func_array(self::$jumptable[$name], $arguments);
	}

	/**
	 * Patches a patchable function.
	 *
	 * @param string $name Name of the function.
	 * @param callable $callback Callback.
	 *
	 * @throws \RuntimeException is attempt to patch an undefined function.
	 */
	static public function patch($name, $callback)
	{
		if (empty(self::$jumptable[$name]))
		{
			throw new \RuntimeException("Undefined patchable: $name.");
		}

		self::$jumptable[$name] = $callback;
	}

	/*
	 * fallbacks
	 */

	/**
	 * This method is the fallback for the {@link format()} function.
	 */
	static private function format($str, array $args = [])
	{
		if (!$args)
		{
			return $str;
		}

		$holders = [];
		$i = 0;

		foreach ($args as $key => $value)
		{
			++$i;

			if (is_array($value) || is_object($value))
			{
				$value = dump($value);
			}
			else if (is_bool($value))
			{
				$value = $value ? 'true' : 'false';
			}
			else if (is_null($value))
			{
				$value = 'null';
			}

			if (is_string($key))
			{
				switch ($key{0})
				{
					case ':': break;
					case '!': $value = escape($value); break;
					case '%': $value = '<q>' . escape($value) . '</q>'; break;

					default:
					{
						$escaped_value = escape($value);

						$holders['!' . $key] = $escaped_value;
						$holders['%' . $key] = '<q>' . $escaped_value . '</q>';

						$key = ':' . $key;
					}
				}
			}
			else if (is_numeric($key))
			{
				$key = '\\' . $i;
				$holders['{' . $i . '}'] = $value;
			}

			$holders[$key] = $value;
		}

		return strtr($str, $holders);
	}

	/**
	 * This method is the fallback for the {@link format_size()} function.
	 */
	static private function format_size($size)
	{
		if ($size < 1024)
		{
			$str = ":size\xC2\xA0b";
		}
		else if ($size < 1024 * 1024)
		{
			$str = ":size\xC2\xA0Kb";
			$size = $size / 1024;
		}
		else if ($size < 1024 * 1024 * 1024)
		{
			$str = ":size\xC2\xA0Mb";
			$size = $size / (1024 * 1024);
		}
		else
		{
			$str = ":size\xC2\xA0Gb";
			$size = $size / (1024 * 1024 * 1024);
		}

		return t($str, [ ':size' => round($size) ]);
	}

	/**
	 * This method is the fallback for the {@link normalize()} function.
	 */
	static private function normalize($str, $separator = '-', $charset = CHARSET)
	{
		$str = str_replace('\'', '', $str);

		$str = htmlentities($str, ENT_NOQUOTES, $charset);
		$str = preg_replace('#&([A-za-z])(?:acute|cedil|circ|grave|orn|ring|slash|th|tilde|uml);#', '\1', $str);
		$str = preg_replace('#&([A-za-z]{2})(?:lig);#', '\1', $str);
		$str = preg_replace('#&[^;]+;#', '', $str);

		$str = strtolower($str);
		$str = preg_replace('#[^a-z0-9]+#', $separator, $str);
		$str = trim($str, $separator);

		return $str;
	}

	/**
	 * This method is the fallback for the {@link t()} function.
	 *
	 * We usually rely on the ICanBoogie framework I18n features to translate our string, if it is
	 * not available we simply format the string using the {@link Brickrouge\format()} function.
	 */
	static private function t($str, array $args = [], array $options = [])
	{
		return format($str, $args);
	}

	/**
	 * This method is the fallback for the {@link get_document()} function.
	 */
	static private function get_document()
	{
		if (self::$document === null)
		{
			self::$document = new Document();
		}

		return self::$document;
	}

	private static $document;

	/**
	 * This method is the fallback for the {@link check_session()} function.
	 */
	static private function check_session()
	{
		if (session_id())
		{
			return;
		}

		session_start();
	}

	const STORE_KEY = 'brickrouge.stored_forms';
	const STORE_MAX = 10;

	/**
	 * Fallback for the {@link store_form()} function.
	 *
	 * The form is saved in the session in the STORE_KEY array.
	 *
	 * @param Form $form
	 *
	 * @return string The key to use to retrieve the form.
	 */
	static private function store_form(Form $form)
	{
		check_session();

		#
		# before we store anything, we do some cleanup. in order to avoid sessions filled with
		# used forms. We only maintain a few. The limit is set using the STORE_MAX constant.
		#

		if (isset($_SESSION[self::STORE_KEY]))
		{
			$n = count($_SESSION[self::STORE_KEY]);

			if ($n > self::STORE_MAX)
			{
				$_SESSION[self::STORE_KEY] = array_slice($_SESSION[self::STORE_KEY], $n - self::STORE_MAX);
			}
		}

		$key = md5(uniqid(mt_rand(), true));

		$_SESSION[self::STORE_KEY][$key] = serialize($form);

		return $key;
	}

	/**
	 * Fallback for the {@link retrieve_form()} function.
	 *
	 * @param string $key
	 *
	 * @return void|Form The retrieved form or null if the key matched none.
	 */
	static private function retrieve_form($key)
	{
		check_session();

		if (empty($_SESSION[self::STORE_KEY][$key]))
		{
			return;
		}

		$form = unserialize($_SESSION[self::STORE_KEY][$key]);

		unset($_SESSION[self::STORE_KEY][$key]);

		return $form;
	}

	static private $errors;

	/**
	 * This method is the fallback for the {@link store_form_errors()} function.
	 */
	static private function store_form_errors($name, $errors)
	{
		self::$errors[$name] = $errors;
	}

	/**
	 * This method is the fallback for the {@link retrieve_form_errors()} function.
	 */
	static private function retrieve_form_errors($name)
	{
		return isset(self::$errors[$name]) ? self::$errors[$name] : [];
	}

	/**
	 * This method is the fallback for the {@link render_exception()} function.
	 *
	 * @param \Exception $exception
	 *
	 * @return string
	 */
	static private function render_exception(\Exception $exception)
	{
		return (string) $exception;
	}

	/**
	 * This method is the fallback for the {@link get_accessible_file()} function.
	 *
	 * @param string $path Absolute path to the web inaccessible file.
	 * @param string $suffix Optional suffix for the web accessible filename.
	 *
	 * @return string The pathname of the replacement.
	 *
	 * @throws \Exception if the replacement file could not be created.
	 */
	static private function get_accessible_file($path, $suffix = null)
	{
		$key = sprintf('%s-%04x%s.%s', md5($path), strlen($path), ($suffix ? '-' . $suffix : ''), pathinfo($path, PATHINFO_EXTENSION));
		$replacement_path = ACCESSIBLE_ASSETS;
		$replacement = $replacement_path . $key;

		if (!is_writable($replacement_path))
		{
			throw new \Exception(format('Unable to make the file %path web accessible, the destination directory %replacement_path is not writtable.', [ 'path' => $path, 'replacement_path' => $replacement_path ]));
		}

		if (!file_exists($replacement) || filemtime($path) > filemtime($replacement))
		{
			file_put_contents($replacement, file_get_contents($path));
		}

		return $replacement;
	}
}

redpajama_set_name: RedPajamaGithub


text:
// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: hello_world.proto

package io.grpc.examples.helloworld;

/**
 * Protobuf type {@code grpc.example.helloworld.HelloRequest}
 *
 *

 * The request message containing the user's name.
 *

 */
public  final class HelloRequest extends
    com.google.protobuf.GeneratedMessage implements
    // @@protoc_insertion_point(message_implements:grpc.example.helloworld.HelloRequest)
    HelloRequestOrBuilder {
  // Use HelloRequest.newBuilder() to construct.
  private HelloRequest(com.google.protobuf.GeneratedMessage.Builder builder) {
    super(builder);
  }
  private HelloRequest() {
    name_ = "";
  }

  @java.lang.Override
  public final com.google.protobuf.UnknownFieldSet
  getUnknownFields() {
    return com.google.protobuf.UnknownFieldSet.getDefaultInstance();
  }
  private HelloRequest(
      com.google.protobuf.CodedInputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    this();
    int mutable_bitField0_ = 0;
    try {
      boolean done = false;
      while (!done) {
        int tag = input.readTag();
        switch (tag) {
          case 0:
            done = true;
            break;
          default: {
            if (!input.skipField(tag)) {
              done = true;
            }
            break;
          }
          case 10: {
            com.google.protobuf.ByteString bs = input.readBytes();

            name_ = bs;
            break;
          }
        }
      }
    } catch (com.google.protobuf.InvalidProtocolBufferException e) {
      throw e.setUnfinishedMessage(this);
    } catch (java.io.IOException e) {
      throw new com.google.protobuf.InvalidProtocolBufferException(
          e.getMessage()).setUnfinishedMessage(this);
    } finally {
      makeExtensionsImmutable();
    }
  }
  public static final com.google.protobuf.Descriptors.Descriptor
      getDescriptor() {
    return io.grpc.examples.helloworld.HelloWorldProto.internal_static_grpc_example_helloworld_HelloRequest_descriptor;
  }

  protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
      internalGetFieldAccessorTable() {
    return io.grpc.examples.helloworld.HelloWorldProto.internal_static_grpc_example_helloworld_HelloRequest_fieldAccessorTable
        .ensureFieldAccessorsInitialized(
            io.grpc.examples.helloworld.HelloRequest.class, io.grpc.examples.helloworld.HelloRequest.Builder.class);
  }

  public static final com.google.protobuf.Parser<HelloRequest> PARSER =
      new com.google.protobuf.AbstractParser<HelloRequest>() {
    public HelloRequest parsePartialFrom(
        com.google.protobuf.CodedInputStream input,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws com.google.protobuf.InvalidProtocolBufferException {
      return new HelloRequest(input, extensionRegistry);
    }
  };

  @java.lang.Override
  public com.google.protobuf.Parser<HelloRequest> getParserForType() {
    return PARSER;
  }

  public static final int NAME_FIELD_NUMBER = 1;
  private java.lang.Object name_;
  /**
   * optional string name = 1;
   */
  public java.lang.String getName() {
    java.lang.Object ref = name_;
    if (ref instanceof java.lang.String) {
      return (java.lang.String) ref;
    } else {
      com.google.protobuf.ByteString bs =
          (com.google.protobuf.ByteString) ref;
      java.lang.String s = bs.toStringUtf8();
      if (bs.isValidUtf8()) {
        name_ = s;
      }
      return s;
    }
  }
  /**
   * optional string name = 1;
   */
  public com.google.protobuf.ByteString
      getNameBytes() {
    java.lang.Object ref = name_;
    if (ref instanceof java.lang.String) {
      com.google.protobuf.ByteString b =
          com.google.protobuf.ByteString.copyFromUtf8(
              (java.lang.String) ref);
      name_ = b;
      return b;
    } else {
      return (com.google.protobuf.ByteString) ref;
    }
  }

  private byte memoizedIsInitialized = -1;
  public final boolean isInitialized() {
    byte isInitialized = memoizedIsInitialized;
    if (isInitialized == 1) return true;
    if (isInitialized == 0) return false;

    memoizedIsInitialized = 1;
    return true;
  }

  public void writeTo(com.google.protobuf.CodedOutputStream output)
                      throws java.io.IOException {
    getSerializedSize();
    if (!getNameBytes().isEmpty()) {
      output.writeBytes(1, getNameBytes());
    }
  }

  private int memoizedSerializedSize = -1;
  public int getSerializedSize() {
    int size = memoizedSerializedSize;
    if (size != -1) return size;

    size = 0;
    if (!getNameBytes().isEmpty()) {
      size += com.google.protobuf.CodedOutputStream
        .computeBytesSize(1, getNameBytes());
    }
    memoizedSerializedSize = size;
    return size;
  }

  private static final long serialVersionUID = 0L;
  public static io.grpc.examples.helloworld.HelloRequest parseFrom(
      com.google.protobuf.ByteString data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }
  public static io.grpc.examples.helloworld.HelloRequest parseFrom(
      com.google.protobuf.ByteString data,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }
  public static io.grpc.examples.helloworld.HelloRequest parseFrom(byte[] data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }
  public static io.grpc.examples.helloworld.HelloRequest parseFrom(
      byte[] data,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }
  public static io.grpc.examples.helloworld.HelloRequest parseFrom(java.io.InputStream input)
      throws java.io.IOException {
    return PARSER.parseFrom(input);
  }
  public static io.grpc.examples.helloworld.HelloRequest parseFrom(
      java.io.InputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return PARSER.parseFrom(input, extensionRegistry);
  }
  public static io.grpc.examples.helloworld.HelloRequest parseDelimitedFrom(java.io.InputStream input)
      throws java.io.IOException {
    return PARSER.parseDelimitedFrom(input);
  }
  public static io.grpc.examples.helloworld.HelloRequest parseDelimitedFrom(
      java.io.InputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return PARSER.parseDelimitedFrom(input, extensionRegistry);
  }
  public static io.grpc.examples.helloworld.HelloRequest parseFrom(
      com.google.protobuf.CodedInputStream input)
      throws java.io.IOException {
    return PARSER.parseFrom(input);
  }
  public static io.grpc.examples.helloworld.HelloRequest parseFrom(
      com.google.protobuf.CodedInputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return PARSER.parseFrom(input, extensionRegistry);
  }

  public static Builder newBuilder() { return new Builder(); }
  public Builder newBuilderForType() { return newBuilder(); }
  public static Builder newBuilder(io.grpc.examples.helloworld.HelloRequest prototype) {
    return newBuilder().mergeFrom(prototype);
  }
  public Builder toBuilder() { return newBuilder(this); }

  @java.lang.Override
  protected Builder newBuilderForType(
      com.google.protobuf.GeneratedMessage.BuilderParent parent) {
    Builder builder = new Builder(parent);
    return builder;
  }
  /**
   * Protobuf type {@code grpc.example.helloworld.HelloRequest}
   *
   *

   * The request message containing the user's name.
   *

   */
  public static final class Builder extends
      com.google.protobuf.GeneratedMessage.Builder<Builder> implements
      // @@protoc_insertion_point(builder_implements:grpc.example.helloworld.HelloRequest)
      io.grpc.examples.helloworld.HelloRequestOrBuilder {
    public static final com.google.protobuf.Descriptors.Descriptor
        getDescriptor() {
      return io.grpc.examples.helloworld.HelloWorldProto.internal_static_grpc_example_helloworld_HelloRequest_descriptor;
    }

    protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
        internalGetFieldAccessorTable() {
      return io.grpc.examples.helloworld.HelloWorldProto.internal_static_grpc_example_helloworld_HelloRequest_fieldAccessorTable
          .ensureFieldAccessorsInitialized(
              io.grpc.examples.helloworld.HelloRequest.class, io.grpc.examples.helloworld.HelloRequest.Builder.class);
    }

    // Construct using io.grpc.examples.helloworld.HelloRequest.newBuilder()
    private Builder() {
      maybeForceBuilderInitialization();
    }

    private Builder(
        com.google.protobuf.GeneratedMessage.BuilderParent parent) {
      super(parent);
      maybeForceBuilderInitialization();
    }
    private void maybeForceBuilderInitialization() {
      if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
      }
    }
    public Builder clear() {
      super.clear();
      name_ = "";

      return this;
    }

    public com.google.protobuf.Descriptors.Descriptor
        getDescriptorForType() {
      return io.grpc.examples.helloworld.HelloWorldProto.internal_static_grpc_example_helloworld_HelloRequest_descriptor;
    }

    public io.grpc.examples.helloworld.HelloRequest getDefaultInstanceForType() {
      return io.grpc.examples.helloworld.HelloRequest.getDefaultInstance();
    }

    public io.grpc.examples.helloworld.HelloRequest build() {
      io.grpc.examples.helloworld.HelloRequest result = buildPartial();
      if (!result.isInitialized()) {
        throw newUninitializedMessageException(result);
      }
      return result;
    }

    public io.grpc.examples.helloworld.HelloRequest buildPartial() {
      io.grpc.examples.helloworld.HelloRequest result = new io.grpc.examples.helloworld.HelloRequest(this);
      result.name_ = name_;
      onBuilt();
      return result;
    }

    public Builder mergeFrom(com.google.protobuf.Message other) {
      if (other instanceof io.grpc.examples.helloworld.HelloRequest) {
        return mergeFrom((io.grpc.examples.helloworld.HelloRequest)other);
      } else {
        super.mergeFrom(other);
        return this;
      }
    }

    public Builder mergeFrom(io.grpc.examples.helloworld.HelloRequest other) {
      if (other == io.grpc.examples.helloworld.HelloRequest.getDefaultInstance()) return this;
      if (!other.getName().isEmpty()) {
        name_ = other.name_;
        onChanged();
      }
      onChanged();
      return this;
    }

    public final boolean isInitialized() {
      return true;
    }

    public Builder mergeFrom(
        com.google.protobuf.CodedInputStream input,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws java.io.IOException {
      io.grpc.examples.helloworld.HelloRequest parsedMessage = null;
      try {
        parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
      } catch (com.google.protobuf.InvalidProtocolBufferException e) {
        parsedMessage = (io.grpc.examples.helloworld.HelloRequest) e.getUnfinishedMessage();
        throw e;
      } finally {
        if (parsedMessage != null) {
          mergeFrom(parsedMessage);
        }
      }
      return this;
    }

    private java.lang.Object name_ = "";
    /**
     * optional string name = 1;
     */
    public java.lang.String getName() {
      java.lang.Object ref = name_;
      if (!(ref instanceof java.lang.String)) {
        com.google.protobuf.ByteString bs =
            (com.google.protobuf.ByteString) ref;
        java.lang.String s = bs.toStringUtf8();
        if (bs.isValidUtf8()) {
          name_ = s;
        }
        return s;
      } else {
        return (java.lang.String) ref;
      }
    }
    /**
     * optional string name = 1;
     */
    public com.google.protobuf.ByteString
        getNameBytes() {
      java.lang.Object ref = name_;
      if (ref instanceof String) {
        com.google.protobuf.ByteString b =
            com.google.protobuf.ByteString.copyFromUtf8(
                (java.lang.String) ref);
        name_ = b;
        return b;
      } else {
        return (com.google.protobuf.ByteString) ref;
      }
    }
    /**
     * optional string name = 1;
     */
    public Builder setName(
        java.lang.String value) {
      if (value == null) {
    throw new NullPointerException();
  }

      name_ = value;
      onChanged();
      return this;
    }
    /**
     * optional string name = 1;
     */
    public Builder clearName() {

      name_ = getDefaultInstance().getName();
      onChanged();
      return this;
    }
    /**
     * optional string name = 1;
     */
    public Builder setNameBytes(
        com.google.protobuf.ByteString value) {
      if (value == null) {
    throw new NullPointerException();
  }

      name_ = value;
      onChanged();
      return this;
    }
    public final Builder setUnknownFields(
        final com.google.protobuf.UnknownFieldSet unknownFields) {
      return this;
    }

    public final Builder mergeUnknownFields(
        final com.google.protobuf.UnknownFieldSet unknownFields) {
      return this;
    }

    // @@protoc_insertion_point(builder_scope:grpc.example.helloworld.HelloRequest)
  }

  // @@protoc_insertion_point(class_scope:grpc.example.helloworld.HelloRequest)
  private static final io.grpc.examples.helloworld.HelloRequest defaultInstance;static {
    defaultInstance = new io.grpc.examples.helloworld.HelloRequest();
  }

  public static io.grpc.examples.helloworld.HelloRequest getDefaultInstance() {
    return defaultInstance;
  }

  public io.grpc.examples.helloworld.HelloRequest getDefaultInstanceForType() {
    return defaultInstance;
  }

}


text:
from rest_framework.routers import DefaultRouter, Route, DynamicListRoute, DynamicDetailRoute
from .views import OrganizationsViewSet, WorksViewSet, IndividualsViewSet, RecordingsViewSet

class OMIRouter(DefaultRouter):
    routes = [
        # List route.
        Route(
            url=r'^{prefix}{trailing_slash}(;.+)?$',
            mapping={
                'get': 'list',
                'post': 'create'
            },
            name='{basename}-list',
            initkwargs={'suffix': 'List'}
        ),
        # Dynamically generated list routes.
        # Generated using @list_route decorator
        # on methods of the viewset.
        DynamicListRoute(
            url=r'^{prefix}/{methodname}{trailing_slash}$',
            name='{basename}-{methodnamehyphen}',
            initkwargs={}
        ),
        # Detail route.
        Route(
            url=r'^{prefix}/{lookup}{trailing_slash}$',
            mapping={
                'get': 'retrieve',
                'put': 'update',
                'patch': 'partial_update',
                'delete': 'destroy'
            },
            name='{basename}-detail',
            initkwargs={'suffix': 'Instance'}
        ),
        # Dynamically generated detail routes.
        # Generated using @detail_route decorator on methods of the viewset.
        DynamicDetailRoute(
            url=r'^{prefix}/{lookup}/{methodname}{trailing_slash}$',
            name='{basename}-{methodnamehyphen}',
            initkwargs={}
        ),
    ]

router = OMIRouter()
router.register(r'works', WorksViewSet, base_name="works")
router.register(r'recordings', RecordingsViewSet, base_name="recordings")
router.register(r'organizations', OrganizationsViewSet, base_name="organizations")
router.register(r'individuals', IndividualsViewSet, base_name="individuals")
api_urlpatterns = router.urls


text:
package net.beaconcontroller.core.internal;

import org.openflow.protocol.statistics.OFDescriptionStatistics;

import net.beaconcontroller.core.IOFSwitch;
import net.beaconcontroller.core.OFSwitchState;

/**
 *  This interface is an extension of IOFSwitch, but is only used internally
 *  for access to members that should not be exposed externally to other
 *  packages.
 *
 * @author David Erickson (daviderickson@cs.stanford.edu)
 */
public interface IOFSwitchExt extends IOFSwitch {
    /**
     * Change state of the switch
     * @param state
     */
    public void transitionToState(OFSwitchState state);

    /**
     * Sets the description statistics received from the switch
     * @param descriptionStatistics
     */
    public void setDescriptionStatistics(OFDescriptionStatistics descriptionStatistics);
}


text:
package net.sourceforge.jaad.mp4.boxes.impl;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import net.sourceforge.jaad.mp4.MP4InputStream;
import net.sourceforge.jaad.mp4.boxes.FullBox;

/**
 * The Progressive download information box aids the progressive download of an
 * ISO file. The box contains pairs of numbers (to the end of the box)
 * specifying combinations of effective file download bitrate in units of
 * bytes/sec and a suggested initial playback delay in units of milliseconds.
 *
 * The download rate can be estimated from the download rate and obtain an upper
 * estimate for a suitable initial delay by linear interpolation between pairs,
 * or by extrapolation from the first or last entry.
 * @author in-somnia
 */
public class ProgressiveDownloadInformationBox extends FullBox {

	private Map<Long, Long> pairs;

	public ProgressiveDownloadInformationBox() {
		super("Progressive Download Information Box");
		pairs = new HashMap<Long, Long>();
	}

	@Override
	public void decode(MP4InputStream in) throws IOException {
		super.decode(in);

		long rate, initialDelay;
		while(getLeft(in)>0) {
			rate = in.readBytes(4);
			initialDelay = in.readBytes(4);
			pairs.put(rate, initialDelay);
		}
	}

	/**
	 * The map contains pairs of bitrates and playback delay.
	 * @return the information pairs
	 */
	public Map<Long, Long> getInformationPairs() {
		return pairs;
	}
}


text:
package spec

import "encoding/json"

//go:generate go-bindata -pkg=spec -prefix=./schemas -ignore=.*\.md ./schemas/...
//go:generate perl -pi -e s,Json,JSON,g bindata.go

const (
	// SwaggerSchemaURL the url for the swagger 2.0 schema to validate specs
	SwaggerSchemaURL = "http://swagger.io/v2/schema.json#"
	// JSONSchemaURL the url for the json schema schema
	JSONSchemaURL = "http://json-schema.org/draft-04/schema#"
)

var (
	jsonSchema    = MustLoadJSONSchemaDraft04()
	swaggerSchema = MustLoadSwagger20Schema()
)

// MustLoadJSONSchemaDraft04 panics when Swagger20Schema returns an error
func MustLoadJSONSchemaDraft04() *Schema {
	d, e := JSONSchemaDraft04()
	if e != nil {
		panic(e)
	}
	return d
}

// JSONSchemaDraft04 loads the json schema document for json shema draft04
func JSONSchemaDraft04() (*Schema, error) {
	b, err := Asset("jsonschema-draft-04.json")
	if err != nil {
		return nil, err
	}

	schema := new(Schema)
	if err := json.Unmarshal(b, schema); err != nil {
		return nil, err
	}
	return schema, nil
}

// MustLoadSwagger20Schema panics when Swagger20Schema returns an error
func MustLoadSwagger20Schema() *Schema {
	d, e := Swagger20Schema()
	if e != nil {
		panic(e)
	}
	return d
}

// Swagger20Schema loads the swagger 2.0 schema from the embedded assets
func Swagger20Schema() (*Schema, error) {

	b, err := Asset("v2/schema.json")
	if err != nil {
		return nil, err
	}

	schema := new(Schema)
	if err := json.Unmarshal(b, schema); err != nil {
		return nil, err
	}
	return schema, nil
}


text:
'use strict';

var randu = require( '@stdlib/random/base/randu' );
var round = require( '@stdlib/math/base/special/round' );
var Uint16Array = require( '@stdlib/array/uint16' );
var MAX_UINT16 = require( '@stdlib/constants/uint16/max' );
var toBinaryString = require( './../lib' );

var x;
var y;
var b;
var i;

// Generate random unsigned 16-bit integers...
x = new Uint16Array( 100 );
for ( i = 0; i < x.length; i++ ) {
	x[ i ] = round( randu()*MAX_UINT16 );
}

// Convert unsigned 16-bit integers to literal bit representations...
for ( i = 0; i < x.length; i++ ) {
	b = toBinaryString( x[i] );
	y = parseInt( b, 2 );
	console.log( 'x: %d, b: %s, y: %d', x[i], b, y );
}


text:
<?php

namespace Application\Model;

use Application\System\CustomException;
use Application\System\Model;
use Application\System\Regex;

/**
 *  Express Model
 *
 * @category   VeXeCuaTui Project
 * @package    Application\Model
 * @author     Nam Vo <vhnam2504@gmail.com>
 * @copyright  Never Give Up Team
 * @license    Education
 */
class ExpressModel extends Model
{
    /**
     * Finding trip
     *
     * @param $from int
     * @param $to int
     * @param $date string
     * @return \Application\System\matrix|array|null
     */
    public function findTrip($from, $to, $date)
    {
        if (Regex::checkSqlInjection($from) && Regex::checkSqlInjection($to) && Regex::checkSqlInjection($date)) {
            $_date = \DateTime::createFromFormat('d/m/Y', $date);
            $date =  $_date->format('m/d/Y');
            $result = $this->more('usp_findTrip', array("$from", "$to", "'$date'"));
            if (empty($result)) {
                $result = array();
            }
        } else {
            $result = array();
        }

        return $result;
    }

    /**
     * Get Province Name
     *
     * @param $name string Province Id
     * @return bool|null|object
     */
    public function getName($name)
    {
        return $this->one('uf_getProvinceName', array("$name"));
    }

    /**
     * Get Trip information
     *
     * @param $trip string
     * @param $car string
     * @return \Application\System\matrix|null
     */
    public function getTripInfo($trip, $car)
    {
        return $this->more('usp_getTripInfo', array("'$trip'", "'$car'"));
    }

    /**
     * Book ticket(s)
     *
     * @param $id string
     * @param $tickets string
     * @param $route string
     * @param $car string
     * @throws CustomException
     * @throws \Exception
     */
    public function bookTickets($id, $tickets, $route, $car)
    {
        try {
            $this->non('usp_bookTickets', array("'$id'", "'$tickets,'", "'$route'", "'$car'"));
        } catch (CustomException $exception) {
            throw $exception;
        }
    }

    /**
     * Get Unpaid Ticket(s)
     *
     * @param $customer string
     * @throws CustomException
     * @throws \Exception
     * @return \Application\System\matrix|null
     */
    public function getUnpaidTickets($customer)
    {
        try {
            return $this->more('usp_getUnpaidTickets', array("'$customer'"));
        } catch (CustomException $exception) {
            throw $exception;
        }
    }

    /**
     * Get unpaid tickets by Car
     *
     * @param $customer string
     * @param $car string
     * @param $date_register string
     * @param $date_start string
     * @throws CustomException
     * @throws \Exception
     */
    public function getUnpaidTicketsByCar($customer, $car, $date_register, $date_start)
    {
        try {
            return $this->more('usp_getUnpaidTicketsByCar', array("'$customer'", "'$car'", "'$date_register'", "'$date_start'"));
        } catch (CustomException $exception) {
            throw $exception;
        }
    }

    /**
     * Remove booked ticket
     *
     * @param $ticket string
     * @param $car string
     * @param $route string
     * @param $seat string
     * @throws CustomException
     * @throws \Exception
     */
    public function removeTicket($ticket, $car, $route, $seat)
    {
        try {
            $this->non('usp_removeTicket', array("'$ticket'", "'$car'", "'$route'", "'$seat,'"));
        } catch (CustomException $exception) {
            throw $exception;
        }
    }

    /**
     * Pay
     * @param $tickets string
     * @throws CustomException
     * @throws \Exception
     */
    public function payment($tickets)
    {
        try {
            $this->non('usp_payment', array("'$tickets,'"));
        } catch (CustomException $exception) {
            throw $exception;
        }
    }

    /**
     * Cancelling all chosen tickets
     *
     * @param $customer string
     * @param $route string
     * @throws CustomException
     * @throws \Exception
     */
    public function cancel($customer, $route)
    {
        try {
            $this->non('usp_cancelTicket', array("'$customer'", "'$route'"));
        } catch (CustomException $exception) {
            throw $exception;
        }
    }

    /**
     * Cancel ticket
     *
     * @param $ticket string
     * @throws CustomException
     * @throws \Exception
     */
    public function cancelTicket($ticket)
    {
        try {
            $this->non('usp_cancelTicketCustomer', array("'$ticket'"));
        } catch (CustomException $exception) {
            throw $exception;
        }
    }

    /**
     * Payment ticket
     *
     * @param $ticket string
     * @throws CustomException
     * @throws \Exception
     */
    public function payTicket($ticket)
    {
        try {
            $this->non('usp_pay', array("'$ticket'"));
        } catch (CustomException $exception) {
            throw $exception;
        }
    }
}


text:
"""
Exposes regular shell commands as services.

For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/shell_command/
"""
import logging
import subprocess

import voluptuous as vol

import blumate.helpers.config_validation as cv

DOMAIN = 'shell_command'

_LOGGER = logging.getLogger(__name__)

CONFIG_SCHEMA = vol.Schema({
    DOMAIN: vol.Schema({
        cv.slug: cv.string,
    }),
}, extra=vol.ALLOW_EXTRA)

SHELL_COMMAND_SCHEMA = vol.Schema({})

def setup(hass, config):
    """Setup the shell_command component."""
    conf = config.get(DOMAIN, {})

    def service_handler(call):
        """Execute a shell command service."""
        try:
            subprocess.call(conf[call.service], shell=True,
                            stdout=subprocess.DEVNULL,
                            stderr=subprocess.DEVNULL)
        except subprocess.SubprocessError:
            _LOGGER.exception('Error running command')

    for name in conf.keys():
        hass.services.register(DOMAIN, name, service_handler,
                               schema=SHELL_COMMAND_SCHEMA)
    return True


text:
package experimento3D;
import java.awt.BorderLayout;
import javax.swing.JFrame;

public class InterfazPrincipal extends JFrame
{
	private static final long serialVersionUID=1L;
	private PanelComunicacion pc;
	private Panel3D pg;

	public static void main(String[] args)
	{
		new InterfazPrincipal();
	}

	public InterfazPrincipal()
	{
		setTitle("Juegos Geometria");
		setSize(600, 600);
		setLocationRelativeTo(null);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setLayout(new BorderLayout());

		pg=new Panel3D();
		pg.main();

		pc=new PanelComunicacion(this);
		add(pc, BorderLayout.CENTER);
		// Display the window.
		setVisible(true);
	}

	public void enviarCaracterLeido(char keyChar)
	{
		pg.procesarComando(keyChar);
	}

}


text:
require "spec_helper"

describe Mongoid::Versioning do

  before(:all) do
    WikiPage.delete_all
  end

  describe "#version" do

    let(:page) do
      WikiPage.new(:title => "1")
    end

    context "when the document is new" do

      it "defaults to 1" do
        page.version.should == 1
      end
    end

    context "after the document's first save" do

      before do
        page.save
      end

      it "returns 1" do
        page.version.should == 1
      end
    end

    context "when saving multiple times" do

      it "increments the version by 1" do
        3.times do |n|
          page.update_attribute(:title, "#{n}")
          page.version.should == n + 1
        end
      end
    end

    context "when skipping versioning" do

      it "does not version" do
        3.times do |n|
          page.versionless do |doc|
            doc.update_attribute(:title, "#{n}")
          end
        end
        page.version.should == 1
      end
    end
  end

  describe "#versions" do

    let(:page) do
      WikiPage.create(:title => "1")
    end

    context "when version is less than the maximum" do

      before do
        4.times do |n|
          page.title = "#{n + 2}"
          page.save
        end
      end

      let(:expected) do
        [ "1", "2", "3", "4" ]
      end

      it "retains all versions" do
        page.versions.size.should == 4
      end

      it "retains the correct values" do
        page.versions.map(&:title).should == expected
      end
    end

    context "when version is over the maximum" do

      before do
        7.times do |n|
          page.title = "#{n + 2}"
          page.save
        end
      end

      let(:expected) do
        [ "3", "4", "5", "6", "7" ]
      end

      context "when saving over the number of maximum versions" do

        context "when saving in succession" do

          before do
            10.times do |n|
              page.update_attribute(:title, "#{n}")
            end
          end

          let(:versions) do
            page.versions
          end

          it "only versions the maximum amount" do
            versions.count.should eq(5)
          end

          it "shifts the versions in order" do
            versions.last.title.should eq("8")
          end

          it "persists the version shifts" do
            page.reload.versions.last.title.should eq("8")
          end
        end

        context "when saving in batches" do

          before do
            2.times do
              5.times do |n|
                WikiPage.find(page.id).update_attributes(:title => "#{n}")
              end
            end
          end

          let(:from_db) do
            WikiPage.find(page.id)
          end

          let(:versions) do
            from_db.versions
          end

          it "only versions the maximum amount" do
            versions.count.should eq(5)
          end
        end
      end

      it "retains the set number of most recent versions" do
        page.versions.size.should == 5
      end

      it "retains the most recent values" do
        page.versions.map(&:title).should == expected
      end
    end

    context "when document is also paranoid" do
      let(:post) do
        ParanoidPost.create(:title => "1")
      end

      context "when version is over the maximum" do
        before do
          7.times do |n|
            post.title = "#{n + 2}"
            post.save
          end
        end

        let(:expected) do
          [ "3", "4", "5", "6", "7" ]
        end

        context "when saving over the number of maximum versions" do

          context "when saving in succession" do

            before do
              10.times do |n|
                post.update_attribute(:title, "#{n}")
              end
            end

            let(:versions) do
              post.versions
            end

            it "only versions the maximum amount" do
              versions.count.should eq(5)
            end

            it "shifts the versions in order" do
              versions.last.title.should eq("8")
            end

            it "persists the version shifts" do
              post.reload.versions.last.title.should eq("8")
            end
          end

          context "when saving in batches" do

            before do
              2.times do
                5.times do |n|
                  ParanoidPost.find(post.id).update_attributes(:title => "#{n}")
                end
              end
            end

            let(:from_db) do
              ParanoidPost.find(post.id)
            end

            let(:versions) do
              from_db.versions
            end

            it "only versions the maximum amount" do
              versions.count.should eq(5)
            end
          end
        end

        it "retains the set number of most recent versions" do
          post.versions.size.should == 5
        end

        it "retains the most recent values" do
          post.versions.map(&:title).should == expected
        end
      end
    end

    it "should not version versions attributes" do
      3.times do |n|
        page.title = "#{n + 2}"
        page.save
      end

      page.versions[1].versions.should == []
      page.versions[2].versions.should == []
    end
  end
end


text:
package generator.standard.nested_json.field_nesting_autocomplete;

import com.google.gson.annotations.SerializedName;
import gsonpath.annotation.AutoGsonAdapter;

@AutoGsonAdapter
public class TestFieldNestingAutocomplete {
    @SerializedName("Json1.")
    public int value1;
}


text:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>eternalFramework</artifactId>
        <groupId>io.github.eternalpro</groupId>
        <version>1.0.0-20150615</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>eternal-dao</artifactId>
    <packaging>jar</packaging>

    <name>eternal-dao</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>io.github.eternalpro</groupId>
            <artifactId>eternal-model</artifactId>
            <version>${project.version}</version>
        </dependency>
    </dependencies>
</project>


text:
module Gitlab
  class Logger < ::Logger
    def self.file_name
      file_name_noext + '.log'
    end

    def self.debug(message)
      build.debug(message)
    end

    def self.error(message)
      build.error(message)
    end

    def self.warn(message)
      build.warn(message)
    end

    def self.info(message)
      build.info(message)
    end

    def self.read_latest
      path = self.full_log_path

      return [] unless File.readable?(path)

      tail_output, _ = Gitlab::Popen.popen(%W(tail -n 2000 #{path}))
      tail_output.split("\n")
    end

    def self.build
      Gitlab::SafeRequestStore[self.cache_key] ||= new(self.full_log_path)
    end

    def self.full_log_path
      Rails.root.join("log", file_name)
    end

    def self.cache_key
      'logger:' + self.full_log_path.to_s
    end
  end
end


text:
"""
[9/10/2014] Challenge #179 [Intermediate] Roguelike - The traveller Game

https://www.reddit.com/r/dailyprogrammer/comments/2g1c80/9102014_challenge_179_intermediate_roguelike_the/

#Description:
So I was fooling around once with an idea to make a fun Rogue like game.
If you do not know what a Rogue Like is check out [Wikipedia Article] (http://en.wikipedia.org/wiki/Roguelike) on what
it is about.
I got this really weak start at just trying to generate a more graphical approach than ASCII text. If you want to see
my attempt. Check out my incomplete project [FORGE] (http://coderd00d.com/Forge/index.html)
For this challenge you will have to develop a character moving in a rogue like environment. So the design requirements.
* 1 Hero character who moves up/down/left/right in a box map.
* Map must have boundary elements to contain it -- Walls/Water/Moutains/Whatever you come up with
* Hero does not have to be a person. Could be a spaceship/sea creature/whatever - Just has to move up/down/left/right
on a 2-D map
* Map has to be 20x20. The boundary are some element which prevents passage like a wall, water or blackholes. Whatever
fits your theme.
* Your hero has 100 movement points. Each time they move up/down/left/right they lose 1 movement points. When they
reach 0 movement points the game ends.
* Random elements are generated in the room. Gold. Treasure. Plants. Towns. Caves. Whatever. When the hero reaches that
point they score a point. You must have 100 random elements.
* At the end of the game when your hero is out of movement. The score is based on how many elements you are able to
move to. The higher the score the better.
* Hero starts either in a fixed room spot or random spot. I leave it to you to decide.
#input:
Some keyboard/other method for moving a hero up/down/left/right and way to end the game like Q or Esc or whatever.
#output:
The 20x20 map with the hero updating if you can with moves. Show how much movement points you have and score.
At the end of the game show some final score box. Good luck and have fun.
#Example:
ASCII Map might look like this. (This is not 20x20 but yours will be 20x20)
* % = Wall
* $ = Random element
* @ = the hero
A simple dungeon.
     %%%%%%%%%%
     %..$.....%
     %......$.%
     %...@....%
     %....$...%
     %.$......%
     %%%%%%%%%%
     Move: 100
     Score: 0
#Creative Challenge:
This is a creative challenge. You can use ASCII graphics or bmp graphics or more. You can add more elements to this.
But regardless have fun trying to make this challenge work for you.
"""

def main():
    pass

if __name__ == "__main__":
    main()


text:
package me.model;

import static java.util.Arrays.asList;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;

import org.junit.Test;

public class ArpUnserializerTest {

  private ArpUnserializer subject = new ArpUnserializer();

  @Test
  public void testUnserializeSimpleArp() throws Exception {
    String arp = "a:1:{s:55:\"urn:mace:terena.org:attribute-def:schacHomeOrganization\";a:1:{i:0;s:1:\"*\";}";
    Collection<String> attributes = subject.unserialize(arp).get();
    assertEquals(asList("urn:mace:terena.org:attribute-def:schacHomeOrganization"), attributes);
  }

  @Test
  public void testUnserialize() throws Exception {
    String arp = "a:6:{s:49:\"urn:mace:dir:attribute-def:eduPersonPrincipalName\";a:1:{i:0;s:1:\"*\";}s:38:\"" +
        "urn:mace:dir:attribute-def:displayName\";a:1:{i:0;s:1:\"*\";}s:29:" +
        "\"urn:mace:dir:attribute-def:cn\";a:1:{i:0;s:1:\"*\";}s:31:" +
        "\"urn:mace:dir:attribute-def:mail\";a:1:{i:0;s:1:\"*\";}s:55:" +
        "\"urn:mace:terena.org:attribute-def:schacHomeOrganization\";a:1:{i:0;s:1:\"*\";}s:47:" +
        "\"urn:mace:dir:attribute-def:eduPersonAffiliation\";a:1:{i:0;s:1:\"*\";}}";
    Collection<String> attributes = subject.unserialize(arp).get();

      List<String> expected = asList(
          "urn:mace:dir:attribute-def:eduPersonPrincipalName",
          "urn:mace:dir:attribute-def:displayName",
          "urn:mace:dir:attribute-def:cn",
          "urn:mace:dir:attribute-def:mail",
          "urn:mace:terena.org:attribute-def:schacHomeOrganization",
          "urn:mace:dir:attribute-def:eduPersonAffiliation");

      Collections.sort(expected);
      List<String> sorted = new ArrayList<>(attributes);
      Collections.sort(sorted);
      assertEquals(expected, sorted);
  }

  @Test
  public void testNewArpStyle() throws Exception {
      String arp = "a:7:{s:46:\"urn:mace:dir:attribute-def:eduPersonTargetedID\";a:1:{i:0;a:1:{s:5:\"value\";s:1:\"*\";}}s:38:\"urn:mace:dir:attribute-def:displayName\";a:1:{i:0;a:1:{s:5:\"value\";s:1:\"*\";}}s:29:\"urn:mace:dir:attribute-def:cn\";a:1:{i:0;a:1:{s:5:\"value\";s:1:\"*\";}}s:29:\"urn:mace:dir:attribute-def:sn\";a:1:{i:0;a:1:{s:5:\"value\";s:1:\"*\";}}s:31:\"urn:mace:dir:attribute-def:mail\";a:1:{i:0;a:1:{s:5:\"value\";s:1:\"*\";}}s:47:\"urn:mace:dir:attribute-def:eduPersonAffiliation\";a:1:{i:0;a:1:{s:5:\"value\";s:1:\"*\";}}s:30:\"urn:mace:dir:attribute-def:uid\";a:1:{i:0;a:1:{s:5:\"value\";s:1:\"*\";}}}";
      Collection<String> attributes = subject.unserialize(arp).get();
      int size = attributes.size();

      Set<String> uniqueValues = new HashSet<>(attributes);
      assertEquals(size, uniqueValues.size());
  }

  @Test
  public void testUnserializeNullArp() throws Exception {
    Optional<Collection<String>> attributes = subject.unserialize(null);
    assertFalse(attributes.isPresent());
  }

  @Test
  public void testUnserializeEmptyArp() throws Exception {
    Collection<String> attributes = subject.unserialize(" ").get();
    assertEquals(0, attributes.size());
  }

  @Test
  public void testUnserializePhpNullArp() throws Exception {
    Optional<Collection<String>> attributes = subject.unserialize("N;");
    assertFalse(attributes.isPresent());
  }
}


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

namespace SeriousGameToolbox.Data.Parameters
{
    public class IntegerParameter : Parameter
    {
        protected int value;

        public override object GetValue()
        {
            return (object)value;
        }

        public IntegerParameter(string id, string caption, int current)
            : base(id, caption)
        {
            this.value = current;
        }

        public static implicit operator int(IntegerParameter p)
        {
            return p.value;
        }

        public override Parameter Clone()
        {
            return new IntegerParameter(this.Id, this.Caption, this.value);
        }

        public override bool Equals(Parameter other)
        {
            if (other == this)
            {
                return true;
            }

            if (!(other is IntegerParameter))
            {
                return false;
            }

            IntegerParameter otherAs = other as IntegerParameter;

            return (other.Id == Id && value == otherAs.value && other.Caption == Caption);
        }

        public void SetValue(int value)
        {
            this.value = value;
        }
    }
}


text:
/////////////////////////////////////////////////////////////////////////////
// Name:        src/gtk/webview_webkit.cpp
// Purpose:     GTK WebKit backend for web view component
// Author:      Marianne Gagnon, Robert Roebling
// Copyright:   (c) 2010 Marianne Gagnon, 1998 Robert Roebling
// Licence:     wxWindows licence
/////////////////////////////////////////////////////////////////////////////

// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"

#if wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT

#include "wx/stockitem.h"
#include "wx/gtk/webview_webkit.h"
#include "wx/gtk/control.h"
#include "wx/gtk/private.h"
#include "wx/filesys.h"
#include "wx/base64.h"
#include "wx/log.h"
#include <webkit/webkit.h>

// ----------------------------------------------------------------------------
// GTK callbacks
// ----------------------------------------------------------------------------

extern "C"
{

static void
wxgtk_webview_webkit_load_status(GtkWidget* widget,
                                 GParamSpec*,
                                 wxWebViewWebKit *webKitCtrl)
{
    wxString url = webKitCtrl->GetCurrentURL();

    WebKitLoadStatus status;
    g_object_get(G_OBJECT(widget), "load-status", &status, NULL);

    wxString target; // TODO: get target (if possible)

    if (status == WEBKIT_LOAD_FINISHED)
    {
        WebKitWebBackForwardList* hist = webkit_web_view_get_back_forward_list(WEBKIT_WEB_VIEW(widget));
        WebKitWebHistoryItem* item = webkit_web_back_forward_list_get_current_item(hist);
        //We have to check if we are actually storing history
        //If the item isn't added we add it ourselves, it isn't added otherwise
        //with a custom scheme.
        if(!item || (WEBKIT_IS_WEB_HISTORY_ITEM(item) &&
                     webkit_web_history_item_get_uri(item) != url))
        {
            WebKitWebHistoryItem*
                newitem = webkit_web_history_item_new_with_data
                          (
                            url.utf8_str(),
                            webKitCtrl->GetCurrentTitle().utf8_str()
                          );
            webkit_web_back_forward_list_add_item(hist, newitem);
        }

        webKitCtrl->m_busy = false;
        wxWebViewEvent event(wxEVT_WEBVIEW_LOADED,
                             webKitCtrl->GetId(),
                             url, target);

        if (webKitCtrl && webKitCtrl->GetEventHandler())
            webKitCtrl->GetEventHandler()->ProcessEvent(event);
    }
    else if (status ==  WEBKIT_LOAD_COMMITTED)
    {
        webKitCtrl->m_busy = true;
        wxWebViewEvent event(wxEVT_WEBVIEW_NAVIGATED,
                             webKitCtrl->GetId(),
                             url, target);

        if (webKitCtrl && webKitCtrl->GetEventHandler())
            webKitCtrl->GetEventHandler()->ProcessEvent(event);
    }
}

static gboolean
wxgtk_webview_webkit_navigation(WebKitWebView *,
                                WebKitWebFrame *frame,
                                WebKitNetworkRequest *request,
                                WebKitWebNavigationAction *,
                                WebKitWebPolicyDecision *policy_decision,
                                wxWebViewWebKit *webKitCtrl)
{
    const gchar* uri = webkit_network_request_get_uri(request);
    wxString target = webkit_web_frame_get_name (frame);

    //If m_creating is true then we are the result of a new window
    //and so we need to send the event and veto the load
    if(webKitCtrl->m_creating)
    {
        webKitCtrl->m_creating = false;
        wxWebViewEvent event(wxEVT_WEBVIEW_NEWWINDOW,
                             webKitCtrl->GetId(),
                             wxString(uri, wxConvUTF8),
                             target);

        if(webKitCtrl && webKitCtrl->GetEventHandler())
            webKitCtrl->GetEventHandler()->ProcessEvent(event);

        webkit_web_policy_decision_ignore(policy_decision);
        return TRUE;
    }

    if(webKitCtrl->m_guard)
    {
        webKitCtrl->m_guard = false;
        //We set this to make sure that we don't try to load the page again from
        //the resource request callback
        webKitCtrl->m_vfsurl = webkit_network_request_get_uri(request);
        webkit_web_policy_decision_use(policy_decision);
        return FALSE;
    }

    webKitCtrl->m_busy = true;

    wxWebViewEvent event(wxEVT_WEBVIEW_NAVIGATING,
                         webKitCtrl->GetId(),
                         wxString( uri, wxConvUTF8 ),
                         target);

    if (webKitCtrl && webKitCtrl->GetEventHandler())
        webKitCtrl->GetEventHandler()->ProcessEvent(event);

    if (!event.IsAllowed())
    {
        webKitCtrl->m_busy = false;
        webkit_web_policy_decision_ignore(policy_decision);
        return TRUE;
    }
    else
    {
        wxString wxuri = uri;
        wxSharedPtr<wxWebViewHandler> handler;
        wxVector<wxSharedPtr<wxWebViewHandler> > hanlders = webKitCtrl->GetHandlers();
        //We are not vetoed so see if we match one of the additional handlers
        for(wxVector<wxSharedPtr<wxWebViewHandler> >::iterator it = hanlders.begin();
            it != hanlders.end(); ++it)
        {
            if(wxuri.substr(0, (*it)->GetName().length()) == (*it)->GetName())
            {
                handler = (*it);
            }
        }
        //If we found a handler we can then use it to load the file directly
        //ourselves
        if(handler)
        {
            webKitCtrl->m_guard = true;
            wxFSFile* file = handler->GetFile(wxuri);
            if(file)
            {
                webKitCtrl->SetPage(*file->GetStream(), wxuri);
            }
            //We need to throw some sort of error here if file is NULL
            webkit_web_policy_decision_ignore(policy_decision);
            return TRUE;
        }
        return FALSE;
    }
}

static gboolean
wxgtk_webview_webkit_error(WebKitWebView*,
                           WebKitWebFrame*,
                           gchar *uri,
                           gpointer web_error,
                           wxWebViewWebKit* webKitWindow)
{
    webKitWindow->m_busy = false;
    wxWebViewNavigationError type = wxWEBVIEW_NAV_ERR_OTHER;

    GError* error = (GError*)web_error;
    wxString description(error->message, wxConvUTF8);

    if (strcmp(g_quark_to_string(error->domain), "soup_http_error_quark") == 0)
    {
        switch (error->code)
        {
            case SOUP_STATUS_CANCELLED:
                type = wxWEBVIEW_NAV_ERR_USER_CANCELLED;
                break;

            case SOUP_STATUS_CANT_RESOLVE:
            case SOUP_STATUS_NOT_FOUND:
                type = wxWEBVIEW_NAV_ERR_NOT_FOUND;
                break;

            case SOUP_STATUS_CANT_RESOLVE_PROXY:
            case SOUP_STATUS_CANT_CONNECT:
            case SOUP_STATUS_CANT_CONNECT_PROXY:
            case SOUP_STATUS_SSL_FAILED:
            case SOUP_STATUS_IO_ERROR:
                type = wxWEBVIEW_NAV_ERR_CONNECTION;
                break;

            case SOUP_STATUS_MALFORMED:
            //case SOUP_STATUS_TOO_MANY_REDIRECTS:
                type = wxWEBVIEW_NAV_ERR_REQUEST;
                break;

            //case SOUP_STATUS_NO_CONTENT:
            //case SOUP_STATUS_RESET_CONTENT:

            case SOUP_STATUS_BAD_REQUEST:
                type = wxWEBVIEW_NAV_ERR_REQUEST;
                break;

            case SOUP_STATUS_UNAUTHORIZED:
            case SOUP_STATUS_FORBIDDEN:
                type = wxWEBVIEW_NAV_ERR_AUTH;
                break;

            case SOUP_STATUS_METHOD_NOT_ALLOWED:
            case SOUP_STATUS_NOT_ACCEPTABLE:
                type = wxWEBVIEW_NAV_ERR_SECURITY;
                break;

            case SOUP_STATUS_PROXY_AUTHENTICATION_REQUIRED:
                type = wxWEBVIEW_NAV_ERR_AUTH;
                break;

            case SOUP_STATUS_REQUEST_TIMEOUT:
                type = wxWEBVIEW_NAV_ERR_CONNECTION;
                break;

            //case SOUP_STATUS_PAYMENT_REQUIRED:
            case SOUP_STATUS_REQUEST_ENTITY_TOO_LARGE:
            case SOUP_STATUS_REQUEST_URI_TOO_LONG:
            case SOUP_STATUS_UNSUPPORTED_MEDIA_TYPE:
                type = wxWEBVIEW_NAV_ERR_REQUEST;
                break;

            case SOUP_STATUS_BAD_GATEWAY:
            case SOUP_STATUS_SERVICE_UNAVAILABLE:
            case SOUP_STATUS_GATEWAY_TIMEOUT:
                type = wxWEBVIEW_NAV_ERR_CONNECTION;
                break;

            case SOUP_STATUS_HTTP_VERSION_NOT_SUPPORTED:
                type = wxWEBVIEW_NAV_ERR_REQUEST;
                break;
            //case SOUP_STATUS_INSUFFICIENT_STORAGE:
            //case SOUP_STATUS_NOT_EXTENDED:
        }
    }
    else if (strcmp(g_quark_to_string(error->domain),
                    "webkit-network-error-quark") == 0)
    {
        switch (error->code)
        {
            //WEBKIT_NETWORK_ERROR_FAILED:
            //WEBKIT_NETWORK_ERROR_TRANSPORT:

            case WEBKIT_NETWORK_ERROR_UNKNOWN_PROTOCOL:
                type = wxWEBVIEW_NAV_ERR_REQUEST;
                break;

            case WEBKIT_NETWORK_ERROR_CANCELLED:
                type = wxWEBVIEW_NAV_ERR_USER_CANCELLED;
                break;

            case WEBKIT_NETWORK_ERROR_FILE_DOES_NOT_EXIST:
                type = wxWEBVIEW_NAV_ERR_NOT_FOUND;
                break;
        }
    }
    else if (strcmp(g_quark_to_string(error->domain),
                    "webkit-policy-error-quark") == 0)
    {
        switch (error->code)
        {
            //case WEBKIT_POLICY_ERROR_FAILED:
            //case WEBKIT_POLICY_ERROR_CANNOT_SHOW_MIME_TYPE:
            //case WEBKIT_POLICY_ERROR_CANNOT_SHOW_URL:
            //case WEBKIT_POLICY_ERROR_FRAME_LOAD_INTERRUPTED_BY_POLICY_CHANGE:
            case WEBKIT_POLICY_ERROR_CANNOT_USE_RESTRICTED_PORT:
                type = wxWEBVIEW_NAV_ERR_SECURITY;
                break;
        }
    }
    /*
    webkit_plugin_error_quark
    else
    {
        printf("Error domain %s\n", g_quark_to_string(error->domain));
    }
    */

    wxWebViewEvent event(wxEVT_WEBVIEW_ERROR,
                         webKitWindow->GetId(),
                         uri, "");
    event.SetString(description);
    event.SetInt(type);

    if (webKitWindow && webKitWindow->GetEventHandler())
    {
        webKitWindow->GetEventHandler()->ProcessEvent(event);
    }

    return FALSE;
}

static gboolean
wxgtk_webview_webkit_new_window(WebKitWebView*,
                                WebKitWebFrame *frame,
                                WebKitNetworkRequest *request,
                                WebKitWebNavigationAction*,
                                WebKitWebPolicyDecision *policy_decision,
                                wxWebViewWebKit *webKitCtrl)
{
    const gchar* uri = webkit_network_request_get_uri(request);

    wxString target = webkit_web_frame_get_name (frame);
    wxWebViewEvent event(wxEVT_WEBVIEW_NEWWINDOW,
                                       webKitCtrl->GetId(),
                                       wxString( uri, wxConvUTF8 ),
                                       target);

    if (webKitCtrl && webKitCtrl->GetEventHandler())
        webKitCtrl->GetEventHandler()->ProcessEvent(event);

    //We always want the user to handle this themselves
    webkit_web_policy_decision_ignore(policy_decision);
    return TRUE;
}

static void
wxgtk_webview_webkit_title_changed(WebKitWebView*,
                                   WebKitWebFrame*,
                                   gchar *title,
                                   wxWebViewWebKit *webKitCtrl)
{
    wxWebViewEvent event(wxEVT_WEBVIEW_TITLE_CHANGED,
                         webKitCtrl->GetId(),
                         webKitCtrl->GetCurrentURL(),
                         "");
    event.SetString(wxString(title, wxConvUTF8));

    if (webKitCtrl && webKitCtrl->GetEventHandler())
        webKitCtrl->GetEventHandler()->ProcessEvent(event);

}

static void
wxgtk_webview_webkit_resource_req(WebKitWebView *,
                                  WebKitWebFrame *,
                                  WebKitWebResource *,
                                  WebKitNetworkRequest *request,
                                  WebKitNetworkResponse *,
                                  wxWebViewWebKit *webKitCtrl)
{
    wxString uri = webkit_network_request_get_uri(request);

    wxSharedPtr<wxWebViewHandler> handler;
    wxVector<wxSharedPtr<wxWebViewHandler> > hanlders = webKitCtrl->GetHandlers();

    //We are not vetoed so see if we match one of the additional handlers
    for(wxVector<wxSharedPtr<wxWebViewHandler> >::iterator it = hanlders.begin();
        it != hanlders.end(); ++it)
    {
        if(uri.substr(0, (*it)->GetName().length()) == (*it)->GetName())
        {
            handler = (*it);
        }
    }
    //If we found a handler we can then use it to load the file directly
    //ourselves
    if(handler)
    {
        //If it is requsting the page itself then return as we have already
        //loaded it from the archive
        if(webKitCtrl->m_vfsurl == uri)
            return;

        wxFSFile* file = handler->GetFile(uri);
        if(file)
        {
            //We load the data into a data url to save it being written out again
            size_t size = file->GetStream()->GetLength();
            char *buffer = new char[size];
            file->GetStream()->Read(buffer, size);
            wxString data = wxBase64Encode(buffer, size);
            delete[] buffer;
            wxString mime = file->GetMimeType();
            wxString path = "data:" + mime + ";base64," + data;
            //Then we can redirect the call
            webkit_network_request_set_uri(request, path.utf8_str());
        }

    }
}

#if WEBKIT_CHECK_VERSION(1, 10, 0)

static gboolean
wxgtk_webview_webkit_context_menu(WebKitWebView *,
                                  GtkWidget *,
                                  WebKitHitTestResult *,
                                  gboolean,
                                  wxWebViewWebKit *webKitCtrl)
{
    if(webKitCtrl->IsContextMenuEnabled())
        return FALSE;
    else
        return TRUE;
}

#endif

static WebKitWebView*
wxgtk_webview_webkit_create_webview(WebKitWebView *web_view,
                                    WebKitWebFrame*,
                                    wxWebViewWebKit *webKitCtrl)
{
    //As we do not know the uri being loaded at this point allow the load to
    //continue and catch it in navigation-policy-decision-requested
    webKitCtrl->m_creating = true;
    return web_view;
}

} // extern "C"

//-----------------------------------------------------------------------------
// wxWebViewWebKit
//-----------------------------------------------------------------------------

wxIMPLEMENT_DYNAMIC_CLASS(wxWebViewWebKit, wxWebView);

wxWebViewWebKit::wxWebViewWebKit()
{
    m_web_view = NULL;
}

bool wxWebViewWebKit::Create(wxWindow *parent,
                      wxWindowID id,
                      const wxString &url,
                      const wxPoint& pos,
                      const wxSize& size,
                      long style,
                      const wxString& name)
{
    m_busy = false;
    m_guard = false;
    m_creating = false;
    FindClear();

    // We currently unconditionally impose scrolling in both directions as it's
    // necessary to show arbitrary pages.
    style |= wxHSCROLL | wxVSCROLL;

    if (!PreCreation( parent, pos, size ) ||
        !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
    {
        wxFAIL_MSG( wxT("wxWebViewWebKit creation failed") );
        return false;
    }

    m_web_view = WEBKIT_WEB_VIEW(webkit_web_view_new());
    GTKCreateScrolledWindowWith(GTK_WIDGET(m_web_view));
    g_object_ref(m_widget);

    g_signal_connect_after(m_web_view, "navigation-policy-decision-requested",
                           G_CALLBACK(wxgtk_webview_webkit_navigation),
                           this);
    g_signal_connect_after(m_web_view, "load-error",
                           G_CALLBACK(wxgtk_webview_webkit_error),
                           this);

    g_signal_connect_after(m_web_view, "new-window-policy-decision-requested",
                           G_CALLBACK(wxgtk_webview_webkit_new_window), this);

    g_signal_connect_after(m_web_view, "title-changed",
                           G_CALLBACK(wxgtk_webview_webkit_title_changed), this);

    g_signal_connect_after(m_web_view, "resource-request-starting",
                           G_CALLBACK(wxgtk_webview_webkit_resource_req), this);

#if WEBKIT_CHECK_VERSION(1, 10, 0)
     g_signal_connect_after(m_web_view, "context-menu",
                           G_CALLBACK(wxgtk_webview_webkit_context_menu), this);
#endif

     g_signal_connect_after(m_web_view, "create-web-view",
                           G_CALLBACK(wxgtk_webview_webkit_create_webview), this);

    m_parent->DoAddChild( this );

    PostCreation(size);

    /* Open a webpage */
    webkit_web_view_load_uri(m_web_view, url.utf8_str());

    //Get the initial history limit so we can enable and disable it later
    WebKitWebBackForwardList* history;
    history = webkit_web_view_get_back_forward_list(m_web_view);
    m_historyLimit = webkit_web_back_forward_list_get_limit(history);

    // last to avoid getting signal too early
    g_signal_connect_after(m_web_view, "notify::load-status",
                           G_CALLBACK(wxgtk_webview_webkit_load_status),
                           this);

    return true;
}

wxWebViewWebKit::~wxWebViewWebKit()
{
    if (m_web_view)
        GTKDisconnect(m_web_view);
}

bool wxWebViewWebKit::Enable( bool enable )
{
    if (!wxControl::Enable(enable))
        return false;

    gtk_widget_set_sensitive(gtk_bin_get_child(GTK_BIN(m_widget)), enable);

    //if (enable)
    //    GTKFixSensitivity();

    return true;
}

GdkWindow*
wxWebViewWebKit::GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const
{
    GdkWindow* window = gtk_widget_get_parent_window(m_widget);
    return window;
}

void wxWebViewWebKit::ZoomIn()
{
    webkit_web_view_zoom_in(m_web_view);
}

void wxWebViewWebKit::ZoomOut()
{
    webkit_web_view_zoom_out(m_web_view);
}

void wxWebViewWebKit::SetWebkitZoom(float level)
{
    webkit_web_view_set_zoom_level(m_web_view, level);
}

float wxWebViewWebKit::GetWebkitZoom() const
{
    return webkit_web_view_get_zoom_level(m_web_view);
}

void wxWebViewWebKit::Stop()
{
     webkit_web_view_stop_loading(m_web_view);
}

void wxWebViewWebKit::Reload(wxWebViewReloadFlags flags)
{
    if (flags & wxWEBVIEW_RELOAD_NO_CACHE)
    {
        webkit_web_view_reload_bypass_cache(m_web_view);
    }
    else
    {
        webkit_web_view_reload(m_web_view);
    }
}

void wxWebViewWebKit::LoadURL(const wxString& url)
{
    webkit_web_view_load_uri(m_web_view, wxGTK_CONV(url));
}

void wxWebViewWebKit::GoBack()
{
    webkit_web_view_go_back(m_web_view);
}

void wxWebViewWebKit::GoForward()
{
    webkit_web_view_go_forward(m_web_view);
}

bool wxWebViewWebKit::CanGoBack() const
{
    return webkit_web_view_can_go_back(m_web_view);
}

bool wxWebViewWebKit::CanGoForward() const
{
    return webkit_web_view_can_go_forward(m_web_view);
}

void wxWebViewWebKit::ClearHistory()
{
    WebKitWebBackForwardList* history;
    history = webkit_web_view_get_back_forward_list(m_web_view);
    webkit_web_back_forward_list_clear(history);
}

void wxWebViewWebKit::EnableHistory(bool enable)
{
    WebKitWebBackForwardList* history;
    history = webkit_web_view_get_back_forward_list(m_web_view);
    if(enable)
    {
        webkit_web_back_forward_list_set_limit(history, m_historyLimit);
    }
    else
    {
        webkit_web_back_forward_list_set_limit(history, 0);
    }
}

wxVector<wxSharedPtr<wxWebViewHistoryItem> > wxWebViewWebKit::GetBackwardHistory()
{
    wxVector<wxSharedPtr<wxWebViewHistoryItem> > backhist;
    WebKitWebBackForwardList* history;
    history = webkit_web_view_get_back_forward_list(m_web_view);
    GList* list = webkit_web_back_forward_list_get_back_list_with_limit(history,
                                                                        m_historyLimit);
    //We need to iterate in reverse to get the order we desire
    for(int i = g_list_length(list) - 1; i >= 0 ; i--)
    {
        WebKitWebHistoryItem* gtkitem = (WebKitWebHistoryItem*)g_list_nth_data(list, i);
        wxWebViewHistoryItem* wxitem = new wxWebViewHistoryItem(
                                   webkit_web_history_item_get_uri(gtkitem),
                                   webkit_web_history_item_get_title(gtkitem));
        wxitem->m_histItem = gtkitem;
        wxSharedPtr<wxWebViewHistoryItem> item(wxitem);
        backhist.push_back(item);
    }
    return backhist;
}

wxVector<wxSharedPtr<wxWebViewHistoryItem> > wxWebViewWebKit::GetForwardHistory()
{
    wxVector<wxSharedPtr<wxWebViewHistoryItem> > forwardhist;
    WebKitWebBackForwardList* history;
    history = webkit_web_view_get_back_forward_list(m_web_view);
    GList* list = webkit_web_back_forward_list_get_forward_list_with_limit(history,
                                                                           m_historyLimit);
    for(guint i = 0; i < g_list_length(list); i++)
    {
        WebKitWebHistoryItem* gtkitem = (WebKitWebHistoryItem*)g_list_nth_data(list, i);
        wxWebViewHistoryItem* wxitem = new wxWebViewHistoryItem(
                                   webkit_web_history_item_get_uri(gtkitem),
                                   webkit_web_history_item_get_title(gtkitem));
        wxitem->m_histItem = gtkitem;
        wxSharedPtr<wxWebViewHistoryItem> item(wxitem);
        forwardhist.push_back(item);
    }
    return forwardhist;
}

void wxWebViewWebKit::LoadHistoryItem(wxSharedPtr<wxWebViewHistoryItem> item)
{
    WebKitWebHistoryItem* gtkitem = (WebKitWebHistoryItem*)item->m_histItem;
    if(gtkitem)
    {
        webkit_web_view_go_to_back_forward_item(m_web_view,
                                                WEBKIT_WEB_HISTORY_ITEM(gtkitem));
    }
}

bool wxWebViewWebKit::CanCut() const
{
    return webkit_web_view_can_cut_clipboard(m_web_view);
}

bool wxWebViewWebKit::CanCopy() const
{
    return webkit_web_view_can_copy_clipboard(m_web_view);
}

bool wxWebViewWebKit::CanPaste() const
{
    return webkit_web_view_can_paste_clipboard(m_web_view);
}

void wxWebViewWebKit::Cut()
{
    webkit_web_view_cut_clipboard(m_web_view);
}

void wxWebViewWebKit::Copy()
{
    webkit_web_view_copy_clipboard(m_web_view);
}

void wxWebViewWebKit::Paste()
{
    webkit_web_view_paste_clipboard(m_web_view);
}

bool wxWebViewWebKit::CanUndo() const
{
    return webkit_web_view_can_undo(m_web_view);
}

bool wxWebViewWebKit::CanRedo() const
{
    return webkit_web_view_can_redo(m_web_view);
}

void wxWebViewWebKit::Undo()
{
    webkit_web_view_undo(m_web_view);
}

void wxWebViewWebKit::Redo()
{
    webkit_web_view_redo(m_web_view);
}

wxString wxWebViewWebKit::GetCurrentURL() const
{
    // FIXME: check which encoding the web kit control uses instead of
    // assuming UTF8 (here and elsewhere too)
    return wxString::FromUTF8(webkit_web_view_get_uri(m_web_view));
}

wxString wxWebViewWebKit::GetCurrentTitle() const
{
    return wxString::FromUTF8(webkit_web_view_get_title(m_web_view));
}

wxString wxWebViewWebKit::GetPageSource() const
{
    WebKitWebFrame* frame = webkit_web_view_get_main_frame(m_web_view);
    WebKitWebDataSource* src = webkit_web_frame_get_data_source (frame);

    // TODO: check encoding with
    // const gchar*
    // webkit_web_data_source_get_encoding(WebKitWebDataSource *data_source);
    return wxString(webkit_web_data_source_get_data (src)->str, wxConvUTF8);
}

wxWebViewZoom wxWebViewWebKit::GetZoom() const
{
    float zoom = GetWebkitZoom();

    // arbitrary way to map float zoom to our common zoom enum
    if (zoom <= 0.65)
    {
        return wxWEBVIEW_ZOOM_TINY;
    }
    else if (zoom > 0.65 && zoom <= 0.90)
    {
        return wxWEBVIEW_ZOOM_SMALL;
    }
    else if (zoom > 0.90 && zoom <= 1.15)
    {
        return wxWEBVIEW_ZOOM_MEDIUM;
    }
    else if (zoom > 1.15 && zoom <= 1.45)
    {
        return wxWEBVIEW_ZOOM_LARGE;
    }
    else if (zoom > 1.45)
    {
        return wxWEBVIEW_ZOOM_LARGEST;
    }

    // to shut up compilers, this can never be reached logically
    wxFAIL;
    return wxWEBVIEW_ZOOM_MEDIUM;
}

void wxWebViewWebKit::SetZoom(wxWebViewZoom zoom)
{
    // arbitrary way to map our common zoom enum to float zoom
    switch (zoom)
    {
        case wxWEBVIEW_ZOOM_TINY:
            SetWebkitZoom(0.6f);
            break;

        case wxWEBVIEW_ZOOM_SMALL:
            SetWebkitZoom(0.8f);
            break;

        case wxWEBVIEW_ZOOM_MEDIUM:
            SetWebkitZoom(1.0f);
            break;

        case wxWEBVIEW_ZOOM_LARGE:
            SetWebkitZoom(1.3);
            break;

        case wxWEBVIEW_ZOOM_LARGEST:
            SetWebkitZoom(1.6);
            break;

        default:
            wxFAIL;
    }
}

void wxWebViewWebKit::SetZoomType(wxWebViewZoomType type)
{
    webkit_web_view_set_full_content_zoom(m_web_view,
                                          (type == wxWEBVIEW_ZOOM_TYPE_LAYOUT ?
                                          TRUE : FALSE));
}

wxWebViewZoomType wxWebViewWebKit::GetZoomType() const
{
    gboolean fczoom = webkit_web_view_get_full_content_zoom(m_web_view);

    if (fczoom) return wxWEBVIEW_ZOOM_TYPE_LAYOUT;
    else        return wxWEBVIEW_ZOOM_TYPE_TEXT;
}

bool wxWebViewWebKit::CanSetZoomType(wxWebViewZoomType) const
{
    // this port supports all zoom types
    return true;
}

void wxWebViewWebKit::DoSetPage(const wxString& html, const wxString& baseUri)
{
    webkit_web_view_load_string (m_web_view,
                                 html.mb_str(wxConvUTF8),
                                 "text/html",
                                 "UTF-8",
                                 baseUri.mb_str(wxConvUTF8));
}

void wxWebViewWebKit::Print()
{
    WebKitWebFrame* frame = webkit_web_view_get_main_frame(m_web_view);
    webkit_web_frame_print (frame);

    // GtkPrintOperationResult  webkit_web_frame_print_full
    //      (WebKitWebFrame *frame,
    //       GtkPrintOperation *operation,
    //       GtkPrintOperationAction action,
    //       GError **error);

}

bool wxWebViewWebKit::IsBusy() const
{
    return m_busy;

    // This code looks nice but returns true after a page was cancelled
    /*
    WebKitLoadStatus status = webkit_web_view_get_load_status
            (WEBKIT_WEB_VIEW(web_view));

#if WEBKIT_CHECK_VERSION(1,1,16)
    // WEBKIT_LOAD_FAILED is new in webkit 1.1.16
    if (status == WEBKIT_LOAD_FAILED)
    {
        return false;
    }
#endif
    if (status == WEBKIT_LOAD_FINISHED)
    {
        return false;
    }

    return true;
     */
}

void wxWebViewWebKit::SetEditable(bool enable)
{
    webkit_web_view_set_editable(m_web_view, enable);
}

bool wxWebViewWebKit::IsEditable() const
{
    return webkit_web_view_get_editable(m_web_view);
}

void wxWebViewWebKit::DeleteSelection()
{
    webkit_web_view_delete_selection(m_web_view);
}

bool wxWebViewWebKit::HasSelection() const
{
    return webkit_web_view_has_selection(m_web_view);
}

void wxWebViewWebKit::SelectAll()
{
    webkit_web_view_select_all(m_web_view);
}

wxString wxWebViewWebKit::GetSelectedText() const
{
    WebKitDOMDocument* doc;
    WebKitDOMDOMWindow* win;
    WebKitDOMDOMSelection* sel;
    WebKitDOMRange* range;

    doc = webkit_web_view_get_dom_document(m_web_view);
    win = webkit_dom_document_get_default_view(WEBKIT_DOM_DOCUMENT(doc));
    sel = webkit_dom_dom_window_get_selection(WEBKIT_DOM_DOM_WINDOW(win));
    range = webkit_dom_dom_selection_get_range_at(WEBKIT_DOM_DOM_SELECTION(sel),
                                                  0, NULL);
    return wxString(webkit_dom_range_get_text(WEBKIT_DOM_RANGE(range)),
                    wxConvUTF8);
}

wxString wxWebViewWebKit::GetSelectedSource() const
{
    WebKitDOMDocument* doc;
    WebKitDOMDOMWindow* win;
    WebKitDOMDOMSelection* sel;
    WebKitDOMRange* range;
    WebKitDOMElement* div;
    WebKitDOMDocumentFragment* clone;
    WebKitDOMHTMLElement* html;

    doc = webkit_web_view_get_dom_document(m_web_view);
    win = webkit_dom_document_get_default_view(WEBKIT_DOM_DOCUMENT(doc));
    sel = webkit_dom_dom_window_get_selection(WEBKIT_DOM_DOM_WINDOW(win));
    range = webkit_dom_dom_selection_get_range_at(WEBKIT_DOM_DOM_SELECTION(sel),
                                                  0, NULL);
    div = webkit_dom_document_create_element(WEBKIT_DOM_DOCUMENT(doc), "div", NULL);

    clone = webkit_dom_range_clone_contents(WEBKIT_DOM_RANGE(range), NULL);
    webkit_dom_node_append_child(&div->parent_instance, &clone->parent_instance, NULL);
    html = (WebKitDOMHTMLElement*)div;

    return wxString(webkit_dom_html_element_get_inner_html(WEBKIT_DOM_HTML_ELEMENT(html)),
                    wxConvUTF8);
}

void wxWebViewWebKit::ClearSelection()
{
    WebKitDOMDocument* doc;
    WebKitDOMDOMWindow* win;
    WebKitDOMDOMSelection* sel;

    doc = webkit_web_view_get_dom_document(m_web_view);
    win = webkit_dom_document_get_default_view(WEBKIT_DOM_DOCUMENT(doc));
    sel = webkit_dom_dom_window_get_selection(WEBKIT_DOM_DOM_WINDOW(win));
    webkit_dom_dom_selection_remove_all_ranges(WEBKIT_DOM_DOM_SELECTION(sel));

}

wxString wxWebViewWebKit::GetPageText() const
{
    WebKitDOMDocument* doc;
    WebKitDOMHTMLElement* body;

    doc = webkit_web_view_get_dom_document(m_web_view);
    body = webkit_dom_document_get_body(WEBKIT_DOM_DOCUMENT(doc));
    return wxString(webkit_dom_html_element_get_inner_text(WEBKIT_DOM_HTML_ELEMENT(body)),
                    wxConvUTF8);
}

void wxWebViewWebKit::RunScript(const wxString& javascript)
{
    webkit_web_view_execute_script(m_web_view,
                                   javascript.mb_str(wxConvUTF8));
}

void wxWebViewWebKit::RegisterHandler(wxSharedPtr<wxWebViewHandler> handler)
{
    m_handlerList.push_back(handler);
}

void wxWebViewWebKit::EnableContextMenu(bool enable)
{
#if !WEBKIT_CHECK_VERSION(1, 10, 0) //If we are using an older version
    g_object_set(webkit_web_view_get_settings(m_web_view),
                 "enable-default-context-menu", enable, NULL);
#endif
    wxWebView::EnableContextMenu(enable);
}

long wxWebViewWebKit::Find(const wxString& text, int flags)
{
    bool newSearch = false;
    if(text != m_findText ||
       (flags & wxWEBVIEW_FIND_MATCH_CASE) != (m_findFlags & wxWEBVIEW_FIND_MATCH_CASE))
    {
        newSearch = true;
        //If it is a new search we need to clear existing highlights
        webkit_web_view_unmark_text_matches(m_web_view);
        webkit_web_view_set_highlight_text_matches(m_web_view, false);
    }

    m_findFlags = flags;
    m_findText = text;

    //If the search string is empty then we clear any selection and highlight
    if(text == "")
    {
        webkit_web_view_unmark_text_matches(m_web_view);
        webkit_web_view_set_highlight_text_matches(m_web_view, false);
        ClearSelection();
        return wxNOT_FOUND;
    }

    bool wrap = false, matchCase = false, forward = true;
    if(flags & wxWEBVIEW_FIND_WRAP)
        wrap = true;
    if(flags & wxWEBVIEW_FIND_MATCH_CASE)
        matchCase = true;
    if(flags & wxWEBVIEW_FIND_BACKWARDS)
        forward = false;

    if(newSearch)
    {
        //Initially we mark the matches to know how many we have
        m_findCount = webkit_web_view_mark_text_matches(m_web_view, wxGTK_CONV(text), matchCase, 0);
        //In this case we return early to match IE behaviour
        m_findPosition = -1;
        return m_findCount;
    }
    else
    {
        if(forward)
            m_findPosition++;
        else
            m_findPosition--;
        if(m_findPosition < 0)
            m_findPosition += m_findCount;
        if(m_findPosition > m_findCount)
            m_findPosition -= m_findCount;
    }

    //Highlight them if needed
    bool highlight = flags & wxWEBVIEW_FIND_HIGHLIGHT_RESULT ? true : false;
    webkit_web_view_set_highlight_text_matches(m_web_view, highlight);

    if(!webkit_web_view_search_text(m_web_view, wxGTK_CONV(text), matchCase, forward, wrap))
    {
        m_findPosition = -1;
        ClearSelection();
        return wxNOT_FOUND;
    }
    wxLogMessage(wxString::Format("Returning %d", m_findPosition));
    return newSearch ? m_findCount : m_findPosition;
}

void wxWebViewWebKit::FindClear()
{
    m_findCount = 0;
    m_findFlags = 0;
    m_findText = "";
    m_findPosition = -1;
}

// static
wxVisualAttributes
wxWebViewWebKit::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
{
     return GetDefaultAttributesFromGTKWidget(webkit_web_view_new());
}

#endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT


text:
name "qless_server"
description "Node that runs the job queue for distributing crawling and parsing tasks"
run_list "recipe[apt]","recipe[build-essential]","recipe[git]","recipe[qless]","recipe[chef-client]"


text:
$:.unshift File.expand_path '../../lib/deck-of-cards', __FILE__

require 'card'
require 'version'

class DeckOfCards
  attr_reader :cards

  SUITS = %w[Hearts Spades Diamonds Clubs]
  RANKS = [*2..10, 'Jack', 'Queen', 'King', 'Ace']

  def initialize
    @cards = []
    SUITS.product(RANKS) { |suit, rank| @cards << Card.new(rank, suit) }
  end

  def to_s
    "#{@cards.count}-card deck."
  end

  def shuffle
    @cards.shuffle!
  end

  def cut
    @cards.rotate! @cards.count / 2
  end

  alias split cut

  def draw
    @cards.shift
  end
end


text:
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
 * Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/licenses/publicdomain/
 * Contributor: Blake Kaplan
 */

//-----------------------------------------------------------------------------
var BUGNUMBER = 565521;
var summary = 'for-each getter calling';
var actual = '';
var expect = 'PASS';

//-----------------------------------------------------------------------------
test();
//-----------------------------------------------------------------------------

function test()
{
  enterFunc ('test');
  printBugNumber(BUGNUMBER);
  printStatus (summary);

  var proto = { get prop() { return (this === proto) ? "FAIL" : "PASS"; } };
  var obj = Object.create(proto);

  var itercount = 0;
  for each (var i in obj) {
      ++itercount;
      actual = i;
  }

  reportCompare(itercount, 1, summary + ': right itercount')
  reportCompare(expect, actual, summary + ': right value');

  exitFunc ('test');
}


text:
package com.netsteadfast.greenstep.action.utils;

import org.apache.commons.lang3.StringUtils;

import com.netsteadfast.greenstep.base.Constants;
import com.netsteadfast.greenstep.base.exception.ControllerException;
import com.netsteadfast.greenstep.base.model.IActionFieldsCheckUtils;

public class SysProgUrlFieldCheckUtils implements IActionFieldsCheckUtils {
	private static final String[] _STRs = { Constants._S2_ACTION_EXTENSION, ".do", ".htm", ".html", ".jsp", ".xhtml", ".jsf", ".groovy", ".gsf" };

	@Override
	public boolean check(String value) throws ControllerException {
		if (StringUtils.isBlank(value)) {
			return true;
		}
		if ( value.indexOf(Constants._COMMON_LOAD_FORM_ACTION)>-1 && value.indexOf("form_id")>-1 && value.indexOf("form_method")>-1 ) { // common form
			return true;
		}
		boolean f = false;
		for (String str : _STRs) {
			if ( value.endsWith(str) ) {
				f = true;
			}
		}
		return f;
		/*
		return ( value.endsWith(Constants._S2_ACTION_EXTENSION)
				|| value.toLowerCase().endsWith(".htm")
				|| value.toLowerCase().endsWith(".html")
				|| value.endsWith(".jsp") );
		*/
	}

}


text:
namespace cit.utilities
{
    static class Constants
    {
        public static string Version = "0.0.1";
        public static string DefaultEnvName = "default";
    }
}


text:
package org.batfish.datamodel.routing_policy.communities;

import static com.google.common.base.MoreObjects.firstNonNull;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

/**
 * A {@link CommunitySetExpr} representing the union of the sets represented by its constituent
 * expressions.
 */
public final class CommunitySetUnion extends CommunitySetExpr {

  public static @Nonnull CommunitySetUnion of(CommunitySetExpr... exprs) {
    return of(Arrays.asList(exprs));
  }

  public static @Nonnull CommunitySetUnion of(Iterable<CommunitySetExpr> exprs) {
    return new CommunitySetUnion(ImmutableSet.copyOf(exprs));
  }

  @Override
  public <T, U> T accept(CommunitySetExprVisitor<T, U> visitor, U arg) {
    return visitor.visitCommunitySetUnion(this, arg);
  }

  @JsonIgnore
  public @Nonnull Set<CommunitySetExpr> getExprs() {
    return _exprs;
  }

  @Override
  public boolean equals(@Nullable Object obj) {
    if (this == obj) {
      return true;
    }
    if (!(obj instanceof CommunitySetUnion)) {
      return false;
    }
    CommunitySetUnion rhs = (CommunitySetUnion) obj;
    return _exprs.equals(rhs._exprs);
  }

  @Override
  public int hashCode() {
    return _exprs.hashCode();
  }

  private static final String PROP_EXPRS = "exprs";

  @JsonCreator
  private static @Nonnull CommunitySetUnion create(
      @JsonProperty(PROP_EXPRS) @Nullable Iterable<CommunitySetExpr> exprs) {
    return new CommunitySetUnion(ImmutableSet.copyOf(firstNonNull(exprs, ImmutableSet.of())));
  }

  private CommunitySetUnion(Set<CommunitySetExpr> exprs) {
    _exprs = exprs;
  }

  @JsonProperty(PROP_EXPRS)
  private @Nonnull List<CommunitySetExpr> getExprsList() {
    return ImmutableList.copyOf(_exprs);
  }

  private final @Nonnull Set<CommunitySetExpr> _exprs;
}


text:
/*
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
 */
package com.ocs.dynamo.importer.impl;

import static java.lang.Float.valueOf;

import java.beans.PropertyDescriptor;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;

import org.springframework.beans.BeanUtils;
import org.springframework.util.StringUtils;

import com.ocs.dynamo.exception.OCSImportException;
import com.ocs.dynamo.importer.ImportField;
import com.ocs.dynamo.importer.dto.AbstractDTO;
import com.ocs.dynamo.utils.ClassUtils;
import com.ocs.dynamo.utils.NumberUtils;

/**
 * Base class for smart upload functionality
 *
 * @author bas.rutten
 * @param <R> the type of a single row
 * @param <U> the type of a single cell or field
 */
public abstract class BaseImporter<R, U> {

	private static final double PERCENTAGE_FACTOR = 100.;

	/**
	 * Counts the number of rows in the input. This method will count all rows,
	 * including the header, and will not check if any of the rows are valid
	 *
	 * @param bytes the byte representation of the input file
	 * @param index the index of the sheet (if appropriate)
	 * @return
	 */
	public abstract int countRows(byte[] bytes, int sheetIndex);

	/**
	 * Retrieves a boolean value from the input and falls back to a default if the
	 * value is empty or not defined
	 *
	 * @param unit  the unit of data value to process
	 * @param field the field definition
	 * @return
	 */
	protected abstract Boolean getBooleanValueWithDefault(U unit, ImportField field);

	/**
	 * Retrieves a date value from the input and falls back to a default if the
	 * value is empty or not defined
	 *
	 * @param unit  the unit of data to process
	 * @param field the field definition
	 * @return
	 */
	protected abstract LocalDate getDateValueWithDefault(U unit, ImportField field);

	/**
	 * Retrieves a value from a unit of data
	 *
	 * @param d     the property descriptor that tells the process the type of the
	 *              value to retrieve
	 * @param unit  the unit of data to process
	 * @param field the field definition
	 * @return
	 */
	@SuppressWarnings("unchecked")
	protected Object getFieldValue(PropertyDescriptor d, U unit, ImportField field) {
		Object obj = null;
		if (String.class.equals(d.getPropertyType())) {
			String value = getStringValueWithDefault(unit, field);
			if (value != null) {
				value = value.trim();
			}
			obj = StringUtils.isEmpty(value) ? null : value;
		} else if (d.getPropertyType().isEnum()) {
			String value = getStringValueWithDefault(unit, field);
			if (value != null) {
				value = value.trim();
				try {
					@SuppressWarnings("rawtypes")
					Class<? extends Enum> enumType = d.getPropertyType().asSubclass(Enum.class);
					obj = Enum.valueOf(enumType, value.toUpperCase());
				} catch (IllegalArgumentException ex) {
					throw new OCSImportException("Value " + value + " cannot be translated to an enumeration value",
							ex);
				}
			}
		} else if (isNumeric(d.getPropertyType())) {
			// numeric field
			Double value = getNumericValueWithDefault(unit, field);
			if (value != null) {

				// if the field represents a percentage but it is
				// received as a
				// fraction, we multiply it by 100
				if (field.percentage() && isPercentageCorrectionSupported()) {
					value = PERCENTAGE_FACTOR * value;
				}

				// illegal negative value
				if (field.cannotBeNegative() && value < 0.0) {
					throw new OCSImportException("Negative value " + value + " found for field '" + d.getName() + "'");
				}

				// round to the nearest integer, then use intValue() or longValue()
				BigDecimal rounded = BigDecimal.valueOf(value).setScale(0, RoundingMode.HALF_UP);
				Class<?> pType = d.getPropertyType();
				if (NumberUtils.isInteger(pType)) {
					obj = rounded.intValue();
				} else if (NumberUtils.isLong(pType)) {
					obj = rounded.longValue();
				} else if (NumberUtils.isFloat(pType)) {
					obj = valueOf(value.floatValue());
				} else if (NumberUtils.isDouble(pType)) {
					obj = value;
				} else if (BigDecimal.class.equals(pType)) {
					obj = BigDecimal.valueOf(value);
				}
			}
		} else if (Boolean.class.isAssignableFrom(d.getPropertyType())) {
			return getBooleanValueWithDefault(unit, field);
		} else if (LocalDate.class.isAssignableFrom(d.getPropertyType())) {
			return getDateValueWithDefault(unit, field);
		}
		return obj;
	}

	/**
	 * Retrieves a numeric value from an input unit and falls back to a default if
	 * the value is empty or not defined
	 *
	 * @param unit  the input unit
	 * @param field the field definition
	 * @return
	 */
	protected abstract Double getNumericValueWithDefault(U unit, ImportField field);

	/**
	 * Retrieves a string from the input and falls back to a default if the value is
	 * empty or not defined
	 *
	 * @param unit  the input unit
	 * @param field the field definition
	 * @return
	 */
	protected abstract String getStringValueWithDefault(U unit, ImportField field);

	/**
	 * Retrieves a unit (a single cell or field) from a row
	 *
	 * @param row   the row
	 * @param field the field definition
	 * @return
	 */
	protected abstract U getUnit(R row, ImportField field);

	/**
	 * Check if the class is a numeric class
	 *
	 * @param clazz the class to check
	 * @return
	 */
	private boolean isNumeric(Class<?> clazz) {
		return Number.class.isAssignableFrom(clazz) || int.class.equals(clazz) || long.class.equals(clazz)
				|| double.class.equals(clazz) || float.class.equals(clazz);
	}

	/**
	 * Indicates whether fraction values are automatically converted to percentages
	 *
	 * @return
	 */
	public abstract boolean isPercentageCorrectionSupported();

	/**
	 * Checks whether a field index is within the range of available columns
	 *
	 * @param row   the row to check
	 * @param field the field definition
	 * @return
	 */
	protected abstract boolean isWithinRange(R row, ImportField field);

	/**
	 * Processes a single row from the input and turns it into an object
	 *
	 * @param rowNum the row number
	 * @param row    the row
	 * @param clazz  the class of the object that must be created
	 * @return
	 */
	public <T extends AbstractDTO> T processRow(int rowNum, R row, Class<T> clazz) {
		T t = ClassUtils.instantiateClass(clazz);
		t.setRowNum(rowNum);

		PropertyDescriptor[] descriptors = BeanUtils.getPropertyDescriptors(clazz);
		for (PropertyDescriptor d : descriptors) {
			ImportField field = ClassUtils.getAnnotation(clazz, d.getName(), ImportField.class);
			if (field != null) {
				if (isWithinRange(row, field)) {
					U unit = getUnit(row, field);

					Object obj = getFieldValue(d, unit, field);
					if (obj != null) {
						ClassUtils.setFieldValue(t, d.getName(), obj);
					} else if (field.required()) {
						// a required value is missing!
						throw new OCSImportException("Required value for field '" + d.getName() + "' is missing");
					}
				} else {
					throw new OCSImportException("Row doesn't have enough columns");
				}
			}
		}
		return t;
	}
}