text:
using ::testing::_;
using ::testing::ElementsAreArray;
using ::testing::Invoke;
using ::testing::SetArgPointee;
using ::testing::SetArrayArgument;

namespace {
typedef gpu::gles2::ShaderTranslator::VariableMap VariableMap;
}  // anonymous namespace

namespace gpu {
namespace gles2 {

class ProgramBinaryEmulator {
 public:
  ProgramBinaryEmulator(GLsizei length,
                        GLenum format,
                        const char* binary)
      : length_(length),
        format_(format),
        binary_(binary) { }

  void GetProgramBinary(GLuint program,
                        GLsizei buffer_size,
                        GLsizei* length,
                        GLenum* format,
                        GLvoid* binary) {
    if (length) {
      *length = length_;
    }
    *format = format_;
    memcpy(binary, binary_, length_);
  }

  void ProgramBinary(GLuint program,
                     GLenum format,
                     const GLvoid* binary,
                     GLsizei length) {
    // format and length are verified by matcher
    EXPECT_EQ(0, memcmp(binary_, binary, length));
  }

  GLsizei length() const { return length_; }
  GLenum format() const { return format_; }
  const char* binary() const { return binary_; }

 private:
  GLsizei length_;
  GLenum format_;
  const char* binary_;
};

class MemoryProgramCacheTest : public testing::Test {
 public:
  static const size_t kCacheSizeBytes = 1024;
  static const GLuint kVertexShaderClientId = 90;
  static const GLuint kVertexShaderServiceId = 100;
  static const GLuint kFragmentShaderClientId = 91;
  static const GLuint kFragmentShaderServiceId = 100;

  MemoryProgramCacheTest()
      : cache_(new MemoryProgramCache(kCacheSizeBytes)),
        vertex_shader_(NULL),
        fragment_shader_(NULL) { }
  ~MemoryProgramCacheTest() {
    shader_manager_.Destroy(false);
  }

 protected:
  virtual void SetUp() {
    gl_.reset(new ::testing::StrictMock<gfx::MockGLInterface>());
    ::gfx::GLInterface::SetGLInterface(gl_.get());

    vertex_shader_ = shader_manager_.CreateShaderInfo(kVertexShaderClientId,
                                                      kVertexShaderServiceId,
                                                      GL_VERTEX_SHADER);
    fragment_shader_ = shader_manager_.CreateShaderInfo(
        kFragmentShaderClientId,
        kFragmentShaderServiceId,
        GL_FRAGMENT_SHADER);
    ASSERT_TRUE(vertex_shader_ != NULL);
    ASSERT_TRUE(fragment_shader_ != NULL);
    typedef ShaderTranslatorInterface::VariableInfo VariableInfo;
    typedef ShaderTranslator::VariableMap VariableMap;
    VariableMap vertex_attrib_map;
    VariableMap vertex_uniform_map;
    VariableMap fragment_attrib_map;
    VariableMap fragment_uniform_map;

    vertex_attrib_map["a"] = VariableInfo(1, 34, "a");
    vertex_uniform_map["a"] = VariableInfo(0, 10, "a");
    vertex_uniform_map["b"] = VariableInfo(2, 3114, "b");
    fragment_attrib_map["jjjbb"] = VariableInfo(463, 1114, "jjjbb");
    fragment_uniform_map["k"] = VariableInfo(10, 34413, "k");

    vertex_shader_->set_attrib_map(vertex_attrib_map);
    vertex_shader_->set_uniform_map(vertex_uniform_map);
    fragment_shader_->set_attrib_map(vertex_attrib_map);
    fragment_shader_->set_uniform_map(vertex_uniform_map);

    vertex_shader_->UpdateSource("bbbalsldkdkdkd");
    fragment_shader_->UpdateSource("bbbal   sldkdkdkas 134 ad");
    vertex_shader_->FlagSourceAsCompiled(true);
    fragment_shader_->FlagSourceAsCompiled(true);

    vertex_shader_->SetStatus(true, NULL, NULL);
    fragment_shader_->SetStatus(true, NULL, NULL);
  }

  virtual void TearDown() {
    ::gfx::GLInterface::SetGLInterface(NULL);
    gl_.reset();
  }

  void SetExpectationsForSaveLinkedProgram(
      const GLint program_id,
      ProgramBinaryEmulator* emulator) const {
    EXPECT_CALL(*gl_.get(),
                GetProgramiv(program_id, GL_PROGRAM_BINARY_LENGTH_OES, _))
        .WillOnce(SetArgPointee<2>(emulator->length()));
    EXPECT_CALL(*gl_.get(),
                GetProgramBinary(program_id, emulator->length(), _, _, _))
        .WillOnce(Invoke(emulator, &ProgramBinaryEmulator::GetProgramBinary));
  }

  void SetExpectationsForLoadLinkedProgram(
      const GLint program_id,
      ProgramBinaryEmulator* emulator) const {
    EXPECT_CALL(*gl_.get(),
                ProgramBinary(program_id,
                              emulator->format(),
                              _,
                              emulator->length()))
        .WillOnce(Invoke(emulator, &ProgramBinaryEmulator::ProgramBinary));
    EXPECT_CALL(*gl_.get(),
                GetProgramiv(program_id, GL_LINK_STATUS, _))
                .WillOnce(SetArgPointee<2>(GL_TRUE));
  }

  void SetExpectationsForLoadLinkedProgramFailure(
      const GLint program_id,
      ProgramBinaryEmulator* emulator) const {
    EXPECT_CALL(*gl_.get(),
                ProgramBinary(program_id,
                              emulator->format(),
                              _,
                              emulator->length()))
        .WillOnce(Invoke(emulator, &ProgramBinaryEmulator::ProgramBinary));
    EXPECT_CALL(*gl_.get(),
                GetProgramiv(program_id, GL_LINK_STATUS, _))
                .WillOnce(SetArgPointee<2>(GL_FALSE));
  }

  // Use StrictMock to make 100% sure we know how GL will be called.
  scoped_ptr< ::testing::StrictMock<gfx::MockGLInterface> > gl_;
  scoped_ptr<MemoryProgramCache> cache_;
  ShaderManager shader_manager_;
  ShaderManager::ShaderInfo* vertex_shader_;
  ShaderManager::ShaderInfo* fragment_shader_;
};

TEST_F(MemoryProgramCacheTest, CacheSave) {
  const GLenum kFormat = 1;
  const int kProgramId = 10;
  const int kBinaryLength = 20;
  char test_binary[kBinaryLength];
  for (int i = 0; i < kBinaryLength; ++i) {
    test_binary[i] = i;
  }
  ProgramBinaryEmulator emulator(kBinaryLength, kFormat, test_binary);

  SetExpectationsForSaveLinkedProgram(kProgramId, &emulator);
  cache_->SaveLinkedProgram(kProgramId, vertex_shader_, fragment_shader_, NULL);

  EXPECT_EQ(ProgramCache::LINK_SUCCEEDED, cache_->GetLinkedProgramStatus(
      *vertex_shader_->deferred_compilation_source(),
      *fragment_shader_->deferred_compilation_source(),
      NULL));
}

TEST_F(MemoryProgramCacheTest, CacheLoadMatchesSave) {
  const GLenum kFormat = 1;
  const int kProgramId = 10;
  const int kBinaryLength = 20;
  char test_binary[kBinaryLength];
  for (int i = 0; i < kBinaryLength; ++i) {
    test_binary[i] = i;
  }
  ProgramBinaryEmulator emulator(kBinaryLength, kFormat, test_binary);

  SetExpectationsForSaveLinkedProgram(kProgramId, &emulator);
  cache_->SaveLinkedProgram(kProgramId, vertex_shader_, fragment_shader_, NULL);

  VariableMap vertex_attrib_map = vertex_shader_->attrib_map();
  VariableMap vertex_uniform_map = vertex_shader_->uniform_map();
  VariableMap fragment_attrib_map = fragment_shader_->attrib_map();
  VariableMap fragment_uniform_map = fragment_shader_->uniform_map();

  vertex_shader_->set_attrib_map(VariableMap());
  vertex_shader_->set_uniform_map(VariableMap());
  fragment_shader_->set_attrib_map(VariableMap());
  fragment_shader_->set_uniform_map(VariableMap());

  SetExpectationsForLoadLinkedProgram(kProgramId, &emulator);

  EXPECT_EQ(ProgramCache::PROGRAM_LOAD_SUCCESS, cache_->LoadLinkedProgram(
      kProgramId,
      vertex_shader_,
      fragment_shader_,
      NULL));

  // apparently the hash_map implementation on android doesn't have the
  // equality operator
#if !defined(OS_ANDROID)
  EXPECT_EQ(vertex_attrib_map, vertex_shader_->attrib_map());
  EXPECT_EQ(vertex_attrib_map, vertex_shader_->uniform_map());
  EXPECT_EQ(vertex_attrib_map, fragment_shader_->attrib_map());
  EXPECT_EQ(vertex_attrib_map, fragment_shader_->uniform_map());
#endif
}

TEST_F(MemoryProgramCacheTest, LoadFailOnLinkFalse) {
  const GLenum kFormat = 1;
  const int kProgramId = 10;
  const int kBinaryLength = 20;
  char test_binary[kBinaryLength];
  for (int i = 0; i < kBinaryLength; ++i) {
    test_binary[i] = i;
  }
  ProgramBinaryEmulator emulator(kBinaryLength, kFormat, test_binary);

  SetExpectationsForSaveLinkedProgram(kProgramId, &emulator);
  cache_->SaveLinkedProgram(kProgramId, vertex_shader_, fragment_shader_, NULL);

  SetExpectationsForLoadLinkedProgramFailure(kProgramId, &emulator);
  EXPECT_EQ(ProgramCache::PROGRAM_LOAD_FAILURE, cache_->LoadLinkedProgram(
      kProgramId,
      vertex_shader_,
      fragment_shader_,
      NULL));
}

TEST_F(MemoryProgramCacheTest, LoadFailOnDifferentSource) {
  const GLenum kFormat = 1;
  const int kProgramId = 10;
  const int kBinaryLength = 20;
  char test_binary[kBinaryLength];
  for (int i = 0; i < kBinaryLength; ++i) {
    test_binary[i] = i;
  }
  ProgramBinaryEmulator emulator(kBinaryLength, kFormat, test_binary);

  SetExpectationsForSaveLinkedProgram(kProgramId, &emulator);
  cache_->SaveLinkedProgram(kProgramId, vertex_shader_, fragment_shader_, NULL);

  const std::string vertex_orig_source =
      *vertex_shader_->deferred_compilation_source();
  vertex_shader_->UpdateSource("different!");
  vertex_shader_->FlagSourceAsCompiled(true);
  EXPECT_EQ(ProgramCache::PROGRAM_LOAD_FAILURE, cache_->LoadLinkedProgram(
      kProgramId,
      vertex_shader_,
      fragment_shader_,
      NULL));

  vertex_shader_->UpdateSource(vertex_orig_source.c_str());
  vertex_shader_->FlagSourceAsCompiled(true);
  fragment_shader_->UpdateSource("different!");
  fragment_shader_->FlagSourceAsCompiled(true);
  EXPECT_EQ(ProgramCache::PROGRAM_LOAD_FAILURE, cache_->LoadLinkedProgram(
      kProgramId,
      vertex_shader_,
      fragment_shader_,
      NULL));
}

TEST_F(MemoryProgramCacheTest, LoadFailOnDifferentMap) {
  const GLenum kFormat = 1;
  const int kProgramId = 10;
  const int kBinaryLength = 20;
  char test_binary[kBinaryLength];
  for (int i = 0; i < kBinaryLength; ++i) {
    test_binary[i] = i;
  }
  ProgramBinaryEmulator emulator(kBinaryLength, kFormat, test_binary);

  SetExpectationsForSaveLinkedProgram(kProgramId, &emulator);
  ProgramCache::LocationMap binding_map;
  binding_map["test"] = 512;
  cache_->SaveLinkedProgram(kProgramId,
                            vertex_shader_,
                            fragment_shader_,
                            &binding_map);

  binding_map["different!"] = 59;
  EXPECT_EQ(ProgramCache::PROGRAM_LOAD_FAILURE, cache_->LoadLinkedProgram(
      kProgramId,
      vertex_shader_,
      fragment_shader_,
      &binding_map));
  EXPECT_EQ(ProgramCache::PROGRAM_LOAD_FAILURE, cache_->LoadLinkedProgram(
      kProgramId,
      vertex_shader_,
      fragment_shader_,
      NULL));
}

TEST_F(MemoryProgramCacheTest, MemoryProgramCacheEviction) {
  typedef ShaderTranslator::VariableMap VariableMap;
  const GLenum kFormat = 1;
  const int kProgramId = 10;
  const int kBinaryLength = 20;
  char test_binary[kBinaryLength];
  for (int i = 0; i < kBinaryLength; ++i) {
    test_binary[i] = i;
  }
  ProgramBinaryEmulator emulator1(kBinaryLength, kFormat, test_binary);

  SetExpectationsForSaveLinkedProgram(kProgramId, &emulator1);
  cache_->SaveLinkedProgram(kProgramId, vertex_shader_, fragment_shader_, NULL);

  const int kEvictingProgramId = 11;
  const GLuint kEvictingBinaryLength = kCacheSizeBytes - kBinaryLength + 1;

  // save old source and modify for new program
  const std::string old_source =
      *fragment_shader_->deferred_compilation_source();
  fragment_shader_->UpdateSource("al sdfkjdk");
  fragment_shader_->FlagSourceAsCompiled(true);

  scoped_array<char> bigTestBinary =
      scoped_array<char>(new char[kEvictingBinaryLength]);
  for (size_t i = 0; i < kEvictingBinaryLength; ++i) {
    bigTestBinary[i] = i % 250;
  }
  ProgramBinaryEmulator emulator2(kEvictingBinaryLength,
                                  kFormat,
                                  bigTestBinary.get());

  SetExpectationsForSaveLinkedProgram(kEvictingProgramId, &emulator2);
  cache_->SaveLinkedProgram(kEvictingProgramId,
                            vertex_shader_,
                            fragment_shader_,
                            NULL);

  EXPECT_EQ(ProgramCache::LINK_SUCCEEDED, cache_->GetLinkedProgramStatus(
      *vertex_shader_->deferred_compilation_source(),
      *fragment_shader_->deferred_compilation_source(),
      NULL));
  EXPECT_EQ(ProgramCache::LINK_UNKNOWN, cache_->GetLinkedProgramStatus(
      old_source,
      *fragment_shader_->deferred_compilation_source(),
      NULL));
}

TEST_F(MemoryProgramCacheTest, SaveCorrectProgram) {
  const GLenum kFormat = 1;
  const int kProgramId = 10;
  const int kBinaryLength = 20;
  char test_binary[kBinaryLength];
  for (int i = 0; i < kBinaryLength; ++i) {
    test_binary[i] = i;
  }
  ProgramBinaryEmulator emulator1(kBinaryLength, kFormat, test_binary);

  vertex_shader_->UpdateSource("different!");
  SetExpectationsForSaveLinkedProgram(kProgramId, &emulator1);
  cache_->SaveLinkedProgram(kProgramId, vertex_shader_, fragment_shader_, NULL);

  EXPECT_EQ(ProgramCache::LINK_SUCCEEDED, cache_->GetLinkedProgramStatus(
      *vertex_shader_->deferred_compilation_source(),
      *fragment_shader_->deferred_compilation_source(),
      NULL));
}

TEST_F(MemoryProgramCacheTest, LoadCorrectProgram) {
  const GLenum kFormat = 1;
  const int kProgramId = 10;
  const int kBinaryLength = 20;
  char test_binary[kBinaryLength];
  for (int i = 0; i < kBinaryLength; ++i) {
    test_binary[i] = i;
  }
  ProgramBinaryEmulator emulator(kBinaryLength, kFormat, test_binary);

  SetExpectationsForSaveLinkedProgram(kProgramId, &emulator);
  cache_->SaveLinkedProgram(kProgramId, vertex_shader_, fragment_shader_, NULL);

  EXPECT_EQ(ProgramCache::LINK_SUCCEEDED, cache_->GetLinkedProgramStatus(
      *vertex_shader_->deferred_compilation_source(),
      *fragment_shader_->deferred_compilation_source(),
      NULL));

  SetExpectationsForLoadLinkedProgram(kProgramId, &emulator);

  fragment_shader_->UpdateSource("different!");
  EXPECT_EQ(ProgramCache::PROGRAM_LOAD_SUCCESS, cache_->LoadLinkedProgram(
      kProgramId,
      vertex_shader_,
      fragment_shader_,
      NULL));
}

TEST_F(MemoryProgramCacheTest, OverwriteOnNewSave) {
  const GLenum kFormat = 1;
  const int kProgramId = 10;
  const int kBinaryLength = 20;
  char test_binary[kBinaryLength];
  for (int i = 0; i < kBinaryLength; ++i) {
    test_binary[i] = i;
  }
  ProgramBinaryEmulator emulator(kBinaryLength, kFormat, test_binary);

  SetExpectationsForSaveLinkedProgram(kProgramId, &emulator);
  cache_->SaveLinkedProgram(kProgramId, vertex_shader_, fragment_shader_, NULL);

  char test_binary2[kBinaryLength];
  for (int i = 0; i < kBinaryLength; ++i) {
    test_binary2[i] = (i*2) % 250;
  }
  ProgramBinaryEmulator emulator2(kBinaryLength, kFormat, test_binary2);
  SetExpectationsForSaveLinkedProgram(kProgramId, &emulator2);
  cache_->SaveLinkedProgram(kProgramId, vertex_shader_, fragment_shader_, NULL);

  SetExpectationsForLoadLinkedProgram(kProgramId, &emulator2);
  EXPECT_EQ(ProgramCache::PROGRAM_LOAD_SUCCESS, cache_->LoadLinkedProgram(
      kProgramId,
      vertex_shader_,
      fragment_shader_,
      NULL));
}

}  // namespace gles2
}  // namespace gpu


