text:
package com.swfarm.biz.wish.bo.wishapi;

import java.lang.reflect.Field;
import java.util.LinkedHashMap;
import java.util.Map;

import javax.xml.bind.annotation.XmlElement;

import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;

public class RetrieveTicketUrlBuilder {

	private static final Logger logger = Logger
			.getLogger(RetrieveTicketUrlBuilder.class);

	public static final String URL = "https://merchant.wish.com/api/v2/ticket";

	private RetrieveTicketParam param;

	public RetrieveTicketUrlBuilder(RetrieveTicketParam p) {
		this.param = p;
	}

	public String build() {
		StringBuffer b = new StringBuffer();
		int i = 0;
		for (Field f : RetrieveTicketParam.class.getDeclaredFields()) {
			f.setAccessible(true);

			XmlElement xe = f.getAnnotation(XmlElement.class);
			String name = xe.name();
			if ("##default".equals(name)) {
				name = f.getName();
			}
			try {
				Object value = f.get(param);
				if (i++ == 0) {
					b.append('?');
				} else {
					b.append('&');
				}
				b.append(name).append('=').append(null == value ? "" : value);
			} catch (IllegalArgumentException e) {
				logger.warn(e);
			} catch (IllegalAccessException e) {
				logger.warn(e);
			}
		}
		return b.toString();
	}

	public Map<String, String> buildMap() {
		Map<String, String> map = new LinkedHashMap<String, String>();
		for (Field f : RetrieveTicketParam.class.getDeclaredFields()) {
			f.setAccessible(true);
			XmlElement xe = f.getAnnotation(XmlElement.class);
			String name = xe.name();
			if ("##default".equals(name)) {
				name = f.getName();
			}
			try {
				Object value = f.get(param);
				if (null != value) {
					String tmp = value.toString();
					if (StringUtils.isNotBlank(tmp)) {
						map.put(name, tmp);
					}
				}
			} catch (IllegalArgumentException e) {
				logger.warn(e);
			} catch (IllegalAccessException e) {
				logger.warn(e);
			}
		}
		return map;
	}

}


text:
ACCEPTED

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

#### Published in
Mycol. Writ. 7: 1179 (1923)

#### Original name
Cordyceps sinclairii Berk., 1855

### Remarks
null

redpajama_set_name: RedPajamaGithub


text:
namespace System.Data.Entity.Hooks.Test.Stubs
{
    internal class DbHookContextStub : DbHookContext, IDbContext
    {
        private static string _connectionId;

        public DbHookContextStub()
            : base(Effort.DbConnectionFactory.CreatePersistent(_connectionId), true)
        {
        }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Entity<FooEntityStub>().HasKey(stub => stub.Id);
            base.OnModelCreating(modelBuilder);
        }

        public DbSet<FooEntityStub> Foos { get; set; }

        public static void ResetConnections()
        {
            _connectionId = Guid.NewGuid().ToString();
        }

        public void AddLoadHook(IDbHook dbHook)
        {
            RegisterLoadHook(dbHook);
        }

        public void AddPreSaveHook(IDbHook dbHook)
        {
            RegisterPreSaveHook(dbHook);
        }

        public void AddPostSaveHook(IDbHook dbHook)
        {
            RegisterPostSaveHook(dbHook);
        }
    }
}


text:
---
title: CSS Trick
layout: post
---

# Horizontal Centering Span that are absolute
once absolutely positioned, it no longer follows the document flow. So the text is centered, but only inside the pink span.
And since it's absolutely positioned, even if it were a div, the width would collapse.

```
solution
span
{
    background-color:pink;
    left: 0;  /*<-*/
    width: 100%;  /*<-*/
}
```

> If you don't want the pink to extend the full width, then you must nest an element (e.g. span) inside the positioned spans and give that element the background color, as seen here.


text:
CATALINA_OPTS="$CATALINA_OPTS -XX:+PrintCommandLineFlags"

# Prevent "Unrecognized Name" SSL warning
CATALINA_OPTS="$CATALINA_OPTS -Djsse.enableSNIExtension=false"

# We need to send a 'portal.home' system property to the JVM;  use the value of PORTAL_HOME, if
# present, or fall back to a value calculated from $CATALINA_BASE
[ -z "$PORTAL_HOME" ] && PORTAL_HOME="$CATALINA_BASE/portal"
echo "PORTAL_HOME=$PORTAL_HOME"
CATALINA_OPTS="$CATALINA_OPTS -Dportal.home=$PORTAL_HOME"

CATALINA_OPTS="$CATALINA_OPTS  -Djava.net.preferIPv4Stack=true -Djava.net.preferIPv4Addresses -Djava.net.preferIPv6Addresses=false"

# Checking if anyother garbage collectors have been defined. If no other garbage
# collector is present, default to G1GC
# List of options taken from:
# http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/gc01/index.html
echo $CATALINA_OPTS | grep -e '-XX:+UseSerialGC' -e '-XX:+UseParallelGC' -e '-XX:ParallelGCThreads' -e '-XX:+UseParallelOldGC' -e '-XX:+UseConcMarkSweepGC' -e '-XX:+UseParNewGC' -e '-XX:+CMSParallelRemarkEnabled' -e '-XX:CMSInitiatingOccupancyFraction' -e '-XX:+UseCMSInitiatingOccupancyOnly' -e '-XX:+UseG1GC'
if [ $? -eq 1 ]
then
    CATALINA_OPTS="$CATALINA_OPTS -XX:+UseG1GC"
fi

# Check to see if heap space allocation has been set
# If there are already set values, leave them be
echo $CATALINA_OPTS | grep -e '-Xms'
if [ $? -eq 1 ]
then
    CATALINA_OPTS="$CATALINA_OPTS -Xms64m"
fi

echo $CATALINA_OPTS | grep -e '-Xmx'
if [ $? -eq 1 ]
then
    CATALINA_OPTS="$CATALINA_OPTS -Xmx512m"
fi


text:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SimShift.Dialogs
{
    public partial class dlTwitchDashboard : Form
    {
        private ucDashboard dsh;

        public dlTwitchDashboard()
        {
            InitializeComponent();
            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);

            var updateUi = new Timer();
            updateUi.Interval = 20;
            updateUi.Tick += new EventHandler(updateUi_Tick);
            updateUi.Start();
            dsh = new ucDashboard(Color.FromArgb(5, 5, 5));
            dsh.Dock = DockStyle.Fill;
            Controls.Add(dsh);

            this.StartPosition = FormStartPosition.CenterScreen;
        }

        void updateUi_Tick(object sender, EventArgs e)
        {
            dsh.Invalidate();

        }

    }
}


text:
package codechicken.nei.config;

import codechicken.lib.config.ConfigTag;
import codechicken.nei.config.GuiOptionList.OptionScrollSlot;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;

import java.util.List;

public abstract class Option
{
    public static void playClickSound() {
        Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F));
    }

    public OptionScrollSlot slot;

    public String namespace = null;
    public final String name;
    public OptionList parent;

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

    public String fullName() {
        return namespaced(name);
    }

    public String configName() {
        return fullName().substring(configBase().fullName().length() + 1);
    }

    public String namespaced(String name) {
        return namespace == null ? name : (namespace + "." + name);
    }

    public String translateN(String s, Object... args) {
        return StatCollector.translateToLocalFormatted(namespaced(s), args);
    }

    public int getHeight() {
        return 20;
    }

    private <T> T assertParentOverride(T elem) {
        if(elem == null) throw new IllegalStateException("Option "+fullName()+" does not have a defined parent list. Use OptionList.setOptionList to insert a parent");
        return elem;
    }

    public ConfigSet globalConfigSet() {
        return assertParentOverride(parent.globalConfigSet());
    }

    public ConfigSet worldConfigSet() {
        return assertParentOverride(parent.worldConfigSet());
    }

    public OptionList configBase() {
        return assertParentOverride(parent.configBase());
    }

    /**
     * @return true if the world config contains a tag with this name
     */
    public boolean worldSpecific() {
        return worldSpecific(configName());
    }

    /**
     * @return true if the world config contains a tag with this name
     */
    public boolean worldSpecific(String s) {
        ConfigTag tag = worldConfigSet().config.getTag(s, false);
        return tag != null && tag.value != null;
    }

    /**
     * @return The currently config set for the gui based on the world/global button
     */
    public ConfigSet configSet() {
        return worldConfig() ? worldConfigSet() : globalConfigSet();
    }

    /**
     * @return The tag to render, world if world override, otherwise global
     */
    public ConfigTag renderTag() {
        return renderTag(configName());
    }

    /**
     * @return The tag to render, world if world override, otherwise global
     */
    public ConfigTag renderTag(String s) {
        return (worldConfig() && worldSpecific(s) ? worldConfigSet() : globalConfigSet()).config.getTag(s);
    }

    /**
     * @return The tag with this name from the current configSet
     */
    public ConfigTag getTag() {
        return getTag(configName());
    }

    /**
     * @return The tag with this name from the current configSet
     */
    public ConfigTag getTag(String s) {
        return configSet().config.getTag(s);
    }

    /**
     * @return The tag currently being used ingame, world if a world override exists, otherwise global
     */
    public ConfigTag activeTag() {
        return activeTag(configName());
    }

    /**
     * @return The tag currently being used ingame, world if a world override exists, otherwise global
     */
    public ConfigTag activeTag(String s) {
        return (worldSpecific() ? worldConfigSet() : globalConfigSet()).config.getTag(s);
    }

    /**
     * @return true if the gui is in world config mode
     */
    public boolean worldConfig() {
        return slot.getGui().worldConfig();
    }

    /**
     * @return true if in world mode, but this tag has no world override. Changes should not be made in this mode
     */
    public boolean defaulting() {
        return defaulting(configName());
    }

    /**
     * @return true if in world mode, but this tag has no world override. Changes should not be made in this mode
     */
    public boolean defaulting(String s) {
        return worldConfig() && !worldSpecific(s);
    }

    /**
     * Called when world specific is disabled for this option. Should delete all world specific overrides
     */
    public void useGlobals() {
        useGlobal(configName());
    }

    /**
     * Deletes a specific named tag from the worldConfig
     */
    public void useGlobal(String s) {
        if (worldConfig())
            worldConfigSet().config.removeTag(s);
    }

    /**
     * Called when world specific is activated for this option. Should copy the global value into a world specific override
     */
    public void copyGlobals() {
        copyGlobal(configName(), true);
    }

    /**
     * Copies the global value into a world specific override
     */
    public void copyGlobal(String s) {
        copyGlobal(s, false);
    }

    public void copyGlobal(String s, boolean recursive) {
        if (!worldConfig())
            return;

        ConfigTag tag = globalConfigSet().config.getTag(s);
        worldConfigSet().config.getTag(s).setValue(tag.getValue());
        if(recursive)
            for(String s2 : tag.childTagMap().keySet())
                copyGlobal(s+"."+s2);
    }

    public void onAdded(OptionScrollSlot slot) {
        this.slot = slot;
    }

    public void onAdded(OptionList list) {
        parent = list;
    }

    /**
     * Mouse coordinates are relative to screen
     */
    public void onMouseClicked(int mx, int my, int button) {
    }

    public void mouseClicked(int mx, int my, int button) {
    }

    public void update() {
    }

    public void draw(int mx, int my, float frame) {
    }

    public void keyTyped(char c, int keycode) {
    }

    public List<String> handleTooltip(int mx, int my, List<String> currenttip) {
        return currenttip;
    }

    public boolean showWorldSelector() {
        return true;
    }

    public boolean hasWorldOverride() {
        return worldSpecific();
    }
}


