text:
<<<<<<< HEAD
<<<<<<< HEAD

// -- This file was mechanically generated: Do not edit! -- //

package java.nio;

class ByteBufferAsDoubleBufferB                  // package-private
    extends DoubleBuffer
{

    protected final ByteBuffer bb;
    protected final int offset;

    ByteBufferAsDoubleBufferB(ByteBuffer bb) {   // package-private

        super(-1, 0,
              bb.remaining() >> 3,
              bb.remaining() >> 3);
        this.bb = bb;
        // enforce limit == capacity
        int cap = this.capacity();
        this.limit(cap);
        int pos = this.position();
        assert (pos <= cap);
        offset = pos;

    }

    ByteBufferAsDoubleBufferB(ByteBuffer bb,
                                     int mark, int pos, int lim, int cap,
                                     int off)
    {

        super(mark, pos, lim, cap);
        this.bb = bb;
        offset = off;

    }

    public DoubleBuffer slice() {
        int pos = this.position();
        int lim = this.limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);
        int off = (pos << 3) + offset;
        assert (off >= 0);
        return new ByteBufferAsDoubleBufferB(bb, -1, 0, rem, rem, off);
    }

    public DoubleBuffer duplicate() {
        return new ByteBufferAsDoubleBufferB(bb,
                                                    this.markValue(),
                                                    this.position(),
                                                    this.limit(),
                                                    this.capacity(),
                                                    offset);
    }

    public DoubleBuffer asReadOnlyBuffer() {

        return new ByteBufferAsDoubleBufferRB(bb,
                                                 this.markValue(),
                                                 this.position(),
                                                 this.limit(),
                                                 this.capacity(),
                                                 offset);

    }

    protected int ix(int i) {
        return (i << 3) + offset;
    }

    public double get() {
        return Bits.getDoubleB(bb, ix(nextGetIndex()));
    }

    public double get(int i) {
        return Bits.getDoubleB(bb, ix(checkIndex(i)));
    }

    public DoubleBuffer put(double x) {

        Bits.putDoubleB(bb, ix(nextPutIndex()), x);
        return this;

    }

    public DoubleBuffer put(int i, double x) {

        Bits.putDoubleB(bb, ix(checkIndex(i)), x);
        return this;

    }

    public DoubleBuffer compact() {

        int pos = position();
        int lim = limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);

        ByteBuffer db = bb.duplicate();
        db.limit(ix(lim));
        db.position(ix(0));
        ByteBuffer sb = db.slice();
        sb.position(pos << 3);
        sb.compact();
        position(rem);
        limit(capacity());
        discardMark();
        return this;

    }

    public boolean isDirect() {
        return bb.isDirect();
    }

    public boolean isReadOnly() {
        return false;
    }

    public ByteOrder order() {

        return ByteOrder.BIG_ENDIAN;

    }

}
=======
/*
 * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.  Oracle designates this
 * particular file as subject to the "Classpath" exception as provided
 * by Oracle in the LICENSE file that accompanied this code.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
 */

// -- This file was mechanically generated: Do not edit! -- //

package java.nio;

class ByteBufferAsDoubleBufferB                  // package-private
    extends DoubleBuffer
{

    protected final ByteBuffer bb;
    protected final int offset;

    ByteBufferAsDoubleBufferB(ByteBuffer bb) {   // package-private

        super(-1, 0,
              bb.remaining() >> 3,
              bb.remaining() >> 3);
        this.bb = bb;
        // enforce limit == capacity
        int cap = this.capacity();
        this.limit(cap);
        int pos = this.position();
        assert (pos <= cap);
        offset = pos;

    }

    ByteBufferAsDoubleBufferB(ByteBuffer bb,
                                     int mark, int pos, int lim, int cap,
                                     int off)
    {

        super(mark, pos, lim, cap);
        this.bb = bb;
        offset = off;

    }

    public DoubleBuffer slice() {
        int pos = this.position();
        int lim = this.limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);
        int off = (pos << 3) + offset;
        assert (off >= 0);
        return new ByteBufferAsDoubleBufferB(bb, -1, 0, rem, rem, off);
    }

    public DoubleBuffer duplicate() {
        return new ByteBufferAsDoubleBufferB(bb,
                                                    this.markValue(),
                                                    this.position(),
                                                    this.limit(),
                                                    this.capacity(),
                                                    offset);
    }

    public DoubleBuffer asReadOnlyBuffer() {

        return new ByteBufferAsDoubleBufferRB(bb,
                                                 this.markValue(),
                                                 this.position(),
                                                 this.limit(),
                                                 this.capacity(),
                                                 offset);

    }

    protected int ix(int i) {
        return (i << 3) + offset;
    }

    public double get() {
        return Bits.getDoubleB(bb, ix(nextGetIndex()));
    }

    public double get(int i) {
        return Bits.getDoubleB(bb, ix(checkIndex(i)));
    }

    public DoubleBuffer put(double x) {

        Bits.putDoubleB(bb, ix(nextPutIndex()), x);
        return this;

    }

    public DoubleBuffer put(int i, double x) {

        Bits.putDoubleB(bb, ix(checkIndex(i)), x);
        return this;

    }

    public DoubleBuffer compact() {

        int pos = position();
        int lim = limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);

        ByteBuffer db = bb.duplicate();
        db.limit(ix(lim));
        db.position(ix(0));
        ByteBuffer sb = db.slice();
        sb.position(pos << 3);
        sb.compact();
        position(rem);
        limit(capacity());
        discardMark();
        return this;

    }

    public boolean isDirect() {
        return bb.isDirect();
    }

    public boolean isReadOnly() {
        return false;
    }

    public ByteOrder order() {

        return ByteOrder.BIG_ENDIAN;

    }

}
>>>>>>> b875702c9c06ab5012e52ff4337439b03918f453
=======
/*
 * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.  Oracle designates this
 * particular file as subject to the "Classpath" exception as provided
 * by Oracle in the LICENSE file that accompanied this code.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
 */

// -- This file was mechanically generated: Do not edit! -- //

package java.nio;

class ByteBufferAsDoubleBufferB                  // package-private
    extends DoubleBuffer
{

    protected final ByteBuffer bb;
    protected final int offset;

    ByteBufferAsDoubleBufferB(ByteBuffer bb) {   // package-private

        super(-1, 0,
              bb.remaining() >> 3,
              bb.remaining() >> 3);
        this.bb = bb;
        // enforce limit == capacity
        int cap = this.capacity();
        this.limit(cap);
        int pos = this.position();
        assert (pos <= cap);
        offset = pos;

    }

    ByteBufferAsDoubleBufferB(ByteBuffer bb,
                                     int mark, int pos, int lim, int cap,
                                     int off)
    {

        super(mark, pos, lim, cap);
        this.bb = bb;
        offset = off;

    }

    public DoubleBuffer slice() {
        int pos = this.position();
        int lim = this.limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);
        int off = (pos << 3) + offset;
        assert (off >= 0);
        return new ByteBufferAsDoubleBufferB(bb, -1, 0, rem, rem, off);
    }

    public DoubleBuffer duplicate() {
        return new ByteBufferAsDoubleBufferB(bb,
                                                    this.markValue(),
                                                    this.position(),
                                                    this.limit(),
                                                    this.capacity(),
                                                    offset);
    }

    public DoubleBuffer asReadOnlyBuffer() {

        return new ByteBufferAsDoubleBufferRB(bb,
                                                 this.markValue(),
                                                 this.position(),
                                                 this.limit(),
                                                 this.capacity(),
                                                 offset);

    }

    protected int ix(int i) {
        return (i << 3) + offset;
    }

    public double get() {
        return Bits.getDoubleB(bb, ix(nextGetIndex()));
    }

    public double get(int i) {
        return Bits.getDoubleB(bb, ix(checkIndex(i)));
    }

    public DoubleBuffer put(double x) {

        Bits.putDoubleB(bb, ix(nextPutIndex()), x);
        return this;

    }

    public DoubleBuffer put(int i, double x) {

        Bits.putDoubleB(bb, ix(checkIndex(i)), x);
        return this;

    }

    public DoubleBuffer compact() {

        int pos = position();
        int lim = limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);

        ByteBuffer db = bb.duplicate();
        db.limit(ix(lim));
        db.position(ix(0));
        ByteBuffer sb = db.slice();
        sb.position(pos << 3);
        sb.compact();
        position(rem);
        limit(capacity());
        discardMark();
        return this;

    }

    public boolean isDirect() {
        return bb.isDirect();
    }

    public boolean isReadOnly() {
        return false;
    }

    public ByteOrder order() {

        return ByteOrder.BIG_ENDIAN;

    }

}
>>>>>>> b875702c9c06ab5012e52ff4337439b03918f453


text:
package com.google.cloud.dataflow.sdk.runners.worker;

import com.google.api.client.json.JsonFactory;
import com.google.api.services.dataflow.model.SourceOperationRequest;
import com.google.api.services.dataflow.model.SourceOperationResponse;
import com.google.api.services.dataflow.model.SourceSplitResponse;
import com.google.cloud.dataflow.sdk.options.PipelineOptions;
import com.google.cloud.dataflow.sdk.runners.dataflow.CustomSources;
import com.google.cloud.dataflow.sdk.util.Transport;
import com.google.cloud.dataflow.sdk.util.common.CounterSet;
import com.google.cloud.dataflow.sdk.util.common.worker.WorkExecutor;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;

/**
 * An executor for a source operation, defined by a {@code SourceOperationRequest}.
 */
@SuppressWarnings("resource")
public class SourceOperationExecutor extends WorkExecutor {
  private static final Logger LOG = LoggerFactory.getLogger(SourceOperationExecutor.class);
  public static final String SPLIT_RESPONSE_TOO_LARGE_ERROR =
      "Total size of the BoundedSource objects generated by splitIntoBundles() operation is larger"
      + " than the allowable limit. For more information, please check the corresponding FAQ"
      + " entry at :\n"
      + "https://cloud.google.com/dataflow/faq";
  // This limit is only used to produce an error message. Actual current limit offered by the
  // service may be different.
  private static final int SOURCE_OPERATION_RESPONSE_SIZE_LIMIT_MB = 20;

  private final PipelineOptions options;
  private final SourceOperationRequest request;
  private SourceOperationResponse response;

  public SourceOperationExecutor(PipelineOptions options,
                                 SourceOperationRequest request,
                                 CounterSet counters) {
    super(counters);
    this.options = options;
    this.request = request;
  }

  @Override
  public void execute() throws Exception {
    LOG.debug("Executing source operation");
    this.response = CustomSources.performSourceOperation(request, options);
    LOG.debug("Source operation execution complete");
  }

  public SourceOperationResponse getResponse() {
    return response;
  }