text:
<!DOCTYPE html>
<meta charset='utf-8' name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />
<title>Hold your zebras</title>
<link rel="icon" href="img/favicon.ico">
<link rel='stylesheet' href='style.css' media='screen' />

<link href="https://fonts.googleapis.com/css?family=PT+Sans:400,700|Roboto+Mono:400,700|Mada:400,700" rel="stylesheet">

                Hold

                your

                zebras

                Visualizing the

                Base Rate Fallacy

            Robert is a man of tiny stature from the United States who wears glasses and likes solving puzzles.
             He is more likely to be,

            (a) A truck driver, or

            (b) A computer science student at Stanford?

            If your mind was drawn to the answer (b), this is the base rate fallacy at work here.
            You probably figured that the description of Robert wouldn't fit in too well with your image or stereotype of truck drivers.
            But if you would to take a step back and think about the bigger picture -
            there are clearly way more truck drivers in the United States,
            than students in a certain university in California.
            Hence, it follows that Robert is more likely to be a truck driver!

            The vivid and oddly specific description has led you to neglect any statistical or general information -
            what is known as base rate information (and hence the name of this cognitive error). Your mind did not attempt to incorporate any prior knowledge into your reasoning, as it had never occurred to be relevant, and simply embraced any causal explanations.

            When Health Screenings are Unhealthy

            Judging someone's profession doesn't seem like much of a big deal. But what happens if our reliance on our
            intuitive judgments can potentially pose real-life consequences?
            Let's take a closer look at an example that you might be able to relate to - health screenings. Suppose that you are a woman reaching her forties.
            You are well aware that breast cancer is the most  common cancer among women, and that an early diagnosis can increase the chance of recovery. So why not make that trip down to the clinic?
            Better to be safe than sorry, right? Plus, a mammography will only incorrectly detect breast cancer on a healthy person 9% of the time,
            which does seem pretty reliable.

            So let's say you got your mammogram done, but unfortunately, you are surprised by a positive result. Here's the important question:
            given the accuracy of the mammogram test,
            what is the probability that you actually have breast cancer?

            We're about to do some simple calculations, so let me visualize the numbers for you:

                    Suppose 100,000 women in their forties decide to undergo a mammogram examination.

                    Let's visualize 1 dotfor every 1,000 women, for a total of 100 dots.

                    For the sake of example, let's assume breast cancer affects 1% of the population.

                    The test is rather accurate; it always correctly identifies those who have the disease.
                    However, roughly 9% of mammograms will generate a false positive, meaning that the person tests positive but does not actually have the disease.

                    Hence, the results of the screening are as follows: 1,000 women are correctly found to have breast cancer.
                     But of the remaining 99,000 healthy ones, around 8,910 are incorrectly identified to have breast cancer.

                    Putting it all together, we can calculate the probability of an inaccurate positive result:
                    a total of 9,910 women will be revealed to have breast cancer,
                    but only 1,000 of them actually carry the disease. In other words, the probability of
                    you having breast cancer is a mere 10%!

            Don't neglect your horses

            Despite the accuracy of the test, a bulk of the people who test positive in the mammogram examination
            do not actually have the disease! If you have tried experimenting with the sliders in the visualization, you might have noticed a trend -
            increasing the prevalence of the disease reduces the proportion of false positives.

            Hence, what is responsible for this seemingly counter-intuitive phenomenon is simply our failure to recognize the base rate -
            which in this case, is the low rate of breast cancer in the population.
            No matter how reliable the test is, the rare occurrence of the disease in the population will always guarantee a sizeable proportion of
            false positive results.

            This is important as
            mass screenings could result in
            overdiagnosis of patients and unnecessary invasive follow-up treatments like surgery and chemotherapy.
            That is why
            doctors only recommend
            health screenings on patients with high risk factors, such as age or a family history of the disease (i.e. increasing the base rate and hence the accuracy of the test).

            In the medical profession, a common saying beaten into the heads of budding doctors is: "When you hear hoofbeats,
            think of horses not zebras." In the context of their practice, it cautions medical students not to make any rare diagnoses
            before considering the more common diseases. It's easy to fall prey to the base-rate fallacy
            (even two-thirds of doctors fail to judge accurately the efficacy of health screenings),
            but hopefully even a rudimentary understanding of it will help you arrive at proper judgments, conclusions and make smarter decisions.

            So whether you are estimating the odds of success of your first business venture, the likelihood of your child getting into Havard,
            or the chance of landing a spot at Google with your computer science degree,
            be sure to ignore any specific information, and focus on the base rate -
            remember to hold your zebras, and utilize your horse sense instead.

redpajama_set_name: RedPajamaGithub


text:
#ifndef REGIONSELECT_H
#define REGIONSELECT_H

#include <QDialog>
#include <QApplication>
#include <QDesktopWidget>
#include <QMouseEvent>
#include <QPainter>

#include "Core/ScreenCapture/ScreenCapture.h"

QT_BEGIN_NAMESPACE
class QLabel;
QT_END_NAMESPACE

class RegionSelect : public QDialog
{
public:
	 RegionSelect(QWidget *parent = nullptr, QPixmap* src = nullptr);
    ~RegionSelect();
    QPixmap getSelection();
	 CScreenshotRegion* selectedRegion();

protected:
    bool event(QEvent *event) override;
    void paintEvent(QPaintEvent *event) override;
    void mouseMoveEvent(QMouseEvent *event) override;

private:
    QRect selectRect;
    QSize sizeDesktop;

    QPoint selStartPoint;
    QPoint selEndPoint;

    bool palBackground;

    QPixmap desktopPixmapBkg;
    QPixmap desktopPixmapClr;

    void drawBackGround();
    void drawRectSelection(QPainter &painter);

};

#endif // REGIONSELECT_H


text:
package com.sun.imageio.plugins.bmp;

public class BMPCompressionTypes {

    private static final String[] compressionTypeNames =
        {"BI_RGB", "BI_RLE8", "BI_RLE4", "BI_BITFIELDS", "BI_JPEG", "BI_PNG"};

    static int getType(String typeString) {
        for (int i = 0; i < compressionTypeNames.length; i++)
            if (compressionTypeNames[i].equals(typeString))
                return i;
        return 0;
    }