text:
title := CardFlippingGame
all: $(title).class

$(title).class: *.java
	javac *.java

again:
	javac *.java

edit:
	emacs $(title).java

run: $(title).class
	java $(title)


text:
<?php

namespace ntentan;

abstract class AbstractMiddleware
{

    /**
     * The instance of the pipeline runner currently running.
     * @var PipelineRunner
     */
    private $runner;
    private $parameters;

    abstract public function run($route, $response);

    public function setRunner(PipelineRunner $runner)
    {
        $this->runner = $runner;
    }

    public function setParameters($parameters)
    {
        $this->parameters = Parameters::wrap($parameters);
    }

    protected function next($response)
    {
        return $this->runner->runMiddleware($response);
    }

    protected function getParameters()
    {
        return $this->parameters;
    }
}


text:
#ifndef _LIBGETTEXT_H
#define _LIBGETTEXT_H 1

/* NLS can be disabled through the configure --disable-nls option
   or through "#define ENABLE NLS 0" before including this file.  */
#if defined ENABLE_NLS && ENABLE_NLS

/* Get declarations of GNU message catalog functions.  */
# include <libintl.h>

/* You can set the DEFAULT_TEXT_DOMAIN macro to specify the domain used by
   the gettext() and ngettext() macros.  This is an alternative to calling
   textdomain(), and is useful for libraries.  */
# ifdef DEFAULT_TEXT_DOMAIN
#  undef gettext
#  define gettext(Msgid) \
     dgettext (DEFAULT_TEXT_DOMAIN, Msgid)
#  undef ngettext
#  define ngettext(Msgid1, Msgid2, N) \
     dngettext (DEFAULT_TEXT_DOMAIN, Msgid1, Msgid2, N)
# endif

#else

/* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which
   chokes if dcgettext is defined as a macro.  So include it now, to make
   later inclusions of <locale.h> a NOP.  We don't include <libintl.h>
   as well because people using "gettext.h" will not include <libintl.h>,
   and also including <libintl.h> would fail on SunOS 4, whereas <locale.h>
   is OK.  */
#if defined(__sun)
# include <locale.h>
#endif

/* Many header files from the libstdc++ coming with g++ 3.3 or newer include
   <libintl.h>, which chokes if dcgettext is defined as a macro.  So include
   it now, to make later inclusions of <libintl.h> a NOP.  */
#if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3)
# include <cstdlib>
# if (__GLIBC__ >= 2 && !defined __UCLIBC__) || _GLIBCXX_HAVE_LIBINTL_H
#  include <libintl.h>
# endif
#endif

/* Disabled NLS.
   The casts to 'const char *' serve the purpose of producing warnings
   for invalid uses of the value returned from these functions.
   On pre-ANSI systems without 'const', the config.h file is supposed to
   contain "#define const".  */
# undef gettext
# define gettext(Msgid) ((const char *) (Msgid))
# undef dgettext
# define dgettext(Domainname, Msgid) ((void) (Domainname), gettext (Msgid))
# undef dcgettext
# define dcgettext(Domainname, Msgid, Category) \
    ((void) (Category), dgettext (Domainname, Msgid))
# undef ngettext
# define ngettext(Msgid1, Msgid2, N) \
    ((N) == 1 \
     ? ((void) (Msgid2), (const char *) (Msgid1)) \
     : ((void) (Msgid1), (const char *) (Msgid2)))
# undef dngettext
# define dngettext(Domainname, Msgid1, Msgid2, N) \
    ((void) (Domainname), ngettext (Msgid1, Msgid2, N))
# undef dcngettext
# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
    ((void) (Category), dngettext (Domainname, Msgid1, Msgid2, N))
# undef textdomain
# define textdomain(Domainname) ((const char *) (Domainname))
# undef bindtextdomain
# define bindtextdomain(Domainname, Dirname) \
    ((void) (Domainname), (const char *) (Dirname))
# undef bind_textdomain_codeset
# define bind_textdomain_codeset(Domainname, Codeset) \
    ((void) (Domainname), (const char *) (Codeset))

#endif

/* Prefer gnulib's setlocale override over libintl's setlocale override.  */
#ifdef GNULIB_defined_setlocale
# undef setlocale
# define setlocale rpl_setlocale
#endif

/* A pseudo function call that serves as a marker for the automated
   extraction of messages, but does not call gettext().  The run-time
   translation is done at a different place in the code.
   The argument, String, should be a literal string.  Concatenated strings
   and other string expressions won't work.
   The macro's expansion is not parenthesized, so that it is suitable as
   initializer for static 'char[]' or 'const char[]' variables.  */
#define gettext_noop(String) String

/* The separator between msgctxt and msgid in a .mo file.  */
#define GETTEXT_CONTEXT_GLUE "\004"

/* Pseudo function calls, taking a MSGCTXT and a MSGID instead of just a
   MSGID.  MSGCTXT and MSGID must be string literals.  MSGCTXT should be
   short and rarely need to change.
   The letter 'p' stands for 'particular' or 'special'.  */
#ifdef DEFAULT_TEXT_DOMAIN
# define pgettext(Msgctxt, Msgid) \
   pgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
#else
# define pgettext(Msgctxt, Msgid) \
   pgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
#endif
#define dpgettext(Domainname, Msgctxt, Msgid) \
  pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
#define dcpgettext(Domainname, Msgctxt, Msgid, Category) \
  pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, Category)
#ifdef DEFAULT_TEXT_DOMAIN
# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
   npgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
#else
# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
   npgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
#endif
#define dnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
  npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
#define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \
  npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category)

#ifdef __GNUC__
__inline
#else
#ifdef __cplusplus
inline
#endif
#endif
static const char *
pgettext_aux (const char *domain,
              const char *msg_ctxt_id, const char *msgid,
              int category)
{
  const char *translation = dcgettext (domain, msg_ctxt_id, category);
  if (translation == msg_ctxt_id)
    return msgid;
  else
    return translation;
}

#ifdef __GNUC__
__inline
#else
#ifdef __cplusplus
inline
#endif
#endif
static const char *
npgettext_aux (const char *domain,
               const char *msg_ctxt_id, const char *msgid,
               const char *msgid_plural, unsigned long int n,
               int category)
{
  const char *translation =
    dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
  if (translation == msg_ctxt_id || translation == msgid_plural)
    return (n == 1 ? msgid : msgid_plural);
  else
    return translation;
}

/* The same thing extended for non-constant arguments.  Here MSGCTXT and MSGID
   can be arbitrary expressions.  But for string literals these macros are
   less efficient than those above.  */

#include <string.h>

/* GNULIB_NO_VLA can be defined to disable use of VLAs even if supported.
   This relates to the -Wvla and -Wvla-larger-than warnings, enabled in
   the default GCC many warnings set.  This allows programs to disable use
   of VLAs, which may be unintended, or may be awkward to support portably,
   or may have security implications due to non-deterministic stack usage.  */

#if (!defined GNULIB_NO_VLA \
     && (((__GNUC__ >= 3 || __GNUG__ >= 2) && !defined __STRICT_ANSI__) \
     /*  || (__STDC_VERSION__ == 199901L && !defined __HP_cc)
         || (__STDC_VERSION__ >= 201112L && !defined __STDC_NO_VLA__) */ ))
# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 1
#else
# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 0
#endif

#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
#include <stdlib.h>
#endif

#define pgettext_expr(Msgctxt, Msgid) \
  dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES)
#define dpgettext_expr(Domainname, Msgctxt, Msgid) \
  dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES)

#ifdef __GNUC__
__inline
#else
#ifdef __cplusplus
inline
#endif
#endif
static const char *
dcpgettext_expr (const char *domain,
                 const char *msgctxt, const char *msgid,
                 int category)
{
  size_t msgctxt_len = strlen (msgctxt) + 1;
  size_t msgid_len = strlen (msgid) + 1;
  const char *translation;
#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
  char msg_ctxt_id[msgctxt_len + msgid_len];
#else
  char buf[1024];
  char *msg_ctxt_id =
    (msgctxt_len + msgid_len <= sizeof (buf)
     ? buf
     : (char *) malloc (msgctxt_len + msgid_len));
  if (msg_ctxt_id != NULL)
#endif
    {
      int found_translation;
      memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
      msg_ctxt_id[msgctxt_len - 1] = '\004';
      memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
      translation = dcgettext (domain, msg_ctxt_id, category);
      found_translation = (translation != msg_ctxt_id);
#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
      if (msg_ctxt_id != buf)
        free (msg_ctxt_id);
#endif
      if (found_translation)
        return translation;
    }
  return msgid;
}

#define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \
  dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
#define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
  dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)

#ifdef __GNUC__
__inline
#else
#ifdef __cplusplus
inline
#endif
#endif
static const char *
dcnpgettext_expr (const char *domain,
                  const char *msgctxt, const char *msgid,
                  const char *msgid_plural, unsigned long int n,
                  int category)
{
  size_t msgctxt_len = strlen (msgctxt) + 1;
  size_t msgid_len = strlen (msgid) + 1;
  const char *translation;
#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
  char msg_ctxt_id[msgctxt_len + msgid_len];
#else
  char buf[1024];
  char *msg_ctxt_id =
    (msgctxt_len + msgid_len <= sizeof (buf)
     ? buf
     : (char *) malloc (msgctxt_len + msgid_len));
  if (msg_ctxt_id != NULL)
#endif
    {
      int found_translation;
      memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
      msg_ctxt_id[msgctxt_len - 1] = '\004';
      memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
      translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
      found_translation = !(translation == msg_ctxt_id || translation == msgid_plural);
#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
      if (msg_ctxt_id != buf)
        free (msg_ctxt_id);
#endif
      if (found_translation)
        return translation;
    }
  return (n == 1 ? msgid : msgid_plural);
}