  static int determineSplitResponseSize(SourceOperationResponse operationResponse) {
    try {
      SourceSplitResponse splitResponse = operationResponse.getSplit();
      JsonFactory factory = splitResponse.getFactory();
      if (factory == null) {
        factory = Transport.getJsonFactory();
      }
      return factory.toByteArray(operationResponse).length;
    } catch (OutOfMemoryError e) {
      LOG.error("Got exception when trying to serialize split response: " + e.getMessage());
      // We will go out of memory if split response is extremely large.
      return Integer.MAX_VALUE;
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }

  static boolean isSplitResponseTooLarge(SourceOperationResponse operationResponse) {
    return determineSplitResponseSize(operationResponse)
        >= SOURCE_OPERATION_RESPONSE_SIZE_LIMIT_MB * 1024 * 1024;
  }
}

redpajama_set_name: RedPajamaGithub


text:
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/chrome_cleaner/zip_archiver/test_zip_archiver_util.h"

#include <limits>
#include <vector>

#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/zlib/contrib/minizip/unzip.h"

namespace chrome_cleaner {

namespace {

const char kTestContent[] = "Hello World";
const base::Time::Exploded kTestFileTime = {
    // Year
    2018,
    // Month
    1,
    // Day of week
    1,
    // Day of month
    1,
    // Hour
    2,
    // Minute
    3,
    // Second
    5,
    // Millisecond
    0,
};
// The zip should be encrypted and use UTF-8 encoding.
const uint16_t kExpectedZipFlag = 0x1 | (0x1 << 11);

const int64_t kReadBufferSize = 4096;

// The |day_of_week| in |base::Time::Exploded| won't be set correctly.
// TODO(veranika): This is copied from
// https://cs.chromium.org/chromium/src/chrome/browser/resources/chromeos/zip_archiver/cpp/volume_archive_minizip.cc.
// It would be better to move it to //base.
base::Time::Exploded ExplodeDosTime(const uint32_t dos_time) {
  base::Time::Exploded time_part;
  uint32_t remain_part = dos_time;
  // 0-4bits, second divied by 2.
  time_part.second = (remain_part & 0x1F) * 2;
  remain_part >>= 5;
  // 5-10bits, minute (0–59).
  time_part.minute = remain_part & 0x3F;
  remain_part >>= 6;
  // 11-15bits, hour (0–23 on a 24-hour clock).
  time_part.hour = remain_part & 0x1F;
  remain_part >>= 5;
  // 16-20bits, day of the month (1-31).
  time_part.day_of_month = remain_part & 0x1F;
  remain_part >>= 5;
  // 21-24bits, month (1-23).
  time_part.month = remain_part & 0xF;
  remain_part >>= 4;
  // 25-31bits, year offset from 1980.
  time_part.year = (remain_part & 0x7F) + 1980;
  return time_part;
}

}  // namespace

ZipArchiverTestFile::ZipArchiverTestFile() : initialized_(false) {}

ZipArchiverTestFile::~ZipArchiverTestFile() = default;

void ZipArchiverTestFile::Initialize() {
  // Can not be reinitialized.
  CHECK(!initialized_);
  initialized_ = true;

  ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
  ASSERT_TRUE(
      base::CreateTemporaryFileInDir(temp_dir_.GetPath(), &src_file_path_));

  ASSERT_EQ(static_cast<size_t>(base::WriteFile(src_file_path_, kTestContent,
                                                strlen(kTestContent))),
            strlen(kTestContent));
  // Set a fixed timestamp, so the modified time will be identical in every
  // test.
  base::Time file_time;
  ASSERT_TRUE(base::Time::FromLocalExploded(kTestFileTime, &file_time));
  ASSERT_TRUE(base::TouchFile(src_file_path_, file_time, file_time));
}

const base::FilePath& ZipArchiverTestFile::GetSourceFilePath() const {
  return src_file_path_;
}

const base::FilePath& ZipArchiverTestFile::GetTempDirPath() const {
  return temp_dir_.GetPath();
}

void ZipArchiverTestFile::ExpectValidZipFile(
    const base::FilePath& zip_file_path,
    const std::string& filename_in_zip,
    const std::string& password) {
  unzFile unzip_object = unzOpen64(zip_file_path.AsUTF8Unsafe().c_str());
  ASSERT_NE(unzip_object, nullptr);
  EXPECT_EQ(unzLocateFile(unzip_object, filename_in_zip.c_str(),
                          /*iCaseSensitivity=*/1),
            UNZ_OK);

  unz_file_info64 file_info;
  const size_t filename_length = strlen(filename_in_zip.c_str());
  std::vector<char> filename(filename_length + 1);
  ASSERT_GT(std::numeric_limits<Cr_z_uLong>::max(), filename.size());
  EXPECT_EQ(unzGetCurrentFileInfo64(
                unzip_object, &file_info, filename.data(),
                static_cast<Cr_z_uLong>(filename.size()),
                /*extraField=*/nullptr, /*extraFieldBufferSize=*/0,
                /*szComment=*/nullptr, /*commentBufferSize=*/0),
            UNZ_OK);
  EXPECT_EQ(file_info.flag & kExpectedZipFlag, kExpectedZipFlag);
  // The compression method should be STORE(0).
  EXPECT_EQ(file_info.compression_method, 0UL);
  EXPECT_EQ(file_info.uncompressed_size, strlen(kTestContent));
  EXPECT_EQ(file_info.size_filename, filename_in_zip.size());
  EXPECT_STREQ(filename.data(), filename_in_zip.c_str());

  base::Time::Exploded file_time = ExplodeDosTime(file_info.dosDate);
  EXPECT_EQ(file_time.year, kTestFileTime.year);
  EXPECT_EQ(file_time.month, kTestFileTime.month);
  EXPECT_EQ(file_time.day_of_month, kTestFileTime.day_of_month);
  EXPECT_EQ(file_time.hour, kTestFileTime.hour);
  EXPECT_EQ(file_time.minute, kTestFileTime.minute);
  // Dos time has a resolution of 2 seconds.
  EXPECT_EQ(file_time.second, (kTestFileTime.second / 2) * 2);

  EXPECT_EQ(unzOpenCurrentFilePassword(unzip_object, password.c_str()), UNZ_OK);

  const size_t content_length = strlen(kTestContent);
  std::vector<char> content;
  uint8_t read_buffer[kReadBufferSize];
  while (true) {
    int read_size =
        unzReadCurrentFile(unzip_object, read_buffer, kReadBufferSize);
    EXPECT_GE(read_size, 0);
    if (read_size == 0) {
      break;
    }
    content.insert(content.end(), read_buffer, read_buffer + read_size);
    if (content.size() > content_length) {
      break;
    }
  }
  EXPECT_EQ(content.size(), content_length);
  EXPECT_EQ(std::string(content.begin(), content.end()), kTestContent);

  EXPECT_EQ(unzCloseCurrentFile(unzip_object), UNZ_OK);
  ASSERT_EQ(unzClose(unzip_object), UNZ_OK);
}

}  // namespace chrome_cleaner


text:
import matplotlib.pyplot as plt
import pandas.util.testing as t
import pandas.stats.moments as m

t.N = 500
ts = t.makeTimeSeries()
ts[::100] = 20

s = ts.cumsum()

plt.figure(figsize=(10, 5))
plt.plot(s.index, m.ewmvol(s, span=50, min_periods=1).values, color='b')
plt.plot(s.index, m.rolling_std(s, 50, min_periods=1).values, color='r')

plt.title('Exp-weighted std with shocks')
plt.legend(('Exp-weighted', 'Equal-weighted'))

f = plt.gcf()
f.autofmt_xdate()

plt.show()
plt.close('all')


text:
package org.simpleds.metadata;

import java.util.Collection;
import java.util.Map;

import javax.inject.Inject;

import org.simpleds.exception.DuplicateException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.collect.Maps;

/**
 * Stores all the metadata about persistence strategy for each class
 * @author icoloma
 */
public class PersistenceMetadataRepository {

	/** the list of ClassMetadata by class */
	private Map<Class, ClassMetadata> metadataByClass = Maps.newHashMap();

	/** the list of ClassMetadata by simple (unqualified) class name */
	private Map<String, ClassMetadata> metadataByKind = Maps.newHashMap();

	@Inject
	private ClassMetadataFactory classMetadataFactory;

	private static Logger log = LoggerFactory.getLogger(PersistenceMetadataRepository.class);

	/**
	 * Adds a persistent class to the repository
	 * @return the ClassMetadata instance created for this persistent class
	 */
	public ClassMetadata add(Class<?> clazz) {
		ClassMetadata metadata = classMetadataFactory.createMetadata(clazz);
		log.debug("Adding persistent class " + metadata.getKind());
		metadata.validate();
		if (metadataByKind.get(metadata.getKind()) != null) {
			throw new DuplicateException("Two entities found with kind='" + metadata.getKind() + "': " + metadata.getPersistentClass().getName() + " and " + metadataByKind.get(metadata.getKind()).getPersistentClass().getName());
		}
		metadataByClass.put(metadata.getPersistentClass(), metadata);
		metadataByKind.put(metadata.getKind(), metadata);
		return metadata;
	}

	/**
	 * Removes a persistent class from the repository
	 * @param clazz the persistent class to remove
	 * @throws IllegalArgumentException if the class is not present in the repository
	 */
	public void remove(Class<?> clazz) {
		ClassMetadata metadata = get(clazz);
		metadataByClass.remove(clazz);
		metadataByKind.remove(metadata.getKind());
	}

	/**
	 * @return the ClassMetadata regsitered for the provided class
	 * @throws IllegalArgumentException if the provided class is not registered as a persistent class
	 */
	public ClassMetadata get(Class clazz) {
		ClassMetadata result = metadataByClass.get(clazz);
		if (result == null) {
			throw new IllegalArgumentException("No persistent class " + clazz.getName() + " could be found");
		}
		return result;
	}

	/**
	 * @param kind the simple (unqualified) class name
	 * @return the ClassMetadata regsitered for the provided simple class name
	 */
	public ClassMetadata get(String kind) {
		ClassMetadata result = metadataByKind.get(kind);
		if (result == null) {
			throw new IllegalArgumentException("No persistent class " + kind + " could be found");
		}
		return result;
	}

	/**
	 * @return the list of all configured {@link ClassMetadata} instances
	 */
	public Collection<ClassMetadata> getAll() {
		return metadataByClass.values();
	}

	public void setClassMetadataFactory(ClassMetadataFactory classMetadataFactory) {
		this.classMetadataFactory = classMetadataFactory;
	}

}


text:
<?php
namespace TYPO3\CMS\Core\Resource;

use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
 * Enumeration object for DuplicationBehavior
 */
class DuplicationBehavior extends \TYPO3\CMS\Core\Type\Enumeration
{
    const __default = self::CANCEL;

    /**
     * If a file is uploaded and another file with
     * the same name already exists, the new file
     * is renamed.
     */
    const RENAME = 'rename';

    /**
     * If a file is uploaded and another file with
     * the same name already exists, the old file
     * gets overwritten by the new file.
     */
    const REPLACE = 'replace';

    /**
     * If a file is uploaded and another file with
     * the same name already exists, the process is
     * aborted.
     */
    const CANCEL = 'cancel';

    /**
     * Mapping of some legacy values, to assure BC
     *
     * @var string[]
     * @deprecated
     */
    protected static $legacyValueMap = [
        '1' => self::REPLACE,
        'overrideExistingFile' => self::REPLACE,
        'renameNewFile' => self::RENAME,
        'changeName' => self::RENAME
    ];