    static String getName(int type) {
        return compressionTypeNames[type];
    }

    public static String[] getCompressionTypes() {
        return compressionTypeNames.clone();
    }
}


text:
package javax.crypto;

import gnu.java.security.Engine;

import java.lang.reflect.InvocationTargetException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.Provider;
import java.security.Security;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.KeySpec;

/**
 * A secret key factory translates {@link SecretKey} objects to and from
 * {@link java.security.spec.KeySpec} objects, and can translate between
 * different vendors' representations of {@link SecretKey} objects (for
 * security or semantics; whichever applies).
 *
 * @author Casey Marshall (csm@gnu.org)
 * @since 1.4
 * @see SecretKey
 */
public class SecretKeyFactory
{

  // Constants and fields.
  // ------------------------------------------------------------------------

  private static final String SERVICE = "SecretKeyFactory";

  /** The underlying factory implementation. */
  private SecretKeyFactorySpi skfSpi;

  /** The provider of the implementation. */
  private Provider provider;

  /** The name of the algorithm. */
  private String algorithm;

  // Constructor.
  // ------------------------------------------------------------------------

  /**
   * Create a new secret key factory.
   *
   * @param skfSpi   The underlying factory implementation.
   * @param provider The provider.
   * @param algorithm The algorithm name.
   */
  protected SecretKeyFactory(SecretKeyFactorySpi skfSpi, Provider provider,
                             String algorithm)
  {
    this.skfSpi = skfSpi;
    this.provider = provider;
    this.algorithm = algorithm;
  }

  // Class methods.
  // ------------------------------------------------------------------------

  /**
   * Create a new secret key factory from the first appropriate
   * instance.
   *
   * @param algorithm The algorithm name.
   * @return The appropriate key factory, if found.
   * @throws java.security.NoSuchAlgorithmException If no provider
   *         implements the specified algorithm.
   */
  public static final SecretKeyFactory getInstance(String algorithm)
    throws NoSuchAlgorithmException
  {
    Provider[] provs = Security.getProviders();
    for (int i = 0; i < provs.length; i++)
      {
        try
          {
            return getInstance(algorithm, provs[i]);
          }
        catch (NoSuchAlgorithmException nsae)
          {
          }
      }
    throw new NoSuchAlgorithmException(algorithm);
  }

  /**
   * Create a new secret key factory from the named provider.
   *
   * @param algorithm The algorithm name.
   * @param provider  The provider name.
   * @return The appropriate key factory, if found.
   * @throws java.security.NoSuchAlgorithmException If the named
   *         provider does not implement the algorithm.
   * @throws java.security.NoSuchProviderException If the named provider
   *         does not exist.
   */
  public static final SecretKeyFactory getInstance(String algorithm,
                                                   String provider)
    throws NoSuchAlgorithmException, NoSuchProviderException
  {
    Provider p = Security.getProvider(provider);
    if (p == null)
      {
        throw new NoSuchProviderException(provider);
      }
    return getInstance(algorithm, p);
  }

  /**
   * Create a new secret key factory from the specified provider.
   *
   * @param algorithm The algorithm name.
   * @param provider  The provider.
   * @return The appropriate key factory, if found.
   * @throws java.security.NoSuchAlgorithmException If the provider
   *         does not implement the algorithm.
   */
  public static final SecretKeyFactory getInstance(String algorithm,
                                                   Provider provider)
    throws NoSuchAlgorithmException
  {
    try
      {
        return new SecretKeyFactory((SecretKeyFactorySpi)
          Engine.getInstance(SERVICE, algorithm, provider),
          provider, algorithm);
      }
    catch (InvocationTargetException ite)
      {
        if (ite.getCause() == null)
          throw new NoSuchAlgorithmException(algorithm);
        if (ite.getCause() instanceof NoSuchAlgorithmException)
          throw (NoSuchAlgorithmException) ite.getCause();
        throw new NoSuchAlgorithmException(algorithm);
      }
    catch (ClassCastException cce)
      {
        throw new NoSuchAlgorithmException(algorithm);
      }
  }

  // Instance methods.
  // ------------------------------------------------------------------------

  /**
   * Generate a secret key from a key specification, if possible.
   *
   * @param keySpec The key specification.
   * @return The secret key.
   * @throws java.security.InvalidKeySpecException If the key specification
   *         cannot be transformed into a secret key.
   */
  public final SecretKey generateSecret(KeySpec keySpec)
    throws InvalidKeySpecException
  {
    return skfSpi.engineGenerateSecret(keySpec);
  }

  /**
   * Get the algorithm name.
   *
   * @return The algorithm name.
   */
  public final String getAlgorithm()
  {
    return algorithm;
  }

  /**
   * Get the key specification from a secret key.
   *
   * @param key     The secret key.
   * @param keySpec The target key specification class.
   * @return The key specification.
   * @throws java.security.spec.InvalidKeySpecException If the secret key cannot
   *         be transformed into the specified key specification.
   */
  public final KeySpec getKeySpec(SecretKey key, Class keySpec)
    throws InvalidKeySpecException
  {
    return skfSpi.engineGetKeySpec(key, keySpec);
  }

  /**
   * Get the provider of this implementation.
   *
   * @return The provider.
   */
  public final Provider getProvider()
  {
    return provider;
  }

  /**
   * Translate a secret key into another form.
   *
   * @param key The key to translate.
   * @return The translated key.
   * @throws java.security.InvalidKeyException If the argument cannot be
   *         translated.
   */
  public final SecretKey translateKey(SecretKey key)
    throws InvalidKeyException
  {
    return skfSpi.engineTranslateKey(key);
  }
}


text:
package scala.meta.internal.tokenizers

import scala.collection.mutable

object Compat {
  def newMutableMap[A, B] = mutable.Map.empty[A, B]
}


text:
/*
** Include Files
*/

#include "dcmtk/config/osconfig.h"    /* make sure OS specific configuration is included first */

#define INCLUDE_CSTDLIB
#define INCLUDE_CSTDIO
#define INCLUDE_CSTRING
#define INCLUDE_CSTDARG
#include "dcmtk/ofstd/ofstdinc.h"

#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif

#include "dcmtk/dcmnet/diutil.h"
#include "dcmtk/dcmnet/dimse.h"         /* always include the module header */
#include "dcmtk/dcmdata/dcuid.h"

static void DIMSE_dumpMessage_start(OFString &str, enum DIMSE_direction dir)
{
    if (dir == DIMSE_INCOMING)
      str = "===================== INCOMING DIMSE MESSAGE ====================\n";
    else
      str = "===================== OUTGOING DIMSE MESSAGE ====================\n";
}

static void DIMSE_dumpMessage_end(OFString &str, DcmItem *dataset = NULL)
{
    str += '\n';
    if (dataset)
    {
      str += "-----------------------------------------------------------------";
      OFOStringStream stream;
      stream << DcmObject::PrintHelper(*dataset, DCMTypes::PF_shortenLongTagValues) << OFStringStream_ends;
      OFSTRINGSTREAM_GETOFSTRING(stream, result);
      str += result;
    }
    str += "======================= END DIMSE MESSAGE =======================";
}

static void DIMSE_printNStatusString(STD_NAMESPACE ostream& dumpStream, int status)
{
  switch(status)
  {
    case STATUS_Success:
      dumpStream << "0x0000: Success";
      break;
    case STATUS_N_Cancel:
      dumpStream << "0xFE00: Cancel";
      break;
    case STATUS_N_AttributeListError:
      dumpStream << "0x0107: Attribute list error";
      break;
    case STATUS_N_SOPClassNotSupported:
      dumpStream << "0x0122: SOP class not supported";
      break;
    case STATUS_N_ClassInstanceConflict:
      dumpStream << "0x0119: Class/instance conflict";
      break;
    case STATUS_N_DuplicateSOPInstance:
      dumpStream << "0x0111: Duplicate SOP instance";
      break;
    case STATUS_N_DuplicateInvocation:
      dumpStream << "0x0210: Duplicate invocation";
      break;
    case STATUS_N_InvalidArgumentValue:
      dumpStream << "0x0115: Invalid argument value";
      break;
    case STATUS_N_InvalidAttributeValue:
      dumpStream << "0x0106: Invalid attribute value";
      break;
    case STATUS_N_AttributeValueOutOfRange:
      dumpStream << "0x0116: Attribute value out of range";
      break;
    case STATUS_N_InvalidObjectInstance:
      dumpStream << "0x0117: Invalid object instance";
      break;
    case STATUS_N_MissingAttribute:
      dumpStream << "0x0120: Missing attribute";
      break;
    case STATUS_N_MissingAttributeValue:
      dumpStream << "0x0121: Missing attribute value";
      break;
    case STATUS_N_MistypedArgument:
      dumpStream << "0x0212: Mistyped argument";
      break;
    case STATUS_N_NoSuchArgument:
      dumpStream << "0x0114: No such argument";
      break;
    case STATUS_N_NoSuchAttribute:
      dumpStream << "0x0105: No such attribute";
      break;
    case STATUS_N_NoSuchEventType:
      dumpStream << "0x0113: No such event type";
      break;
    case STATUS_N_NoSuchObjectInstance:
      dumpStream << "0x0112: No such object instance";
      break;
    case STATUS_N_NoSuchSOPClass:
      dumpStream << "0x0118: No such SOP class";
      break;
    case STATUS_N_ProcessingFailure:
      dumpStream << "0x0110: Processing failure";
      break;
    case STATUS_N_ResourceLimitation:
      dumpStream << "0x0213: Resource limitation";
      break;
    case STATUS_N_UnrecognizedOperation:
      dumpStream << "0x0211: Unrecognized operation";
      break;
    case STATUS_N_PRINT_BFS_Warn_MemoryAllocation:
      dumpStream << "0xB600: Basic film session warning - Memory allocation";
      break;
    case STATUS_N_PRINT_BFS_Warn_NoSessionPrinting:
      dumpStream << "0xB601: Basic film session warning - No session printing";
      break;
    case STATUS_N_PRINT_BFS_Warn_EmptyPage:
      dumpStream << "0xB602: Basic film session warning - Empty page";
      break;
    case STATUS_N_PRINT_BFB_Warn_EmptyPage:
      dumpStream << "0xB603: Basic film box warning - Empty page";
      break;
    case STATUS_N_PRINT_BFS_Fail_NoFilmBox:
      dumpStream << "0xC600: Basic film session failure - No film box";
      break;
    case STATUS_N_PRINT_BFS_Fail_PrintQueueFull:
      dumpStream << "0xC601: Basic film session failure - Print queue full";
      break;
    case STATUS_N_PRINT_BSB_Fail_PrintQueueFull:
      dumpStream << "0xC602: Basic film box failure - Print queue full";
      break;
    case STATUS_N_PRINT_BFS_BFB_Fail_ImageSize:
      dumpStream << "0xC603: Basic film session/box failure - Image size";
      break;
    case STATUS_N_PRINT_BFS_BFB_Fail_PositionCollision:
      dumpStream << "0xC604: Basic film session/box failure - Position collision";
      break;
    case STATUS_N_PRINT_IB_Fail_InsufficientMemory:
      dumpStream << "0xC605: Image box failure - Insufficient memory";
      break;
    case STATUS_N_PRINT_IB_Fail_MoreThanOneVOILUT:
      dumpStream << "0xC606: Image box failure - More than one VOI LUT";
      break;
    default:
      dumpStream << "0x" << STD_NAMESPACE hex << STD_NAMESPACE setfill('0') << STD_NAMESPACE setw(4)
          << status << ": Unknown Status Code";
      break;
  }
}