#endif /* _LIBGETTEXT_H */


text:
require 'spec_helper'

describe ApplicationHelper do

  it "renders html from an xml string" do
    example_xml = File.expand_path("../../support/example.xml", __FILE__)
    plist = File.read example_xml
    helper.render_xml_as_html(plist).should eq("<?xml version="1.0" encoding="UTF-8"?>
<content>
  <name>Sample</name>
  <subcontent>
    <name>Sub-Sample-1</name>
    <name>Sub-Sample-2</name>
  </subcontent>
</content>")
  end

end


text:
cr.define('cloudprint', function() {
  function printTestPage() {
    chrome.send('PrintTestPage', ['']);
    chrome.send('DialogClose', ['']);
  }

  function setMessage(msg) {
    $('msgContent').innerHTML = msg;
  }

  function onPageShown() {
    $('close').focus();
  }

  return {
    printTestPage: printTestPage,
    setMessage: setMessage,
    onPageShown: onPageShown
  };
});


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">
  <modelVersion>4.0.0</modelVersion>

  <name>Flowable - Rest</name>
  <artifactId>flowable-webapp-rest2</artifactId>
  <packaging>war</packaging>

  <parent>
    <groupId>org.flowable</groupId>
    <artifactId>flowable-root</artifactId>
    <relativePath>../..</relativePath>
    <version>6.0.0.RC1-SNAPSHOT</version>
  </parent>

  <build>
    <plugins>
      <plugin>
        <groupId>org.zeroturnaround</groupId>
        <artifactId>jrebel-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>generate-rebel-xml</id>
            <phase>process-resources</phase>
            <goals>
              <goal>generate</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
	    <groupId>org.apache.tomcat.maven</groupId>
        <artifactId>tomcat7-maven-plugin</artifactId>
		<configuration>
		  <port>8080</port>
		  <path>/flowable-rest</path>
		  <systemProperties>
		    <com.sun.management.jmxremote.port>4000</com.sun.management.jmxremote.port>
          </systemProperties>
		</configuration>
      </plugin>
    </plugins>
    <pluginManagement>
      <plugins>
        <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
        <plugin>
          <groupId>org.eclipse.m2e</groupId>
          <artifactId>lifecycle-mapping</artifactId>
          <version>1.0.0</version>
          <configuration>
            <lifecycleMappingMetadata>
              <pluginExecutions>
                <pluginExecution>
                  <pluginExecutionFilter>
                    <groupId>
                      org.zeroturnaround
                    </groupId>
                    <artifactId>
                      jrebel-maven-plugin
                    </artifactId>
                    <versionRange>
                      [1.0.7,)
                    </versionRange>
                    <goals>
                      <goal>generate</goal>
                    </goals>
                  </pluginExecutionFilter>
                  <action>
                    <ignore></ignore>
                  </action>
                </pluginExecution>
              </pluginExecutions>
            </lifecycleMappingMetadata>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

  <profiles>
    <profile>
	  <id>buildExecutableWar</id>
	    <build>
		  <plugins>
            <plugin>
              <groupId>org.apache.tomcat.maven</groupId>
			  <artifactId>tomcat7-maven-plugin</artifactId>
			  <version>2.1</version>
			  <configuration>
			    <path>/</path>
			  </configuration>
			  <executions>
			    <execution>
				  <id>tomcat-run</id>
				  <goals>
				    <goal>exec-war-only</goal>
				  </goals>
				  <phase>package</phase>
				  <configuration>
                    <path>/flowable-rest</path>
                  </configuration>
				</execution>
			  </executions>
			</plugin>
		  </plugins>
	  </build>
    </profile>
    <profile>
      <id>swagger</id>
      <build>
        <plugins>
          <plugin>
            <groupId>com.github.kongchen</groupId>
            <artifactId>swagger-maven-plugin</artifactId>
            <version>3.1.4</version>
            <configuration>
              <apiSources>
                <!-- ++++++++++ -->
                <!-- FORMS -->
                <!-- ++++++++++ -->
                <apiSource>
                  <springmvc>true</springmvc>
                  <locations>
                    <location>org.activiti.rest.service.api.form</location>
                  </locations>
                  <schemes>
                    <scheme>http</scheme>
                    <scheme>https</scheme>
                  </schemes>
                  <host>localhost:8080</host>
                  <basePath>/flowable-rest/service</basePath>
                  <info>
                    <title>Flowable REST API</title>
                    <version>v1</version>
                    <contact>
                      <email></email>
                      <name>Flowable</name>
                      <url>http://www.flowable.org/</url>
                    </contact>
                    <license>
                      <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
                      <name>Apache 2.0</name>
                    </license>
                  </info>
                  <securityDefinitions>
                    <securityDefinition>
                      <name>basicAuth</name>
                      <type>basic</type>
                    </securityDefinition>
                  </securityDefinitions>
                  <descriptionFile>${basedir}/src/main/resources/swagger/info.txt</descriptionFile>
                  <outputFormats>json,yaml</outputFormats>
                  <swaggerFileName>flowable-forms</swaggerFileName>
                  <swaggerDirectory>${basedir}/src/main/webapp/docs/specfile/forms</swaggerDirectory>
                </apiSource>
                <!-- ++++++++++ -->
                <!-- HISTORY -->
                <!-- ++++++++++ -->
                <apiSource>
                  <springmvc>true</springmvc>
                  <locations>
                    <location>org.activiti.rest.service.api.history</location>
                  </locations>
                  <schemes>
                    <scheme>http</scheme>
                    <scheme>https</scheme>
                  </schemes>
                  <host>localhost:8080</host>
                  <basePath>/flowable-rest/service</basePath>
                  <info>
                    <title>Flowable REST API</title>
                    <version>v1</version>
                    <contact>
                      <email></email>
                      <name>Flowable</name>
                      <url>http://www.flowable.org/</url>
                    </contact>
                    <license>
                      <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
                      <name>Apache 2.0</name>
                    </license>
                  </info>
                  <securityDefinitions>
                    <securityDefinition>
                      <name>basicAuth</name>
                      <type>basic</type>
                    </securityDefinition>
                  </securityDefinitions>
                  <descriptionFile>${basedir}/src/main/resources/swagger/info.txt</descriptionFile>
                  <outputFormats>json,yaml</outputFormats>
                  <swaggerFileName>flowable-history</swaggerFileName>
                  <swaggerDirectory>${basedir}/src/main/webapp/docs/specfile/history</swaggerDirectory>
                </apiSource>
                <!-- ++++++++++ -->
                <!-- IDENTITY -->
                <!-- ++++++++++ -->
                <apiSource>
                  <springmvc>true</springmvc>
                  <locations>
                    <location>org.activiti.rest.service.api.identity</location>
                  </locations>
                  <schemes>
                    <scheme>http</scheme>
                    <scheme>https</scheme>
                  </schemes>
                  <host>localhost:8080</host>
                  <basePath>/flowable-rest/service</basePath>
                  <info>
                    <title>Flowable REST API</title>
                    <version>v1</version>
                    <contact>
                      <email></email>
                      <name>Flowable</name>
                      <url>http://www.flowable.org/</url>
                    </contact>
                    <license>
                      <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
                      <name>Apache 2.0</name>
                    </license>
                  </info>
                  <securityDefinitions>
                    <securityDefinition>
                      <name>basicAuth</name>
                      <type>basic</type>
                    </securityDefinition>
                  </securityDefinitions>
                  <descriptionFile>${basedir}/src/main/resources/swagger/info.txt</descriptionFile>
                  <outputFormats>json,yaml</outputFormats>
                  <swaggerFileName>flowable-identity</swaggerFileName>
                  <swaggerDirectory>${basedir}/src/main/webapp/docs/specfile/identity</swaggerDirectory>
                </apiSource>
                <!-- ++++++++++ -->
                <!-- MANAGEMENT -->
                <!-- ++++++++++ -->
                <apiSource>
                  <springmvc>true</springmvc>
                  <locations>
                    <location>org.activiti.rest.service.api.management</location>
                  </locations>
                  <schemes>
                    <scheme>http</scheme>
                    <scheme>https</scheme>
                  </schemes>
                  <host>localhost:8080</host>
                  <basePath>/flowable-rest/service</basePath>
                  <info>
                    <title>Flowable REST API</title>
                    <version>v1</version>
                    <contact>
                      <email></email>
                      <name>Flowable</name>
                      <url>http://www.flowable.org/</url>
                    </contact>
                    <license>
                      <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
                      <name>Apache 2.0</name>
                    </license>
                  </info>
                  <securityDefinitions>
                    <securityDefinition>
                      <name>basicAuth</name>
                      <type>basic</type>
                    </securityDefinition>
                  </securityDefinitions>
                  <descriptionFile>${basedir}/src/main/resources/swagger/info.txt</descriptionFile>
                  <outputFormats>json,yaml</outputFormats>
                  <swaggerFileName>flowable-management</swaggerFileName>
                  <swaggerDirectory>${basedir}/src/main/webapp/docs/specfile/management</swaggerDirectory>
                </apiSource>
                <!-- ++++++++++ -->
                <!-- REPOSITORY -->
                <!-- ++++++++++ -->
                <apiSource>
                  <springmvc>true</springmvc>
                  <locations>
                    <location>org.activiti.rest.service.api.repository</location>
                  </locations>
                  <schemes>
                    <scheme>http</scheme>
                    <scheme>https</scheme>
                  </schemes>
                  <host>localhost:8080</host>
                  <basePath>/flowable-rest/service</basePath>
                  <info>
                    <title>Flowable REST API</title>
                    <version>v1</version>
                    <contact>
                      <email></email>
                      <name>Flowable</name>
                      <url>http://www.flowable.org/</url>
                    </contact>
                    <license>
                      <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
                      <name>Apache 2.0</name>
                    </license>
                  </info>
                  <securityDefinitions>
                    <securityDefinition>
                      <name>basicAuth</name>
                      <type>basic</type>
                    </securityDefinition>
                  </securityDefinitions>
                  <descriptionFile>${basedir}/src/main/resources/swagger/info.txt</descriptionFile>
                  <outputFormats>json,yaml</outputFormats>
                  <swaggerFileName>flowable-repository</swaggerFileName>
                  <templatePath>${basedir}/src/main/resources/swagger/templates/strapdown.html.hbs</templatePath>
                  <outputPath>${basedir}/target/generated/document.html</outputPath>
                  <swaggerDirectory>${basedir}/src/main/webapp/docs/specfile/repository</swaggerDirectory>
                </apiSource>
                <!-- ++++++++++ -->
                <!-- RUNTIME -->
                <!-- ++++++++++ -->
                <apiSource>
                  <springmvc>true</springmvc>
                  <locations>
                    <location>org.activiti.rest.service.api.runtime</location>
                  </locations>
                  <schemes>
                    <scheme>http</scheme>
                    <scheme>https</scheme>
                  </schemes>
                  <host>localhost:8080</host>
                  <basePath>/flowable-rest/service</basePath>
                  <info>
                    <title>Flowable Runtime REST API</title>
                    <version>v1</version>
                    <contact>
                      <email></email>
                      <name>Flowable</name>
                      <url>http://www.flowable.org/</url>
                    </contact>
                    <license>
                      <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
                      <name>Apache 2.0</name>
                    </license>
                  </info>
                  <securityDefinitions>
                    <securityDefinition>
                      <name>basicAuth</name>
                      <type>basic</type>
                    </securityDefinition>
                  </securityDefinitions>
                  <descriptionFile>${basedir}/src/main/resources/swagger/info.txt</descriptionFile>
                  <outputFormats>json,yaml</outputFormats>
                  <swaggerFileName>flowable-runtime</swaggerFileName>
                  <swaggerDirectory>${basedir}/src/main/webapp/docs/specfile/runtime</swaggerDirectory>
                </apiSource>
                <!-- ++++++++++ -->
                <!-- RUNTIME PROCESS -->
                <!-- ++++++++++ -->
                <apiSource>
                  <springmvc>true</springmvc>
                  <locations>
                    <location>org.activiti.rest.service.api.runtime.process</location>
                  </locations>
                  <schemes>
                    <scheme>http</scheme>
                    <scheme>https</scheme>
                  </schemes>
                  <host>localhost:8080</host>
                  <basePath>/flowable-rest/service</basePath>
                  <info>
                    <title>Flowable Runtime REST API</title>
                    <version>v1</version>
                    <contact>
                      <email></email>
                      <name>Flowable</name>
                      <url>http://www.flowable.org/</url>
                    </contact>
                    <license>
                      <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
                      <name>Apache 2.0</name>
                    </license>
                  </info>
                  <securityDefinitions>
                    <securityDefinition>
                      <name>basicAuth</name>
                      <type>basic</type>
                    </securityDefinition>
                  </securityDefinitions>
                  <descriptionFile>${basedir}/src/main/resources/swagger/info.txt</descriptionFile>
                  <outputFormats>json,yaml</outputFormats>
                  <swaggerFileName>flowable-runtime-process</swaggerFileName>
                  <swaggerDirectory>${basedir}/src/main/webapp/docs/specfile/process</swaggerDirectory>
                </apiSource>
                <!-- ++++++++++ -->
                <!-- RUNTIME TASK -->
                <!-- ++++++++++ -->
                <apiSource>
                  <springmvc>true</springmvc>
                  <locations>
                    <location>org.activiti.rest.service.api.runtime.task</location>
                  </locations>
                  <schemes>
                    <scheme>http</scheme>
                    <scheme>https</scheme>
                  </schemes>
                  <host>localhost:8080</host>
                  <basePath>/flowable-rest/service</basePath>
                  <info>
                    <title>Flowable Runtime REST API</title>
                    <version>v1</version>
                    <contact>
                      <email></email>
                      <name>Flowable</name>
                      <url>http://www.flowable.org/</url>
                    </contact>
                    <license>
                      <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
                      <name>Apache 2.0</name>
                    </license>
                  </info>
                  <securityDefinitions>
                    <securityDefinition>
                      <name>basicAuth</name>
                      <type>basic</type>
                    </securityDefinition>
                  </securityDefinitions>
                  <descriptionFile>${basedir}/src/main/resources/swagger/info.txt</descriptionFile>
                  <outputFormats>json,yaml</outputFormats>
                  <swaggerFileName>flowable-runtime-task</swaggerFileName>
                  <swaggerDirectory>${basedir}/src/main/webapp/docs/specfile/task</swaggerDirectory>
                </apiSource>
                <!-- ++++++++++ -->
                <!-- ALL -->
                <!-- ++++++++++ -->
                <apiSource>
                  <springmvc>true</springmvc>
                  <locations>
                    <location>org.activiti.rest.service.api</location>
                  </locations>
                  <schemes>
                    <scheme>http</scheme>
                    <scheme>https</scheme>
                  </schemes>
                  <host>localhost:8080</host>
                  <basePath>/flowable-rest/service</basePath>
                  <info>
                    <title>Flowable REST API</title>
                    <version>v1</version>
                    <contact>
                      <email></email>
                      <name>Flowable</name>
                      <url>http://www.flowable.org/</url>
                    </contact>
                    <license>
                      <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
                      <name>Apache 2.0</name>
                    </license>
                  </info>
                  <securityDefinitions>
                    <securityDefinition>
                      <name>basicAuth</name>
                      <type>basic</type>
                    </securityDefinition>
                  </securityDefinitions>
                  <descriptionFile>${basedir}/src/main/resources/swagger/info.txt</descriptionFile>
                  <outputFormats>json,yaml</outputFormats>
                  <swaggerFileName>flowable</swaggerFileName>
                  <!-- <swaggerDirectory>${basedir}/target/generated/swagger</swaggerDirectory> -->
                  <swaggerDirectory>${basedir}/src/main/webapp/docs/specfile</swaggerDirectory>
                </apiSource>
              </apiSources>
            </configuration>
            <executions>
              <execution>
                <phase>compile</phase>
                <goals>
                  <goal>generate</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

  <dependencies>
    <dependency>
      <groupId>org.flowable</groupId>
      <artifactId>flowable-engine</artifactId>
    </dependency>
    <dependency>
      <groupId>org.flowable</groupId>
      <artifactId>flowable-spring</artifactId>
    </dependency>
    <dependency>
      <groupId>org.flowable</groupId>
      <artifactId>flowable-rest</artifactId>
    </dependency>
    <dependency>
      <groupId>org.flowable</groupId>
      <artifactId>flowable-json-converter</artifactId>
    </dependency>
    <dependency>
      <groupId>com.h2database</groupId>
      <artifactId>h2</artifactId>
    </dependency>
    <dependency>
      <groupId>com.zaxxer</groupId>
      <artifactId>HikariCP</artifactId>
      <version>2.4.6</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-all</artifactId>
    </dependency>
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      <version>3.1.0</version>
      <scope>provided</scope>
    </dependency>
  </dependencies>
</project>


text:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using Alphora.Dataphor;
using Alphora.Dataphor.DAE;
using Alphora.Dataphor.DAE.Compiling;
using Alphora.Dataphor.DAE.Device;
using Alphora.Dataphor.DAE.Language.D4;
using Alphora.Dataphor.DAE.Runtime;
using Alphora.Dataphor.DAE.Runtime.Data;
using Alphora.Dataphor.DAE.Runtime.Instructions;
using Alphora.Dataphor.DAE.Server;
using Alphora.Dataphor.PHINVADS.Core;
using hessiancsharp.client;
using VadsClient;
using Schema = Alphora.Dataphor.DAE.Schema;

namespace Aphora.Dataphor.PHINVADS.Device
{
	public class PHINVADSDevice : Schema.Device
	{
		public PHINVADSDevice(int iD, string name) : base(iD, name)
		{
			_supportsTransactions = true;
			_supportsNestedTransactions = true;
		}

		public override Schema.DeviceCapability Capabilities
		{
			get
			{
				return
					Schema.DeviceCapability.RowLevelInsert
						| Schema.DeviceCapability.RowLevelUpdate
						| Schema.DeviceCapability.RowLevelDelete;
			}
		}

		private string _endpoint;
		public string Endpoint
		{
			get { return _endpoint; }
			set { _endpoint = value; }
		}

		protected override Schema.DeviceSession InternalConnect(ServerProcess serverProcess, Schema.DeviceSessionInfo deviceSessionInfo)
		{
			return new PHINVADSDeviceSession(this, serverProcess, deviceSessionInfo);
		}

		protected override DevicePlanNode InternalPrepare(Schema.DevicePlan plan, PlanNode planNode)
		{
			// return a DevicePlanNode appropriate for execution of the given node
			TableNode tableNode = planNode as TableNode;
			if (tableNode != null)
			{
				var fhirTableNode = new PHINVADSDeviceTableNode(tableNode);
				fhirTableNode.Prepare(plan);
				if (plan.IsSupported)
				{
					return fhirTableNode;
				}

				return null;
			}

			CreateTableNode createTableNode = planNode as CreateTableNode;
			if (createTableNode != null)
			{
				var fhirCreateTableNode = new PHINVADSCreateTableNode(createTableNode);
				return fhirCreateTableNode;
			}

			DropTableNode dropTableNode = planNode as DropTableNode;
			if (dropTableNode != null)
			{
				var fhirDropTableNode = new PHINVADSDropTableNode(dropTableNode);
				return fhirDropTableNode;
			}

			return null;
		}

		private string ToPHINVADSTableName(string fullTypeName)
		{
			return Schema.Object.Unqualify(fullTypeName) + "s"; // Pluralize the name of the resource to produce the table name
		}

		public override Schema.Catalog GetDeviceCatalog(ServerProcess process, Schema.Catalog serverCatalog, Schema.TableVar tableVar)
		{
			Schema.Catalog catalog = base.GetDeviceCatalog(process, serverCatalog, tableVar);

			using (Plan plan = new Plan(process))
			{

				// Need to support reverse lookup to determine the scalar type for a given native type

				Type[] types = typeof(Authority).Assembly.GetTypes();

				foreach (Type type in types)
				{
					// create a table var for each class
					if (type.IsClass && type.GetField("id") != null)
						if (!type.IsGenericTypeDefinition)
						{
							string tableName = Schema.Object.Qualify(ToPHINVADSTableName(type.Name), plan.CurrentLibrary.Name);
							if (tableVar == null || Schema.Object.NamesEqual(tableName, tableVar.Name))
							{
								Schema.BaseTableVar localTableVar = new Schema.BaseTableVar(tableName, null);
								localTableVar.Owner = plan.User;
								localTableVar.Library = plan.CurrentLibrary;
								localTableVar.Device = this;
								localTableVar.MetaData = new MetaData();

								// with a FHIR.ResourceType tag
								localTableVar.MetaData.Tags.Add(new Tag("PHINVADS.ResourceType", type.Name));
								localTableVar.AddDependency(this);
								localTableVar.DataType = new Schema.TableType();

								var d4TypeName = Schema.Object.Qualify(GenerateTypesNode.GetD4TypeName(type.FullName), "PHINVADS.Core");
								var d4Type = Compiler.ResolveCatalogIdentifier(plan, d4TypeName, false) as Schema.ScalarType;
								if (d4Type != null)
								{
									AddColumnsForType(localTableVar, d4Type);

									localTableVar.Keys.Add(new Schema.Key(new Schema.TableVarColumn[] { localTableVar.Columns["id"] }));

									switch (type.Name)
									{
										case "CodeSystem":
											localTableVar.Keys.Add(new Schema.Key(new Schema.TableVarColumn[] { localTableVar.Columns["oid"] }));
											localTableVar.Keys.Add(new Schema.Key(new Schema.TableVarColumn[] { localTableVar.Columns["codeSystemCode"] }));
											localTableVar.Keys.Add(new Schema.Key(new Schema.TableVarColumn[] { localTableVar.Columns["hl70396Identifier"] }));
										break;
										case "CodeSystemConcept": localTableVar.Keys.Add(new Schema.Key(new Schema.TableVarColumn[] { localTableVar.Columns["codeSystemOid"], localTableVar.Columns["conceptCode"] })); break;
										case "ValueSet":
											localTableVar.Keys.Add(new Schema.Key(new Schema.TableVarColumn[] { localTableVar.Columns["oid"] }));
											localTableVar.Keys.Add(new Schema.Key(new Schema.TableVarColumn[] { localTableVar.Columns["code"] }));
										break;

										case "ValueSetConcept":
											localTableVar.Keys.Add(new Schema.Key(new Schema.TableVarColumn[] { localTableVar.Columns["codeSystemOid"], localTableVar.Columns["conceptCode"] }));
											localTableVar.Keys.Add(new Schema.Key(new Schema.TableVarColumn[] { localTableVar.Columns["valueSetVersionId"], localTableVar.Columns["conceptCode"] }));
										break;

										case "ValueSetVersion":
											localTableVar.Keys.Add(new Schema.Key(new Schema.TableVarColumn[] { localTableVar.Columns["valueSetOid"], localTableVar.Columns["versionNumber"] }));
										break;
									}

									catalog.Add(localTableVar);
								}
							}
						}
				}

				return catalog;
			}
		}

		private void AddColumnsForType(Schema.TableVar tableVar, Schema.ScalarType d4Type)
		{
			// Add columns for the base type, if any
			foreach (var parentType in d4Type.ParentTypes)
				AddColumnsForType(tableVar, parentType);

			// Add columns for the default representation
			var representation = Compiler.FindDefaultRepresentation(d4Type);
			if (representation != null)
			{
				// And columns for each property of the default representation
				foreach (var property in representation.Properties)
				{
					var column = new Schema.Column(property.Name, property.DataType);
					var tableVarColumn = new Schema.TableVarColumn(column);
					tableVar.DataType.Columns.Add(column);
					tableVar.Columns.Add(tableVarColumn);
				}
			}

			tableVar.AddDependency(d4Type);
		}

		public static Type GetSearchParamTypeForResource(Plan plan, string resourceType)
		{
			var searchParamsClassName = resourceType + "SearchCriteriaDto";
			return plan.Catalog.ClassLoader.CreateType(plan.CatalogDeviceSession, new ClassDefinition(Schema.Object.Qualify(searchParamsClassName, "VadsClient")));
		}

		public static object GetSearchParamInstanceForResource(Plan plan, string resourceType)
		{
			var searchParamType = GetSearchParamTypeForResource(plan, resourceType);
			if (searchParamType != null)
				return Activator.CreateInstance(searchParamType);
			return null;
		}

		public static Type GetResultTypeForResource(string resourceType)
		{
			var resultTypeClassName = resourceType + "ResultDto";
			return Type.GetType(resultTypeClassName);
		}

		public static string GetSearchParamIndicatorName(string resourceType, string columnName)
		{
			switch (resourceType)
			{
				case "ValueSetVersion":
					switch (columnName)
					{
						case "valueSetOid": return "oidSearch";
						default: return columnName + "Search";
					}

				case "ValueSetConcept":
					switch (columnName)
					{
						case "valueSetOid": return "valueSetOids";
						default: return columnName + "Search";
					}

				default: return columnName + "Search";
			}
		}
	}

	public class PHINVADSDevicePlanNode : DevicePlanNode
	{
		public PHINVADSDevicePlanNode(PlanNode node) : base(node) { }
	}

	public class PHINVADSDropTableNode : PHINVADSDevicePlanNode
	{
		public PHINVADSDropTableNode(DropTableNode node) : base(node) { }

		public new DropTableNode Node { get { return (DropTableNode)base.Node; } }
	}

	public class PHINVADSCreateTableNode : PHINVADSDevicePlanNode
	{
		public PHINVADSCreateTableNode(CreateTableNode node) : base(node) { }

		public new CreateTableNode Node { get { return (CreateTableNode)base.Node; } }
	}

	public class PHINVADSDeviceTableNode : PHINVADSDevicePlanNode
	{
		public PHINVADSDeviceTableNode(TableNode node) : base(node) { }

		public new TableNode Node { get { return (TableNode)base.Node; } }

		private string _resourceType;
		public string ResourceType
		{
			get { return _resourceType; }
			set { _resourceType = value; }
		}

		public void SetSearchParamContainer(Schema.DevicePlan plan)
		{
			_searchParams = PHINVADSDevice.GetSearchParamInstanceForResource(plan.Plan, _resourceType);
			_directParams = new Dictionary<string, object>();
		}

		private object _searchParams;
		public object SearchParams { get { return _searchParams; } }

		private Dictionary<string, object> _directParams;

		public void Prepare(Schema.DevicePlan plan)
		{
			InternalPrepare(plan, Node);
		}

		private bool IsSearchParamColumn(Schema.TableVarColumn column)
		{
			return _searchParams != null && _searchParams.GetType().GetMember(PHINVADSDevice.GetSearchParamIndicatorName(_resourceType, column.Name)) != null;
		}

		private void InternalPrepare(Schema.DevicePlan plan, TableNode planNode)
		{
			RestrictNode restrictNode = planNode as RestrictNode;
			if (restrictNode != null)
			{
				// Prepare the source
				InternalPrepare(plan, restrictNode.SourceNode);

				if (plan.IsSupported)
				{
					SetSearchParamContainer(plan);
					if (restrictNode.IsSeekable)
					{
						foreach (ColumnConditions columnConditions in restrictNode.Conditions)
						{
							if (!IsSearchParamColumn(columnConditions.Column))
							{
								plan.TranslationMessages.Add(new Schema.TranslationMessage(String.Format("Service does not support restriction by {0}.", columnConditions.Column.Name)));
								plan.IsSupported = false;
								break;
							}
						}
					}
					else if (restrictNode.IsScanable)
					{
						foreach (ColumnConditions columnConditions in restrictNode.Conditions)
						{
							if (!IsSearchParamColumn(columnConditions.Column))
							{
								plan.TranslationMessages.Add(new Schema.TranslationMessage(String.Format("Service does not support restriction by {0}.", columnConditions.Column.Name)));
								plan.IsSupported = false;
								break;
							}

							foreach (ColumnCondition condition in columnConditions)
							{
								if (condition.Instruction != Instructions.Equal)
								{
									plan.IsSupported = false;
									break;
								}
							}

							if (!plan.IsSupported)
								break;
						}
					}
					else if (restrictNode.Nodes[1] is SatisfiesSearchParamNode)
					{
						plan.IsSupported = true;
					}
					else
					{
						plan.TranslationMessages.Add(new Schema.TranslationMessage("Service does not support arbitrary restriction."));
						plan.IsSupported = false;
					}
				}

				return;
			}

			BaseTableVarNode baseTableVarNode = planNode as BaseTableVarNode;
			if (baseTableVarNode != null)
			{
				ResourceType = MetaData.GetTag(baseTableVarNode.TableVar.MetaData, "PHINVADS.ResourceType", Schema.Object.Unqualify(baseTableVarNode.TableVar.Name));
				return;
			}

			plan.TranslationMessages.Add(new Schema.TranslationMessage("Service does not support arbitrary queries."));
			plan.IsSupported = false;
			return;
		}
	}

	public class PHINVADSDeviceSession : Schema.DeviceSession
	{
		public PHINVADSDeviceSession(PHINVADSDevice device, ServerProcess serverProcess, Schema.DeviceSessionInfo deviceSessionInfo) : base(device, serverProcess, deviceSessionInfo)
		{
			// Initialize the PHINVADS Client
			_factory = new CHessianProxyFactory();
			_client = (VocabService)_factory.Create(typeof(VocabService), device.Endpoint);

			// TODO: Establish authentication/authorization tokens?
		}

		private CHessianProxyFactory _factory;

		private VocabService _client;
		public VocabService Client { get { return _client; } }

		protected override bool IsConnectionFailure(Exception exception)
		{
			return base.IsConnectionFailure(exception);
		}

		protected override bool IsTransactionFailure(Exception exception)
		{
			return base.IsTransactionFailure(exception);
		}

		protected override object InternalExecute(Program program, PlanNode planNode)
		{
			if (planNode.DeviceNode == null)
			{
				throw new DeviceException(DeviceException.Codes.UnpreparedDevicePlan, ErrorSeverity.System);
			}

			var fhirTableNode = planNode.DeviceNode as PHINVADSDeviceTableNode;
			if (fhirTableNode != null)
			{
				var fhirTable = new PHINVADSTable(this, program, fhirTableNode);
				fhirTable.Open();
				return fhirTable;
			}

			var fhirCreateTableNode = planNode.DeviceNode as PHINVADSCreateTableNode;
			if (fhirCreateTableNode != null)
			{
				return null; // TODO: Throw an error if reconilication is not none...
			}

			var fhirDropTableNode = planNode.DeviceNode as PHINVADSDropTableNode;
			if (fhirDropTableNode != null)
			{
				return null; // TODO: Throw an error if reconciliation is not none...
			}

			return base.InternalExecute(program, planNode);
		}

		protected override void InternalInsertRow(Program program, Schema.TableVar table, IRow row, BitArray valueFlags)
		{
			base.InternalInsertRow(program, table, row, valueFlags);
			// TODO: Log the operation so it can be performed during the commit
			// NOTE: This will require that the operation log be considered a "cache" that will be read locally prior to returning a result (or as part of post-processing a result?)
			// Can use a PUT if we manage Id generation, assuming the server supports it
			// Must use a POST to allow the server to assign the Id, in that case the Location header of the response will contain the newly assigned Id
		}

		protected override void InternalUpdateRow(Program program, Schema.TableVar table, IRow oldRow, IRow newRow, BitArray valueFlags)
		{
			// TODO: Log the operation so it can be performed during the commit
			base.InternalUpdateRow(program, table, oldRow, newRow, valueFlags);
			// PUT, w/ ETag header equal to oldRow.meta.version
		}

		protected override void InternalDeleteRow(Program program, Schema.TableVar table, IRow row)
		{
			// TODO: Log the operation so it can be performed during the commit
			base.InternalDeleteRow(program, table, row);
			// DELETE, w/ ETag header equal to row.meta.version
		}

		protected override void InternalBeginTransaction(IsolationLevel isolationLevel)
		{
			// Do nothing, the transaction is managed as a single request/response to the server
		}

		protected override void InternalPrepareTransaction()
		{
			// If this is the root transaction, invoke the operations for the current transaction against the server
		}

		protected override void InternalCommitTransaction()
		{
			// If no errors occurred during the prepare, the commit is a no-op.
		}

		protected override void InternalRollbackTransaction()
		{
			// Do nothing, the prepare is what actually performs the operations
		}
	}

	public class PHINVADSTable : Table
	{
		const int CMinPageNumber = 1;

		public PHINVADSTable(PHINVADSDeviceSession deviceSession, Program program, PHINVADSDeviceTableNode fhirTableNode) : base(fhirTableNode.Node, program)
		{
			_deviceSession = deviceSession;
			_fhirTableNode = fhirTableNode;
		}

		private PHINVADSDeviceSession _deviceSession;
		private PHINVADSDeviceTableNode _fhirTableNode;
		private object _bundle;
		private List<object> _resources;
		private Type _resourceType;
		private int _pageSize = 20;
		private int _currentIndex;
		private int _currentPage;
		private int _totalResults;
		private object _searchParams;
		private Dictionary<string, object> _directParams;
		private enum APIType { GetAll, Find, Direct };
		private APIType _apiType;
		private string _idValue;

		private void InitializeResourceType()
		{
			_resourceType = _program.Catalog.ClassLoader.CreateType(_program.CatalogDeviceSession, new ClassDefinition(String.Format("VadsClient.{0}", _fhirTableNode.ResourceType)));
		}

		private string GetSearchParamName(Schema.TableVarColumn column)
		{
			return GetSearchParamName(column.Name);
		}

		private string GetSearchParamName(string columnName)
		{
			return PHINVADSDevice.GetSearchParamIndicatorName(_fhirTableNode.ResourceType, columnName);
		}

		private string GetSearchParamValue(ColumnCondition columnCondition)
		{
			var result = columnCondition.Argument.Execute(_program);
			if (result != null)
				return result.ToString();
			return null;
		}

		private void SetSearchParam(string paramName, object paramValue)
		{
			if (_apiType == APIType.Direct)
			{
				if (!_directParams.ContainsKey(paramName))
					_directParams.Add(paramName, paramValue);
				else
					_directParams[paramName] = paramValue;
			}
			else
			{
				_searchParams.GetType().GetField(paramName).SetValue(_searchParams, true);
				_searchParams.GetType().GetField("searchText").SetValue(_searchParams, Convert.ToString(paramValue));
				_searchParams.GetType().GetField("searchType").SetValue(_searchParams, 1); // Exact Match

				switch (_fhirTableNode.ResourceType)
				{
					case "ValueSetConcept":
					case "ValueSetVersion":
					case "ViewVersion":
						_searchParams.GetType().GetField("versionOption").SetValue(_searchParams, 3); // Latest
					break;
				}
			}
		}

		private bool IsDirectSearch(string columnName)
		{
			if (columnName == "id")
				return true;

			switch (_fhirTableNode.ResourceType)
			{
				case "ValueSetConcept": return columnName == "valueSetVersionId";
				default: return false;
			}

			// getViewById(viewId)
			// getViewByName(viewName)
			// getViewVersionById(viewVersionId)
			// getViewVersionByViewNameAndVersionNumber(viewName, versionNumber)
			// getGroupById(groupId)
			// getGroupByName(name)
			// getValueSetVersionById(valueSetVersionId)
			// getValueSetVersionByValueSetOidAndVersionNumber(valueSetOid, versionNumber)
			// getCodeSystemConceptByOidAndCode(codeSystemOid, conceptCode)
			// getValueSetConceptById(valueSetConceptId)
			// getCodeSystemByOid(codeSystemOid)
			// getAuthorityById(authorityId)
			// getSourceById(sourceId)
			// getValueSetByOid(valueSetOid)

			// getGroupsByValueSetOid(valueSetOid)
			// getGroupIdsByValueSetOid(valueSetOid)
			// getViewVersionsByValueSetVersionId(valueSetVersionId)
			// getViewVersionIdsByValueSetVersionId(valueSetVersionId)
			// getValueSetVersionsByValueSetOid(valueSetOid)
			// getValueSetVersionIdsByValueSetOid(valueSetOid)
			// getValueSetConceptsByValueSetVersionId(valueSetVersionId, pageNumber, pageSize)
			// getCodeSystemConceptAltDesignationByOidAndCode(codeSystemOid, conceptCode)
			// getChildCodeSystemConceptsByRelationshipType(codeSystemOid, conceptCode, relationshipType, pageNumber, pageSize)
			// getParentCodeSystemConceptsByRelationshipType(codeSystemOid, conceptCode, relationshipType)
			// getCodeSystemPropertyDefinitionsByCodeSystemOid(codeSystemOid)
			// getValueSetVersionsByCodeSystemConceptOidAndCode(codeSystemOid, conceptCode)
			// getValueSetVersionIdsByCodeSystemConceptOidAndCode(codeSystemOid, conceptCode)
			// getCodeSystemConceptPertyValuesByOidAndCode(codeSystemOid, conceptCode)
			// getCodeSystemConceptsByCodeSystemOid(codeSystemOid)
			// getValueSetsByGroupId(groupId)
			// getValueSetsByGroupName(name)
			// getValueSetOidsByGroupId(groupId)
			// getValueSetVersionsByViewVersionId(viewVersionId)
		}

		private void InitializeSearchParams()
		{
			_searchParams = PHINVADSDevice.GetSearchParamInstanceForResource(_program.Plan, _fhirTableNode.ResourceType);
			_directParams = new Dictionary<String, Object>();

			// Ignoring the search params on the plan for now, create search params for this execution here
			var restrictNode = _fhirTableNode.Node as RestrictNode;
			if (restrictNode != null)
			{
				_apiType = APIType.Find;
				// TODO: Generalize the stack offset here, this is safe because we know the only scenario we support is restriction of a base table var
				_program.Stack.Push(null);
				try
				{
					if (restrictNode.IsSeekable)
					{
						// Verify that there is only one condition and that it corresponds to a known search parameter for this resource
						foreach (ColumnConditions columnConditions in restrictNode.Conditions)
						{
							// A seekable condition will only have one column condition
							var searchParamName = GetSearchParamName(columnConditions.Column);
							var searchValue = GetSearchParamValue(columnConditions[0]);
							if (IsDirectSearch(columnConditions.Column.Name))
								_apiType = APIType.Direct;
							SetSearchParam(searchParamName, searchValue);
						}
					}
					else if (restrictNode.IsScanable)
					{
						foreach (ColumnConditions columnConditions in restrictNode.Conditions)
						{
							// A scanable condition will always have equality as its instruction
							foreach (ColumnCondition condition in columnConditions)
							{
								var searchParamName = GetSearchParamName(columnConditions.Column);
								var searchValue = GetSearchParamValue(condition);
								if (IsDirectSearch(columnConditions.Column.Name))
									_apiType = APIType.Direct;
								SetSearchParam(searchParamName, searchValue);
							}
						}
					}
					else
					{
						var searchParamNode = restrictNode.Nodes[1] as SatisfiesSearchParamNode;
						if (searchParamNode != null)
						{
							var columnName = (string)searchParamNode.Nodes[1].Execute(_program);
							var searchParamName = GetSearchParamName(columnName);
							var searchValue = (string)searchParamNode.Nodes[2].Execute(_program);
							if (IsDirectSearch(columnName))
								_apiType = APIType.Direct;
							SetSearchParam(searchParamName, searchValue);
						}
					}
				}
				finally
				{
					_program.Stack.Pop();
				}
			}
		}

		private IEnumerable<object> GetResults(object results)
		{
			switch (_fhirTableNode.ResourceType)
			{
				case "Authority": return ((AuthorityResultDto)results).authorities as IEnumerable<object>;
				case "CodeSystemConceptAltDesignation": return ((CodeSystemConceptAltDesignationResultDto)results).codeSystemConceptAltDesignations as IEnumerable<object>;
				case "CodeSystemConceptPropertyValue": return ((CodeSystemConceptPropertyValueResultDto)results).codeSystemConceptPropertyValues as IEnumerable<object>;
				case "CodeSystemConcept": return ((CodeSystemConceptResultDto)results).codeSystemConcepts as IEnumerable<object>;
				case "CodeSystemPropertyDefinition": return ((CodeSystemPropertyDefinitionResultDto)results).codeSystemPropertyDefinitions as IEnumerable<object>;
				case "CodeSystem": return ((CodeSystemResultDto)results).codeSystems as IEnumerable<object>;
				//case "Custom": return results.GetType().GetField("results").GetValue(results) as List<object>;
				case "Group": return ((GroupResultDto)results).groups as IEnumerable<object>;
				case "Id": return ((IdResultDto)results).ids as IEnumerable<object>;
				case "Source": return ((SourceResultDto)results).sources as IEnumerable<object>;
				case "ValueSetConcept": return ((ValueSetConceptResultDto)results).valueSetConcepts as IEnumerable<object>;
				case "ValueSet": return ((ValueSetResultDto)results).valueSet as IEnumerable<object>;
				case "ValueSetVersion": return ((ValueSetVersionResultDto)results).valueSetVersions as IEnumerable<object>;
				case "View": return ((ViewResultDto)results).views as IEnumerable<object>;
				case "ViewVersion": return ((ViewVersionResultDto)results).viewVersions as IEnumerable<object>;
				default: throw new InvalidOperationException(String.Format("Could not retrieve results for resource type {0}.", _fhirTableNode.ResourceType));
			}
		}

		private object GetResult()
		{
			switch (_fhirTableNode.ResourceType)
			{
				case "Authority": return _deviceSession.Client.getAllAuthorities();
				//case "CodeSystemConceptAltDesignation": return _deviceSession.Client.getAllCodeSystemConceptAltDesignations();
				//case "CodeSystemConceptPropertyValue": return _deviceSession.Client.getAllCodeSystemConceptPropertyValues();
				//case "CodeSystemConcept": return _deviceSession.Client.getAllCodeSystemConcepts();
				case "CodeSystemPropertyDefinition": return _deviceSession.Client.getAllCodeSystemPropertyDefinitions();
				case "CodeSystem": return _deviceSession.Client.getAllCodeSystems();
				//case "Custom": return results.GetType().GetField("results").GetValue(results) as List<object>;
				case "Group": return _deviceSession.Client.getAllGroups();
				//case "Id": return results.GetType().GetField("ids").GetValue(results) as List<object>;
				case "Source": return _deviceSession.Client.getAllSources();
				//case "ValueSetConcept": return _deviceSession.Client.getAllValueSetConcepts();
				case "ValueSet": return _deviceSession.Client.getAllValueSets();
				case "ValueSetVersion": return _deviceSession.Client.getAllValueSetVersions();
				case "View": return _deviceSession.Client.getAllViews();
				case "ViewVersion": return _deviceSession.Client.getAllViewVersions();
				default: throw new InvalidOperationException(String.Format("Could not retrieve result for resource type {0}.", _fhirTableNode.ResourceType));
			}
		}

		private object GetDirect(int pageNumber)
		{
			switch (_fhirTableNode.ResourceType)
			{
				case "Authority": return _deviceSession.Client.getAuthorityById((string)_directParams["idSearch"]);
				case "CodeSystemConceptAltDesignation": return _deviceSession.Client.getCodeSystemConceptAltDesignationByOidAndCode((string)_directParams["codeSystemOidSearch"], (string)_directParams["conceptCodeSearch"]);
				//case "CodeSystemConceptPropertyValue": return _deviceSession.Client.getAllCodeSystemConceptPropertyValues();
				//case "CodeSystemConcept": return _deviceSession.Client.getAllCodeSystemConcepts();
				//case "CodeSystemPropertyDefinition": return _deviceSession.Client.getAllCodeSystemPropertyDefinitions();
				//case "CodeSystem": return _deviceSession.Client.getAllCodeSystems();
				//case "Custom": return results.GetType().GetField("results").GetValue(results) as List<object>;
				//case "Group": return _deviceSession.Client.getAllGroups();
				//case "Id": return results.GetType().GetField("ids").GetValue(results) as List<object>;
				case "Source": return _deviceSession.Client.getSourceById((string)_directParams["idSearch"]);
				case "ValueSetConcept": return _deviceSession.Client.getValueSetConceptsByValueSetVersionId((string)_directParams["valueSetVersionIdSearch"], pageNumber, _pageSize);
				case "ValueSet": return _deviceSession.Client.getValueSetByOid((string)_directParams["valueSetOidSearch"]);
				case "ValueSetVersion": return _deviceSession.Client.getValueSetVersionById((string)_directParams["idSearch"]);
				case "View": return _deviceSession.Client.getViewById((string)_directParams["idSearch"]);
				case "ViewVersion": return _deviceSession.Client.getViewVersionById((string)_directParams["idSearch"]);
				default: throw new InvalidOperationException(String.Format("Could not retrieve result for resource type {0}.", _fhirTableNode.ResourceType));
			}

			// getViewById(viewId)
			// getViewByName(viewName)
			// getViewVersionById(viewVersionId)
			// getViewVersionByViewNameAndVersionNumber(viewName, versionNumber)
			// getGroupById(groupId)
			// getGroupByName(name)
			// getValueSetVersionById(valueSetVersionId)
			// getValueSetVersionByValueSetOidAndVersionNumber(valueSetOid, versionNumber)
			// getCodeSystemConceptByOidAndCode(codeSystemOid, conceptCode)
			// getValueSetConceptById(valueSetConceptId)
			// getCodeSystemByOid(codeSystemOid)
			// getAuthorityById(authorityId)
			// getSourceById(sourceId)
			// getValueSetByOid(valueSetOid)

			// getGroupsByValueSetOid(valueSetOid)
			// getGroupIdsByValueSetOid(valueSetOid)
			// getViewVersionsByValueSetVersionId(valueSetVersionId)
			// getViewVersionIdsByValueSetVersionId(valueSetVersionId)
			// getValueSetVersionsByValueSetOid(valueSetOid)
			// getValueSetVersionIdsByValueSetOid(valueSetOid)
			// getValueSetConceptsByValueSetVersionId(valueSetVersionId, pageNumber, pageSize)
			// getCodeSystemConceptAltDesignationByOidAndCode(codeSystemOid, conceptCode)
			// getChildCodeSystemConceptsByRelationshipType(codeSystemOid, conceptCode, relationshipType, pageNumber, pageSize)
			// getParentCodeSystemConceptsByRelationshipType(codeSystemOid, conceptCode, relationshipType)
			// getCodeSystemPropertyDefinitionsByCodeSystemOid(codeSystemOid)
			// getValueSetVersionsByCodeSystemConceptOidAndCode(codeSystemOid, conceptCode)
			// getValueSetVersionIdsByCodeSystemConceptOidAndCode(codeSystemOid, conceptCode)
			// getCodeSystemConceptPertyValuesByOidAndCode(codeSystemOid, conceptCode)
			// getCodeSystemConceptsByCodeSystemOid(codeSystemOid)
			// getValueSetsByGroupId(groupId)
			// getValueSetsByGroupName(name)
			// getValueSetOidsByGroupId(groupId)
			// getValueSetVersionsByViewVersionId(viewVersionId)
		}

		private object FindResult(int pageNumber)
		{
			switch (_fhirTableNode.ResourceType)
			{
				//case "Authority": return _deviceSession.Client.findAuthorities(pageNumber, _searchParams);
				//case "CodeSystemConceptAltDesignation": return _deviceSession.Client.findCodeSystemConceptAltDesignations();
				//case "CodeSystemConceptPropertyValue": return _deviceSession.Client.findCodeSystemConceptPropertyValues();
				case "CodeSystemConcept": return _deviceSession.Client.findCodeSystemConcepts((CodeSystemConceptSearchCriteriaDto)_searchParams, pageNumber, _pageSize);
				//case "CodeSystemPropertyDefinition": _deviceSession.Client.findCodeSystemPropertyDefinitions();
				case "CodeSystem": return _deviceSession.Client.findCodeSystems((CodeSystemSearchCriteriaDto)_searchParams, pageNumber, _pageSize);
				//case "Custom": return _deviceSession.Client.invokeCustomMethod();
				case "Group": return _deviceSession.Client.findGroups((GroupSearchCriteriaDto)_searchParams, pageNumber, _pageSize);
				//case "Id": return _deviceSession.Client.findIds(_searchParams, pageNumber, _pageSize);
				//case "Source": return _deviceSession.Client.findSources(_searchParams, pageNumber, _pageSize);
				case "ValueSetConcept": return _deviceSession.Client.findValueSetConcepts((ValueSetConceptSearchCriteriaDto)_searchParams, pageNumber, _pageSize);
				case "ValueSet": return _deviceSession.Client.findValueSets((ValueSetSearchCriteriaDto)_searchParams, pageNumber, _pageSize);
				case "ValueSetVersion": return _deviceSession.Client.findValueSetVersions((ValueSetVersionSearchCriteriaDto)_searchParams, pageNumber, _pageSize);
				case "View": return _deviceSession.Client.findViews((ViewSearchCriteriaDto)_searchParams, pageNumber, _pageSize);
				case "ViewVersion": return _deviceSession.Client.findViewVersions((ViewVersionSearchCriteriaDto)_searchParams, pageNumber, _pageSize);
				default: throw new InvalidOperationException(String.Format("Could not invoke find result for resource type {0}.", _fhirTableNode.ResourceType));
			}
		}

		private void SetTotalResults(object results)
		{
			var totalResults = (Int32)results.GetType().GetField("totalResults").GetValue(results);
			_totalResults = totalResults;
		}

		private string GetErrorText(object results)
		{
			return results.GetType().GetField("errorText").GetValue(results) as String;
		}

		private void CheckError(object results)
		{
			var errorText = GetErrorText(results);
			if (errorText != null)
			{
				// TODO: Create a PHINVADSDeviceException for proper marshalling of this error
				throw new InvalidOperationException(errorText);
			}
		}

		private object OpenResult(int pageNumber)
		{
			// If the search is restricted, issue as a find, otherwise, issue as a getAll
			object result = null;
			switch (_apiType)
			{
				case APIType.Find:
					result = FindResult(pageNumber);
				break;

				case APIType.GetAll:
					result = GetResult();
				break;

				case APIType.Direct:
					result = GetDirect(pageNumber);
				break;
			}

			CheckError(result);
			_currentPage = pageNumber;
			return result;
		}

		private int GetMaxPageNumber()
		{
			if (_apiType != APIType.GetAll)
			{
				return _totalResults / _pageSize + (_totalResults % _pageSize > 0 ? 1 : 0);
			}
			else
			{
				return CMinPageNumber;
			}
		}

		private void OpenBundle(object bundle)
		{
			_bundle = bundle;
			_resources = new List<object>();
			if (_bundle != null)
			{
				// TODO: Would be more efficient to leave it as an IEnumerable, but would change the way the cursor works...
				_resources.AddRange(GetResults(_bundle));
				// Set TotalResults
				SetTotalResults(bundle);
			}
		}

		private bool FirstPage()
		{
			if (_bundle != null)
			{
				OpenBundle(OpenResult(CMinPageNumber));
				return true;
			}
			return false;
		}

		private bool LastPage()
		{
			if (_bundle != null)
			{
				OpenBundle(OpenResult(GetMaxPageNumber()));
				return true;
			}

			return false;
		}

		private bool NextPage()
		{
			if (_bundle != null)
			{
				if (_currentPage < (GetMaxPageNumber()))
				{
					OpenBundle(OpenResult(_currentPage + 1));
					return true;
				}
			}

			return false;
		}

		private bool PriorPage()
		{
			if (_bundle != null)
			{
				if (_currentPage > CMinPageNumber)
				{
					OpenBundle(OpenResult(_currentPage - 1));
					return true;
				}
			}

			return false;
		}

		private bool IsFirstPage()
		{
			if (_bundle != null)
			{
				return _currentPage == CMinPageNumber;
			}

			return true;
		}

		private bool IsLastPage()
		{
			if (_bundle != null)
			{
				return _currentPage == GetMaxPageNumber();
			}

			return true;
		}

		protected override void InternalOpen()
		{
			InitializeResourceType();
			InitializeSearchParams();

			OpenBundle(OpenResult(CMinPageNumber));

			_currentIndex = -1; // Set to the BOF crack
		}

		protected override void InternalClose()
		{
			// Nothing to do
		}

		public override CursorCapability Capabilities
		{
			get
			{
				return CursorCapability.Navigable
					| CursorCapability.BackwardsNavigable;
			}
		}

		public override CursorType CursorType
		{
			get { return CursorType.Dynamic; }
		}

		protected override bool InternalRefresh(IRow row)
		{
			return base.InternalRefresh(row);
		}

		protected override void InternalSelect(IRow row)
		{
			// TODO: Will column order in this row always be guaranteed... if so we could avoid the lookup, but...
			// Return a row containing the values for the current resource in the bundle
			var resource = _resources[_currentIndex];
			for (int index = 0; index < row.DataType.Columns.Count; index++)
			{
				var value = ObjectMarshal.ToNativeOf(Program.ValueManager, row.DataType.Columns[index].DataType, _resourceType.GetField(row.DataType.Columns[index].Name).GetValue(resource));
				row[index] = value;
			}
		}

		protected override bool InternalNext()
		{
			_currentIndex++;
			if (_currentIndex >= _resources.Count)
			{
				if (NextPage())
					_currentIndex = 0;
			}
			return _currentIndex < _resources.Count;
		}

		protected override bool InternalPrior()
		{
			_currentIndex--;
			if (_currentIndex < 0)
			{
				if (PriorPage())
					_currentIndex = _resources.Count;
			}
			return _currentIndex < 0;
		}

		protected override bool InternalBOF()
		{
			return IsFirstPage() && _currentIndex < 0;
		}

		protected override bool InternalEOF()
		{
			return IsLastPage() && _currentIndex >= _resources.Count;
		}

		protected override void InternalFirst()
		{
			FirstPage();
			_currentIndex = -1;
		}

		protected override void InternalLast()
		{
			LastPage();
			_currentIndex = _resources.Count;
		}
	}
}


text:
package io.magentys.training.ncp.dao.impl;

import org.mongodb.morphia.Datastore;
import org.mongodb.morphia.query.Query;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import io.magentys.mvc.authentication.model.User;
import io.magentys.training.ncp.dao.UserProfileDao;
import io.magentys.training.ncp.model.UserProfile;

@Repository
public class UserProfileDaoImpl implements UserProfileDao {

	private final Datastore datastore;

	@Autowired
	public UserProfileDaoImpl(Datastore datastore) {
		this.datastore = datastore;
	}

	@Override
	public void insertFollower(User follower, User followee) {
		UserProfile profile = getProfile(follower);
		profile.getFollows().add(followee.getUsername());
		datastore.save(profile);
	}

	@Override
	public void deleteFollower(User follower, User followee) {
		UserProfile profile = getProfile(follower);
		profile.getFollows().remove(followee.getUsername());
		datastore.save(profile);
	}

	@Override
	public boolean isUserFollower(User follower, User followee) {
		UserProfile profile = getProfile(follower);
		return profile.getFollows().contains(followee.getUsername());
	}

	public UserProfile getProfile(User user) {
		Query<UserProfile> query = datastore.createQuery(UserProfile.class)
			.field("user").equal(user);
		UserProfile profile = query.get();
		if (profile == null ) {
			profile = new UserProfile();
			profile.setUser(user);
		}
		return profile;
	}

}


text:
ACCEPTED

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

#### Published in
Bull. Soc. Path. Exot. 15: 594 (1922)

#### Original name
Trichophyton pedis M. Ota, 1922

### Remarks
null


text:
package com.jadarstudios.developercapes.cape;

import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.client.renderer.texture.ITextureObject;
import net.minecraft.util.ResourceLocation;

/**
 * @author jadar
 */
public interface ICape {

    public String getName();

    public ITextureObject getTexture();

    public ResourceLocation getLocation();

    public void loadTexture(AbstractClientPlayer player);

    public boolean isTextureLoaded(AbstractClientPlayer player);
}


text:
#ifndef AIS_SINK_H_
#define AIS_SINK_H_

#include <gst/base/gstbasesink.h>

#include "aistreams/c/c_api.h"

G_BEGIN_DECLS

#define AIS_TYPE_SINK (ais_sink_get_type())
#define AIS_SINK(obj) \
  (G_TYPE_CHECK_INSTANCE_CAST((obj), AIS_TYPE_SINK, AisSink))
#define AIS_SINK_CLASS(klass) \
  (G_TYPE_CHECK_CLASS_CAST((klass), AIS_TYPE_SINK, AisSinkClass))
#define AIS_IS_SINK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), AIS_TYPE_SINK))
#define AIS_IS_SINK_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass), AIS_TYPE_SINK))

typedef struct _AisSink AisSink;
typedef struct _AisSinkClass AisSinkClass;

/**
 * AisSink:
 * @target_address: the address to the stream server.
 *
 * The data associated with each #AisSink object.
 */
struct _AisSink {
  GstBaseSink parent;

  gchar *target_address;
  gchar *stream_name;
  gboolean authenticate_with_google;
  gboolean use_insecure_channel;
  gchar *ssl_domain_name;
  gchar *ssl_root_cert_path;
  gdouble trace_probability;

  /* An AI Streamer sender object. */
  AIS_Sender *ais_sender;

  /* An AI Streamer sender object. */
  AIS_ConnectionOptions *ais_connection_options;

  /* An AI Streamer status object. */
  AIS_Status *ais_status;
};

struct _AisSinkClass {
  GstBaseSinkClass parent_class;
};

GType ais_sink_get_type(void);

G_END_DECLS

#endif


text:
.class Landroid/webkit/FindActionModeCallback$1;
.super Ljava/lang/Object;
.source "FindActionModeCallback.java"

# interfaces
.implements Landroid/view/View$OnFocusChangeListener;

# annotations
.annotation system Ldalvik/annotation/EnclosingMethod;
    value = Landroid/webkit/FindActionModeCallback;-><init>(Landroid/content/Context;)V
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x0
    name = null
.end annotation

# instance fields
.field final synthetic this$0:Landroid/webkit/FindActionModeCallback;

# direct methods
.method constructor <init>(Landroid/webkit/FindActionModeCallback;)V
    .locals 0
    .parameter

    .prologue
    .line 57
    iput-object p1, p0, Landroid/webkit/FindActionModeCallback$1;->this$0:Landroid/webkit/FindActionModeCallback;

    invoke-direct/range {p0 .. p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method

# virtual methods
.method public onFocusChange(Landroid/view/View;Z)V
    .locals 1
    .parameter "v"
    .parameter "hasFocus"

    .prologue
    .line 60
    if-nez p2, :cond_0

    iget-object v0, p0, Landroid/webkit/FindActionModeCallback$1;->this$0:Landroid/webkit/FindActionModeCallback;

    #getter for: Landroid/webkit/FindActionModeCallback;->mActionMode:Landroid/view/ActionMode;
    invoke-static {v0}, Landroid/webkit/FindActionModeCallback;->access$000(Landroid/webkit/FindActionModeCallback;)Landroid/view/ActionMode;

    move-result-object v0

    if-eqz v0, :cond_0

    .line 62
    iget-object v0, p0, Landroid/webkit/FindActionModeCallback$1;->this$0:Landroid/webkit/FindActionModeCallback;

    invoke-virtual {v0}, Landroid/webkit/FindActionModeCallback;->finish()V

    .line 64
    :cond_0
    return-void
.end method


text:
namespace blink {

static ScriptStreamerThread* s_sharedThread = 0;
// Guards s_sharedThread. s_sharedThread is initialized and deleted in the main
// thread, but also used by the streamer thread. Races can occur during
// shutdown.
static Mutex* s_mutex = 0;

void ScriptStreamerThread::init() {
  ASSERT(!s_sharedThread);
  ASSERT(isMainThread());
  // This is called in the main thread before any tasks are created, so no
  // locking is needed.
  s_mutex = new Mutex();
  s_sharedThread = new ScriptStreamerThread();
}

void ScriptStreamerThread::shutdown() {
  ASSERT(s_sharedThread);
  ScriptStreamerThread* toDelete;
  {
    MutexLocker locker(*s_mutex);
    toDelete = s_sharedThread;
    // The background thread can now safely check s_sharedThread; if it's
    // not 0, we're not shutting down.
    s_sharedThread = 0;
  }
  // This will run the pending tasks into completion. We shouldn't hold the
  // mutex while doing that.
  delete toDelete;
  // Now it's safe to delete s_mutex, since there are no tasks that could
  // access it later.
  delete s_mutex;
}

ScriptStreamerThread* ScriptStreamerThread::shared() {
  return s_sharedThread;
}

void ScriptStreamerThread::postTask(std::unique_ptr<CrossThreadClosure> task) {
  ASSERT(isMainThread());
  MutexLocker locker(m_mutex);
  ASSERT(!m_runningTask);
  m_runningTask = true;
  platformThread().getWebTaskRunner()->postTask(BLINK_FROM_HERE,
                                                std::move(task));
}

void ScriptStreamerThread::taskDone() {
  MutexLocker locker(m_mutex);
  ASSERT(m_runningTask);
  m_runningTask = false;
}

WebThread& ScriptStreamerThread::platformThread() {
  if (!isRunning())
    m_thread =
        wrapUnique(Platform::current()->createThread("ScriptStreamerThread"));
  return *m_thread;
}

void ScriptStreamerThread::runScriptStreamingTask(
    std::unique_ptr<v8::ScriptCompiler::ScriptStreamingTask> task,
    ScriptStreamer* streamer) {
  TRACE_EVENT1(
      "v8,devtools.timeline", "v8.parseOnBackground", "data",
      InspectorParseScriptEvent::data(streamer->scriptResourceIdentifier(),
                                      streamer->scriptURLString()));
  // Running the task can and will block: SourceStream::GetSomeData will get
  // called and it will block and wait for data from the network.
  task->Run();
  streamer->streamingCompleteOnBackgroundThread();
  MutexLocker locker(*s_mutex);
  ScriptStreamerThread* thread = shared();
  if (thread)
    thread->taskDone();
  // If thread is 0, we're shutting down.
}

}  // namespace blink