    /**
     * @param mixed $value
     */
    public function __construct($value = null)
    {
        if (isset(static::$legacyValueMap[$value])) {
            GeneralUtility::deprecationLog('Using ' . $value . ' for resolving conflicts in file names is deprecated. Make use of the enumeration "\TYPO3\CMS\Core\Resource\DuplicationBehavior" instead.');
            $value = static::$legacyValueMap[$value];
        }
        parent::__construct($value);
    }
}


text:
import { expect } from 'chai';
import { describe, it } from 'mocha';
import scenarioPlan from '../../src/plans/scenarioPlan';
import sinon from 'sinon';

describe('scenarioPlan', () => {

	describe('create', () => {

		it('requires phase', () => {
			expect(() => scenarioPlan.create(undefined, {})).throw('phase must be defined');
		});

		it('requires scenario', () => {
			expect(() => scenarioPlan.create({}, undefined)).throw('scenario must be defined');
		});

		it('create', () => {
			const phase = { id: 123 };
			const scenario = { getOperationsForPhase() {} };
			const operations = [{}, {}];
			sinon.stub(scenario, 'getOperationsForPhase').withArgs(123).returns(operations);
			const plan = scenarioPlan.create(phase, scenario);
			expect(plan.operations).equals(operations);
		});
	});
});


text:
module Phone (areaCode, number, prettyPrint) where

import Data.Char

areaCode :: String -> Maybe String
areaCode str
    | length number < 10 = Nothing
    | otherwise = Just $ take 3 number
    where number = filter isDigit str

number :: String -> Maybe String
number str
    | length number < 10 || length number > 11 = Nothing
    | length number == 11 && head number == '1' = Just $ tail number
    | length number == 11 && head number /= '1' = Nothing
    | otherwise = Just $ number
    where number = filter isDigit str

prettyPrint :: String -> Maybe String
prettyPrint str
    | length number < 10 = Nothing
    | length number == 11 && head number == '1'
    = Just ("(" ++ take 3 numberOneRemoved ++ ") " ++ fst halfNumRemoved ++ "-" ++ snd halfNumRemoved)
    | otherwise = Just ("(" ++ take 3 number ++ ") " ++ fst halfNum ++ "-" ++ snd halfNum)
    where number = filter isDigit str
          numberOneRemoved = drop 1 number
          halfNum = splitAt 3 $ drop 3 number
          halfNumRemoved = splitAt 3 $ drop 3 numberOneRemoved


text:
package xal.plugin.epics7.server;

import com.cosylab.epics.caj.cas.util.MemoryProcessVariable;
import gov.aps.jca.CAException;
import gov.aps.jca.dbr.DBR;
import gov.aps.jca.dbr.DBRType;
import gov.aps.jca.dbr.DBR_Byte;
import gov.aps.jca.dbr.DBR_Double;
import gov.aps.jca.dbr.DBR_Float;
import gov.aps.jca.dbr.DBR_Int;
import gov.aps.jca.dbr.DBR_Short;
import gov.aps.jca.dbr.DBR_String;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.epics.pvdata.factory.PVDataFactory;
import org.epics.pvdata.factory.StandardFieldFactory;
import org.epics.pvdata.pv.PVByteArray;
import org.epics.pvdata.pv.PVDataCreate;
import org.epics.pvdata.pv.PVDoubleArray;
import org.epics.pvdata.pv.PVField;
import org.epics.pvdata.pv.PVFloatArray;
import org.epics.pvdata.pv.PVIntArray;
import org.epics.pvdata.pv.PVLongArray;
import org.epics.pvdata.pv.PVShortArray;
import org.epics.pvdata.pv.PVStringArray;
import org.epics.pvdata.pv.PVStructure;
import org.epics.pvdata.pv.ScalarType;
import org.epics.pvdata.pv.StandardField;
import org.epics.pvdata.pv.Structure;
import org.epics.pvdata.pv.Type;
import org.epics.pvdatabase.PVRecord;
import xal.ca.ChannelRecord;
import xal.ca.ChannelStatusRecord;
import xal.ca.ChannelTimeRecord;
import xal.ca.ConnectionException;
import xal.ca.GetException;
import xal.ca.IEventSinkValStatus;
import xal.ca.IEventSinkValTime;
import xal.ca.IEventSinkValue;
import xal.ca.IServerChannel;
import xal.ca.Monitor;
import xal.ca.MonitorException;
import xal.ca.PutException;
import xal.ca.PutListener;
import xal.plugin.epics7.Epics7Channel;
import xal.plugin.epics7.Epics7ChannelRecord;
import xal.plugin.epics7.Epics7ChannelStatusRecord;
import xal.plugin.epics7.Epics7ChannelTimeRecord;

/**
 * Server channel implementation. It creates PVAccess and CA channels,
 * independently of the signal prefix. This is done to ensure backwards
 * compatibility.
 *
 * Gets are done on the PVRecord, while sets are done to both PVRecord and CA
 * PV, so that they are always in sync.
 *
 * @author Juan F. Esteban Müller <JuanF.EstebanMuller@ess.eu>
 */
public class Epics7ServerChannel extends Epics7Channel implements IServerChannel {

    // Record associated with this channel.
    private MemoryProcessVariable memoryProcessVariable;
    private PVRecord pvRecord;

    private final Epics7ServerChannelSystem epics7ServerChannelSystem;

    private static final String PROPERTIES = ALARM_FIELD + "," + TIMESTAMP_FIELD + ","
            + DISPLAY_FIELD + "," + CONTROL_FIELD;

    public Epics7ServerChannel(String signalName, Epics7ServerChannelSystem CHANNEL_SYSTEM) {
        super(signalName, CHANNEL_SYSTEM);

        // Removing protocol in case it is defined.
        if (m_strId.startsWith("ca://") || m_strId.startsWith("pva://")) {
            m_strId = m_strId.substring(m_strId.indexOf("://") + 3);
        }

        this.epics7ServerChannelSystem = CHANNEL_SYSTEM;

        requestConnection();
    }

    // Always return true because there is no connection to be made.
    @Override
    public boolean connectAndWait(double timeout) {
        requestConnection();
        return isConnected();
    }

    // No connection to be made, just create the record. By default its type is double.
    @Override
    public final void requestConnection() {
        if (pvRecord == null) {
            addCAPV(DBRType.DOUBLE);
            addRecord(ScalarType.pvDouble, false);

            // Adding a monitor to update the value on one protocol channel when the
            // other one is updated by new data received in a put.
            try {
                Epics7ServerMonitor.createNewMonitor(pvRecord, memoryProcessVariable,
                        Epics7Channel.VALUE_REQUEST, (pvS) -> {
                        }, 0);
            } catch (ConnectionException e) {
                Logger.getLogger(Epics7ServerChannel.class.getName()).severe("Not possible to set callback to update value");
            }

            connectionFlag = true;
        }
    }

    @Override
    public void disconnect() {
        removeCAPV();
        removeRecord();
        connectionFlag = false;
    }

    private void addCAPV(DBRType type) {
        MemoryProcessVariable newMemoryProcessVariable = new MemoryProcessVariable(m_strId, null, type, new double[]{0.0});

        if (memoryProcessVariable != null) {
            // TODO: Copy metadata from old record to new record
            removeCAPV();
        }
        memoryProcessVariable = newMemoryProcessVariable;

        epics7ServerChannelSystem.addMemPV(memoryProcessVariable);
    }

    private void addRecord(ScalarType scalarType, boolean array) {
        StandardField standardField = StandardFieldFactory.getStandardField();

        String properties = PROPERTIES;
        if (scalarType != ScalarType.pvString) {
            properties += "," + VALUE_ALARM_FIELD;
        }

        Structure structure;
        if (array) {
            structure = standardField.scalarArray(scalarType, properties);
        } else {
            structure = standardField.scalar(scalarType, properties);
        }
        PVDataCreate pvDataCreate = PVDataFactory.getPVDataCreate();
        PVStructure pvStructure = pvDataCreate.createPVStructure(structure);
        PVRecord newPVRecord = new PVRecord(m_strId, pvStructure);
        if (pvRecord != null) {
            // TODO: Copy metadata from old record to new record
            removeRecord();
        }
        pvRecord = newPVRecord;

        epics7ServerChannelSystem.addRecord(pvRecord);
    }

    private void removeCAPV() {
        if (memoryProcessVariable != null) {
            epics7ServerChannelSystem.removeMemPV(memoryProcessVariable);
            memoryProcessVariable = null;
        }
    }

    private void removeRecord() {
        if (pvRecord != null) {
            epics7ServerChannelSystem.removeRecord(pvRecord);
            pvRecord = null;
        }
    }

    @Override
    public int elementCount() throws ConnectionException {
        if (pvRecord != null) {
            PVField valueField = pvRecord.getPVStructure().getSubField(VALUE_FIELD);
            Type type = valueField.getField().getType();
            switch (type) {
                case scalar:
                    return 1;
                case scalarArray:
                    return Epics7ChannelRecord.getCountArray(pvRecord.getPVStructure(), valueField);
                default:
                    break;
            }
        }
        return 0;
    }

    protected PVStructure getDisplay() {
        if (pvRecord != null) {
            return pvRecord.getPVStructure().getStructureField(DISPLAY_FIELD);
        }
        return null;
    }

    protected PVStructure getVAlueAlarm() {
        if (pvRecord != null) {
            return pvRecord.getPVStructure().getStructureField(VALUE_ALARM_FIELD);
        }
        return null;
    }

    protected PVStructure getControl() {
        if (pvRecord != null) {
            return pvRecord.getPVStructure().getStructureField(CONTROL_FIELD);
        }
        return null;
    }

    @Override
    public String getUnits() {
        PVStructure displayStructure = getDisplay();
        if (displayStructure != null) {
            return displayStructure.getStringField("units").get();
        }

        return "";
    }

    @Override
    public ChannelRecord getRawValueRecord() throws ConnectionException, GetException {
        return new Epics7ChannelRecord(pvRecord.getPVStructure(), m_strId);
    }

    @Override
    public ChannelStatusRecord getRawStatusRecord() throws ConnectionException, GetException {
        return new Epics7ChannelStatusRecord(pvRecord.getPVStructure(), m_strId);
    }

    @Override
    public ChannelTimeRecord getRawTimeRecord() throws ConnectionException, GetException {
        return new Epics7ChannelTimeRecord(pvRecord.getPVStructure(), m_strId);
    }

    @Override
    protected void getRawValueCallback(IEventSinkValue listener) throws ConnectionException, GetException {
        listener.eventValue(getRawValueRecord(), this);
    }

    @Override
    protected void getRawValueCallback(IEventSinkValue listener, boolean attemptConnection) throws ConnectionException, GetException {
        listener.eventValue(getRawValueRecord(), this);
    }

    @Override
    public void getRawValueTimeCallback(IEventSinkValTime listener, boolean attemptConnection) throws ConnectionException, GetException {
        listener.eventValue(getRawTimeRecord(), this);
    }

    @Override
    public Monitor addMonitorValTime(IEventSinkValTime listener, int intMaskFire) throws ConnectionException, MonitorException {
        checkConnection("addMonitorValTime");

        return Epics7ServerMonitor.createNewMonitor(pvRecord, memoryProcessVariable, Epics7Channel.TIME_REQUEST, (pvStructure) -> {
            ChannelTimeRecord record = new Epics7ChannelTimeRecord(pvStructure, this.channelName());
            listener.eventValue(record, this);
        }, intMaskFire);
    }

    @Override
    public Monitor addMonitorValStatus(IEventSinkValStatus listener, int intMaskFire) throws ConnectionException, MonitorException {
        checkConnection("addMonitorValStatus");

        return Epics7ServerMonitor.createNewMonitor(pvRecord, memoryProcessVariable, Epics7Channel.STATUS_REQUEST, (pvStructure) -> {
            ChannelStatusRecord record = new Epics7ChannelStatusRecord(pvStructure, this.channelName());
            listener.eventValue(record, this);
        }, intMaskFire);
    }

    @Override
    public Monitor addMonitorValue(IEventSinkValue listener, int intMaskFire) throws ConnectionException, MonitorException {
        checkConnection("addMonitorValue");

        return Epics7ServerMonitor.createNewMonitor(pvRecord, memoryProcessVariable, Epics7Channel.VALUE_REQUEST, (pvStructure) -> {
            ChannelRecord record = new Epics7ChannelRecord(pvStructure, this.channelName());
            listener.eventValue(record, this);
        }, intMaskFire);
    }