static void DIMSE_printCStoreStatusString(STD_NAMESPACE ostream& dumpStream, int status)
{
  dumpStream << "0x" << STD_NAMESPACE hex << STD_NAMESPACE setfill('0')
      << STD_NAMESPACE setw(4) << status;

  if ((status & 0xff00) == STATUS_STORE_Refused_OutOfResources)
  {
    dumpStream << ": Error: Refused - Out of resources";
  }
  else if ((status & 0xff00) == STATUS_STORE_Refused_SOPClassNotSupported)
  {
    dumpStream << ": Error: Refused - SOP Class not supported";
  }
  else if ((status & 0xff00) == STATUS_STORE_Error_DataSetDoesNotMatchSOPClass)
  {
    dumpStream << ": Error: Refused - Data Set does not match SOP Class";
  }
  else if ((status & 0xf000) == STATUS_STORE_Error_CannotUnderstand)
  {
    dumpStream << ": Error: Cannot understand";
  }
  else if (status == STATUS_STORE_Warning_CoersionOfDataElements)
  {
    dumpStream << ": Warning: Coersion of data elements";
  }
  else if (status == STATUS_STORE_Warning_DataSetDoesNotMatchSOPClass)
  {
    dumpStream << ": Warning: Data Set does not match SOP Class";
  }
  else if (status == STATUS_STORE_Warning_ElementsDiscarded)
  {
    dumpStream << ": Warning: Elements discarded";
  }
  else if (DICOM_WARNING_STATUS(status))
  {
    dumpStream << ": Warning";
  }
  else if (DICOM_PENDING_STATUS(status))
  {
    dumpStream << ": Pending";
  }
  else if (status == STATUS_Success)
  {
    dumpStream << ": Success";
  }
  else
  {
    dumpStream << ": Unknown Status Code";
  }
}

static void DIMSE_printCFindStatusString(STD_NAMESPACE ostream& dumpStream, int status)
{
  dumpStream << "0x" << STD_NAMESPACE hex << STD_NAMESPACE setfill('0')
      << STD_NAMESPACE setw(4) << status;

  if ((status & 0xff00) == STATUS_FIND_Refused_OutOfResources)
  {
    dumpStream << ": Error: Refused - Out of resources";
  }
  else if ((status & 0xff00) == STATUS_FIND_Refused_SOPClassNotSupported)
  {
    dumpStream << ": Error: Refused - SOP Class not supported";
  }
  else if ((status & 0xff00) == STATUS_FIND_Failed_IdentifierDoesNotMatchSOPClass)
  {
    dumpStream << ": Error: Failed - Identifier does not match SOP Class";
  }
  else if ((status & 0xf000) == STATUS_FIND_Failed_UnableToProcess)
  {
    dumpStream << ": Error: Failed - Unable to process";
  }
  else if (status == STATUS_FIND_Cancel_MatchingTerminatedDueToCancelRequest)
  {
    dumpStream << ": Cancel: Matching terminated due to Cancel Request";
  }
  else if (status == STATUS_FIND_Pending_WarningUnsupportedOptionalKeys)
  {
    dumpStream << ": Pending: Warning - Unsupported optional keys";
  }
  else if (DICOM_WARNING_STATUS(status))
  {
    dumpStream << ": Warning";
  }
  else if (DICOM_PENDING_STATUS(status))
  {
    dumpStream << ": Pending";
  }
  else if (status == STATUS_Success)
  {
    dumpStream << ": Success";
  }
  else
  {
    dumpStream << ": Unknown Status Code";
  }
}

static void DIMSE_printCGetMoveStatusString(STD_NAMESPACE ostream& dumpStream, int status)
{
  dumpStream << "0x" << STD_NAMESPACE hex << STD_NAMESPACE setfill('0')
      << STD_NAMESPACE setw(4) << status;

  if ((status & 0xf000) == STATUS_MOVE_Failed_UnableToProcess)
  {
    dumpStream << ": Error: Failed - Unable to process";
  }
  else if (status == STATUS_MOVE_Refused_OutOfResourcesNumberOfMatches)
  {
    dumpStream << ": Error: Refused - Out of resources - Number of matches";
  }
  else if (status == STATUS_MOVE_Refused_OutOfResourcesSubOperations)
  {
    dumpStream << ": Error: Refused - Out of resources - Suboperations";
  }
  else if (status == STATUS_MOVE_Failed_SOPClassNotSupported)
  {
    dumpStream << ": Failed: SOP Class not supported";
  }
  else if (status == STATUS_MOVE_Failed_MoveDestinationUnknown)
  {
    dumpStream << ": Failed: Move Destination unknown";
  }
  else if (status == STATUS_MOVE_Failed_IdentifierDoesNotMatchSOPClass)
  {
    dumpStream << ": Failed: Identifier does not match SOP Class";
  }
  else if (status == STATUS_MOVE_Cancel_SubOperationsTerminatedDueToCancelIndication)
  {
    dumpStream << ": Cancel: Suboperations terminated due to Cancel Indication";
  }
  else if (status == STATUS_MOVE_Warning_SubOperationsCompleteOneOrMoreFailures)
  {
    dumpStream << ": Warning: Suboperations complete, one or more failures";
  }
  else if (DICOM_WARNING_STATUS(status))
  {
    dumpStream << ": Warning";
  }
  else if (DICOM_PENDING_STATUS(status))
  {
    dumpStream << ": Pending";
  }
  else if (status == STATUS_Success)
  {
    dumpStream << ": Success";
  }
  else
  {
    dumpStream << ": Unknown Status Code";
  }
}

static void DIMSE_printCEchoStatusString(STD_NAMESPACE ostream& dumpStream, int status)
{
  dumpStream << "0x" << STD_NAMESPACE hex << STD_NAMESPACE setfill('0')
      << STD_NAMESPACE setw(4) << status;
  if (DICOM_WARNING_STATUS(status))
  {
    dumpStream << ": Warning";
  }
  else if (DICOM_PENDING_STATUS(status))
  {
    dumpStream << ": Pending";
  }
  else if (status == STATUS_Success)
  {
    dumpStream << ": Success";
  }
  else
  {
    dumpStream << ": Unknown Status Code";
  }
}

OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_C_EchoRQ &msg, enum DIMSE_direction dir, DcmItem *dataset, T_ASC_PresentationContextID presID)
{
    OFOStringStream stream;
    DIMSE_dumpMessage_start(str, dir);
    stream << "Message Type                  : C-ECHO RQ" << OFendl;
    if (presID > 0)
    {
        stream << "Presentation Context ID       : " << OFstatic_cast(int, presID) << OFendl;
    }
    stream << "Message ID                    : " << msg.MessageID << OFendl
           << "Data Set                      : " << ((msg.DataSetType==DIMSE_DATASET_NULL) ? "none" : "present");

    OFSTRINGSTREAM_GETSTR(stream, result)
    str += result;
    OFSTRINGSTREAM_FREESTR(stream)

    DIMSE_dumpMessage_end(str, dataset);

    return str;
}

OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_C_EchoRSP &msg, enum DIMSE_direction dir, DcmItem *dataset, T_ASC_PresentationContextID presID)
{
    OFOStringStream stream;
    const char *uid = NULL;

    DIMSE_dumpMessage_start(str, dir);
    if (msg.opts & O_ECHO_AFFECTEDSOPCLASSUID) uid = dcmFindNameOfUID(msg.AffectedSOPClassUID);
    stream << "Message Type                  : C-ECHO RSP" << OFendl;
    if (presID > 0)
    {
        stream << "Presentation Context ID       : " << OFstatic_cast(int, presID) << OFendl;
    }
    stream << "Message ID Being Responded To : " << msg.MessageIDBeingRespondedTo << OFendl
           << "Affected SOP Class UID        : ";
    if (msg.opts & O_ECHO_AFFECTEDSOPCLASSUID) stream << (uid ? uid : msg.AffectedSOPClassUID) << OFendl;
    else stream << "none" << OFendl;

    stream << "Data Set                      : " << ((msg.DataSetType==DIMSE_DATASET_NULL) ? "none" : "present") << OFendl
           << "DIMSE Status                  : ";
    DIMSE_printCEchoStatusString(stream, msg.DimseStatus);

    OFSTRINGSTREAM_GETSTR(stream, result)
    str += result;
    OFSTRINGSTREAM_FREESTR(stream)

    DIMSE_dumpMessage_end(str, dataset);

    return str;
}

OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_C_StoreRQ &msg, enum DIMSE_direction dir, DcmItem *dataset, T_ASC_PresentationContextID presID)
{
    OFOStringStream stream;
    const char *uid = dcmFindNameOfUID(msg.AffectedSOPClassUID);

    DIMSE_dumpMessage_start(str, dir);
    stream << "Message Type                  : C-STORE RQ" << OFendl;
    if (presID > 0)
    {
        stream << "Presentation Context ID       : " << OFstatic_cast(int, presID) << OFendl;
    }
    stream << "Message ID                    : " << msg.MessageID << OFendl
           << "Affected SOP Class UID        : " << (uid ? uid : msg.AffectedSOPClassUID) << OFendl
           << "Affected SOP Instance UID     : " << msg.AffectedSOPInstanceUID << OFendl
           << "Data Set                      : " << ((msg.DataSetType==DIMSE_DATASET_NULL) ? "none" : "present") << OFendl
           << "Priority                      : ";
    switch (msg.Priority)
    {
      case DIMSE_PRIORITY_LOW:
        stream << "low";
        break;
      case DIMSE_PRIORITY_MEDIUM:
        stream << "medium";
        break;
      case DIMSE_PRIORITY_HIGH:
        stream << "high";
        break;
    }
    if (msg.opts & O_STORE_MOVEORIGINATORAETITLE)
    {
        stream  << OFendl << "Move Originator AE Title      : " << msg.MoveOriginatorApplicationEntityTitle;
    }
    if (msg.opts & O_STORE_MOVEORIGINATORID)
    {
        stream  << OFendl << "Move Originator ID            : " << msg.MoveOriginatorID;
    }

    OFSTRINGSTREAM_GETSTR(stream, result)
    str += result;
    OFSTRINGSTREAM_FREESTR(stream)

    DIMSE_dumpMessage_end(str, dataset);

    return str;
}

OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_C_StoreRSP &msg, enum DIMSE_direction dir, DcmItem *dataset, T_ASC_PresentationContextID presID)
{
    OFOStringStream stream;
    const char *uid = NULL;

    DIMSE_dumpMessage_start(str, dir);
    if (msg.opts & O_STORE_AFFECTEDSOPCLASSUID) uid = dcmFindNameOfUID(msg.AffectedSOPClassUID);
    stream << "Message Type                  : C-STORE RSP" << OFendl;
    if (presID > 0)
    {
        stream << "Presentation Context ID       : " << OFstatic_cast(int, presID) << OFendl;
    }
    stream << "Message ID Being Responded To : " << msg.MessageIDBeingRespondedTo << OFendl
           << "Affected SOP Class UID        : ";
    if (msg.opts & O_STORE_AFFECTEDSOPCLASSUID) stream << (uid ? uid : msg.AffectedSOPClassUID) << OFendl;
    else stream << "none" << OFendl;
    stream << "Affected SOP Instance UID     : ";
    if (msg.opts & O_STORE_AFFECTEDSOPINSTANCEUID) stream << msg.AffectedSOPInstanceUID << OFendl;
    else stream << "none" << OFendl;
    stream << "Data Set                      : " << ((msg.DataSetType==DIMSE_DATASET_NULL) ? "none" : "present") << OFendl
           << "DIMSE Status                  : ";
    DIMSE_printCStoreStatusString(stream, msg.DimseStatus);

    OFSTRINGSTREAM_GETSTR(stream, result)
    str += result;
    OFSTRINGSTREAM_FREESTR(stream)

    DIMSE_dumpMessage_end(str, dataset);

    return str;
}

OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_C_GetRQ &msg, enum DIMSE_direction dir, DcmItem *dataset, T_ASC_PresentationContextID presID)
{
    OFOStringStream stream;
    const char *uid = dcmFindNameOfUID(msg.AffectedSOPClassUID);

    DIMSE_dumpMessage_start(str, dir);
    stream << "Message Type                  : C-GET RQ" << OFendl;
    if (presID > 0)
    {
        stream << "Presentation Context ID       : " << OFstatic_cast(int, presID) << OFendl;
    }
    stream << "Message ID                    : " << msg.MessageID << OFendl
           << "Affected SOP Class UID        : " << (uid ? uid : msg.AffectedSOPClassUID) << OFendl
           << "Data Set                      : " << ((msg.DataSetType==DIMSE_DATASET_NULL) ? "none" : "present") << OFendl
           << "Priority                      : ";
    switch (msg.Priority)
    {
      case DIMSE_PRIORITY_LOW:
        stream << "low";
        break;
      case DIMSE_PRIORITY_MEDIUM:
        stream << "medium";
        break;
      case DIMSE_PRIORITY_HIGH:
        stream << "high";
        break;
    }

    OFSTRINGSTREAM_GETSTR(stream, result)
    str += result;
    OFSTRINGSTREAM_FREESTR(stream)

    DIMSE_dumpMessage_end(str, dataset);

    return str;
}

OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_C_GetRSP &msg, enum DIMSE_direction dir, DcmItem *dataset, T_ASC_PresentationContextID presID)
{
    OFOStringStream stream;
    const char *uid = NULL;

    DIMSE_dumpMessage_start(str, dir);
    if (msg.opts & O_GET_AFFECTEDSOPCLASSUID) uid = dcmFindNameOfUID(msg.AffectedSOPClassUID);
    stream << "Message Type                  : C-GET RSP" << OFendl;
    if (presID > 0)
    {
        stream << "Presentation Context ID       : " << OFstatic_cast(int, presID) << OFendl;
    }
    stream << "Message ID Being Responded To : " << msg.MessageIDBeingRespondedTo << OFendl
           << "Affected SOP Class UID        : ";
    if (msg.opts & O_GET_AFFECTEDSOPCLASSUID) stream << (uid ? uid : msg.AffectedSOPClassUID) << OFendl;
    else stream << "none" << OFendl;
    stream << "Remaining Suboperations       : ";
    if (msg.opts & O_GET_NUMBEROFREMAININGSUBOPERATIONS) stream << msg.NumberOfRemainingSubOperations << OFendl;
    else stream << "none" << OFendl;
    stream << "Completed Suboperations       : ";
    if (msg.opts & O_GET_NUMBEROFCOMPLETEDSUBOPERATIONS) stream << msg.NumberOfCompletedSubOperations << OFendl;
    else stream << "none" << OFendl;
    stream << "Failed Suboperations          : ";
    if (msg.opts & O_GET_NUMBEROFFAILEDSUBOPERATIONS) stream << msg.NumberOfFailedSubOperations << OFendl;
    else stream << "none" << OFendl;
    stream << "Warning Suboperations         : ";
    if (msg.opts & O_GET_NUMBEROFWARNINGSUBOPERATIONS) stream << msg.NumberOfWarningSubOperations << OFendl;
    else stream << "none" << OFendl;
    stream << "Data Set                      : " << ((msg.DataSetType==DIMSE_DATASET_NULL) ? "none" : "present") << OFendl
           << "DIMSE Status                  : ";
    DIMSE_printCGetMoveStatusString(stream, msg.DimseStatus);

    OFSTRINGSTREAM_GETSTR(stream, result)
    str += result;
    OFSTRINGSTREAM_FREESTR(stream)

    DIMSE_dumpMessage_end(str, dataset);

    return str;
}

OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_C_MoveRQ &msg, enum DIMSE_direction dir, DcmItem *dataset, T_ASC_PresentationContextID presID)
{
    OFOStringStream stream;
    const char *uid = dcmFindNameOfUID(msg.AffectedSOPClassUID);

    DIMSE_dumpMessage_start(str, dir);
    stream << "Message Type                  : C-MOVE RQ" << OFendl;
    if (presID > 0)
    {
        stream << "Presentation Context ID       : " << OFstatic_cast(int, presID) << OFendl;
    }
    stream << "Message ID                    : " << msg.MessageID << OFendl
           << "Affected SOP Class UID        : " << (uid ? uid : msg.AffectedSOPClassUID) << OFendl
           << "Data Set                      : " << ((msg.DataSetType==DIMSE_DATASET_NULL) ? "none" : "present") << OFendl
           << "Priority                      : ";
    switch (msg.Priority)
    {
      case DIMSE_PRIORITY_LOW:
        stream << "low";
        break;
      case DIMSE_PRIORITY_MEDIUM:
        stream << "medium";
        break;
      case DIMSE_PRIORITY_HIGH:
        stream << "high";
        break;
    }
    stream << OFendl << "Move Destination              : " << msg.MoveDestination;

    OFSTRINGSTREAM_GETSTR(stream, result)
    str += result;
    OFSTRINGSTREAM_FREESTR(stream)

    DIMSE_dumpMessage_end(str, dataset);

    return str;
}

OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_C_MoveRSP &msg, enum DIMSE_direction dir, DcmItem *dataset, T_ASC_PresentationContextID presID)
{
    OFOStringStream stream;
    const char *uid = NULL;

    DIMSE_dumpMessage_start(str, dir);
    if (msg.opts & O_MOVE_AFFECTEDSOPCLASSUID) uid = dcmFindNameOfUID(msg.AffectedSOPClassUID);
    stream << "Message Type                  : C-MOVE RSP" << OFendl;
    if (presID > 0)
    {
        stream << "Presentation Context ID       : " << OFstatic_cast(int, presID) << OFendl;
    }
    stream << "Message ID Being Responded To : " << msg.MessageIDBeingRespondedTo << OFendl
           << "Affected SOP Class UID        : ";
    if (msg.opts & O_MOVE_AFFECTEDSOPCLASSUID) stream << (uid ? uid : msg.AffectedSOPClassUID) << OFendl;
    else stream << "none" << OFendl;
    stream << "Remaining Suboperations       : ";
    if (msg.opts & O_MOVE_NUMBEROFREMAININGSUBOPERATIONS) stream << msg.NumberOfRemainingSubOperations << OFendl;
    else stream << "none" << OFendl;
    stream << "Completed Suboperations       : ";
    if (msg.opts & O_MOVE_NUMBEROFCOMPLETEDSUBOPERATIONS) stream << msg.NumberOfCompletedSubOperations << OFendl;
    else stream << "none" << OFendl;
    stream << "Failed Suboperations          : ";
    if (msg.opts & O_MOVE_NUMBEROFFAILEDSUBOPERATIONS) stream << msg.NumberOfFailedSubOperations << OFendl;
    else stream << "none" << OFendl;
    stream << "Warning Suboperations         : ";
    if (msg.opts & O_MOVE_NUMBEROFWARNINGSUBOPERATIONS) stream << msg.NumberOfWarningSubOperations << OFendl;
    else stream << "none" << OFendl;
    stream << "Data Set                      : " << ((msg.DataSetType==DIMSE_DATASET_NULL) ? "none" : "present") << OFendl
           << "DIMSE Status                  : ";
    DIMSE_printCGetMoveStatusString(stream, msg.DimseStatus);

    OFSTRINGSTREAM_GETSTR(stream, result)
    str += result;
    OFSTRINGSTREAM_FREESTR(stream)

    DIMSE_dumpMessage_end(str, dataset);

    return str;
}

OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_C_FindRQ &msg, enum DIMSE_direction dir, DcmItem *dataset, T_ASC_PresentationContextID presID)
{
    OFOStringStream stream;
    const char *uid = dcmFindNameOfUID(msg.AffectedSOPClassUID);

    DIMSE_dumpMessage_start(str, dir);
    stream << "Message Type                  : C-FIND RQ" << OFendl;
    if (presID > 0)
    {
        stream << "Presentation Context ID       : " << OFstatic_cast(int, presID) << OFendl;
    }
    stream << "Message ID                    : " << msg.MessageID << OFendl
           << "Affected SOP Class UID        : " << (uid ? uid : msg.AffectedSOPClassUID) << OFendl
           << "Data Set                      : " << ((msg.DataSetType==DIMSE_DATASET_NULL) ? "none" : "present") << OFendl
           << "Priority                      : ";
    switch (msg.Priority)
    {
      case DIMSE_PRIORITY_LOW:
        stream << "low";
        break;
      case DIMSE_PRIORITY_MEDIUM:
        stream << "medium";
        break;
      case DIMSE_PRIORITY_HIGH:
        stream << "high";
        break;
    }

    OFSTRINGSTREAM_GETSTR(stream, result)
    str += result;
    OFSTRINGSTREAM_FREESTR(stream)

    DIMSE_dumpMessage_end(str, dataset);

    return str;
}

OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_C_FindRSP &msg, enum DIMSE_direction dir, DcmItem *dataset, T_ASC_PresentationContextID presID)
{
    OFOStringStream stream;
    const char *uid = NULL;

    DIMSE_dumpMessage_start(str, dir);
    if (msg.opts & O_FIND_AFFECTEDSOPCLASSUID) uid = dcmFindNameOfUID(msg.AffectedSOPClassUID);
    stream << "Message Type                  : C-FIND RSP" << OFendl;
    if (presID > 0)
    {
        stream << "Presentation Context ID       : " << OFstatic_cast(int, presID) << OFendl;
    }
    stream << "Message ID Being Responded To : " << msg.MessageIDBeingRespondedTo << OFendl
           << "Affected SOP Class UID        : ";
    if (msg.opts & O_FIND_AFFECTEDSOPCLASSUID) stream << (uid ? uid : msg.AffectedSOPClassUID) << OFendl;
    else stream << "none" << OFendl;
    stream << "Data Set                      : " << ((msg.DataSetType==DIMSE_DATASET_NULL) ? "none" : "present") << OFendl
           << "DIMSE Status                  : ";
    DIMSE_printCFindStatusString(stream, msg.DimseStatus);

    OFSTRINGSTREAM_GETSTR(stream, result)
    str += result;
    OFSTRINGSTREAM_FREESTR(stream)

    DIMSE_dumpMessage_end(str, dataset);

    return str;
}

OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_C_CancelRQ &msg, enum DIMSE_direction dir, DcmItem *dataset, T_ASC_PresentationContextID presID)
{
    OFOStringStream stream;

    DIMSE_dumpMessage_start(str, dir);
    stream << "Message Type                  : C-CANCEL RQ" << OFendl;
    if (presID > 0)
    {
        stream << "Presentation Context ID       : " << OFstatic_cast(int, presID) << OFendl;
    }
    stream << "Message ID Being Responded To : " << msg.MessageIDBeingRespondedTo << OFendl
           << "Data Set                      : " << ((msg.DataSetType==DIMSE_DATASET_NULL) ? "none" : "present");

    OFSTRINGSTREAM_GETSTR(stream, result)
    str += result;
    OFSTRINGSTREAM_FREESTR(stream)

    DIMSE_dumpMessage_end(str, dataset);

    return str;
}

OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_N_EventReportRQ &msg, enum DIMSE_direction dir, DcmItem *dataset, T_ASC_PresentationContextID presID)
{
    OFOStringStream stream;
    const char *uid = dcmFindNameOfUID(msg.AffectedSOPClassUID);

    DIMSE_dumpMessage_start(str, dir);
    stream << "Message Type                  : N-EVENT-REPORT RQ" << OFendl;
    if (presID > 0)
    {
        stream << "Presentation Context ID       : " << OFstatic_cast(int, presID) << OFendl;
    }
    stream << "Message ID                    : " << msg.MessageID << OFendl
           << "Affected SOP Class UID        : " << (uid ? uid : msg.AffectedSOPClassUID) << OFendl
           << "Affected SOP Instance UID     : " << msg.AffectedSOPInstanceUID << OFendl
           << "Data Set                      : " << ((msg.DataSetType==DIMSE_DATASET_NULL) ? "none" : "present") << OFendl
           << "Event Type ID                 : " << msg.EventTypeID;

    OFSTRINGSTREAM_GETSTR(stream, result)
    str += result;
    OFSTRINGSTREAM_FREESTR(stream)

    DIMSE_dumpMessage_end(str, dataset);

    return str;
}

OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_N_EventReportRSP &msg, enum DIMSE_direction dir, DcmItem *dataset, T_ASC_PresentationContextID presID)
{
    OFOStringStream stream;
    const char *uid = NULL;

    DIMSE_dumpMessage_start(str, dir);
    if (msg.opts & O_NEVENTREPORT_AFFECTEDSOPCLASSUID) uid = dcmFindNameOfUID(msg.AffectedSOPClassUID);
    stream << "Message Type                  : N-EVENT-REPORT RSP" << OFendl;
    if (presID > 0)
    {
        stream << "Presentation Context ID       : " << OFstatic_cast(int, presID) << OFendl;
    }
    stream << "Message ID Being Responded To : " << msg.MessageIDBeingRespondedTo << OFendl
           << "Affected SOP Class UID        : " ;
    if (msg.opts & O_NEVENTREPORT_AFFECTEDSOPCLASSUID) stream << (uid ? uid : msg.AffectedSOPClassUID) << OFendl;
    else stream << "none" << OFendl;
    stream << "Affected SOP Instance UID     : ";
    if (msg.opts & O_NEVENTREPORT_AFFECTEDSOPINSTANCEUID) stream << msg.AffectedSOPInstanceUID << OFendl;
    else stream << "none" << OFendl;
    stream << "Data Set                      : " << ((msg.DataSetType==DIMSE_DATASET_NULL) ? "none" : "present") << OFendl
           << "Event Type ID                 : ";
    if (msg.opts & O_NEVENTREPORT_EVENTTYPEID) stream << msg.EventTypeID << OFendl;
    else stream << "none" << OFendl;
    stream << "DIMSE Status                  : ";
    DIMSE_printNStatusString(stream, msg.DimseStatus);

    OFSTRINGSTREAM_GETSTR(stream, result)
    str += result;
    OFSTRINGSTREAM_FREESTR(stream)

    DIMSE_dumpMessage_end(str, dataset);

    return str;
}

OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_N_GetRQ &msg, enum DIMSE_direction dir, DcmItem *dataset, T_ASC_PresentationContextID presID)
{
    OFOStringStream stream;
    const char *uid = dcmFindNameOfUID(msg.RequestedSOPClassUID);

    DIMSE_dumpMessage_start(str, dir);
    stream << "Message Type                  : N-GET RQ" << OFendl;
    if (presID > 0)
    {
        stream << "Presentation Context ID       : " << OFstatic_cast(int, presID) << OFendl;
    }
    stream << "Message ID                    : " << msg.MessageID << OFendl
           << "Requested SOP Class UID       : " << (uid ? uid : msg.RequestedSOPClassUID) << OFendl
           << "Requested SOP Instance UID    : " << msg.RequestedSOPInstanceUID << OFendl
           << "Data Set                      : " << ((msg.DataSetType==DIMSE_DATASET_NULL) ? "none" : "present") << OFendl
           << "Attribute Identifier List     : ";
    if (msg.ListCount == 0) stream << "none";
    else for (int cList = 0; cList < msg.ListCount; cList += 2)
    {
      stream << "(" << STD_NAMESPACE hex << STD_NAMESPACE setfill('0') << STD_NAMESPACE setw(4)
             << msg.AttributeIdentifierList[cList]
             << "," << STD_NAMESPACE hex << STD_NAMESPACE setfill('0') << STD_NAMESPACE setw(4)
             << msg.AttributeIdentifierList[cList + 1] << ") ";
    }

    OFSTRINGSTREAM_GETSTR(stream, result)
    str += result;
    OFSTRINGSTREAM_FREESTR(stream)

    DIMSE_dumpMessage_end(str, dataset);

    return str;
}

OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_N_GetRSP &msg, enum DIMSE_direction dir, DcmItem *dataset, T_ASC_PresentationContextID presID)
{
    OFOStringStream stream;
    const char *uid = NULL;

    DIMSE_dumpMessage_start(str, dir);
    if (msg.opts & O_NGET_AFFECTEDSOPCLASSUID) uid = dcmFindNameOfUID(msg.AffectedSOPClassUID);
    stream << "Message Type                  : N-GET RSP" << OFendl;
    if (presID > 0)
    {
        stream << "Presentation Context ID       : " << OFstatic_cast(int, presID) << OFendl;
    }
    stream << "Message ID Being Responded To : " << msg.MessageIDBeingRespondedTo << OFendl
           << "Affected SOP Class UID        : " ;
    if (msg.opts & O_NGET_AFFECTEDSOPCLASSUID) stream << (uid ? uid : msg.AffectedSOPClassUID) << OFendl;
    else stream << "none" << OFendl;
    stream << "Affected SOP Instance UID     : ";
    if (msg.opts & O_NGET_AFFECTEDSOPINSTANCEUID) stream << msg.AffectedSOPInstanceUID << OFendl;
    else stream << "none" << OFendl;
    stream << "Data Set                      : " << ((msg.DataSetType==DIMSE_DATASET_NULL) ? "none" : "present") << OFendl
           << "DIMSE Status                  : ";
    DIMSE_printNStatusString(stream, msg.DimseStatus);

    OFSTRINGSTREAM_GETSTR(stream, result)
    str += result;
    OFSTRINGSTREAM_FREESTR(stream)

    DIMSE_dumpMessage_end(str, dataset);

    return str;
}

OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_N_SetRQ &msg, enum DIMSE_direction dir, DcmItem *dataset, T_ASC_PresentationContextID presID)
{
    OFOStringStream stream;
    const char *uid = dcmFindNameOfUID(msg.RequestedSOPClassUID);

    DIMSE_dumpMessage_start(str, dir);
    stream << "Message Type                  : N-SET RQ" << OFendl;
    if (presID > 0)
    {
        stream << "Presentation Context ID       : " << OFstatic_cast(int, presID) << OFendl;
    }
    stream << "Message ID                    : " << msg.MessageID << OFendl
           << "Requested SOP Class UID       : " << (uid ? uid : msg.RequestedSOPClassUID) << OFendl
           << "Requested SOP Instance UID    : " << msg.RequestedSOPInstanceUID << OFendl
           << "Data Set                      : " << ((msg.DataSetType==DIMSE_DATASET_NULL) ? "none" : "present");

    OFSTRINGSTREAM_GETSTR(stream, result)
    str += result;
    OFSTRINGSTREAM_FREESTR(stream)

    DIMSE_dumpMessage_end(str, dataset);

    return str;
}

OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_N_SetRSP &msg, enum DIMSE_direction dir, DcmItem *dataset, T_ASC_PresentationContextID presID)
{
    OFOStringStream stream;
    const char *uid = NULL;

    DIMSE_dumpMessage_start(str, dir);
    if (msg.opts & O_NSET_AFFECTEDSOPCLASSUID) uid = dcmFindNameOfUID(msg.AffectedSOPClassUID);
    stream << "Message Type                  : N-SET RSP" << OFendl;
    if (presID > 0)
    {
        stream << "Presentation Context ID       : " << OFstatic_cast(int, presID) << OFendl;
    }
    stream << "Message ID Being Responded To : " << msg.MessageIDBeingRespondedTo << OFendl
           << "Affected SOP Class UID        : " ;
    if (msg.opts & O_NSET_AFFECTEDSOPCLASSUID) stream << (uid ? uid : msg.AffectedSOPClassUID) << OFendl;
    else stream << "none" << OFendl;
    stream << "Affected SOP Instance UID     : ";
    if (msg.opts & O_NSET_AFFECTEDSOPINSTANCEUID) stream << msg.AffectedSOPInstanceUID << OFendl;
    else stream << "none" << OFendl;
    stream << "Data Set                      : " << ((msg.DataSetType==DIMSE_DATASET_NULL) ? "none" : "present") << OFendl
           << "DIMSE Status                  : ";
    DIMSE_printNStatusString(stream, msg.DimseStatus);

    OFSTRINGSTREAM_GETSTR(stream, result)
    str += result;
    OFSTRINGSTREAM_FREESTR(stream)

    DIMSE_dumpMessage_end(str, dataset);

    return str;
}

OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_N_ActionRQ &msg, enum DIMSE_direction dir, DcmItem *dataset, T_ASC_PresentationContextID presID)
{
    OFOStringStream stream;
    const char *uid = dcmFindNameOfUID(msg.RequestedSOPClassUID);

    DIMSE_dumpMessage_start(str, dir);
    stream << "Message Type                  : N-ACTION RQ" << OFendl;
    if (presID > 0)
    {
        stream << "Presentation Context ID       : " << OFstatic_cast(int, presID) << OFendl;
    }
    stream << "Message ID                    : " << msg.MessageID << OFendl
           << "Requested SOP Class UID       : " << (uid ? uid : msg.RequestedSOPClassUID) << OFendl
           << "Requested SOP Instance UID    : " << msg.RequestedSOPInstanceUID << OFendl
           << "Action Type ID                : " << msg.ActionTypeID << OFendl
           << "Data Set                      : " << ((msg.DataSetType==DIMSE_DATASET_NULL) ? "none" : "present");

    OFSTRINGSTREAM_GETSTR(stream, result)
    str += result;
    OFSTRINGSTREAM_FREESTR(stream)

    DIMSE_dumpMessage_end(str, dataset);

    return str;
}

OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_N_ActionRSP &msg, enum DIMSE_direction dir, DcmItem *dataset, T_ASC_PresentationContextID presID)
{
    OFOStringStream stream;
    const char *uid = NULL;

    DIMSE_dumpMessage_start(str, dir);
    if (msg.opts & O_NACTION_AFFECTEDSOPCLASSUID) uid = dcmFindNameOfUID(msg.AffectedSOPClassUID);
    stream << "Message Type                  : N-ACTION RSP" << OFendl;
    if (presID > 0)
    {
        stream << "Presentation Context ID       : " << OFstatic_cast(int, presID) << OFendl;
    }
    stream << "Message ID Being Responded To : " << msg.MessageIDBeingRespondedTo << OFendl
           << "Affected SOP Class UID        : " ;
    if (msg.opts & O_NACTION_AFFECTEDSOPCLASSUID) stream << (uid ? uid : msg.AffectedSOPClassUID) << OFendl;
    else stream << "none" << OFendl;
    stream << "Affected SOP Instance UID     : ";
    if (msg.opts & O_NACTION_AFFECTEDSOPINSTANCEUID) stream << msg.AffectedSOPInstanceUID << OFendl;
    else stream << "none" << OFendl;
    stream << "Data Set                      : " << ((msg.DataSetType==DIMSE_DATASET_NULL) ? "none" : "present") << OFendl
           << "Action Type ID                : ";
    if (msg.opts & O_NACTION_ACTIONTYPEID) stream << msg.ActionTypeID << OFendl;
    else stream << "none" << OFendl;
    stream << "DIMSE Status                  : ";
    DIMSE_printNStatusString(stream, msg.DimseStatus);

    OFSTRINGSTREAM_GETSTR(stream, result)
    str += result;
    OFSTRINGSTREAM_FREESTR(stream)

    DIMSE_dumpMessage_end(str, dataset);

    return str;
}

OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_N_CreateRQ &msg, enum DIMSE_direction dir, DcmItem *dataset, T_ASC_PresentationContextID presID)
{
    OFOStringStream stream;
    const char *uid = dcmFindNameOfUID(msg.AffectedSOPClassUID);

    DIMSE_dumpMessage_start(str, dir);
    stream << "Message Type                  : N-CREATE RQ" << OFendl;
    if (presID > 0)
    {
        stream << "Presentation Context ID       : " << OFstatic_cast(int, presID) << OFendl;
    }
    stream << "Message ID                    : " << msg.MessageID << OFendl
           << "Affected SOP Class UID        : " << (uid ? uid : msg.AffectedSOPClassUID) << OFendl
           << "Affected SOP Instance UID     : ";
    if (msg.opts & O_NCREATE_AFFECTEDSOPINSTANCEUID) stream << msg.AffectedSOPInstanceUID << OFendl;
    else stream << "none" << OFendl;
    stream << "Data Set                      : " << ((msg.DataSetType==DIMSE_DATASET_NULL) ? "none" : "present");

    OFSTRINGSTREAM_GETSTR(stream, result)
    str += result;
    OFSTRINGSTREAM_FREESTR(stream)

    DIMSE_dumpMessage_end(str, dataset);

    return str;
}

OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_N_CreateRSP &msg, enum DIMSE_direction dir, DcmItem *dataset, T_ASC_PresentationContextID presID)
{
    OFOStringStream stream;
    const char *uid = NULL;

    DIMSE_dumpMessage_start(str, dir);
    if (msg.opts & O_NCREATE_AFFECTEDSOPCLASSUID) uid = dcmFindNameOfUID(msg.AffectedSOPClassUID);
    stream << "Message Type                  : N-CREATE RSP" << OFendl;
    if (presID > 0)
    {
        stream << "Presentation Context ID       : " << OFstatic_cast(int, presID) << OFendl;
    }
    stream << "Message ID Being Responded To : " << msg.MessageIDBeingRespondedTo << OFendl
           << "Affected SOP Class UID        : " ;
    if (msg.opts & O_NCREATE_AFFECTEDSOPCLASSUID) stream << (uid ? uid : msg.AffectedSOPClassUID) << OFendl;
    else stream << "none" << OFendl;
    stream << "Affected SOP Instance UID     : ";
    if (msg.opts & O_NCREATE_AFFECTEDSOPINSTANCEUID) stream << msg.AffectedSOPInstanceUID << OFendl;
    else stream << "none" << OFendl;
    stream << "Data Set                      : " << ((msg.DataSetType==DIMSE_DATASET_NULL) ? "none" : "present") << OFendl
           << "DIMSE Status                  : ";
    DIMSE_printNStatusString(stream, msg.DimseStatus);

    OFSTRINGSTREAM_GETSTR(stream, result)
    str += result;
    OFSTRINGSTREAM_FREESTR(stream)

    DIMSE_dumpMessage_end(str, dataset);

    return str;
}

OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_N_DeleteRQ &msg, enum DIMSE_direction dir, DcmItem *dataset, T_ASC_PresentationContextID presID)
{
    OFOStringStream stream;
    const char *uid = dcmFindNameOfUID(msg.RequestedSOPClassUID);

    DIMSE_dumpMessage_start(str, dir);
    stream << "Message Type                  : N-DELETE RQ" << OFendl;
    if (presID > 0)
    {
        stream << "Presentation Context ID       : " << OFstatic_cast(int, presID) << OFendl;
    }
    stream << "Message ID                    : " << msg.MessageID << OFendl
           << "Requested SOP Class UID       : " << (uid ? uid : msg.RequestedSOPClassUID) << OFendl
           << "Requested SOP Instance UID    : " << msg.RequestedSOPInstanceUID << OFendl
           << "Data Set                      : " << ((msg.DataSetType==DIMSE_DATASET_NULL) ? "none" : "present");

    OFSTRINGSTREAM_GETSTR(stream, result)
    str += result;
    OFSTRINGSTREAM_FREESTR(stream)

    DIMSE_dumpMessage_end(str, dataset);

    return str;
}

OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_N_DeleteRSP &msg, enum DIMSE_direction dir, DcmItem *dataset, T_ASC_PresentationContextID presID)
{
    OFOStringStream stream;
    const char *uid = NULL;

    DIMSE_dumpMessage_start(str, dir);
    if (msg.opts & O_NDELETE_AFFECTEDSOPCLASSUID) uid = dcmFindNameOfUID(msg.AffectedSOPClassUID);
    stream << "Message Type                  : N-DELETE RSP" << OFendl;
    if (presID > 0)
    {
        stream << "Presentation Context ID       : " << OFstatic_cast(int, presID) << OFendl;
    }
    stream << "Message ID Being Responded To : " << msg.MessageIDBeingRespondedTo << OFendl
           << "Affected SOP Class UID        : " ;
    if (msg.opts & O_NDELETE_AFFECTEDSOPCLASSUID) stream << (uid ? uid : msg.AffectedSOPClassUID) << OFendl;
    else stream << "none" << OFendl;
    stream << "Affected SOP Instance UID     : ";
    if (msg.opts & O_NDELETE_AFFECTEDSOPINSTANCEUID) stream << msg.AffectedSOPInstanceUID << OFendl;
    else stream << "none" << OFendl;
    stream << "Data Set                      : " << ((msg.DataSetType==DIMSE_DATASET_NULL) ? "none" : "present") << OFendl
           << "DIMSE Status                  : ";
    DIMSE_printNStatusString(stream, msg.DimseStatus);

    OFSTRINGSTREAM_GETSTR(stream, result)
    str += result;
    OFSTRINGSTREAM_FREESTR(stream)

    DIMSE_dumpMessage_end(str, dataset);

    return str;
}

OFString& DIMSE_dumpMessage(OFString &str, T_DIMSE_Message &msg, enum DIMSE_direction dir, DcmItem *dataset, T_ASC_PresentationContextID presID)
{
    switch (msg.CommandField) {
    case DIMSE_C_STORE_RQ:
        DIMSE_dumpMessage(str, msg.msg.CStoreRQ, dir, dataset, presID);
        break;
    case DIMSE_C_STORE_RSP:
        DIMSE_dumpMessage(str, msg.msg.CStoreRSP, dir, dataset, presID);
        break;
    case DIMSE_C_GET_RQ:
        DIMSE_dumpMessage(str, msg.msg.CGetRQ, dir, dataset, presID);
        break;
    case DIMSE_C_GET_RSP:
        DIMSE_dumpMessage(str, msg.msg.CGetRSP, dir, dataset, presID);
        break;
    case DIMSE_C_FIND_RQ:
        DIMSE_dumpMessage(str, msg.msg.CFindRQ, dir, dataset, presID);
        break;
    case DIMSE_C_FIND_RSP:
        DIMSE_dumpMessage(str, msg.msg.CFindRSP, dir, dataset, presID);
        break;
    case DIMSE_C_MOVE_RQ:
        DIMSE_dumpMessage(str, msg.msg.CMoveRQ, dir, dataset, presID);
        break;
    case DIMSE_C_MOVE_RSP:
        DIMSE_dumpMessage(str, msg.msg.CMoveRSP, dir, dataset, presID);
        break;
    case DIMSE_C_ECHO_RQ:
        DIMSE_dumpMessage(str, msg.msg.CEchoRQ, dir, dataset, presID);
        break;
    case DIMSE_C_ECHO_RSP:
        DIMSE_dumpMessage(str, msg.msg.CEchoRSP, dir, dataset, presID);
        break;
    case DIMSE_C_CANCEL_RQ:
        DIMSE_dumpMessage(str, msg.msg.CCancelRQ, dir, dataset, presID);
        break;
    case DIMSE_N_EVENT_REPORT_RQ:
        DIMSE_dumpMessage(str, msg.msg.NEventReportRQ, dir, dataset, presID);
        break;
    case DIMSE_N_EVENT_REPORT_RSP:
        DIMSE_dumpMessage(str, msg.msg.NEventReportRSP, dir, dataset, presID);
        break;
    case DIMSE_N_GET_RQ:
        DIMSE_dumpMessage(str, msg.msg.NGetRQ, dir, dataset, presID);
        break;
    case DIMSE_N_GET_RSP:
        DIMSE_dumpMessage(str, msg.msg.NGetRSP, dir, dataset, presID);
        break;
    case DIMSE_N_SET_RQ:
        DIMSE_dumpMessage(str, msg.msg.NSetRQ, dir, dataset, presID);
        break;
    case DIMSE_N_SET_RSP:
        DIMSE_dumpMessage(str, msg.msg.NSetRSP, dir, dataset, presID);
        break;
    case DIMSE_N_ACTION_RQ:
        DIMSE_dumpMessage(str, msg.msg.NActionRQ, dir, dataset, presID);
        break;
    case DIMSE_N_ACTION_RSP:
        DIMSE_dumpMessage(str, msg.msg.NActionRSP, dir, dataset, presID);
        break;
    case DIMSE_N_CREATE_RQ:
        DIMSE_dumpMessage(str, msg.msg.NCreateRQ, dir, dataset, presID);
        break;
    case DIMSE_N_CREATE_RSP:
        DIMSE_dumpMessage(str, msg.msg.NCreateRSP, dir, dataset, presID);
        break;
    case DIMSE_N_DELETE_RQ:
        DIMSE_dumpMessage(str, msg.msg.NDeleteRQ, dir, dataset, presID);
        break;
    case DIMSE_N_DELETE_RSP:
        DIMSE_dumpMessage(str, msg.msg.NDeleteRSP, dir, dataset, presID);
        break;
    default:
        DIMSE_dumpMessage_start(str, dir);
        str += "Message Type                  : UNKNOWN (DIMSE Protocol Error)";
        DIMSE_dumpMessage_end(str, dataset);
        break;
    }

    return str;
}


text:
(function (context) {

    function processValueTemplate (value) {
        if (value instanceof Array) {
            return processArrayTemplate(value);
        }

        if (typeof value === "object") {
            return processObjectTemplate(value);
        }

        if (typeof value === "string" || typeof value === "number") {
            return processStringOrNumberTemplate(value);
        }

        if (typeof value === "boolean") {
            return processBooleanTemplate(value);
        }

        return processNullTemplate(value);
    }

    function processKeyValueTemplate (key, value) {
        var template = JRE.templates["keyvalue"];

        return template({
            key : key,
            value : processValueTemplate(value)
        });
    }

    function processArrayTemplate (array) {
        var template = JRE.templates["value-array"],
            data = {};

        data.elements = [];

        array.forEach(function (el) {
            data.elements.push({ value : processValueTemplate(el) });
        });

        return template(data);
    }

    function processBooleanTemplate (bool) {
        var template = JRE.templates["value-boolean"];

        return template({ value : (bool ? "true" : null) });
    }

    function processNullTemplate () {
        var template = JRE.templates["value-null"];

        return template({ value : "null" });
    }

    function processObjectTemplate (obj) {
        var template = JRE.templates["value-object"],
            keys = Object.keys(obj),
            result = []
        ;

        keys.forEach(function (key) {
            result.push(processKeyValueTemplate(key, obj[key]));
        });

        return template({ content : result.join("") });
    }

    function processStringOrNumberTemplate (string) {
        var template = JRE.templates["value-stringornumber"];

        return template({ value : string });
    }

    var EditorGenerator;

    EditorGenerator = function (json) {
        this.json = json;
        this.content = "";
        this.init();
    };

    EditorGenerator.fn = EditorGenerator.prototype;

    EditorGenerator.fn.init = function () {
        var template = JRE.templates["form"],
            html,
            json;

        // try {
            json = JSON.parse(this.json);
            html = template({ content : processValueTemplate(json) });

            $("#json-editor").html(html);
        // } catch (err) {
        //     console.log(err);
        // }
    };

    context.EditorGenerator = EditorGenerator;

})(this);

new EditorGenerator($("textarea").val());


text:
/**
 * @fileoverview Config file operations. This file must be usable in the browser,
 * so no Node-specific code can be here.
 * @author Nicholas C. Zakas
 */
"use strict";

//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------

const minimatch = require("minimatch"),
    path = require("path");

const debug = require("debug")("eslint:config-ops");

//------------------------------------------------------------------------------
// Private
//------------------------------------------------------------------------------

const RULE_SEVERITY_STRINGS = ["off", "warn", "error"],
    RULE_SEVERITY = RULE_SEVERITY_STRINGS.reduce((map, value, index) => {
        map[value] = index;
        return map;
    }, {}),
    VALID_SEVERITIES = [0, 1, 2, "off", "warn", "error"];

//------------------------------------------------------------------------------
// Public Interface
//------------------------------------------------------------------------------