    private void updateTimeStampAlarmsAndTriggerListener(PutListener listener) {
        long currentTimeMillis = System.currentTimeMillis();

        int nanoSeconds = (int) (1000000 * currentTimeMillis % 1000);
        long seconds = currentTimeMillis / 1000;

        PVStructure timeStampField = pvRecord.getPVStructure().getStructureField(TIMESTAMP_FIELD);

        timeStampField.getLongField(Epics7ChannelTimeRecord.SECONDS_FIELD_NAME).put(seconds);
        timeStampField.getIntField(Epics7ChannelTimeRecord.NANOSECONDS_FIELD_NAME).put(nanoSeconds);

        //TODO: update alarms
        if (listener != null) {
            listener.putCompleted(this);
        }
    }

    @Override
    public void putRawValCallback(String newVal, PutListener listener) throws ConnectionException, PutException {
        if (elementType() != String.class) {
            addCAPV(DBRType.STRING);
            addRecord(ScalarType.pvString, false);
        }

        pvRecord.getPVStructure().getStringField(VALUE_FIELD).put(newVal);

        DBR dbr = new DBR_String(new String[]{newVal});
        try {
            memoryProcessVariable.write(dbr, null);
        } catch (CAException ex) {
            Logger.getLogger(Epics7ServerChannel.class.getName()).log(Level.SEVERE, null, ex);
        }

        updateTimeStampAlarmsAndTriggerListener(listener);
    }

    @Override
    public void putRawValCallback(byte newVal, PutListener listener) throws ConnectionException, PutException {
        if (elementType() != byte.class) {
            addCAPV(DBRType.BYTE);
            addRecord(ScalarType.pvByte, false);
        }

        pvRecord.getPVStructure().getByteField(VALUE_FIELD).put(newVal);

        DBR dbr = new DBR_Byte(new byte[]{newVal});
        try {
            memoryProcessVariable.write(dbr, null);
        } catch (CAException ex) {
            Logger.getLogger(Epics7ServerChannel.class.getName()).log(Level.SEVERE, null, ex);
        }

        updateTimeStampAlarmsAndTriggerListener(listener);
    }

    @Override
    public void putRawValCallback(short newVal, PutListener listener) throws ConnectionException, PutException {
        if (elementType() != short.class) {
            addCAPV(DBRType.SHORT);
            addRecord(ScalarType.pvShort, false);
        }

        pvRecord.getPVStructure().getShortField(VALUE_FIELD).put(newVal);

        DBR dbr = new DBR_Short(new short[]{newVal});
        try {
            memoryProcessVariable.write(dbr, null);
        } catch (CAException ex) {
            Logger.getLogger(Epics7ServerChannel.class.getName()).log(Level.SEVERE, null, ex);
        }

        updateTimeStampAlarmsAndTriggerListener(listener);
    }

    @Override
    public void putRawValCallback(int newVal, PutListener listener) throws ConnectionException, PutException {
        if (elementType() != int.class) {
            addCAPV(DBRType.INT);
            addRecord(ScalarType.pvInt, false);
        }

        pvRecord.getPVStructure().getIntField(VALUE_FIELD).put(newVal);

        DBR dbr = new DBR_Int(new int[]{newVal});
        try {
            memoryProcessVariable.write(dbr, null);
        } catch (CAException ex) {
            Logger.getLogger(Epics7ServerChannel.class.getName()).log(Level.SEVERE, null, ex);
        }

        updateTimeStampAlarmsAndTriggerListener(listener);
    }

    /**
     * Long is not supported in EPICS3, so they are casted to int for CA.
     */
    @Override
    public void putRawValCallback(long newVal, PutListener listener) throws ConnectionException, PutException {
        if (elementType() != long.class) {
            addCAPV(DBRType.INT);
            addRecord(ScalarType.pvLong, false);
        }

        pvRecord.getPVStructure().getLongField(VALUE_FIELD).put(newVal);

        DBR dbr = new DBR_Int(new int[]{(int) newVal});
        try {
            memoryProcessVariable.write(dbr, null);
        } catch (CAException ex) {
            Logger.getLogger(Epics7ServerChannel.class.getName()).log(Level.SEVERE, null, ex);
        }

        updateTimeStampAlarmsAndTriggerListener(listener);
    }

    @Override
    public void putRawValCallback(float newVal, PutListener listener) throws ConnectionException, PutException {
        if (elementType() != float.class) {
            addCAPV(DBRType.FLOAT);
            addRecord(ScalarType.pvFloat, false);
        }

        pvRecord.getPVStructure().getFloatField(VALUE_FIELD).put(newVal);

        DBR dbr = new DBR_Float(new float[]{newVal});
        try {
            memoryProcessVariable.write(dbr, null);
        } catch (CAException ex) {
            Logger.getLogger(Epics7ServerChannel.class.getName()).log(Level.SEVERE, null, ex);
        }

        updateTimeStampAlarmsAndTriggerListener(listener);
    }

    @Override
    public void putRawValCallback(double newVal, PutListener listener) throws ConnectionException, PutException {
        if (elementType() != double.class) {
            addCAPV(DBRType.DOUBLE);
            addRecord(ScalarType.pvDouble, false);
        }

        pvRecord.getPVStructure().getDoubleField(VALUE_FIELD).put(newVal);

        DBR dbr = new DBR_Double(new double[]{newVal});
        try {
            memoryProcessVariable.write(dbr, null);
        } catch (CAException ex) {
            Logger.getLogger(Epics7ServerChannel.class.getName()).log(Level.SEVERE, null, ex);
        }

        updateTimeStampAlarmsAndTriggerListener(listener);
    }

    @Override
    public void putRawValCallback(String[] newVal, PutListener listener) throws ConnectionException, PutException {
        if (elementType() != String[].class) {
            addCAPV(DBRType.STRING);
            addRecord(ScalarType.pvString, true);
        }

        pvRecord.getPVStructure().getSubField(PVStringArray.class, Epics7Channel.VALUE_REQUEST).put(0, newVal.length, newVal, 0);

        DBR dbr = new DBR_String(newVal);
        try {
            memoryProcessVariable.write(dbr, null);
        } catch (CAException ex) {
            Logger.getLogger(Epics7ServerChannel.class.getName()).log(Level.SEVERE, null, ex);
        }

        updateTimeStampAlarmsAndTriggerListener(listener);
    }

    @Override
    public void putRawValCallback(byte[] newVal, PutListener listener) throws ConnectionException, PutException {
        if (elementType() != byte[].class) {
            addCAPV(DBRType.BYTE);
            addRecord(ScalarType.pvByte, true);
        }

        pvRecord.getPVStructure().getSubField(PVByteArray.class, Epics7Channel.VALUE_REQUEST).put(0, newVal.length, newVal, 0);

        DBR dbr = new DBR_String(newVal);
        try {
            memoryProcessVariable.write(dbr, null);
        } catch (CAException ex) {
            Logger.getLogger(Epics7ServerChannel.class.getName()).log(Level.SEVERE, null, ex);
        }

        updateTimeStampAlarmsAndTriggerListener(listener);
    }

    @Override
    public void putRawValCallback(short[] newVal, PutListener listener) throws ConnectionException, PutException {
        if (elementType() != short[].class) {
            addCAPV(DBRType.SHORT);
            addRecord(ScalarType.pvShort, true);
        }

        pvRecord.getPVStructure().getSubField(PVShortArray.class, Epics7Channel.VALUE_REQUEST).put(0, newVal.length, newVal, 0);

        DBR dbr = new DBR_Short(newVal);
        try {
            memoryProcessVariable.write(dbr, null);
        } catch (CAException ex) {
            Logger.getLogger(Epics7ServerChannel.class.getName()).log(Level.SEVERE, null, ex);
        }

        updateTimeStampAlarmsAndTriggerListener(listener);
    }

    @Override
    public void putRawValCallback(int[] newVal, PutListener listener) throws ConnectionException, PutException {
        if (elementType() != int[].class) {
            addCAPV(DBRType.INT);
            addRecord(ScalarType.pvInt, true);
        }

        pvRecord.getPVStructure().getSubField(PVIntArray.class, Epics7Channel.VALUE_REQUEST).put(0, newVal.length, newVal, 0);

        DBR dbr = new DBR_Int(newVal);
        try {
            memoryProcessVariable.write(dbr, null);
        } catch (CAException ex) {
            Logger.getLogger(Epics7ServerChannel.class.getName()).log(Level.SEVERE, null, ex);
        }

        updateTimeStampAlarmsAndTriggerListener(listener);
    }

    /**
     * Long is not supported in EPICS3, so they are casted to int for CA.
     */
    @Override
    public void putRawValCallback(long[] newVal, PutListener listener) throws ConnectionException, PutException {
        if (elementType() != long[].class) {
            addCAPV(DBRType.INT);
            addRecord(ScalarType.pvLong, true);
        }

        pvRecord.getPVStructure().getSubField(PVLongArray.class, Epics7Channel.VALUE_REQUEST).put(0, newVal.length, newVal, 0);

        int[] newInt = new int[newVal.length];
        for (int i = 0; i < newVal.length; i++) {
            newInt[i] = (int) newVal[i];
        }
        DBR dbr = new DBR_Int(newInt);
        try {
            memoryProcessVariable.write(dbr, null);
        } catch (CAException ex) {
            Logger.getLogger(Epics7ServerChannel.class.getName()).log(Level.SEVERE, null, ex);
        }

        updateTimeStampAlarmsAndTriggerListener(listener);
    }

    @Override
    public void putRawValCallback(float[] newVal, PutListener listener) throws ConnectionException, PutException {
        if (elementType() != float[].class) {
            addCAPV(DBRType.FLOAT);
            addRecord(ScalarType.pvFloat, true);
        }

        pvRecord.getPVStructure().getSubField(PVFloatArray.class, Epics7Channel.VALUE_REQUEST).put(0, newVal.length, newVal, 0);

        DBR dbr = new DBR_Float(newVal);
        try {
            memoryProcessVariable.write(dbr, null);
        } catch (CAException ex) {
            Logger.getLogger(Epics7ServerChannel.class.getName()).log(Level.SEVERE, null, ex);
        }

        updateTimeStampAlarmsAndTriggerListener(listener);
    }

    @Override
    public void putRawValCallback(double[] newVal, PutListener listener) throws ConnectionException, PutException {
        if (elementType() != double[].class) {
            addCAPV(DBRType.DOUBLE);
            addRecord(ScalarType.pvDouble, true);
        }

        pvRecord.getPVStructure().getSubField(PVDoubleArray.class, Epics7Channel.VALUE_REQUEST).put(0, newVal.length, newVal, 0);

        DBR dbr = new DBR_Double(newVal);
        try {
            memoryProcessVariable.write(dbr, null);
        } catch (CAException ex) {
            Logger.getLogger(Epics7ServerChannel.class.getName()).log(Level.SEVERE, null, ex);
        }

        updateTimeStampAlarmsAndTriggerListener(listener);
    }

    @Override
    public void setUnits(String units) {
        PVStructure displayStructure = getDisplay();
        if (displayStructure != null) {
            displayStructure.getStringField("units").put(units);
        } else {
            Logger.getLogger(Epics7ServerChannel.class.getName()).severe("Couldn't find \"display\" field.");
        }

        memoryProcessVariable.setUnits(units);
    }

    @Override
    public void setLowerDispLimit(Number lowerLimit) {
        PVStructure displayStructure = getDisplay();
        if (displayStructure != null) {
            displayStructure.getDoubleField("limitLow").put(lowerLimit.doubleValue());
        } else {
            Logger.getLogger(Epics7ServerChannel.class.getName()).severe("Couldn't find \"display\" field.");
        }

        memoryProcessVariable.setLowerDispLimit(lowerLimit);
    }

    @Override
    public void setUpperDispLimit(Number upperLimit) {
        PVStructure displayStructure = getDisplay();
        if (displayStructure != null) {
            displayStructure.getDoubleField("limitHigh").put(upperLimit.doubleValue());
        } else {
            Logger.getLogger(Epics7ServerChannel.class.getName()).severe("Couldn't find  \"display\" field.");
        }

        memoryProcessVariable.setUpperDispLimit(upperLimit);
    }

    @Override
    public void setLowerAlarmLimit(Number lowerLimit) {
        PVStructure alarmValueStructure = getVAlueAlarm();
        if (alarmValueStructure != null) {
            alarmValueStructure.getDoubleField("lowAlarmLimit").put(lowerLimit.doubleValue());
        } else {
            Logger.getLogger(Epics7ServerChannel.class.getName()).severe("Couldn't find  \"valueAlarm\" field.");
        }

        memoryProcessVariable.setLowerAlarmLimit(lowerLimit);
    }

    @Override
    public void setUpperAlarmLimit(Number upperLimit) {
        PVStructure alarmValueStructure = getVAlueAlarm();
        if (alarmValueStructure != null) {
            alarmValueStructure.getDoubleField("highAlarmLimit").put(upperLimit.doubleValue());
        } else {
            Logger.getLogger(Epics7ServerChannel.class.getName()).severe("Couldn't find  \"valueAlarm\" field.");
        }

        memoryProcessVariable.setUpperAlarmLimit(upperLimit);
    }

    @Override
    public void setLowerWarningLimit(Number lowerLimit) {
        PVStructure alarmValueStructure = getVAlueAlarm();
        if (alarmValueStructure != null) {
            alarmValueStructure.getDoubleField("lowWarningLimit").put(lowerLimit.doubleValue());
        } else {
            Logger.getLogger(Epics7ServerChannel.class.getName()).severe("Couldn't find  \"valueAlarm\" field.");
        }

        memoryProcessVariable.setLowerWarningLimit(lowerLimit);
    }

    @Override
    public void setUpperWarningLimit(Number upperLimit) {
        PVStructure alarmValueStructure = getVAlueAlarm();
        if (alarmValueStructure != null) {
            alarmValueStructure.getDoubleField("highWarningLimit").put(upperLimit.doubleValue());
        } else {
            Logger.getLogger(Epics7ServerChannel.class.getName()).severe("Couldn't find  \"valueAlarm\" field.");
        }

        memoryProcessVariable.setUpperWarningLimit(upperLimit);
    }

    @Override
    public void setLowerCtrlLimit(Number lowerLimit) {
        PVStructure alarmValueStructure = getControl();
        if (alarmValueStructure != null) {
            alarmValueStructure.getDoubleField("limitLow").put(lowerLimit.doubleValue());
        } else {
            Logger.getLogger(Epics7ServerChannel.class.getName()).severe("Couldn't find  \"control\" field.");
        }

        memoryProcessVariable.setLowerCtrlLimit(lowerLimit);
    }

    @Override
    public void setUpperCtrlLimit(Number upperLimit) {
        PVStructure alarmValueStructure = getControl();
        if (alarmValueStructure != null) {
            alarmValueStructure.getDoubleField("limitHigh").put(upperLimit.doubleValue());
        } else {
            Logger.getLogger(Epics7ServerChannel.class.getName()).severe("Couldn't find  \"control\" field.");
        }

        memoryProcessVariable.setUpperCtrlLimit(upperLimit);
    }

    @Override
    public void setSettable(boolean settable) {
        // Does nothing.
    }
}


text: My Personal Site


text:
<?php
namespace Webbamboo\Fortnox\Model;

interface iInvoice {
    public function getAdministrationfee();
    public function setAdministrationfee($administrationfee);
    public function getAddress1();
    public function setAddress1($address1);
    public function getAddress2();
    public function setAddress2($address2);
    public function getCreditinvoicereference();
    public function setCreditinvoicereference($creditinvoicereference);
    public function getCity();
    public function setCity($city);
    public function getComments();
    public function setComments($comments);
    public function getCountry();
    public function setCountry($country);
    public function getCostcenter();
    public function setCostcenter($costcenter);
    public function getCurrency();
    public function setCurrency($currency);
    public function getCurrencyrate();
    public function setCurrencyrate($currencyrate);
    public function getCurrencyunit();
    public function setCurrencyunit($currencyunit);
    public function getCustomername();
    public function setCustomername($customername);
    public function getCustomernumber();
    public function setCustomernumber($customernumber);
    public function getDeliveryaddress1();
    public function setDeliveryaddress1($deliveryaddress1);
    public function getDeliveryaddress2();
    public function setDeliveryaddress2($deliveryaddress2);
    public function getDeliverycity();
    public function setDeliverycity($deliverycity);
    public function getDeliverycountry();
    public function setDeliverycountry($deliverycountry);
    public function getDeliverydate();
    public function setDeliverydate($deliverydate);
    public function getDeliveryzipcode();
    public function setDeliveryzipcode($deliveryzipcode);
    public function getDocumentnumber();
    public function setDocumentnumber($documentnumber);
    public function getDuedate();
    public function setDuedate($duedate);
    public function getEdiinformation();
    public function setEdiinformation(EDIInformation $ediinformation);
    public function getEmailinformation();
    public function setEmailinformation(EmailInformation $emailinformation);
    public function getExternalinvoicereference1();
    public function setExternalinvoicereference1($externalinvoicereference1);
    public function getExternalinvoicereference();
    public function setExternalinvoicereference($externalinvoicereference);
    public function getFreight();
    public function setFreight($freight);
    public function getInvoicedate();
    public function setInvoicedate($invoicedate);
    public function getInvoicerows();
    public function addInvoicerow(InvoiceRow $invoicerow);
    public function getInvoicetype();
    public function setInvoicetype($invoicetype);
    public function getLanguage();
    public function setLanguage($language);
    public function getNotcompleted();
    public function setNotcompleted($notcompleted);
    public function getOcr();
    public function setOcr($ocr);
    public function getOurreference();
    public function setOurreference($ourreference);
    public function getPhone1();
    public function setPhone1($phone1);
    public function getPhone2();
    public function setPhone2($phone2);
    public function getPricelist();
    public function setPricelist($pricelist);
    public function getPrinttemplate();
    public function setPrinttemplate($printtemplate);
    public function getProject();
    public function setProject($project);
    public function getRemarks();
    public function setRemarks($remarks);
    public function getTermsofdelivery();
    public function setTermsofdelivery($termsofdelivery);
    public function getTermsofpayment();
    public function setTermsofpayment($termsofpayment);
    public function getVatincluded();
    public function setVatincluded($vatincluded);
    public function getWayofdelivery();
    public function setWayofdelivery($wayofdelivery);
    public function getYourordernumber();
    public function setYourordernumber($yourordernumber);
    public function getYourreference();
    public function setYourreference($yourreference);
    public function getZipcode();
    public function setZipcode($zipcode);
}

class FortnoxInvoice implements iInvoice {
    protected $administrationfee;
    protected $address1;
    protected $address2;
    protected $creditinvoicereference;
    protected $city;
    protected $comments;
    protected $country;
    protected $costcenter;
    protected $currency;
    protected $currencyrate;
    protected $currencyunit;
    protected $customername;
    protected $customernumber;
    protected $deliveryaddress1;
    protected $deliveryaddress2;
    protected $deliverycity;
    protected $deliverycountry;
    protected $deliverydate;
    protected $deliveryzipcode;
    protected $documentnumber;
    protected $duedate;
    protected $ediinformation;
    protected $emailinformation;
    protected $externalinvoicereference1;
    protected $externalinvoicereference;
    protected $freight;
    protected $invoicedate;
    protected $invoicerows = array();
    protected $invoicetype;
    protected $language;
    protected $notcompleted;
    protected $ocr;
    protected $ourreference;
    protected $phone1;
    protected $phone2;
    protected $pricelist;
    protected $printtemplate;
    protected $project;
    protected $remarks;
    protected $termsofdelivery;
    protected $termsofpayment;
    protected $vatincluded;
    protected $wayofdelivery;
    protected $yourordernumber;
    protected $yourreference;
    protected $zipcode;

    public function getAdministrationfee(){
        return $this->administrationfee;
    }

    public function setAdministrationfee($administrationfee){
        $this->administrationfee = $administrationfee;
        return $this;
    }

    public function getAddress1(){
        return $this->address1;
    }

    public function setAddress1($address1){
        $this->address1 = $address1;
        return $this;
    }

    public function getAddress2(){
        return $this->address2;
    }

    public function setAddress2($address2){
        $this->address2 = $address2;
        return $this;
    }

    public function getCreditinvoicereference(){
        return $this->creditinvoicereference;
    }

    public function setCreditinvoicereference($creditinvoicereference){
        $this->creditinvoicereference = $creditinvoicereference;
        return $this;
    }

    public function getCity(){
        return $this->city;
    }

    public function setCity($city){
        $this->city = $city;
        return $this;
    }

    public function getComments(){
        return $this->comments;
    }

    public function setComments($comments){
        $this->comments = $comments;
        return $this;
    }

    public function getCountry(){
        return $this->country;
    }

    public function setCountry($country){
        $this->country = $country;
        return $this;
    }

    public function getCostcenter(){
        return $this->costcenter;
    }

    public function setCostcenter($costcenter){
        $this->costcenter = $costcenter;
        return $this;
    }

    public function getCurrency(){
        return $this->currency;
    }

    public function setCurrency($currency){
        $this->currency = $currency;
        return $this;
    }

    public function getCurrencyrate(){
        return $this->currencyrate;
    }

    public function setCurrencyrate($currencyrate){
        $this->currencyrate = $currencyrate;
        return $this;
    }

    public function getCurrencyunit(){
        return $this->currencyunit;
    }

    public function setCurrencyunit($currencyunit){
        $this->currencyunit = $currencyunit;
        return $this;
    }

    public function getCustomername(){
        return $this->customername;
    }

    public function setCustomername($customername){
        $this->customername = $customername;
        return $this;
    }

    public function getCustomernumber(){
        return $this->customernumber;
    }
    public function setCustomernumber($customernumber){
        $this->customernumber = $customernumber;
        return $this;
    }

    public function getDeliveryaddress1(){
        return $this->deliveryaddress1;
    }

    public function setDeliveryaddress1($deliveryaddress1){
        $this->deliveryaddress1 = $deliveryaddress1;
        return $this;
    }

    public function getDeliveryaddress2(){
        return $this->deliveryaddress2;
    }

    public function setDeliveryaddress2($deliveryaddress2){
        $this->deliveryaddress2 = $deliveryaddress2;
        return $this;
    }

    public function getDeliverycity(){
        return $this->deliverycity;
    }

    public function setDeliverycity($deliverycity){
        $this->deliverycity = $deliverycity;
        return $this;
    }

    public function getDeliverycountry(){
        return $this->deliverycountry;
    }

    public function setDeliverycountry($deliverycountry){
        $this->deliverycountry = $deliverycountry;
        return $this;
    }

    public function getDeliverydate(){
        return $this->deliverydate;
    }

    public function setDeliverydate($deliverydate){
        $this->deliverydate = $deliverydate;
        return $this;
    }

    public function getDeliveryzipcode(){
        return $this->deliveryzipcode;
    }

    public function setDeliveryzipcode($deliveryzipcode){
        $this->deliveryzipcode = $deliveryzipcode;
        return $this;
    }

    public function getDocumentnumber(){
        return $this->documentnumber;
    }

    public function setDocumentnumber($documentnumber){
        $this->documentnumber = $documentnumber;
        return $this;
    }

    public function getDuedate(){
        return $this->duedate;
    }

    public function setDuedate($duedate){
        $this->duedate = $duedate;
        return $this;
    }

    public function getEdiinformation(){
        return $this->ediinformation;
    }