module.exports = {

    /**
     * Creates an empty configuration object suitable for merging as a base.
     * @returns {Object} A configuration object.
     */
    createEmptyConfig() {
        return {
            globals: {},
            env: {},
            rules: {},
            parserOptions: {}
        };
    },

    /**
     * Creates an environment config based on the specified environments.
     * @param {Object<string,boolean>} env The environment settings.
     * @param {Environments} envContext The environment context.
     * @returns {Object} A configuration object with the appropriate rules and globals
     *      set.
     */
    createEnvironmentConfig(env, envContext) {

        const envConfig = this.createEmptyConfig();

        if (env) {

            envConfig.env = env;

            Object.keys(env).filter(name => env[name]).forEach(name => {
                const environment = envContext.get(name);

                if (environment) {
                    debug(`Creating config for environment ${name}`);
                    if (environment.globals) {
                        Object.assign(envConfig.globals, environment.globals);
                    }

                    if (environment.parserOptions) {
                        Object.assign(envConfig.parserOptions, environment.parserOptions);
                    }
                }
            });
        }

        return envConfig;
    },

    /**
     * Given a config with environment settings, applies the globals and
     * ecmaFeatures to the configuration and returns the result.
     * @param {Object} config The configuration information.
     * @param {Environments} envContent env context.
     * @returns {Object} The updated configuration information.
     */
    applyEnvironments(config, envContent) {
        if (config.env && typeof config.env === "object") {
            debug("Apply environment settings to config");
            return this.merge(this.createEnvironmentConfig(config.env, envContent), config);
        }

        return config;
    },

    /**
     * Merges two config objects. This will not only add missing keys, but will also modify values to match.
     * @param {Object} target config object
     * @param {Object} src config object. Overrides in this config object will take priority over base.
     * @param {boolean} [combine] Whether to combine arrays or not
     * @param {boolean} [isRule] Whether its a rule
     * @returns {Object} merged config object.
     */
    merge: function deepmerge(target, src, combine, isRule) {

        /*
         * The MIT License (MIT)
         *
         * Copyright (c) 2012 Nicholas Fisher
         *
         * Permission is hereby granted, free of charge, to any person obtaining a copy
         * of this software and associated documentation files (the "Software"), to deal
         * in the Software without restriction, including without limitation the rights
         * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
         * copies of the Software, and to permit persons to whom the Software is
         * furnished to do so, subject to the following conditions:
         *
         * The above copyright notice and this permission notice shall be included in
         * all copies or substantial portions of the Software.
         *
         * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
         * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
         * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
         * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
         * THE SOFTWARE.
         */

        /*
         * This code is taken from deepmerge repo
         * (https://github.com/KyleAMathews/deepmerge)
         * and modified to meet our needs.
         */
        const array = Array.isArray(src) || Array.isArray(target);
        let dst = array && [] || {};

        if (array) {
            const resolvedTarget = target || [];

            // src could be a string, so check for array
            if (isRule && Array.isArray(src) && src.length > 1) {
                dst = dst.concat(src);
            } else {
                dst = dst.concat(resolvedTarget);
            }
            const resolvedSrc = typeof src === "object" ? src : [src];

            Object.keys(resolvedSrc).forEach((_, i) => {
                const e = resolvedSrc[i];

                if (typeof dst[i] === "undefined") {
                    dst[i] = e;
                } else if (typeof e === "object") {
                    if (isRule) {
                        dst[i] = e;
                    } else {
                        dst[i] = deepmerge(resolvedTarget[i], e, combine, isRule);
                    }
                } else {
                    if (!combine) {
                        dst[i] = e;
                    } else {
                        if (dst.indexOf(e) === -1) {
                            dst.push(e);
                        }
                    }
                }
            });
        } else {
            if (target && typeof target === "object") {
                Object.keys(target).forEach(key => {
                    dst[key] = target[key];
                });
            }
            Object.keys(src).forEach(key => {
                if (key === "overrides") {
                    dst[key] = (target[key] || []).concat(src[key] || []);
                } else if (Array.isArray(src[key]) || Array.isArray(target[key])) {
                    dst[key] = deepmerge(target[key], src[key], key === "plugins" || key === "extends", isRule);
                } else if (typeof src[key] !== "object" || !src[key] || key === "exported" || key === "astGlobals") {
                    dst[key] = src[key];
                } else {
                    dst[key] = deepmerge(target[key] || {}, src[key], combine, key === "rules");
                }
            });
        }

        return dst;
    },

    /**
     * Normalizes the severity value of a rule's configuration to a number
     * @param {(number|string|[number, ...*]|[string, ...*])} ruleConfig A rule's configuration value, generally
     * received from the user. A valid config value is either 0, 1, 2, the string "off" (treated the same as 0),
     * the string "warn" (treated the same as 1), the string "error" (treated the same as 2), or an array
     * whose first element is one of the above values. Strings are matched case-insensitively.
     * @returns {(0|1|2)} The numeric severity value if the config value was valid, otherwise 0.
     */
    getRuleSeverity(ruleConfig) {
        const severityValue = Array.isArray(ruleConfig) ? ruleConfig[0] : ruleConfig;

        if (severityValue === 0 || severityValue === 1 || severityValue === 2) {
            return severityValue;
        }

        if (typeof severityValue === "string") {
            return RULE_SEVERITY[severityValue.toLowerCase()] || 0;
        }

        return 0;
    },

    /**
     * Converts old-style severity settings (0, 1, 2) into new-style
     * severity settings (off, warn, error) for all rules. Assumption is that severity
     * values have already been validated as correct.
     * @param {Object} config The config object to normalize.
     * @returns {void}
     */
    normalizeToStrings(config) {

        if (config.rules) {
            Object.keys(config.rules).forEach(ruleId => {
                const ruleConfig = config.rules[ruleId];

                if (typeof ruleConfig === "number") {
                    config.rules[ruleId] = RULE_SEVERITY_STRINGS[ruleConfig] || RULE_SEVERITY_STRINGS[0];
                } else if (Array.isArray(ruleConfig) && typeof ruleConfig[0] === "number") {
                    ruleConfig[0] = RULE_SEVERITY_STRINGS[ruleConfig[0]] || RULE_SEVERITY_STRINGS[0];
                }
            });
        }
    },

    /**
     * Determines if the severity for the given rule configuration represents an error.
     * @param {int|string|Array} ruleConfig The configuration for an individual rule.
     * @returns {boolean} True if the rule represents an error, false if not.
     */
    isErrorSeverity(ruleConfig) {

        let severity = Array.isArray(ruleConfig) ? ruleConfig[0] : ruleConfig;

        if (typeof severity === "string") {
            severity = RULE_SEVERITY[severity.toLowerCase()] || 0;
        }

        return (typeof severity === "number" && severity === 2);
    },

    /**
     * Checks whether a given config has valid severity or not.
     * @param {number|string|Array} ruleConfig - The configuration for an individual rule.
     * @returns {boolean} `true` if the configuration has valid severity.
     */
    isValidSeverity(ruleConfig) {
        let severity = Array.isArray(ruleConfig) ? ruleConfig[0] : ruleConfig;

        if (typeof severity === "string") {
            severity = severity.toLowerCase();
        }
        return VALID_SEVERITIES.indexOf(severity) !== -1;
    },

    /**
     * Checks whether every rule of a given config has valid severity or not.
     * @param {Object} config - The configuration for rules.
     * @returns {boolean} `true` if the configuration has valid severity.
     */
    isEverySeverityValid(config) {
        return Object.keys(config).every(ruleId => this.isValidSeverity(config[ruleId]));
    },

    /**
     * Merges all configurations in a given config vector. A vector is an array of objects, each containing a config
     * file path and a list of subconfig indices that match the current file path. All config data is assumed to be
     * cached.
     * @param {Array<Object>} vector list of config files and their subconfig indices that match the current file path
     * @param {Object} configCache the config cache
     * @returns {Object} config object
     */
    getConfigFromVector(vector, configCache) {

        const cachedConfig = configCache.getMergedVectorConfig(vector);

        if (cachedConfig) {
            return cachedConfig;
        }

        debug("Using config from partial cache");

        const subvector = Array.from(vector);
        let nearestCacheIndex = subvector.length - 1,
            partialCachedConfig;

        while (nearestCacheIndex >= 0) {
            partialCachedConfig = configCache.getMergedVectorConfig(subvector);
            if (partialCachedConfig) {
                break;
            }
            subvector.pop();
            nearestCacheIndex--;
        }

        if (!partialCachedConfig) {
            partialCachedConfig = {};
        }

        let finalConfig = partialCachedConfig;

        // Start from entry immediately following nearest cached config (first uncached entry)
        for (let i = nearestCacheIndex + 1; i < vector.length; i++) {
            finalConfig = this.mergeVectorEntry(finalConfig, vector[i], configCache);
            configCache.setMergedVectorConfig(vector.slice(0, i + 1), finalConfig);
        }

        return finalConfig;
    },

    /**
     * Merges the config options from a single vector entry into the supplied config.
     * @param {Object} config the base config to merge the vector entry's options into
     * @param {Object} vectorEntry a single entry from a vector, consisting of a config file path and an array of
     * matching override indices
     * @param {Object} configCache the config cache
     * @returns {Object} merged config object
     */
    mergeVectorEntry(config, vectorEntry, configCache) {
        const vectorEntryConfig = Object.assign({}, configCache.getConfig(vectorEntry.filePath));
        let mergedConfig = Object.assign({}, config),
            overrides;

        if (vectorEntryConfig.overrides) {
            overrides = vectorEntryConfig.overrides.filter(
                (override, overrideIndex) => vectorEntry.matchingOverrides.indexOf(overrideIndex) !== -1
            );
        } else {
            overrides = [];
        }

        mergedConfig = this.merge(mergedConfig, vectorEntryConfig);

        delete mergedConfig.overrides;

        mergedConfig = overrides.reduce((lastConfig, override) => this.merge(lastConfig, override), mergedConfig);

        if (mergedConfig.filePath) {
            delete mergedConfig.filePath;
            delete mergedConfig.baseDirectory;
        } else if (mergedConfig.files) {
            delete mergedConfig.files;
        }

        return mergedConfig;
    },

    /**
     * Checks that the specified file path matches all of the supplied glob patterns.
     * @param {string} filePath The file path to test patterns against
     * @param {string|string[]} patterns One or more glob patterns, of which at least one should match the file path
     * @param {string|string[]} [excludedPatterns] One or more glob patterns, of which none should match the file path
     * @returns {boolean} True if all the supplied patterns match the file path, false otherwise
     */
    pathMatchesGlobs(filePath, patterns, excludedPatterns) {
        const patternList = [].concat(patterns);
        const excludedPatternList = [].concat(excludedPatterns || []);

        patternList.concat(excludedPatternList).forEach(pattern => {
            if (path.isAbsolute(pattern) || pattern.includes("..")) {
                throw new Error(`Invalid override pattern (expected relative path not containing '..'): ${pattern}`);
            }
        });

        const opts = { matchBase: true };

        return patternList.some(pattern => minimatch(filePath, pattern, opts)) &&
            !excludedPatternList.some(excludedPattern => minimatch(filePath, excludedPattern, opts));
    }
};


text:
using System;
using System.Collections.Generic;
using Weapsy.Cqrs.Domain;
using Weapsy.Framework.Domain;

namespace Weapsy.Domain.Pages.Events
{
    public class PageModulesReordered : DomainEvent
    {
        public Guid SiteId { get; set; }
        public IList<PageModule> PageModules { get; set; }

        public class PageModule
        {
            public Guid PageModuleId { get; set; }
            public string Zone { get; set; }
            public int SortOrder { get; set; }
        }
    }
}


text:
package com.aokyu.pocket;

import com.aokyu.pocket.error.PocketException;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.List;
import java.util.Map;

/**
 * TODO: This class should be replaced with a class using a JSON-POJO mapper.
 */
public class ModifyResponse extends Response {

    public final class Parameter {

        public static final String ACTION_RESULTS = "action_results";
        public static final String STATUS = "status";

    }

    /* package */ ModifyResponse(JSONObject jsonObj, Map<String, List<String>> headerFields)
            throws JSONException, PocketException {
        super(jsonObj, headerFields);
    }

    public boolean[] getActionResults() throws JSONException {
        JSONArray jsonArray = (JSONArray) get(Parameter.ACTION_RESULTS);
        int size = jsonArray.length();
        boolean[] results = new boolean[size];
        for (int i = 0; i < size; i++) {
            results[i] = jsonArray.getBoolean(i);
        }
        return results;
    }

}


text:
Crafty.c("KeyMoveControls", {
	init: function() {
		this.requires('Multiway');
	},

	keyControls: function(speed) {
		this.multiway(speed, {UP_ARROW: -90, DOWN_ARROW: 90, RIGHT_ARROW: 0, LEFT_ARROW: 180})
		return this;
	}

});