    public function setEdiinformation(EDIInformation $ediinformation){
        $this->ediinformation = $ediinformation->toArray();
        return $this;
    }

    public function getEmailinformation(){
        return $this->emailinformation;
    }

    public function setEmailinformation(EmailInformation $emailinformation){
        $this->emailinformation = $emailinformation->toArray();
        return $this;
    }

    public function getExternalinvoicereference1(){
        return $this->externalinvoicereference1;
    }

    public function setExternalinvoicereference1($externalinvoicereference1){
        $this->externalinvoicereference1 = $externalinvoicereference1;
        return $this;
    }

    public function getExternalinvoicereference(){
        return $this->externalinvoicereference;
    }

    public function setExternalinvoicereference($externalinvoicereference){
        $this->externalinvoicereference = $externalinvoicereference;
        return $this;
    }

    public function getFreight(){
        return $this->freight;
    }

    public function setFreight($freight){
        $this->freight = $freight;
        return $this;
    }

    public function getInvoicedate(){
        return $this->invoicedate;
    }

    public function setInvoicedate($invoicedate){
        $this->invoicedate = $invoicedate;
        return $this;
    }

    public function getInvoicerows(){
        return $this->invoicerows;
    }

    public function addInvoicerow(InvoiceRow $invoicerow){
        $this->invoicerows[] = $invoicerow->toArray();
        return $this;
    }

    public function getInvoicetype(){
        return $this->invoicetype;
    }

    public function setInvoicetype($invoicetype){
        $this->invoicetype = $invoicetype;
        return $this;
    }

    public function getLanguage(){
        return $this->language;
    }

    public function setLanguage($language){
        $this->language = $language;
        return $this;
    }

    public function getNotcompleted(){
        return $this->notcompleted;
    }

    public function setNotcompleted($notcompleted){
        $this->notcompleted = $notcompleted;
        return $this;
    }

    public function getOcr(){
        return $this->ocr;
    }

    public function setOcr($ocr){
        $this->ocr = $ocr;
        return $this;
    }

    public function getOurreference(){
        return $this->ourreference;
    }

    public function setOurreference($ourreference){
        $this->ourreference = $ourreference;
        return $this;
    }

    public function getPhone1(){
        return $this->phone1;
    }

    public function setPhone1($phone1){
        $this->phone1 = $phone1;
        return $this;
    }

    public function getPhone2(){
        return $this->phone2;
    }

    public function setPhone2($phone2){
        $this->phone2 = $phone2;
        return $this;
    }

    public function getPricelist(){
        return $this->pricelist;
    }

    public function setPricelist($pricelist){
        $this->pricelist = $pricelist;
        return $this;
    }

    public function getPrinttemplate(){
        return $this->printtemplate;
    }

    public function setPrinttemplate($printtemplate){
        $this->printtemplate = $printtemplate;
        return $this;
    }

    public function getProject(){
        return $this->project;
    }

    public function setProject($project){
        $this->project = $project;
        return $this;
    }

    public function getRemarks(){
        return $this->remarks;
    }

    public function setRemarks($remarks){
        $this->remarks = $remarks;
        return $this;
    }

    public function getTermsofdelivery(){
        return $this->termsofdelivery;
    }

    public function setTermsofdelivery($termsofdelivery){
        $this->termsofdelivery = $termsofdelivery;
        return $this;
    }

    public function getTermsofpayment(){
        return $this->termsofpayment;
    }

    public function setTermsofpayment($termsofpayment){
        $this->termsofpayment = $termsofpayment;
        return $this;
    }

    public function getVatincluded(){
        return $this->vatincluded;
    }

    public function setVatincluded($vatincluded){
        $this->vatincluded = $vatincluded;
        return $this;
    }

    public function getWayofdelivery(){
        return $this->wayofdelivery;
    }

    public function setWayofdelivery($wayofdelivery){
        $this->wayofdelivery = $wayofdelivery;
        return $this;
    }

    public function getYourordernumber(){
        return $this->yourordernumber;
    }

    public function setYourordernumber($yourordernumber){
        $this->yourordernumber = $yourordernumber;
        return $this;
    }

    public function getYourreference(){
        return $this->yourreference;
    }

    public function setYourreference($yourreference){
        $this->yourreference = $yourreference;
        return $this;
    }

    public function getZipcode(){
        return $this->zipcode;
    }

    public function setZipcode($zipcode){
        $this->zipcode = $zipcode;
        return $this;
    }

    public function __toString()
    {
        $fields = array(
            "AdministrationFee" => $this->getAdministrationfee(),
            "Address1" => $this->getAddress1(),
            "Address2" => $this->getAddress2(),
            "CreditInvoiceReference" => $this->getCreditinvoicereference(),
            "City" => $this->getCity(),
            "Comments" => $this->getComments(),
            "Country" => $this->getCountry(),
            "CostCenter" => $this->getCostcenter(),
            "Currency" => $this->getCurrency(),
            "CurrencyRate" => $this->getCurrencyrate(),
            "CurrencyUnit" => $this->getCurrencyunit(),
            "CustomerName" => $this->getCustomername(),
            "CustomerNumber" => $this->getCustomernumber(),
            "DeliveryAddress1" => $this->getDeliveryaddress1(),
            "DeliveryAddress2" => $this->getDeliveryaddress2(),
            "DeliveryCity" => $this->getDeliverycity(),
            "DeliveryCountry" => $this->getDeliverycountry(),
            "DeliveryDate" => $this->getDeliverydate(),
            "DeliveryZipCode" => $this->getDeliveryzipcode(),
            "DocumentNumber" => $this->getDocumentnumber(),
            "DueDate" => $this->getDuedate(),
            "EDIInformation" => $this->getEdiinformation(),
            "EmailInformation" => $this->getEmailinformation(),
            "ExternalInvoiceReference1" => $this->getExternalinvoicereference1(),
            "ExternalInvoiceReference" => $this->getExternalinvoicereference(),
            "Freight" => $this->getFreight(),
            "InvoiceDate" => $this->getInvoicedate(),
            "InvoiceRows" => $this->getInvoicerows(),
            "InvoiceType" => $this->getInvoicetype(),
            "Language" => $this->getLanguage(),
            "NotCompleted" => $this->getNotcompleted(),
            "OCR" => $this->getOcr(),
            "OurReference" => $this->getOurreference(),
            "Phone1" => $this->getPhone1(),
            "Phone2" => $this->getPhone2(),
            "PriceList" => $this->getPricelist(),
            "PrintTemplate" => $this->getPrinttemplate(),
            "Project" => $this->getProject(),
            "Remarks" => $this->getRemarks(),
            "TermsOfDelivery" => $this->getTermsofdelivery(),
            "TermsOfPayment" => $this->getTermsofpayment(),
            "VATIncluded" => $this->getVatincluded(),
            "WayOfDelivery" => $this->getWayofdelivery(),
            "YourOrderNumber" => $this->getYourordernumber(),
            "YourReference" => $this->getYourreference(),
            "ZipCode" => $this->getZipcode()
        );
        $invoice = [
            "Invoice" => [
            ]
        ];
        foreach($fields as $field => $value)
        {
            if(!is_null($value) && !empty($value))
            {
                $invoice['Invoice'][$field] = $value;
            }
        }
        return json_encode($invoice);
    }
}

class InvoiceRow {
    protected $accountnumber;
    protected $articlenumber;
    protected $costcenter;
    protected $deliveredquantity;
    protected $description;
    protected $discount;
    protected $discounttype;
    protected $housework;
    protected $price;
    protected $project;
    protected $unit;
    protected $VAT;

    public function getAccountnumber(){
        return $this->accountnumber;
    }

    public function setAccountnumber($accountnumber){
        $this->accountnumber = $accountnumber;
        return $this;
    }

    public function getArticlenumber(){
        return $this->articlenumber;
    }

    public function setArticlenumber($articlenumber){
        $this->articlenumber = $articlenumber;
        return $this;
    }

    public function getCostcenter(){
        return $this->costcenter;
    }

    public function setCostcenter($costcenter){
        $this->costcenter = $costcenter;
        return $this;
    }

    public function getDeliveredquantity(){
        return $this->deliveredquantity;
    }

    public function setDeliveredquantity($deliveredquantity){
        $this->deliveredquantity = $deliveredquantity;
        return $this;
    }

    public function getDescription(){
        return $this->description;
    }

    public function setDescription($description){
        $this->description = $description;
        return $this;
    }

    public function getDiscount(){
        return $this->discount;
    }

    public function setDiscount($discount){
        $this->discount = $discount;
        return $this;
    }

    public function getDiscounttype(){
        return $this->discounttype;
    }

    public function setDiscounttype($discounttype){
        $this->discounttype = $discounttype;
        return $this;
    }

    public function getHousework(){
        return $this->housework;
    }

    public function setHousework($housework){
        $this->housework = $housework;
        return $this;
    }

    public function getPrice(){
        return $this->price;
    }

    public function setPrice($price){
        $this->price = $price;
        return $this;
    }

    public function getProject(){
        return $this->project;
    }

    public function setProject($project){
        $this->project = $project;
        return $this;
    }

    public function getUnit(){
        return $this->unit;
    }

    public function setUnit($unit){
        $this->unit = $unit;
        return $this;
    }

    public function getVAT(){
        return $this->VAT;
    }

    public function setVAT($VAT){
        $this->VAT = $VAT;
        return $this;
    }

    public function toArray()
    {
        $fields = array(
            "AccountNumber" => $this->getAccountnumber(),
            "ArticleNumber" => $this->getArticlenumber(),
            "CostCenter" => $this->getCostcenter(),
            "DeliveredQuantity" => $this->getDeliveredquantity(),
            "Description" => $this->getDescription(),
            "Discount" => $this->getDiscount(),
            "DiscountType" => $this->getDiscounttype(),
            "HouseWork" => $this->getHousework(),
            "Price" => $this->getPrice(),
            "Project" => $this->getProject(),
            "Unit" => $this->getUnit(),
            "VAT" => $this->getVAT()
        );
        $InvoiceRow = [

        ];
        foreach($fields as $field => $value)
        {
            if(!is_null($value) && !empty($value))
            {
                $InvoiceRow[$field] = $value;
            }
        }
        return $InvoiceRow;
    }
}

class EDIInformation {
    protected $edigloballocationnumber;
    protected $edigloballocationnumberdelivery;
    protected $ediinvoiceextra1;
    protected $ediinvoiceextra2;
    protected $ediourelectronicreference;
    protected $ediyourelectronicreference;

    public function getEdigloballocationnumber(){
        return $this->edigloballocationnumber;
    }

    public function setEdigloballocationnumber($edigloballocationnumber){
        $this->edigloballocationnumber = $edigloballocationnumber;
        return $this;
    }

    public function getEdigloballocationnumberdelivery(){
        return $this->edigloballocationnumberdelivery;
    }

    public function setEdigloballocationnumberdelivery($edigloballocationnumberdelivery){
        $this->edigloballocationnumberdelivery = $edigloballocationnumberdelivery;
        return $this;
    }

    public function getEdiinvoiceextra1(){
        return $this->ediinvoiceextra1;
    }

    public function setEdiinvoiceextra1($ediinvoiceextra1){
        $this->ediinvoiceextra1 = $ediinvoiceextra1;
        return $this;
    }

    public function getEdiinvoiceextra2(){
        return $this->ediinvoiceextra2;
    }

    public function setEdiinvoiceextra2($ediinvoiceextra2){
        $this->ediinvoiceextra2 = $ediinvoiceextra2;
        return $this;
    }

    public function getEdiourelectronicreference(){
        return $this->ediourelectronicreference;
    }

    public function setEdiourelectronicreference($ediourelectronicreference){
        $this->ediourelectronicreference = $ediourelectronicreference;
        return $this;
    }

    public function getEdiyourelectronicreference(){
        return $this->ediyourelectronicreference;
    }

    public function setEdiyourelectronicreference($ediyourelectronicreference){
        $this->ediyourelectronicreference = $ediyourelectronicreference;
        return $this;
    }

    public function toArray()
    {
        $EDIInformation = [
            "EDIGlobalLocationNumber" => $this->getEdigloballocationnumber(),
            "EDIGlobalLocationNumberDelivery" => $this->getEdigloballocationnumberdelivery(),
            "EDIInvoiceExtra1" => $this->getEdiinvoiceextra1(),
            "EDIInvoiceExtra2" => $this->getEdiinvoiceextra2(),
            "EDIOurElectronicReference" => $this->getEdiourelectronicreference(),
            "EDIYourElectronicReference" => $this->getEdiyourelectronicreference()
        ];
        return $EDIInformation;
    }
}

class EmailInformation {
    protected $emailaddressto;
    protected $emailaddresscc;
    protected $emailaddressbcc;
    protected $emailsubject;
    protected $emailbody;

    public function getEmailaddressto(){
        return $this->emailaddressto;
    }

    public function setEmailaddressto($emailaddressto){
        $this->emailaddressto = $emailaddressto;
        return $this;
    }

    public function getEmailaddresscc(){
        return $this->emailaddresscc;
    }

    public function setEmailaddresscc($emailaddresscc){
        $this->emailaddresscc = $emailaddresscc;
        return $this;
    }

    public function getEmailaddressbcc(){
        return $this->emailaddressbcc;
    }

    public function setEmailaddressbcc($emailaddressbcc){
        $this->emailaddressbcc = $emailaddressbcc;
        return $this;
    }

    public function getEmailsubject(){
        return $this->emailsubject;
    }

    public function setEmailsubject($emailsubject){
        $this->emailsubject = $emailsubject;
        return $this;
    }

    public function getEmailbody(){
        return $this->emailbody;
    }

    public function setEmailbody($emailbody){
        $this->emailbody = $emailbody;
        return $this;
    }

    public function toArray()
    {
        $emailInformation = [
            "EmailAddressTo" => $this->getEmailaddressto(),
            "EmailAddressCC" => $this->getEmailaddresscc(),
            "EmailAddressBCC" => $this->getEmailaddressbcc(),
            "EmailSubject" => $this->getEmailsubject(),
            "EmailBody" => $this->getEmailbody()
        ];
        return $emailInformation;
    }
}


text:
/* -*- Mode: JavaScript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */

"use strict";
const Cu = Components.utils;
const Ci = Components.interfaces;

Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");

function TestInterfaceJSMaplike() {}

TestInterfaceJSMaplike.prototype = {
  classID: Components.ID("{4bc6f6f3-e005-4f0a-b42d-4d1663a9013a}"),
  contractID: "@mozilla.org/dom/test-interface-js-maplike;1",
  QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports,
                                         Ci.nsIDOMGlobalPropertyInitializer]),

  init: function(win) { this._win = win; },

  __init: function () {},

  setInternal: function(aKey, aValue) {
    return this.__DOM_IMPL__.__set(aKey, aValue);
  },

  deleteInternal: function(aKey) {
    return this.__DOM_IMPL__.__delete(aKey);
  },

  clearInternal: function() {
    return this.__DOM_IMPL__.__clear();
  }
};

this.NSGetFactory = XPCOMUtils.generateNSGetFactory([TestInterfaceJSMaplike])


text:
package controllers

import (
	// "errors"
	// "net/http"
	// "fmt"
	// "reflect"
	"io/ioutil"

	// "labix.org/v2/mgo/bson"
	"github.com/phenax/diary-pwa/config"
	"github.com/phenax/diary-pwa/libs"
	"github.com/phenax/diary-pwa/models"
	// "github.com/gorilla/mux"
)

const (
	// EncryptionKey - Key to use in the encryption algorithm
	EncryptionKey = "98c36hby8iwnseho8qwy38ryuagnukdshxkvastcvw4"
)

//
// HomePage - homepage controller
//
// params
// -- ctx {*Context}  Server request context
//
func HomePage(ctx *Context) {

	var users []models.User

	models.Users.Find(nil).All(&users)

	options := &map[string]interface{}{
		"Ctx":           ctx,
		"Users":         users,
		"Title":         "",
		"StaticVersion": config.StaticFileVersion,
	}

	ctx.Render("index", options)
}

//
// Encrypt - Encrypt and decrypt string
func Encrypt(ctx *Context) {

	response := map[string]string{}

	ctx.JSON(response)
}

//
// JSONTest - Send json test data to the client
//
// params
// -- ctx {*Context}
//
func JSONTest(ctx *Context) {

	type Product struct {
		ID   int
		Name string
	}

	type Response struct {
		Access   bool
		Products []*Product
	}

	obj := &Response{
		Access: true,
		Products: []*Product{
			&Product{
				ID:   1,
				Name: "Soap",
			},
			&Product{
				ID:   2,
				Name: "Shampoo",
			},
		},
	}

	ctx.JSON(obj)
}

//
// ServeServiceWorker - Serve the service worker js file
//
// params
// -- ctx {*Context}
//
func ServeServiceWorker(ctx *Context) {

	bundleStatsData, err := ioutil.ReadFile(config.BundleStatsFilepath)

	swScript := `self.STATIC_BASE_URL = '` + libs.GetStaticURL("") + `';
self.STATIC_CACHE_VERSION = '` + config.StaticFileVersion + `';
self.BUNDLE_STATS=` + string(bundleStatsData) + `;`

	serviceWorkerJsFile, err := ioutil.ReadFile(config.ServiceWorkerPath)

	if err != nil {
		ctx.ErrorMessage(500, err)
		return
	}

	swScript += string(serviceWorkerJsFile)

	ctx.Send(string(swScript), &ResponseConfig{
		ContentType: "application/javascript",
	})

	// Gzip the string
	// gzipppedContent, err := libs.GzipString(swScript)

	// if err != nil {
	// 	ctx.ErrorMessage(500, err)
	// 	return
	// }

	// ctx.Send(string(gzipppedContent), &ResponseConfig{
	// 	ContentType:     "application/javascript",
	// 	ContentEncoding: "gzip",
	// })
}


text:
package com.wolkabout.wolk.model;

import com.wolkabout.wolk.util.JsonMultivalueSerializer;

import java.util.List;

public class Configuration {

    private final String reference;
    private final List<String> values;
    private final String value;

    public Configuration(String reference, String value) {
        this.reference = reference;
        this.value = value;
        this.values = JsonMultivalueSerializer.valuesFromString(value);
    }

    public Configuration(String reference, List<String> values) {
        this.reference = reference;
        this.value = JsonMultivalueSerializer.valuesToString(values);
        this.values = values;
    }

    public String getReference() {
        return reference;
    }

    public List<String> getValues() {
        return values;
    }

    public String getValue() {
        return value;
    }

    @Override
    public String toString() {
        return "Configuration{" +
                "reference='" + reference + '\'' +
                ", value='" + value + '\'' +
                '}';
    }
}


text:
package de.be.thaw.auth.exception;

/**
 * Exception thrown when a user could not be stored.
 *
 * Created by Benjamin Eder on 01.05.2017.
 */
public class UserStoreException extends AuthException {

	public UserStoreException() {
		super();
	}

	public UserStoreException(String message) {
		super(message);
	}

	public UserStoreException(String message, Throwable cause) {
		super(message, cause);
	}

	public UserStoreException(Throwable cause) {
		super(cause);
	}

}


text:
<?php

declare(strict_types=1);

namespace StructType;

use InvalidArgumentException;
use WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for SubscriptionRenewFailedChannelEventType StructType
 * @package Ews
 * @subpackage Structs
 * @author WsdlToPhp <contact@wsdltophp.com>
 */
class EwsSubscriptionRenewFailedChannelEventType extends EwsSubscriptionLevelChannelEventType
{
}


text:
using namespace std;

const int TREE_LIMIT_SMALL = 4;
const int TREE_LIMIT_MED = 18;
const int DYM_X = 70;
const int DYM_Y = 30;
const int HEIGHT_MAX_POINTS = 2;
const int HEIGHT_CHECK_DISTANCE = 3;

// WorldMap Class
class WorldMap {
public:
	int getXPos();
	int getYPos();
	vector<vector<SectorMap>> getMapVector();
	//vector<SectorMap> getMapVector();
	void makeMap(int newX, int newY);
	void viewMap();
	void TrickelDown(int x, int y, int distance, int orgHeight);

private:
	void viewHeightMap();
	void viewHeightMapNoInput();
	void viewHeightMapStatic();
	void viewHeightMapDynamic(int finX, int finY);
	void viewMapNoInput();
	void viewMapStatic();
	void viewMapDynamic(int finX, int finY);
	void SpawnBioCenters();
	void TreeSpawn();
	void TreeSpawn(int currentX, int currentY);
	int CountTrees();
	void TreeRec(int indI, int indN, int startDist);
	int x;
	int y;
	vector<vector<SectorMap>> map;
	// vector<SectorMap> map;
};

#endif //WORLDMAP_H


text:
using System;
using System.Linq;

namespace BinaryCalculations
{
    class Program
    {
        static void Main(string[] args)
        {
            SimpleCalculations();
            BitShifts();
            SignedNumbers();
        }

        private static void SignedNumbers()
        {
            Console.WriteLine("signed numbers");
            uint x1 = 0b1;
            Console.WriteLine(x1.ToBinaryString());
            Console.WriteLine($"number: {x1:X}");
            x1 = x1 << 31;
            Console.WriteLine("shift left 31 bits");
            Console.WriteLine(x1);
            Console.WriteLine(x1.ToBinaryString());
            Console.WriteLine($"number: {x1:X}");
            int x2 = (int)x1;
            Console.WriteLine(x2);
            Console.WriteLine(x2.ToBinaryString());
            Console.WriteLine($"number: {x2:X}");
            Console.WriteLine();

            int x3 = 0b1000;
            Console.WriteLine(x3);
            int x4 = ~x3;
            Console.WriteLine(x4);
            uint x5 = 0b11111111_11111111_11111111_11111111;
            Console.WriteLine($"x5: decimal: {x5} hex: {x5:X}");
            int x6 = (int)x5;
            Console.WriteLine($"x6: decimal: {x6} hex: {x6:X}");
            x6--;
            Console.WriteLine($"x6: decimal: {x6} hex: {x6:X}");
        }

        static void SimpleCalculations()
        {
            uint binary1 = 0b1111_0000_1100_0011_1110_0001_0001_1000;
            uint binary2 = 0b0000_1111_1100_0011_0101_1010_1110_0111;
            uint binaryAnd = binary1 & binary2;
            DisplayBits("AND", binaryAnd, binary1, binary2);
            uint binaryOR = binary1 | binary2;
            DisplayBits("OR", binaryOR, binary1, binary2);
            uint binaryXOR = binary1 ^ binary2;
            DisplayBits("XOR", binaryXOR, binary1, binary2);
            uint reverse1 = ~binary1;
            DisplayBits("NOT", reverse1, binary1);
        }
        static void DisplayBits(string title, uint result, uint left, uint? right = null)
        {
            Console.WriteLine(title);
            Console.WriteLine(left.ToBinaryString().AddSeparators());
            if (right.HasValue)
            {
                Console.WriteLine(right.Value.ToBinaryString().AddSeparators());
            }
            Console.WriteLine(result.ToBinaryString().AddSeparators());
            Console.WriteLine();
        }

        static void BitShifts()
        {
            ushort s1 = 0b01;
            for (int i = 0; i < 16; i++)
            {
                Console.WriteLine($"{s1} hex: {s1:X}");
                s1 = (ushort)(s1 << 1);
            }
        }
    }
}


text:
SYNONYM

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

#### Published in
Trans. Kansas Acad. Sci. 16: 167 (1899)

#### Original name
Cladotrichum brassicae Ellis & Barthol., 1899

### Remarks
null


text:
#import "NSObject.h"

#import "NSCopying-Protocol.h"

@class NSString;

// Not exported
@interface TSDLineEnd : NSObject <NSCopying>
{
    struct CGPath *mPath;
    struct CGPath *mWrapPath;
    struct CGPoint mEndPoint;
    _Bool mIsFilled;
    NSString *mIdentifier;
    int mLineJoin;
}

+ (id)lineEndWithPath:(struct CGPath *)arg1 wrapPath:(struct CGPath *)arg2 endPoint:(struct CGPoint)arg3 isFilled:(_Bool)arg4 identifier:(id)arg5;
+ (id)lineEndWithPath:(struct CGPath *)arg1 endPoint:(struct CGPoint)arg2 isFilled:(_Bool)arg3 identifier:(id)arg4;
+ (id)lineEndWithIdentifier:(id)arg1;
+ (id)lineEndWithType:(int)arg1;
+ (id)none;
+ (id)line;
+ (id)invertedArrow;
+ (id)openCircle;
+ (id)openSquare;
+ (id)filledSquare;
+ (id)filledArrow;
+ (id)openArrow;
+ (id)filledDiamond;
+ (id)filledCircle;
+ (id)simpleArrow;
@property(readonly, nonatomic) int lineJoin; // @synthesize lineJoin=mLineJoin;
@property(readonly, nonatomic) _Bool isFilled; // @synthesize isFilled=mIsFilled;
@property(readonly, nonatomic) struct CGPoint endPoint; // @synthesize endPoint=mEndPoint;
@property(readonly, nonatomic) struct CGPath *path; // @synthesize path=mPath;
@property(readonly, nonatomic) NSString *identifier; // @synthesize identifier=mIdentifier;
- (id)description;
@property(readonly, nonatomic) _Bool isNone;
@property(readonly, nonatomic) struct CGPath *wrapPath;
- (struct CGImage *)newLineEndImageOnRight:(_Bool)arg1 forContentsScale:(double)arg2 withSize:(struct CGSize)arg3;
- (id)copyWithZone:(struct _NSZone *)arg1;
- (_Bool)isEqual:(id)arg1;
- (unsigned long long)hash;
- (void)dealloc;
- (id)initWithPath:(struct CGPath *)arg1 endPoint:(struct CGPoint)arg2 isFilled:(_Bool)arg3 identifier:(id)arg4;
- (id)initWithPath:(struct CGPath *)arg1 wrapPath:(struct CGPath *)arg2 endPoint:(struct CGPoint)arg3 isFilled:(_Bool)arg4 identifier:(id)arg5 lineJoin:(int)arg6;

@end


text:
title: practice of part of ES6 standard
layout: post
date: 2016-12-18 12:06
tag:
- koajs
- ES6
- Module
blog: true
---

#### Preface

I wrote my weekly summary until sunday. Because i drinked on Tuesday night, the wine is strong, it took me two days to fully awake. So it's time for us to talk about work. This week i mainly learn two features of es6.

1. Identifier: const, let and var
2. Modules: import and explore

#### how to choose const, let or var?

const and let is new indentifiers and different with var, which appear in es6. I don't want to explain the differences between them, you can find the details in the reference [3]. I make my choice based on the following principle:

1. Use `const` as file scope and immutable constants.
2. Use `let` as function scope variables.
3. Avoid using `var`.

#### import and explore modules

Compare to nodejs module loading system, i prefer es6's. I have written an article [4] about syntax of es6 modules. Now i just put it into pratice.

#### Conclusions

Since i use `babel` to write next generation javascript. I need to spend more time to practise es6 syntax. Another problem is how to organize my directory structure as the app goes forward.

#### References

[1] http://es6-features.org/#Constants
[2] http://www.2ality.com/2014/09/es6-modules-final.html
[3] https://medium.com/javascript-scene/javascript-es6-var-let-or-const-ba58b8dcde75#.1iebr2zg4
[4] http://jadeydi.github.io/posts/2016/08/13/modules-of-es6.html


text:
<?php
include_once 'Data/Blog.php';
include_once 'Database/Verbinding/DatabaseFactory.php';
include_once 'Database/CRUD/FotoDB.php';
/**
 * Created by PhpStorm.
 * User: max
 * Date: 8-8-2017
 * Time: 10:58
 */
class BlogDb
{
    private static function getVerbinding()
    {
        return DatabaseFactory::getDatabase();
    }
    public static function getAllAdmin()
    {
        $resultaat = self::getVerbinding()->voerSqlQueryUit("SELECT * FROM Blogs");

        $resultatenArray = array();
        for ($index = 0; $index < $resultaat->num_rows; $index++) {
            $databaseRij = $resultaat->fetch_array();
            $nieuw = self::converteerRijNaarObject($databaseRij);
            $resultatenArray[$index] = $nieuw;
        }
        return $resultatenArray;
    }

    public static function getAll()
    {
        $resultaat = self::getVerbinding()->voerSqlQueryUit("SELECT * FROM Blogs where isDeleted=0");

        $resultatenArray = array();
        for ($index = 0; $index < $resultaat->num_rows; $index++) {
            $databaseRij = $resultaat->fetch_array();
            $nieuw = self::converteerRijNaarObject($databaseRij);
            $resultatenArray[$index] = $nieuw;
        }
        return $resultatenArray;
    }

    public static function getHot()
    {
        $resultaat = self::getVerbinding()->voerSqlQueryUit("SELECT * FROM Blogs where isDeleted=0 order by totalComments DESC limit 3");

        $resultatenArray = array();

        for ($index = 0; $index < $resultaat->num_rows; $index++) {
            $databaseRij = $resultaat->fetch_array();
            $nieuw = self::converteerRijNaarObject($databaseRij);
            $resultatenArray[$index] = $nieuw;
        }

        return $resultatenArray;
    }
    public static function getRandom()
    {
        $maand = date('n');
        $resultaat = self::getVerbinding()->voerSqlQueryUit("SELECT * FROM Blogs where isDeleted=0 AND MONTH(datum) =? limit 3",array($maand));

        $resultatenArray = array();
        for ($index = 0; $index < $resultaat->num_rows; $index++) {
            $databaseRij = $resultaat->fetch_array();
            $nieuw = self::converteerRijNaarObject($databaseRij);
            $resultatenArray[$index] = $nieuw;
        }
        return $resultatenArray;
    }

    public static function getById($id)
    {
        $resultaat = self::getVerbinding()->voerSqlQueryUit("SELECT * FROM Blogs WHERE blogId=? AND isDeleted=0", array($id));
        if ($resultaat->num_rows == 1) {
            $databaseRij = $resultaat->fetch_array();
            return self::converteerRijNaarObject($databaseRij);
        } else {
            //Er is waarschijnlijk iets mis gegaan
            return false;
        }
    }

    public static function getFiltered($categorie,$maand)
    {
    /*    if($categorie != "" and $maand != "")
        {
            $resultaat = self::getVerbinding()->voerSqlQueryUit("SELECT * FROM Blogs where isDeleted=0 and MONTH(datum)= ? and categorieID=?", array($maand),array($categorie));

            $resultatenArray = array();

            for ($index = 0; $index < $resultaat->num_rows; $index++) {
                $databaseRij = $resultaat->fetch_array();
                $nieuw = self::converteerRijNaarObject($databaseRij);
                $resultatenArray[$index] = $nieuw;
            }

            return $resultatenArray;
        }*/
        if ($categorie != "") {
            $resultaat = self::getVerbinding()->voerSqlQueryUit("SELECT * FROM Blogs where isDeleted=0 and categorieID=?", array($categorie));

            $resultatenArray = array();

            for ($index = 0; $index < $resultaat->num_rows; $index++) {
                $databaseRij = $resultaat->fetch_array();
                $nieuw = self::converteerRijNaarObject($databaseRij);
                $resultatenArray[$index] = $nieuw;
            }

            return $resultatenArray;
        }
        elseif($maand != ""){
            $resultaat = self::getVerbinding()->voerSqlQueryUit("SELECT * FROM Blogs where isDeleted=0 and MONTH(datum)= ?", array($maand));

            $resultatenArray = array();

            for ($index = 0; $index < $resultaat->num_rows; $index++) {
                $databaseRij = $resultaat->fetch_array();
                $nieuw = self::converteerRijNaarObject($databaseRij);
                $resultatenArray[$index] = $nieuw;
            }

            return $resultatenArray;
        }
        else{
            return self::getAll();
        }
    }
    public static function relevanteBlogs($blogId,$categorieId)
    {
        $resultaat = self::getVerbinding()->voerSqlQueryUit("SELECT * FROM Blogs where isDeleted=0 AND categorieId = ? AND blogId != ".$blogId." limit 3",array($categorieId));

        $resultatenArray = array();

            for ($index = 0; $index < $resultaat->num_rows; $index++) {
                $databaseRij = $resultaat->fetch_array();
                $nieuw = self::converteerRijNaarObject($databaseRij);
                $resultatenArray[$index] = $nieuw;
            }

        return $resultatenArray;
    }
    public static function getTotalComments($blogId)
    {
        $resultaat = self::getVerbinding()->voerSqlQueryUit("SELECT * FROM Blogs where isDeleted=0 AND blogId = ?",array($blogId));
        if ($resultaat->num_rows == 1) {
            $databaseRij = $resultaat->fetch_array();
            $blog = self::converteerRijNaarObject($databaseRij);
            return $blog->totalComments;
        } else {
            //Er is waarschijnlijk iets mis gegaan
            return false;
        }
    }
    public static function addBlog($blog,$blogDetail,$foto)
    {

      $result = self::getVerbinding()->voerSqlQueryUit("INSERT INTO `Blogs` (`blogId`, `titel`, `datum`, `isDeleted`, `userId`, `categorieID`, `totalComments`) VALUES (NULL, '$blog->titel', '$blog->datum', '0', '$blog->userId', '$blog->categorieId', '0');");
      var_dump("INSERT INTO `Blogs` (`blogId`, `titel`, `datum`, `isDeleted`, `userId`, `categorieID`, `totalComments`) VALUES (NULL, '$blog->titel', '$blog->datum', '0', '$blog->userId', '$blog->categorieId', '0');");

          $resultaat = self::getVerbinding()->voerSqlQueryUit("SELECT * FROM Blogs where isDeleted=0 AND titel = '$blog->titel' and datum = '$blog->datum' and userId = '$blog->userId' and categorieId = '$blog->categorieId' and totalComments = '0';");

          if ($resultaat->num_rows == 1) {
              $databaseRij = $resultaat->fetch_array();
              $deBlog = self::converteerRijNaarObject($databaseRij);
              $blogDetail->blogId = $deBlog->blogId;
              $foto->blogId = $deBlog->blogId;
              BlogDetailDb::addBlogDetail($blogDetail);
              FotoDb::addFotoBlog($foto);
              return $blog;

          } else {
              //Er is waarschijnlijk iets mis gegaan
              return false;
          }
      }

    protected static function converteerRijNaarObject($databaseRij)
    {
        return new Blog(
            $databaseRij['blogId'],
                $databaseRij['titel'],
                $databaseRij['datum'],
                $databaseRij['isDeleted'],
                $databaseRij['userId'],
                $databaseRij['categorieID'],
                $databaseRij['totalComments']);
    }
}