text:
AudioBuffer::AudioBuffer()
{
	currentBuffer = getBufferFromPool();
	queuedBuffers.push_back(currentBuffer);
	reset();
}

AudioBuffer::~AudioBuffer()
{
}

std::shared_ptr<int16_t> AudioBuffer::getBufferFromPool()
{
	if (bufferPool.empty()) {
		bufferPool.push_front(std::shared_ptr<int16_t>(new int16_t[BUFFER_SIZE], [](int16_t *p) { delete[] p; }));
	}

	auto front = bufferPool.front();
	bufferPool.pop_front();
	return front;
}

int AudioBuffer::addData(const int16_t *data, const unsigned int samples)
{
	mutex.lock();
	// If samples is 0 - there has been a seek, Reset stuff
	if (samples == 0) {
		readOffset = 0;
		writeOffset = 0;
		writeBufferOffset = 0;
		readBufferOffset = 0;
		queuedBuffers.clear();
		currentBuffer = getBufferFromPool();
		queuedBuffers.push_back(currentBuffer);
		mutex.unlock();
		return 0;
	}

	if (queuedBuffers.size() == 3) {
		mutex.unlock();
		return 0;
	}
	int samplesLeft = samples;

	while (samplesLeft > 0) {

		if (writeBufferOffset == BUFFER_SIZE) {
			currentBuffer = getBufferFromPool();

			queuedBuffers.push_back(currentBuffer);
			writeBufferOffset = 0;
		}
		int dataSize = std::min(samplesLeft, BUFFER_SIZE - writeBufferOffset);

		memcpy(currentBuffer.get() + writeBufferOffset, data + (samples - samplesLeft), dataSize * 2);
		samplesLeft -= dataSize;
		writeBufferOffset += dataSize;
	}
	writeOffset += samples;

	mutex.unlock();
	return samples;
}

int AudioBuffer::readData(int16_t *dest, const unsigned int samples)
{
	int totSamples = samples;
	int samplesLeft = samples;
	mutex.lock();
	// Are we trying to read more data than we have queued?
	if (queuedBuffers.size() <= 1) {
		memset(dest, 0, samples * sizeof(uint16_t));
		mutex.unlock();
		if (m_flush) {
			m_flush = false;
			return -1;
		}
		return samples;
	}

	while(samplesLeft > 0) {
		if (readBufferOffset == BUFFER_SIZE) {
			auto buffer = queuedBuffers.front();
			bufferPool.push_back(buffer);
			queuedBuffers.pop_front();
			readBufferOffset = 0;
		}

		assert(!queuedBuffers.empty());

		if (queuedBuffers.size() == 0) {
			mutex.unlock();
			return -1;
		}

		auto buffer = queuedBuffers.front();

		//assert(buffer.get() != currentBuffer.get());

		unsigned int dataSize = std::min(samplesLeft, BUFFER_SIZE - readBufferOffset);

		memcpy(dest + (samples - samplesLeft), buffer.get() + readBufferOffset, dataSize * 2);
		samplesLeft -= dataSize;
		readBufferOffset += dataSize;

	}
	readOffset += samples;
	currentFrame += samples;
	mutex.unlock();
	return totSamples;
}

unsigned int AudioBuffer::getPlayTime()
{
	return currentFrame / ((SAMPLE_RATE * CHANNELS) / 1000);
}

void AudioBuffer::setPlayTime(unsigned int time)
{
	unsigned int newPlayedFrame = ((SAMPLE_RATE * CHANNELS) / 1000) * time;

	mutex.lock();

	if (newPlayedFrame < readOffset) {
		readBufferOffset = 0;
		writeBufferOffset = 0;
		writeOffset = 0;
	}

	while (!queuedBuffers.empty() && queuedBuffers.front() != currentBuffer) {
		bufferPool.push_front(queuedBuffers.front());
		queuedBuffers.pop_front();
	}

	currentFrame = newPlayedFrame;

	mutex.unlock();
}

void AudioBuffer::reset()
{
	wxLogDebug("Resetting audio buffer with readOffset: %d writeOffset: %d", readOffset, writeOffset);

	mutex.lock();

	readOffset = 0;
	writeOffset = 0;
	m_flush = false;
	currentFrame = 0;
	readBufferOffset = 0;
	writeBufferOffset = 0;

	// start fresh!
	while (!queuedBuffers.empty()) {
		bufferPool.push_front(queuedBuffers.front());
		queuedBuffers.pop_front();
	}
	currentBuffer = getBufferFromPool();
	queuedBuffers.push_back(currentBuffer);

	mutex.unlock();

}

void AudioBuffer::flush()
{
	mutex.lock();
	m_flush = true;
	mutex.unlock();
}


text:
from numpy.testing import assert_almost_equal

import torch
from torch.nn import Embedding, Module, Parameter

from allennlp.common.testing import AllenNlpTestCase
from allennlp.modules import TimeDistributed

class TestTimeDistributed(AllenNlpTestCase):
    def test_time_distributed_reshapes_named_arg_correctly(self):
        char_embedding = Embedding(2, 2)
        char_embedding.weight = Parameter(torch.FloatTensor([[0.4, 0.4], [0.5, 0.5]]))
        distributed_embedding = TimeDistributed(char_embedding)
        char_input = torch.LongTensor([[[1, 0], [1, 1]]])
        output = distributed_embedding(char_input)
        assert_almost_equal(
            output.data.numpy(), [[[[0.5, 0.5], [0.4, 0.4]], [[0.5, 0.5], [0.5, 0.5]]]]
        )

    def test_time_distributed_reshapes_positional_kwarg_correctly(self):
        char_embedding = Embedding(2, 2)
        char_embedding.weight = Parameter(torch.FloatTensor([[0.4, 0.4], [0.5, 0.5]]))
        distributed_embedding = TimeDistributed(char_embedding)
        char_input = torch.LongTensor([[[1, 0], [1, 1]]])
        output = distributed_embedding(input=char_input)
        assert_almost_equal(
            output.data.numpy(), [[[[0.5, 0.5], [0.4, 0.4]], [[0.5, 0.5], [0.5, 0.5]]]]
        )

    def test_time_distributed_works_with_multiple_inputs(self):
        module = lambda x, y: x + y
        distributed = TimeDistributed(module)
        x_input = torch.LongTensor([[[1, 2], [3, 4]]])
        y_input = torch.LongTensor([[[4, 2], [9, 1]]])
        output = distributed(x_input, y_input)
        assert_almost_equal(output.data.numpy(), [[[5, 4], [12, 5]]])

    def test_time_distributed_reshapes_multiple_inputs_with_pass_through_tensor_correctly(self):
        class FakeModule(Module):
            def forward(self, input_tensor, tensor_to_pass_through=None, another_tensor=None):

                return input_tensor + tensor_to_pass_through + another_tensor

        module = FakeModule()
        distributed_module = TimeDistributed(module)

        input_tensor1 = torch.LongTensor([[[1, 2], [3, 4]]])
        input_to_pass_through = torch.LongTensor([3, 7])
        input_tensor2 = torch.LongTensor([[[4, 2], [9, 1]]])

        output = distributed_module(
            input_tensor1,
            tensor_to_pass_through=input_to_pass_through,
            another_tensor=input_tensor2,
            pass_through=["tensor_to_pass_through"],
        )
        assert_almost_equal(output.data.numpy(), [[[8, 11], [15, 12]]])

    def test_time_distributed_reshapes_multiple_inputs_with_pass_through_non_tensor_correctly(self):
        class FakeModule(Module):
            def forward(self, input_tensor, number=0, another_tensor=None):

                return input_tensor + number + another_tensor

        module = FakeModule()
        distributed_module = TimeDistributed(module)

        input_tensor1 = torch.LongTensor([[[1, 2], [3, 4]]])
        input_number = 5
        input_tensor2 = torch.LongTensor([[[4, 2], [9, 1]]])

        output = distributed_module(
            input_tensor1,
            number=input_number,
            another_tensor=input_tensor2,
            pass_through=["number"],
        )
        assert_almost_equal(output.data.numpy(), [[[10, 9], [17, 10]]])

redpajama_set_name: RedPajamaGithub


text:
ACCEPTED

#### According to
International Plant Names Index

#### Published in
null

#### Original name
Erodium cossonii Guitt. & Mathez

### Remarks
null


text:
package org.arakhne.afc.ui.swing.zoom;

import java.awt.event.MouseEvent;

import javax.swing.SwingUtilities;

/** This enumeration contains all the methods to start
 * scrolling.
 *
 * @author $Author: sgalland$
 * @version $FullVersion$
 * @mavengroupid $GroupId$
 * @mavenartifactid $ArtifactId$
 * @deprecated see JavaFX API
 */
@Deprecated
public enum ScrollingMethod {

	/** Scroll on middle mouse press.
	 */
	MIDDLE_BUTTON {
		@Override
		void tryScroll(MouseEvent me, ScrollingMethodListener listener) {
			if (SwingUtilities.isMiddleMouseButton(me)) {
				listener.startScrolling(me, 0);
			}
		}
	},
	/** Scroll on left mouse press.
	 */
	LEFT_BUTTON {
		@Override
		void tryScroll(MouseEvent me, ScrollingMethodListener listener) {
			if (SwingUtilities.isLeftMouseButton(me)) {
				listener.startScrolling(me, 500);
			}
		}
	};

	/** Start to scroll if possible.
	 *
	 * @param me is the mouse event.
	 * @param listener is the listener on the scrolling action.
	 */
	abstract void tryScroll(MouseEvent me, ScrollingMethodListener listener);

	/** Listener on scrolling start.
	 *
	 * @author $Author: sgalland$
	 * @version $FullVersion$
	 * @mavengroupid $GroupId$
	 * @mavenartifactid $ArtifactId$
	 */
	interface ScrollingMethodListener {

		/** Start to scroll.
		 *
		 * @param event
		 * @param delay is the delay (ms) to wait before starting to scroll.
		 */
		public void startScrolling(MouseEvent event, int delay);

		/** Stop to scroll.
		 *
		 * @param event
		 */
		public void stopScrolling(MouseEvent event);

	}

}


text:
package poisondog.math.function.activation;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

/**
 * @author Adam Huang <poisondog@gmail.com>
 */
public class HardLimiterTest {

	/**
	 * @throws java.lang.Exception
	 */
	@Before
	public void setUp() throws Exception {
	}

	@Test
	public void testCalculate() throws Exception {
		HardLimiter function = new HardLimiter();
		Assert.assertEquals(1, function.calculate(1), Math.pow(10, -6));
		Assert.assertEquals(1, function.calculate(0.1), Math.pow(10, -6));
		Assert.assertEquals(1, function.calculate(0.01), Math.pow(10, -6));
		Assert.assertEquals(1, function.calculate(0), Math.pow(10, -6));
		Assert.assertEquals(-1, function.calculate(-0.01), Math.pow(10, -6));
		Assert.assertEquals(-1, function.calculate(-0.1), Math.pow(10, -6));
		Assert.assertEquals(-1, function.calculate(-1), Math.pow(10, -6));
	}
}


text:
import {Component, ElementRef, Input, NgModule, OnInit, ViewEncapsulation} from "@angular/core";
import * as marked from 'marked';
import {AbstractJigsawComponent} from "jigsaw/public_api";

@Component({
    selector: 'jigsaw-markdown, j-markdown',
    template: '<ng-content></ng-content>',
    host: {
        '[class.markdown-wrap]': 'true'
    },
    styleUrls: ['./markdown.scss'],
    encapsulation: ViewEncapsulation.None
})
export class JigsawMarkdown extends AbstractJigsawComponent implements OnInit {
    constructor(private _elementRef: ElementRef) {
        super()
    }

    private _markdown: string;

    @Input()
    public get markdown(): string {
        return this._markdown;
    }

    public set markdown(value: string) {
        this._markdown = value;
        this._parseMarkdown(value);
    }

    @Input()
    public prefixWhiteSpaceLength: number = NaN;

    private _calculateWhiteSpaceLength(markdown: string): number {
        if (!markdown) {
            return 0;
        }
        const match = markdown.match(/\n( *)\S[\s\S]*$/);
        return match ? match[1].length : 0;
    }

    private _parseMarkdown(markdown): void {
        if (!markdown || !this.initialized) {
            return;
        }
        if (isNaN(this.prefixWhiteSpaceLength)) {
            this.prefixWhiteSpaceLength = this._calculateWhiteSpaceLength(markdown);
        }

        // strip the leading white spaces
        const mdLines = markdown.split(/\r?\n/g);
        markdown = '';
        mdLines.forEach(line => {
            markdown += line.substring(this.prefixWhiteSpaceLength) + '\n';
        });

        markdown = marked(markdown.trim());

        // redirect internal doc link to the ued site
        markdown = markdown.replace(/<a\s+href="(\/components\/api\/.*?)"/g,
            `<a href="javascript:top.location.hash='$1'" target="_self"`);

        // add class to raise the css priority
        markdown = markdown.replace(/<(\w+)(\s|>)/g, (found, tag, border) => {
            tag = tag.toLowerCase();
            switch (tag) {
                case 'p':
                case 'blockquote':
                case 'ul':
                case 'ol':
                case 'dl':
                case 'table':
                case 'pre':
                case 'h1':
                case 'h2':
                case 'h3':
                case 'h4':
                case 'h5':
                case 'h6':
                case 'code':
                case 'tt':
                case 'kbd':
                case 'hr':
                case 'img':
                    return `<${tag} class="md-${tag}"${border}`;
                default:
                    return found;
            }
        });
        this._elementRef.nativeElement.innerHTML = markdown;
    }

    ngOnInit() {
        super.ngOnInit();
        if (!this._markdown) {
            this._markdown = this._elementRef.nativeElement.innerHTML;
        }
        this._parseMarkdown(this._markdown);
    }
}

@NgModule({
    declarations: [JigsawMarkdown],
    exports: [JigsawMarkdown]
})
export class JigsawMarkdownModule {
}


text:
<?php

namespace Berny\Google\Maps\Geocode\Response;

class Geometry
{
    const LOCATION_TYPE_ROOFTOP = 'ROOFTOP';
    const LOCATION_TYPE_RANGE_INTERPOLATED = 'RANGE_INTERPOLATED';
    const LOCATION_TYPE_GEOMETRIC_CENTER = 'GEOMETRIC_CENTER';
    const LOCATION_TYPE_APPROXIMATE = 'APPROXIMATE';

    private $location;
    private $location_type;
    private $viewport;
    private $bounds;

    public function __construct(Location $location, $location_type, Viewport $viewport, Viewport $bounds = null)
    {
        $this->location = $location;
        $this->location_type = $location_type;
        $this->viewport = $viewport;
        $this->bounds = $bounds;
    }

    public function getLocation()
    {
        return $this->location;
    }

    public function getLocationType()
    {
        return $this->location_type;
    }

    public function isPrecise()
    {
        return $this->location_type === self::LOCATION_TYPE_ROOFTOP;
    }

    public function getViewport()
    {
        return $this->viewport;
    }

    public function getBounds()
    {
        return $this->bounds;
    }
}


text:
// @file multicmd.h

#pragma once

#include "../../util/background.h"
#include "connections.h"

namespace mongo {

    struct Target {
        Target(string hostport) : toHost(hostport), ok(false) { }
        //Target() : ok(false) { }
        const string toHost;
        bool ok;
        BSONObj result;
    };

    /** send a command to several servers in parallel.  waits for all to complete before
        returning.

        in: Target::toHost
        out: Target::result and Target::ok
    */
    void multiCommand(BSONObj cmd, list<Target>& L);

    class _MultiCommandJob : public BackgroundJob {
    public:
        BSONObj& cmd;
        Target& d;
        _MultiCommandJob(BSONObj& _cmd, Target& _d) : cmd(_cmd), d(_d) { }

    private:
        string name() const { return "MultiCommandJob"; }
        void run() {
            try {
                ScopedConn c(d.toHost);
                d.ok = c.runCommand("admin", cmd, d.result);
            }
            catch(DBException&) {
                DEV log() << "dev caught dbexception on multiCommand " << d.toHost << rsLog;
            }
        }
    };

    inline void multiCommand(BSONObj cmd, list<Target>& L) {
        list< shared_ptr<BackgroundJob> > jobs;

        for( list<Target>::iterator i = L.begin(); i != L.end(); i++ ) {
            Target& d = *i;
            _MultiCommandJob *j = new _MultiCommandJob(cmd, d);
            jobs.push_back( shared_ptr<BackgroundJob>(j) );
            j->go();
        }

        for( list< shared_ptr<BackgroundJob> >::iterator i = jobs.begin(); i != jobs.end(); i++ ) {
            (*i)->wait();
        }
    }
}


text:
package com.amazonaws.services.cloudfront.model;

import java.io.Serializable;
import javax.annotation.Generated;

/**
 *

 * A summary of the information about a CloudFront distribution.
 *

 *
 * @see AWS API
 *      Documentation
 */
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class DistributionSummary implements Serializable, Cloneable {

    /**
     *

     * The identifier for the distribution. For example: EDFDVBD632BHDS5.
     *

     */
    private String id;
    /**
     *

     * The ARN (Amazon Resource Name) for the distribution. For example:
     * arn:aws:cloudfront::123456789012:distribution/EDFDVBD632BHDS5, where 123456789012 is
     * your Amazon Web Services account ID.
     *

     */
    private String aRN;
    /**
     *

     * The current status of the distribution. When the status is Deployed, the distribution's information
     * is propagated to all CloudFront edge locations.
     *

     */
    private String status;
    /**
     *

     * The date and time the distribution was last modified.
     *

     */
    private java.util.Date lastModifiedTime;
    /**
     *

     * The domain name that corresponds to the distribution, for example, d111111abcdef8.cloudfront.net.
     *

     */
    private String domainName;
    /**
     *

     * A complex type that contains information about CNAMEs (alternate domain names), if any, for this distribution.
     *

     */
    private Aliases aliases;
    /**
     *

     * A complex type that contains information about origins for this distribution.
     *

     */
    private Origins origins;
    /**
     *

     * A complex type that contains information about origin groups for this distribution.
     *

     */
    private OriginGroups originGroups;
    /**
     *

     * A complex type that describes the default cache behavior if you don't specify a CacheBehavior
     * element or if files don't match any of the values of PathPattern in CacheBehavior
     * elements. You must create exactly one default cache behavior.
     *

     */
    private DefaultCacheBehavior defaultCacheBehavior;
    /**
     *

     * A complex type that contains zero or more CacheBehavior elements.
     *

     */
    private CacheBehaviors cacheBehaviors;
    /**
     *

     * A complex type that contains zero or more CustomErrorResponses elements.
     *

     */
    private CustomErrorResponses customErrorResponses;
    /**
     *

     * The comment originally specified when this distribution was created.
     *

     */
    private String comment;
    /**
     *

     * A complex type that contains information about price class for this streaming distribution.
     *

     */
    private String priceClass;
    /**
     *

     * Whether the distribution is enabled to accept user requests for content.
     *

     */
    private Boolean enabled;
    /**
     *

     * A complex type that determines the distribution's SSL/TLS configuration for communicating with viewers.
     *

     */
    private ViewerCertificate viewerCertificate;
    /**
     *

     * A complex type that identifies ways in which you want to restrict distribution of your content.
     *

     */
    private Restrictions restrictions;
    /**
     *

     * The Web ACL Id (if any) associated with the distribution.
     *

     */
    private String webACLId;
    /**
     *

     * Specify the maximum HTTP version that you want viewers to use to communicate with CloudFront. The default value
     * for new web distributions is http2. Viewers that don't support HTTP/2 will
     * automatically use an earlier version.
     *

     */
    private String httpVersion;
    /**
     *

     * Whether CloudFront responds to IPv6 DNS requests with an IPv6 address for your distribution.
     *

     */
    private Boolean isIPV6Enabled;
    /**
     *

     * Amazon Web Services services in China customers must file for an Internet Content Provider (ICP) recordal if they
     * want to serve content publicly on an alternate domain name, also known as a CNAME, that they've added to
     * CloudFront. AliasICPRecordal provides the ICP recordal status for CNAMEs associated with distributions.
     *

     *

     * For more information about ICP recordals, see  Signup, Accounts, and
     * Credentials in Getting Started with Amazon Web Services services in China.
     *

     */
    private com.amazonaws.internal.SdkInternalList<AliasICPRecordal> aliasICPRecordals;

    /**
     *

     * The identifier for the distribution. For example: EDFDVBD632BHDS5.
     *

     *
     * @param id
     *        The identifier for the distribution. For example: EDFDVBD632BHDS5.
     */

    public void setId(String id) {
        this.id = id;
    }

    /**
     *

     * The identifier for the distribution. For example: EDFDVBD632BHDS5.
     *

     *
     * @return The identifier for the distribution. For example: EDFDVBD632BHDS5.
     */

    public String getId() {
        return this.id;
    }

    /**
     *

     * The identifier for the distribution. For example: EDFDVBD632BHDS5.
     *

     *
     * @param id
     *        The identifier for the distribution. For example: EDFDVBD632BHDS5.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public DistributionSummary withId(String id) {
        setId(id);
        return this;
    }

    /**
     *

     * The ARN (Amazon Resource Name) for the distribution. For example:
     * arn:aws:cloudfront::123456789012:distribution/EDFDVBD632BHDS5, where 123456789012 is
     * your Amazon Web Services account ID.
     *

     *
     * @param aRN
     *        The ARN (Amazon Resource Name) for the distribution. For example:
     *        arn:aws:cloudfront::123456789012:distribution/EDFDVBD632BHDS5, where
     *        123456789012 is your Amazon Web Services account ID.
     */

    public void setARN(String aRN) {
        this.aRN = aRN;
    }

    /**
     *

     * The ARN (Amazon Resource Name) for the distribution. For example:
     * arn:aws:cloudfront::123456789012:distribution/EDFDVBD632BHDS5, where 123456789012 is
     * your Amazon Web Services account ID.
     *

     *
     * @return The ARN (Amazon Resource Name) for the distribution. For example:
     *         arn:aws:cloudfront::123456789012:distribution/EDFDVBD632BHDS5, where
     *         123456789012 is your Amazon Web Services account ID.
     */

    public String getARN() {
        return this.aRN;
    }

    /**
     *

     * The ARN (Amazon Resource Name) for the distribution. For example:
     * arn:aws:cloudfront::123456789012:distribution/EDFDVBD632BHDS5, where 123456789012 is
     * your Amazon Web Services account ID.
     *

     *
     * @param aRN
     *        The ARN (Amazon Resource Name) for the distribution. For example:
     *        arn:aws:cloudfront::123456789012:distribution/EDFDVBD632BHDS5, where
     *        123456789012 is your Amazon Web Services account ID.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public DistributionSummary withARN(String aRN) {
        setARN(aRN);
        return this;
    }

    /**
     *

     * The current status of the distribution. When the status is Deployed, the distribution's information
     * is propagated to all CloudFront edge locations.
     *

     *
     * @param status
     *        The current status of the distribution. When the status is Deployed, the distribution's
     *        information is propagated to all CloudFront edge locations.
     */

    public void setStatus(String status) {
        this.status = status;
    }

    /**
     *

     * The current status of the distribution. When the status is Deployed, the distribution's information
     * is propagated to all CloudFront edge locations.
     *

     *
     * @return The current status of the distribution. When the status is Deployed, the distribution's
     *         information is propagated to all CloudFront edge locations.
     */

    public String getStatus() {
        return this.status;
    }

    /**
     *

     * The current status of the distribution. When the status is Deployed, the distribution's information
     * is propagated to all CloudFront edge locations.
     *

     *
     * @param status
     *        The current status of the distribution. When the status is Deployed, the distribution's
     *        information is propagated to all CloudFront edge locations.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public DistributionSummary withStatus(String status) {
        setStatus(status);
        return this;
    }

    /**
     *

     * The date and time the distribution was last modified.
     *

     *
     * @param lastModifiedTime
     *        The date and time the distribution was last modified.
     */

    public void setLastModifiedTime(java.util.Date lastModifiedTime) {
        this.lastModifiedTime = lastModifiedTime;
    }

    /**
     *

     * The date and time the distribution was last modified.
     *

     *
     * @return The date and time the distribution was last modified.
     */

    public java.util.Date getLastModifiedTime() {
        return this.lastModifiedTime;
    }

    /**
     *

     * The date and time the distribution was last modified.
     *

     *
     * @param lastModifiedTime
     *        The date and time the distribution was last modified.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public DistributionSummary withLastModifiedTime(java.util.Date lastModifiedTime) {
        setLastModifiedTime(lastModifiedTime);
        return this;
    }

    /**
     *

     * The domain name that corresponds to the distribution, for example, d111111abcdef8.cloudfront.net.
     *

     *
     * @param domainName
     *        The domain name that corresponds to the distribution, for example,
     *        d111111abcdef8.cloudfront.net.
     */

    public void setDomainName(String domainName) {
        this.domainName = domainName;
    }

    /**
     *

     * The domain name that corresponds to the distribution, for example, d111111abcdef8.cloudfront.net.
     *

     *
     * @return The domain name that corresponds to the distribution, for example,
     *         d111111abcdef8.cloudfront.net.
     */

    public String getDomainName() {
        return this.domainName;
    }

    /**
     *

     * The domain name that corresponds to the distribution, for example, d111111abcdef8.cloudfront.net.
     *

     *
     * @param domainName
     *        The domain name that corresponds to the distribution, for example,
     *        d111111abcdef8.cloudfront.net.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public DistributionSummary withDomainName(String domainName) {
        setDomainName(domainName);
        return this;
    }

    /**
     *

     * A complex type that contains information about CNAMEs (alternate domain names), if any, for this distribution.
     *

     *
     * @param aliases
     *        A complex type that contains information about CNAMEs (alternate domain names), if any, for this
     *        distribution.
     */

    public void setAliases(Aliases aliases) {
        this.aliases = aliases;
    }

    /**
     *

     * A complex type that contains information about CNAMEs (alternate domain names), if any, for this distribution.
     *

     *
     * @return A complex type that contains information about CNAMEs (alternate domain names), if any, for this
     *         distribution.
     */

    public Aliases getAliases() {
        return this.aliases;
    }

    /**
     *

     * A complex type that contains information about CNAMEs (alternate domain names), if any, for this distribution.
     *

     *
     * @param aliases
     *        A complex type that contains information about CNAMEs (alternate domain names), if any, for this
     *        distribution.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public DistributionSummary withAliases(Aliases aliases) {
        setAliases(aliases);
        return this;
    }

    /**
     *

     * A complex type that contains information about origins for this distribution.
     *

     *
     * @param origins
     *        A complex type that contains information about origins for this distribution.
     */

    public void setOrigins(Origins origins) {
        this.origins = origins;
    }

    /**
     *

     * A complex type that contains information about origins for this distribution.
     *

     *
     * @return A complex type that contains information about origins for this distribution.
     */

    public Origins getOrigins() {
        return this.origins;
    }

    /**
     *

     * A complex type that contains information about origins for this distribution.
     *

     *
     * @param origins
     *        A complex type that contains information about origins for this distribution.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public DistributionSummary withOrigins(Origins origins) {
        setOrigins(origins);
        return this;
    }

    /**
     *

     * A complex type that contains information about origin groups for this distribution.
     *

     *
     * @param originGroups
     *        A complex type that contains information about origin groups for this distribution.
     */

    public void setOriginGroups(OriginGroups originGroups) {
        this.originGroups = originGroups;
    }

    /**
     *

     * A complex type that contains information about origin groups for this distribution.
     *

     *
     * @return A complex type that contains information about origin groups for this distribution.
     */

    public OriginGroups getOriginGroups() {
        return this.originGroups;
    }

    /**
     *

     * A complex type that contains information about origin groups for this distribution.
     *

     *
     * @param originGroups
     *        A complex type that contains information about origin groups for this distribution.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public DistributionSummary withOriginGroups(OriginGroups originGroups) {
        setOriginGroups(originGroups);
        return this;
    }

    /**
     *

     * A complex type that describes the default cache behavior if you don't specify a CacheBehavior
     * element or if files don't match any of the values of PathPattern in CacheBehavior
     * elements. You must create exactly one default cache behavior.
     *

     *
     * @param defaultCacheBehavior
     *        A complex type that describes the default cache behavior if you don't specify a CacheBehavior
     *        element or if files don't match any of the values of PathPattern in
     *        CacheBehavior elements. You must create exactly one default cache behavior.
     */

    public void setDefaultCacheBehavior(DefaultCacheBehavior defaultCacheBehavior) {
        this.defaultCacheBehavior = defaultCacheBehavior;
    }

    /**
     *

     * A complex type that describes the default cache behavior if you don't specify a CacheBehavior
     * element or if files don't match any of the values of PathPattern in CacheBehavior
     * elements. You must create exactly one default cache behavior.
     *

     *
     * @return A complex type that describes the default cache behavior if you don't specify a
     *         CacheBehavior element or if files don't match any of the values of PathPattern
     *         in CacheBehavior elements. You must create exactly one default cache behavior.
     */

    public DefaultCacheBehavior getDefaultCacheBehavior() {
        return this.defaultCacheBehavior;
    }

    /**
     *

     * A complex type that describes the default cache behavior if you don't specify a CacheBehavior
     * element or if files don't match any of the values of PathPattern in CacheBehavior
     * elements. You must create exactly one default cache behavior.
     *

     *
     * @param defaultCacheBehavior
     *        A complex type that describes the default cache behavior if you don't specify a CacheBehavior
     *        element or if files don't match any of the values of PathPattern in
     *        CacheBehavior elements. You must create exactly one default cache behavior.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public DistributionSummary withDefaultCacheBehavior(DefaultCacheBehavior defaultCacheBehavior) {
        setDefaultCacheBehavior(defaultCacheBehavior);
        return this;
    }

    /**
     *

     * A complex type that contains zero or more CacheBehavior elements.
     *

     *
     * @param cacheBehaviors
     *        A complex type that contains zero or more CacheBehavior elements.
     */

    public void setCacheBehaviors(CacheBehaviors cacheBehaviors) {
        this.cacheBehaviors = cacheBehaviors;
    }

    /**
     *

     * A complex type that contains zero or more CacheBehavior elements.
     *

     *
     * @return A complex type that contains zero or more CacheBehavior elements.
     */

    public CacheBehaviors getCacheBehaviors() {
        return this.cacheBehaviors;
    }

    /**
     *

     * A complex type that contains zero or more CacheBehavior elements.
     *

     *
     * @param cacheBehaviors
     *        A complex type that contains zero or more CacheBehavior elements.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public DistributionSummary withCacheBehaviors(CacheBehaviors cacheBehaviors) {
        setCacheBehaviors(cacheBehaviors);
        return this;
    }

    /**
     *

     * A complex type that contains zero or more CustomErrorResponses elements.
     *

     *
     * @param customErrorResponses
     *        A complex type that contains zero or more CustomErrorResponses elements.
     */

    public void setCustomErrorResponses(CustomErrorResponses customErrorResponses) {
        this.customErrorResponses = customErrorResponses;
    }

    /**
     *

     * A complex type that contains zero or more CustomErrorResponses elements.
     *

     *
     * @return A complex type that contains zero or more CustomErrorResponses elements.
     */

    public CustomErrorResponses getCustomErrorResponses() {
        return this.customErrorResponses;
    }

    /**
     *

     * A complex type that contains zero or more CustomErrorResponses elements.
     *

     *
     * @param customErrorResponses
     *        A complex type that contains zero or more CustomErrorResponses elements.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public DistributionSummary withCustomErrorResponses(CustomErrorResponses customErrorResponses) {
        setCustomErrorResponses(customErrorResponses);
        return this;
    }

    /**
     *

     * The comment originally specified when this distribution was created.
     *

     *
     * @param comment
     *        The comment originally specified when this distribution was created.
     */

    public void setComment(String comment) {
        this.comment = comment;
    }

    /**
     *

     * The comment originally specified when this distribution was created.
     *

     *
     * @return The comment originally specified when this distribution was created.
     */

    public String getComment() {
        return this.comment;
    }

    /**
     *

     * The comment originally specified when this distribution was created.
     *

     *
     * @param comment
     *        The comment originally specified when this distribution was created.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public DistributionSummary withComment(String comment) {
        setComment(comment);
        return this;
    }

    /**
     *

     * A complex type that contains information about price class for this streaming distribution.
     *

     *
     * @param priceClass
     *        A complex type that contains information about price class for this streaming distribution.
     * @see PriceClass
     */

    public void setPriceClass(String priceClass) {
        this.priceClass = priceClass;
    }

    /**
     *

     * A complex type that contains information about price class for this streaming distribution.
     *

     *
     * @return A complex type that contains information about price class for this streaming distribution.
     * @see PriceClass
     */

    public String getPriceClass() {
        return this.priceClass;
    }

    /**
     *

     * A complex type that contains information about price class for this streaming distribution.
     *

     *
     * @param priceClass
     *        A complex type that contains information about price class for this streaming distribution.
     * @return Returns a reference to this object so that method calls can be chained together.
     * @see PriceClass
     */

    public DistributionSummary withPriceClass(String priceClass) {
        setPriceClass(priceClass);
        return this;
    }

    /**
     *

     * A complex type that contains information about price class for this streaming distribution.
     *

     *
     * @param priceClass
     *        A complex type that contains information about price class for this streaming distribution.
     * @see PriceClass
     */

    public void setPriceClass(PriceClass priceClass) {
        withPriceClass(priceClass);
    }

    /**
     *

     * A complex type that contains information about price class for this streaming distribution.
     *

     *
     * @param priceClass
     *        A complex type that contains information about price class for this streaming distribution.
     * @return Returns a reference to this object so that method calls can be chained together.
     * @see PriceClass
     */

    public DistributionSummary withPriceClass(PriceClass priceClass) {
        this.priceClass = priceClass.toString();
        return this;
    }

    /**
     *

     * Whether the distribution is enabled to accept user requests for content.
     *

     *
     * @param enabled
     *        Whether the distribution is enabled to accept user requests for content.
     */

    public void setEnabled(Boolean enabled) {
        this.enabled = enabled;
    }

    /**
     *

     * Whether the distribution is enabled to accept user requests for content.
     *

     *
     * @return Whether the distribution is enabled to accept user requests for content.
     */

    public Boolean getEnabled() {
        return this.enabled;
    }

    /**
     *

     * Whether the distribution is enabled to accept user requests for content.
     *

     *
     * @param enabled
     *        Whether the distribution is enabled to accept user requests for content.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public DistributionSummary withEnabled(Boolean enabled) {
        setEnabled(enabled);
        return this;
    }

    /**
     *

     * Whether the distribution is enabled to accept user requests for content.
     *

     *
     * @return Whether the distribution is enabled to accept user requests for content.
     */

    public Boolean isEnabled() {
        return this.enabled;
    }

    /**
     *

     * A complex type that determines the distribution's SSL/TLS configuration for communicating with viewers.
     *

     *
     * @param viewerCertificate
     *        A complex type that determines the distribution's SSL/TLS configuration for communicating with viewers.
     */

    public void setViewerCertificate(ViewerCertificate viewerCertificate) {
        this.viewerCertificate = viewerCertificate;
    }

    /**
     *

     * A complex type that determines the distribution's SSL/TLS configuration for communicating with viewers.
     *

     *
     * @return A complex type that determines the distribution's SSL/TLS configuration for communicating with viewers.
     */

    public ViewerCertificate getViewerCertificate() {
        return this.viewerCertificate;
    }

    /**
     *

     * A complex type that determines the distribution's SSL/TLS configuration for communicating with viewers.
     *

     *
     * @param viewerCertificate
     *        A complex type that determines the distribution's SSL/TLS configuration for communicating with viewers.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public DistributionSummary withViewerCertificate(ViewerCertificate viewerCertificate) {
        setViewerCertificate(viewerCertificate);
        return this;
    }

    /**
     *

     * A complex type that identifies ways in which you want to restrict distribution of your content.
     *

     *
     * @param restrictions
     *        A complex type that identifies ways in which you want to restrict distribution of your content.
     */

    public void setRestrictions(Restrictions restrictions) {
        this.restrictions = restrictions;
    }

    /**
     *

     * A complex type that identifies ways in which you want to restrict distribution of your content.
     *

     *
     * @return A complex type that identifies ways in which you want to restrict distribution of your content.
     */

    public Restrictions getRestrictions() {
        return this.restrictions;
    }

    /**
     *

     * A complex type that identifies ways in which you want to restrict distribution of your content.
     *

     *
     * @param restrictions
     *        A complex type that identifies ways in which you want to restrict distribution of your content.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public DistributionSummary withRestrictions(Restrictions restrictions) {
        setRestrictions(restrictions);
        return this;
    }

    /**
     *

     * The Web ACL Id (if any) associated with the distribution.
     *

     *
     * @param webACLId
     *        The Web ACL Id (if any) associated with the distribution.
     */

    public void setWebACLId(String webACLId) {
        this.webACLId = webACLId;
    }

    /**
     *

     * The Web ACL Id (if any) associated with the distribution.
     *

     *
     * @return The Web ACL Id (if any) associated with the distribution.
     */

    public String getWebACLId() {
        return this.webACLId;
    }

    /**
     *

     * The Web ACL Id (if any) associated with the distribution.
     *

     *
     * @param webACLId
     *        The Web ACL Id (if any) associated with the distribution.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public DistributionSummary withWebACLId(String webACLId) {
        setWebACLId(webACLId);
        return this;
    }

    /**
     *

     * Specify the maximum HTTP version that you want viewers to use to communicate with CloudFront. The default value
     * for new web distributions is http2. Viewers that don't support HTTP/2 will
     * automatically use an earlier version.
     *

     *
     * @param httpVersion
     *        Specify the maximum HTTP version that you want viewers to use to communicate with CloudFront. The default
     *        value for new web distributions is http2. Viewers that don't support HTTP/2 will
     *        automatically use an earlier version.
     * @see HttpVersion
     */

    public void setHttpVersion(String httpVersion) {
        this.httpVersion = httpVersion;
    }

    /**
     *

     * Specify the maximum HTTP version that you want viewers to use to communicate with CloudFront. The default value
     * for new web distributions is http2. Viewers that don't support HTTP/2 will
     * automatically use an earlier version.
     *

     *
     * @return Specify the maximum HTTP version that you want viewers to use to communicate with CloudFront. The default
     *         value for new web distributions is http2. Viewers that don't support HTTP/2
     *         will automatically use an earlier version.
     * @see HttpVersion
     */

    public String getHttpVersion() {
        return this.httpVersion;
    }

    /**
     *

     * Specify the maximum HTTP version that you want viewers to use to communicate with CloudFront. The default value
     * for new web distributions is http2. Viewers that don't support HTTP/2 will
     * automatically use an earlier version.
     *

     *
     * @param httpVersion
     *        Specify the maximum HTTP version that you want viewers to use to communicate with CloudFront. The default
     *        value for new web distributions is http2. Viewers that don't support HTTP/2 will
     *        automatically use an earlier version.
     * @return Returns a reference to this object so that method calls can be chained together.
     * @see HttpVersion
     */

    public DistributionSummary withHttpVersion(String httpVersion) {
        setHttpVersion(httpVersion);
        return this;
    }

    /**
     *

     * Specify the maximum HTTP version that you want viewers to use to communicate with CloudFront. The default value
     * for new web distributions is http2. Viewers that don't support HTTP/2 will
     * automatically use an earlier version.
     *

     *
     * @param httpVersion
     *        Specify the maximum HTTP version that you want viewers to use to communicate with CloudFront. The default
     *        value for new web distributions is http2. Viewers that don't support HTTP/2 will
     *        automatically use an earlier version.
     * @see HttpVersion
     */

    public void setHttpVersion(HttpVersion httpVersion) {
        withHttpVersion(httpVersion);
    }

    /**
     *

     * Specify the maximum HTTP version that you want viewers to use to communicate with CloudFront. The default value
     * for new web distributions is http2. Viewers that don't support HTTP/2 will
     * automatically use an earlier version.
     *

     *
     * @param httpVersion
     *        Specify the maximum HTTP version that you want viewers to use to communicate with CloudFront. The default
     *        value for new web distributions is http2. Viewers that don't support HTTP/2 will
     *        automatically use an earlier version.
     * @return Returns a reference to this object so that method calls can be chained together.
     * @see HttpVersion
     */

    public DistributionSummary withHttpVersion(HttpVersion httpVersion) {
        this.httpVersion = httpVersion.toString();
        return this;
    }

    /**
     *

     * Whether CloudFront responds to IPv6 DNS requests with an IPv6 address for your distribution.
     *

     *
     * @param isIPV6Enabled
     *        Whether CloudFront responds to IPv6 DNS requests with an IPv6 address for your distribution.
     */

    public void setIsIPV6Enabled(Boolean isIPV6Enabled) {
        this.isIPV6Enabled = isIPV6Enabled;
    }

    /**
     *

     * Whether CloudFront responds to IPv6 DNS requests with an IPv6 address for your distribution.
     *

     *
     * @return Whether CloudFront responds to IPv6 DNS requests with an IPv6 address for your distribution.
     */

    public Boolean getIsIPV6Enabled() {
        return this.isIPV6Enabled;
    }

    /**
     *

     * Whether CloudFront responds to IPv6 DNS requests with an IPv6 address for your distribution.
     *

     *
     * @param isIPV6Enabled
     *        Whether CloudFront responds to IPv6 DNS requests with an IPv6 address for your distribution.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public DistributionSummary withIsIPV6Enabled(Boolean isIPV6Enabled) {
        setIsIPV6Enabled(isIPV6Enabled);
        return this;
    }

    /**
     *

     * Whether CloudFront responds to IPv6 DNS requests with an IPv6 address for your distribution.
     *

     *
     * @return Whether CloudFront responds to IPv6 DNS requests with an IPv6 address for your distribution.
     */

    public Boolean isIPV6Enabled() {
        return this.isIPV6Enabled;
    }

    /**
     *

     * Amazon Web Services services in China customers must file for an Internet Content Provider (ICP) recordal if they
     * want to serve content publicly on an alternate domain name, also known as a CNAME, that they've added to
     * CloudFront. AliasICPRecordal provides the ICP recordal status for CNAMEs associated with distributions.
     *

     *

     * For more information about ICP recordals, see  Signup, Accounts, and
     * Credentials in Getting Started with Amazon Web Services services in China.
     *

     *
     * @return Amazon Web Services services in China customers must file for an Internet Content Provider (ICP) recordal
     *         if they want to serve content publicly on an alternate domain name, also known as a CNAME, that they've
     *         added to CloudFront. AliasICPRecordal provides the ICP recordal status for CNAMEs associated with
     *         distributions.

     *

     *         For more information about ICP recordals, see  Signup,
     *         Accounts, and Credentials in Getting Started with Amazon Web Services services in China.
     */

    public java.util.List<AliasICPRecordal> getAliasICPRecordals() {
        if (aliasICPRecordals == null) {
            aliasICPRecordals = new com.amazonaws.internal.SdkInternalList<AliasICPRecordal>();
        }
        return aliasICPRecordals;
    }

    /**
     *

     * Amazon Web Services services in China customers must file for an Internet Content Provider (ICP) recordal if they
     * want to serve content publicly on an alternate domain name, also known as a CNAME, that they've added to
     * CloudFront. AliasICPRecordal provides the ICP recordal status for CNAMEs associated with distributions.
     *

     *

     * For more information about ICP recordals, see  Signup, Accounts, and
     * Credentials in Getting Started with Amazon Web Services services in China.
     *

     *
     * @param aliasICPRecordals
     *        Amazon Web Services services in China customers must file for an Internet Content Provider (ICP) recordal
     *        if they want to serve content publicly on an alternate domain name, also known as a CNAME, that they've
     *        added to CloudFront. AliasICPRecordal provides the ICP recordal status for CNAMEs associated with
     *        distributions.

     *

     *        For more information about ICP recordals, see  Signup,
     *        Accounts, and Credentials in Getting Started with Amazon Web Services services in China.
     */

    public void setAliasICPRecordals(java.util.Collection<AliasICPRecordal> aliasICPRecordals) {
        if (aliasICPRecordals == null) {
            this.aliasICPRecordals = null;
            return;
        }

        this.aliasICPRecordals = new com.amazonaws.internal.SdkInternalList<AliasICPRecordal>(aliasICPRecordals);
    }

    /**
     *

     * Amazon Web Services services in China customers must file for an Internet Content Provider (ICP) recordal if they
     * want to serve content publicly on an alternate domain name, also known as a CNAME, that they've added to
     * CloudFront. AliasICPRecordal provides the ICP recordal status for CNAMEs associated with distributions.
     *

     *

     * For more information about ICP recordals, see  Signup, Accounts, and
     * Credentials in Getting Started with Amazon Web Services services in China.
     *

     *

     * NOTE: This method appends the values to the existing list (if any). Use
     * {@link #setAliasICPRecordals(java.util.Collection)} or {@link #withAliasICPRecordals(java.util.Collection)} if
     * you want to override the existing values.
     *

     *
     * @param aliasICPRecordals
     *        Amazon Web Services services in China customers must file for an Internet Content Provider (ICP) recordal
     *        if they want to serve content publicly on an alternate domain name, also known as a CNAME, that they've
     *        added to CloudFront. AliasICPRecordal provides the ICP recordal status for CNAMEs associated with
     *        distributions.

     *

     *        For more information about ICP recordals, see  Signup,
     *        Accounts, and Credentials in Getting Started with Amazon Web Services services in China.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public DistributionSummary withAliasICPRecordals(AliasICPRecordal... aliasICPRecordals) {
        if (this.aliasICPRecordals == null) {
            setAliasICPRecordals(new com.amazonaws.internal.SdkInternalList<AliasICPRecordal>(aliasICPRecordals.length));
        }
        for (AliasICPRecordal ele : aliasICPRecordals) {
            this.aliasICPRecordals.add(ele);
        }
        return this;
    }

    /**
     *

     * Amazon Web Services services in China customers must file for an Internet Content Provider (ICP) recordal if they
     * want to serve content publicly on an alternate domain name, also known as a CNAME, that they've added to
     * CloudFront. AliasICPRecordal provides the ICP recordal status for CNAMEs associated with distributions.
     *

     *

     * For more information about ICP recordals, see  Signup, Accounts, and
     * Credentials in Getting Started with Amazon Web Services services in China.
     *

     *
     * @param aliasICPRecordals
     *        Amazon Web Services services in China customers must file for an Internet Content Provider (ICP) recordal
     *        if they want to serve content publicly on an alternate domain name, also known as a CNAME, that they've
     *        added to CloudFront. AliasICPRecordal provides the ICP recordal status for CNAMEs associated with
     *        distributions.

     *

     *        For more information about ICP recordals, see  Signup,
     *        Accounts, and Credentials in Getting Started with Amazon Web Services services in China.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public DistributionSummary withAliasICPRecordals(java.util.Collection<AliasICPRecordal> aliasICPRecordals) {
        setAliasICPRecordals(aliasICPRecordals);
        return this;
    }

    /**
     * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
     * redacted from this string using a placeholder value.
     *
     * @return A string representation of this object.
     *
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("{");
        if (getId() != null)
            sb.append("Id: ").append(getId()).append(",");
        if (getARN() != null)
            sb.append("ARN: ").append(getARN()).append(",");
        if (getStatus() != null)
            sb.append("Status: ").append(getStatus()).append(",");
        if (getLastModifiedTime() != null)
            sb.append("LastModifiedTime: ").append(getLastModifiedTime()).append(",");
        if (getDomainName() != null)
            sb.append("DomainName: ").append(getDomainName()).append(",");
        if (getAliases() != null)
            sb.append("Aliases: ").append(getAliases()).append(",");
        if (getOrigins() != null)
            sb.append("Origins: ").append(getOrigins()).append(",");
        if (getOriginGroups() != null)
            sb.append("OriginGroups: ").append(getOriginGroups()).append(",");
        if (getDefaultCacheBehavior() != null)
            sb.append("DefaultCacheBehavior: ").append(getDefaultCacheBehavior()).append(",");
        if (getCacheBehaviors() != null)
            sb.append("CacheBehaviors: ").append(getCacheBehaviors()).append(",");
        if (getCustomErrorResponses() != null)
            sb.append("CustomErrorResponses: ").append(getCustomErrorResponses()).append(",");
        if (getComment() != null)
            sb.append("Comment: ").append(getComment()).append(",");
        if (getPriceClass() != null)
            sb.append("PriceClass: ").append(getPriceClass()).append(",");
        if (getEnabled() != null)
            sb.append("Enabled: ").append(getEnabled()).append(",");
        if (getViewerCertificate() != null)
            sb.append("ViewerCertificate: ").append(getViewerCertificate()).append(",");
        if (getRestrictions() != null)
            sb.append("Restrictions: ").append(getRestrictions()).append(",");
        if (getWebACLId() != null)
            sb.append("WebACLId: ").append(getWebACLId()).append(",");
        if (getHttpVersion() != null)
            sb.append("HttpVersion: ").append(getHttpVersion()).append(",");
        if (getIsIPV6Enabled() != null)
            sb.append("IsIPV6Enabled: ").append(getIsIPV6Enabled()).append(",");
        if (getAliasICPRecordals() != null)
            sb.append("AliasICPRecordals: ").append(getAliasICPRecordals());
        sb.append("}");
        return sb.toString();
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;

        if (obj instanceof DistributionSummary == false)
            return false;
        DistributionSummary other = (DistributionSummary) obj;
        if (other.getId() == null ^ this.getId() == null)
            return false;
        if (other.getId() != null && other.getId().equals(this.getId()) == false)
            return false;
        if (other.getARN() == null ^ this.getARN() == null)
            return false;
        if (other.getARN() != null && other.getARN().equals(this.getARN()) == false)
            return false;
        if (other.getStatus() == null ^ this.getStatus() == null)
            return false;
        if (other.getStatus() != null && other.getStatus().equals(this.getStatus()) == false)
            return false;
        if (other.getLastModifiedTime() == null ^ this.getLastModifiedTime() == null)
            return false;
        if (other.getLastModifiedTime() != null && other.getLastModifiedTime().equals(this.getLastModifiedTime()) == false)
            return false;
        if (other.getDomainName() == null ^ this.getDomainName() == null)
            return false;
        if (other.getDomainName() != null && other.getDomainName().equals(this.getDomainName()) == false)
            return false;
        if (other.getAliases() == null ^ this.getAliases() == null)
            return false;
        if (other.getAliases() != null && other.getAliases().equals(this.getAliases()) == false)
            return false;
        if (other.getOrigins() == null ^ this.getOrigins() == null)
            return false;
        if (other.getOrigins() != null && other.getOrigins().equals(this.getOrigins()) == false)
            return false;
        if (other.getOriginGroups() == null ^ this.getOriginGroups() == null)
            return false;
        if (other.getOriginGroups() != null && other.getOriginGroups().equals(this.getOriginGroups()) == false)
            return false;
        if (other.getDefaultCacheBehavior() == null ^ this.getDefaultCacheBehavior() == null)
            return false;
        if (other.getDefaultCacheBehavior() != null && other.getDefaultCacheBehavior().equals(this.getDefaultCacheBehavior()) == false)
            return false;
        if (other.getCacheBehaviors() == null ^ this.getCacheBehaviors() == null)
            return false;
        if (other.getCacheBehaviors() != null && other.getCacheBehaviors().equals(this.getCacheBehaviors()) == false)
            return false;
        if (other.getCustomErrorResponses() == null ^ this.getCustomErrorResponses() == null)
            return false;
        if (other.getCustomErrorResponses() != null && other.getCustomErrorResponses().equals(this.getCustomErrorResponses()) == false)
            return false;
        if (other.getComment() == null ^ this.getComment() == null)
            return false;
        if (other.getComment() != null && other.getComment().equals(this.getComment()) == false)
            return false;
        if (other.getPriceClass() == null ^ this.getPriceClass() == null)
            return false;
        if (other.getPriceClass() != null && other.getPriceClass().equals(this.getPriceClass()) == false)
            return false;
        if (other.getEnabled() == null ^ this.getEnabled() == null)
            return false;
        if (other.getEnabled() != null && other.getEnabled().equals(this.getEnabled()) == false)
            return false;
        if (other.getViewerCertificate() == null ^ this.getViewerCertificate() == null)
            return false;
        if (other.getViewerCertificate() != null && other.getViewerCertificate().equals(this.getViewerCertificate()) == false)
            return false;
        if (other.getRestrictions() == null ^ this.getRestrictions() == null)
            return false;
        if (other.getRestrictions() != null && other.getRestrictions().equals(this.getRestrictions()) == false)
            return false;
        if (other.getWebACLId() == null ^ this.getWebACLId() == null)
            return false;
        if (other.getWebACLId() != null && other.getWebACLId().equals(this.getWebACLId()) == false)
            return false;
        if (other.getHttpVersion() == null ^ this.getHttpVersion() == null)
            return false;
        if (other.getHttpVersion() != null && other.getHttpVersion().equals(this.getHttpVersion()) == false)
            return false;
        if (other.getIsIPV6Enabled() == null ^ this.getIsIPV6Enabled() == null)
            return false;
        if (other.getIsIPV6Enabled() != null && other.getIsIPV6Enabled().equals(this.getIsIPV6Enabled()) == false)
            return false;
        if (other.getAliasICPRecordals() == null ^ this.getAliasICPRecordals() == null)
            return false;
        if (other.getAliasICPRecordals() != null && other.getAliasICPRecordals().equals(this.getAliasICPRecordals()) == false)
            return false;
        return true;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int hashCode = 1;

        hashCode = prime * hashCode + ((getId() == null) ? 0 : getId().hashCode());
        hashCode = prime * hashCode + ((getARN() == null) ? 0 : getARN().hashCode());
        hashCode = prime * hashCode + ((getStatus() == null) ? 0 : getStatus().hashCode());
        hashCode = prime * hashCode + ((getLastModifiedTime() == null) ? 0 : getLastModifiedTime().hashCode());
        hashCode = prime * hashCode + ((getDomainName() == null) ? 0 : getDomainName().hashCode());
        hashCode = prime * hashCode + ((getAliases() == null) ? 0 : getAliases().hashCode());
        hashCode = prime * hashCode + ((getOrigins() == null) ? 0 : getOrigins().hashCode());
        hashCode = prime * hashCode + ((getOriginGroups() == null) ? 0 : getOriginGroups().hashCode());
        hashCode = prime * hashCode + ((getDefaultCacheBehavior() == null) ? 0 : getDefaultCacheBehavior().hashCode());
        hashCode = prime * hashCode + ((getCacheBehaviors() == null) ? 0 : getCacheBehaviors().hashCode());
        hashCode = prime * hashCode + ((getCustomErrorResponses() == null) ? 0 : getCustomErrorResponses().hashCode());
        hashCode = prime * hashCode + ((getComment() == null) ? 0 : getComment().hashCode());
        hashCode = prime * hashCode + ((getPriceClass() == null) ? 0 : getPriceClass().hashCode());
        hashCode = prime * hashCode + ((getEnabled() == null) ? 0 : getEnabled().hashCode());
        hashCode = prime * hashCode + ((getViewerCertificate() == null) ? 0 : getViewerCertificate().hashCode());
        hashCode = prime * hashCode + ((getRestrictions() == null) ? 0 : getRestrictions().hashCode());
        hashCode = prime * hashCode + ((getWebACLId() == null) ? 0 : getWebACLId().hashCode());
        hashCode = prime * hashCode + ((getHttpVersion() == null) ? 0 : getHttpVersion().hashCode());
        hashCode = prime * hashCode + ((getIsIPV6Enabled() == null) ? 0 : getIsIPV6Enabled().hashCode());
        hashCode = prime * hashCode + ((getAliasICPRecordals() == null) ? 0 : getAliasICPRecordals().hashCode());
        return hashCode;
    }

    @Override
    public DistributionSummary clone() {
        try {
            return (DistributionSummary) super.clone();
        } catch (CloneNotSupportedException e) {
            throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone() " + "even though we're Cloneable!", e);
        }
    }

}


text:
package mil.army.usace.ehlschlaeger.rgik.util;

import mil.army.usace.ehlschlaeger.rgik.core.DataException;

public class RowRLE {
	private char[] values;
	private short[] maxColumnIndex;
	private boolean isRLE, autoOptimizeAfterSetCellValue;
	private int numColumns;
	private int lastLocation;

	public RowRLE( int numberColumns) {
		isRLE = autoOptimizeAfterSetCellValue = false;
		values = new char[ numberColumns];
		for( int c = numberColumns - 1; c >= 0; c--) {
			values[ c] = (char) 0;
		}
		maxColumnIndex = null;
		numColumns = numberColumns;
		lastLocation = 0;
	}

	public boolean isRunLengthEncoded() {
		return isRLE;
	}

	public int getNumberColumns() {
		return numColumns;
	}

	public int getLengthRow() {
		return values.length;
	}

	public void setCellValue( int columnIndex, int cellValue) {
		if(!isRLE) {
			values[ columnIndex] = (char) cellValue;
		} else {
			flattenRow();
			values[ columnIndex] = (char) cellValue;
			if( autoOptimizeAfterSetCellValue == true) {
				optimizeRow();
			}
		}
	}

	public int getCellValue( int columnIndex) {
		if( isRLE == false) {
			return values[ columnIndex];
		}
		if( columnIndex == 0) {
			lastLocation = 0;
			return values[ 0];
		}
		if( columnIndex == numColumns - 1) {
			lastLocation = maxColumnIndex.length - 1;
			return values[ lastLocation];
		}
		if( maxColumnIndex[ lastLocation] >= columnIndex) {
			while( true) {
				if( lastLocation == 0 || maxColumnIndex[ lastLocation - 1] < columnIndex) {
					return values[ lastLocation];
				}
				lastLocation--;
			}
		}
		while( lastLocation != maxColumnIndex.length - 1 &&
			maxColumnIndex[ lastLocation] < columnIndex) {
				lastLocation++;
		}
		return values[ lastLocation];
	}

	public void setAutomaticOptimizeAfterSetCellValue( boolean value) {
		autoOptimizeAfterSetCellValue = value;
	}

	public boolean optimizeRow() {
		if(isRLE) {
			return true;
		} else {
			int ci = 1;
			int currentValue = values[ 0];
			for( int i = 1; i < numColumns; i++) {
				if( values[ i] != currentValue) {
					ci++;
					currentValue = values[ i];
				}
			}
			if( ci * 3 < numColumns) {
				encodeRow( ci);
				return true;
			}
		}
		return false;
	}

	public void encodeRow() {
		if(isRLE)
		    throw new DataException("row is already run length encoded");

		int ci = 1;
		int currentValue = values[ 0];
		for( int i = 1; i < numColumns; i++) {
			if( values[ i] != currentValue) {
				ci++;
				currentValue = values[ i];
			}
		}
		encodeRow( ci);
	}

	private void encodeRow( int sizeIndex) {
        if(isRLE)
            throw new DataException("row is already run length encoded");

        //System.out.println( "was [" + values.length + "], will be [" + sizeIndex + "]");
		char[] newValues = new char[ sizeIndex];
		maxColumnIndex = new short[ sizeIndex];
		sizeIndex = 0;
		int i = 1;
		newValues[ 0] = values[ 0];
		while( i < numColumns) {
			if( values[ i] != newValues[ sizeIndex]) {
				maxColumnIndex[ sizeIndex++] = (short) (i - 1);
				newValues[ sizeIndex] = (char) values[ i];
			}
			i++;
		}
		maxColumnIndex[ sizeIndex] = (short) (numColumns - 1);
		if( sizeIndex != newValues.length - 1) {
		    throw new DataException("sizeIndex [" +
				sizeIndex + "] doesn't equal length-1 [" + (newValues.length - 1) + "]");
		}
		values = newValues;
		isRLE = true;
		lastLocation = 0;
	}

	public void flattenRow() {
        if(!isRLE)
            throw new DataException("row is already flat");
		char[] newValues = new char[ numColumns];
		int i = 0;
		for( int ci = 0; ci < maxColumnIndex.length; ci++) {
			int mi = maxColumnIndex[ ci];
			while( i <= mi) {
				newValues[ i] = values[ ci];
				i++;
			}
			if( i >= numColumns)
				ci = maxColumnIndex.length;
		}
		values = newValues;
		isRLE = false;
		maxColumnIndex = null;
	}
}


text:
module ActsAsMultipartForm

  # Specify this to let the controller know how to setup the multipart forms.
  # This sets up the form action, the form parts, and any other needed options.
  # Each controller can have multiple multipart forms included on it
  #
  # The controller expects there to be an action for every form part for form_part_name and form_part_name_update
  # There are currently no checks to verify these actions but an exception will be thrown when a missing
  # action is called
  module MultipartFormInController

    def self.included(base)
      base.extend ClassMethods
    end

    module ClassMethods
      # Sets up the multipart form handler with the data needed to create and move through a multipart form
      # The arguments takes several important values including:
      # name: The name of the multipart form.  This creates a controller action with that name that can be used in routes and other situations
      # parts: An array of multipart form parts.  Each part must have a corresponding part_name and part_name_update method
      # model: The name of the model used to identify the multipart form.  Defaults to the singularized name of the controller.
      # form_route: The route for the form as specified in the config/routes file. Defaults to model_form_name downcased.
      # show_route: The route the form redirects to once the last part is filled out.  Defaults to the name of the model, downcased.
      #
      # The args parameter is an array of hashes and multiple multipart forms can be specified with a single acts_as_multipart_form call.
      # To keep the lines from being too long, acts_as_multipart_form can be called multiple times to setup the forms
      #
      # sample set of multipart form actions
      # def person_info
      #   @person = Person.find(params[:id])
      # end
      #
      # def person_info_update
      #   @person = Person.find(params[:id])
      #   @person = Person.new if @person.nil?
      #   @person.multipart_form_controller_action = "person_info_update"
      #
      #   valid = @person.update_attributes(params[:person])
      #   return {:valid => valid}
      # end
      #
      # def job_info
      #   @job_position = JobPosition.new
      #   @job_position.person = Person.find(load_multipart_form_data(form_instance_id, :person))
      #   @job_position.multipart_form_controller_action = "job_info_update"
      # end
      #
      # def job_info_update
      #   valid = @job_position.update_attributes(params[:job_position])
      #   return {:valid => valid}
      # end
      #
      # @param [Array] args An array of hashes that determines the data for a multipart form
      def acts_as_multipart_form(*args)

        mattr_accessor :multipart_forms unless self.respond_to?(:multipart_forms)
        self.multipart_forms = {} unless self.multipart_forms.is_a?(Hash)

        mattr_accessor :stay_string unless self.respond_to?(:stay_string)

        forms = []
        args.each do |arg|
          # add the update parts
          parts = arg[:parts]
          arg[:parts] = []
          parts.each do |part|
            arg[:parts] << part
            arg[:parts] << (part.to_s + "_update").to_sym
          end
          # sets default model if it is not set
          arg[:model] = self.to_s.gsub("Controller", "").singularize unless arg.has_key?(:model)
          arg[:form_route] = (arg[:name].to_s + "_" + arg[:model].gsub("::", "").underscore) unless arg.has_key?(:form_route)
          arg[:show_route] = (arg[:model].gsub("::", "").underscore) unless arg.has_key?(:show_route)
          # copy args to fields
          self.multipart_forms[arg[:name]] = arg
          forms << arg[:name]

          self.stay_string = arg[:stay_on_button]
        end

        before_filter :multipart_form_handler, :only => forms

        include ActsAsMultipartForm::MultipartFormInController::InstanceMethods

      end
    end

    module InstanceMethods

      # A bad hack to load the multipart form information for the index page
      # This must be called if you want to use the multipart_form/index_links partial
      #
      # Adds several instance variables available for the view
      #
      # @param [Symbol] form_name The name of the form
      # @param [Array] form_subjects An array of active record objects that are form subjects for the given form
      def load_multipart_form_index_links(form_name, form_subjects)
        @multipart_form_index_parts = {}
        form_subjects.each do |form_subject|
          in_progress_form = find_or_initialize_multipart_in_progress_form(form_name, form_subject)
          @multipart_form_index_parts[form_subject.id] = {}
          @multipart_form_index_parts[form_subject.id][:parts] = get_available_multipart_form_parts(form_name, in_progress_form.last_completed_step)
          @multipart_form_index_parts[form_subject.id][:completed] = in_progress_form.completed
        end
        @multipart_form_path = (self.multipart_forms[form_name][:form_route] + "_path").to_sym
      end

      # Handles multipart form setup on the controller
      # Automatically called on the hire form action as a before filter
      #
      # It adds a bunch of instance variables to the controller so they are accessible to the view page.
      # Not sure if this is the best way to do things
      def multipart_form_handler
        form_name = params[:action].to_sym
        form_subject_id = params[:id]

        @form_subject = find_or_initialize_multipart_form_subject(form_name, form_subject_id)
        params[:id] = @form_subject.id

        in_progress_form = find_or_initialize_multipart_in_progress_form(form_name, @form_subject)

        # set the part based on the params or in progress form
        if params[:multipart_form_part]
          part = params[:multipart_form_part].to_sym
        elsif in_progress_form.last_completed_step != "none"
          part = get_next_multipart_form_part(form_name, in_progress_form.last_completed_step.to_sym)
        else
          part = self.multipart_forms[form_name][:parts].first
        end

        # call and save the part information
        if(part && self.multipart_forms[form_name][:parts].include?(part.to_sym))
          result = self.send(part)

          if(part.match(/_update$/))
            if(result && result[:valid] && params[:commit] != self.stay_string )
              completed = redirect_to_next_multipart_form_part(form_name, @form_subject, part)

              # if the form has been completed, set last_completed step to the first part of the form (JH 5-24-2012)
              # the next time the user edits the form, they will go to the first page
              # they should not be automatically redirected to the show page
              saved_step = ( completed ? "none" : part )

              # added form_subject_id in case it was not set when the in_progress_form was created (JH 5-15-2012)
              # this would happen on a new page, but not an edit page
              in_progress_form.update_attributes({
                :form_subject_id => @form_subject.id,
                :last_completed_step => saved_step,
                :completed => completed })
            else
              # render the previous page but stay on this page so we keep the errors
              part = get_previous_multipart_form_part(form_name, part)
              # actually run the part we just found
              # can't believe we missed this one (JH 3-20-2012)
              self.send(part)
            end
          end

          # move forward or backwards 2 parts for the previous and next links on the bredcrumb
          skip_update_part = true
          @breadcrumb_links= {
            :previous => get_previous_multipart_form_part(form_name, part, skip_update_part).to_s,
            :next => get_next_multipart_form_part(form_name, part, skip_update_part).to_s,
          }

          # needs to be a string so that the view can read it
          @next_multipart_form_part = get_next_multipart_form_part(form_name, part).to_s
          @multipart_form_part = part.to_s
          @available_multipart_form_parts = get_available_multipart_form_parts(form_name, in_progress_form.last_completed_step)
          @multipart_form_path = (self.multipart_forms[form_name][:form_route] + "_path").to_sym
          @multipart_form_complete = in_progress_form.completed
        end
      end

      # Determines if the symbol matches a multipart form name
      #
      # @param [Symbol] sym A name that may or may not correspond to a multipart form name
      # @return [Boolean] Returns true if the symbol matches a multipart form name
      def multipart_form_action?(sym)
        self.multipart_forms.keys.include?(sym)
      end

      # Gets the previous multipart form part for the form or returns the current part if it is first
      #
      # @param [Symbol] form The name of the multipart form
      # @param [Symbol] part The name of the current part
      # @param [Boolean] skip_update_part If set to true, moves back two parts instead of one
      # @returns [Symbol] The name of the next part
      def get_previous_multipart_form_part(form, part, skip_update_part = false)
        part_index = self.multipart_forms[form][:parts].index(part)

        if skip_update_part
          prev_part_distance = 2
        else
          prev_part_distance = 1
        end

        if part_index - prev_part_distance >= 0
          return self.multipart_forms[form][:parts][part_index - prev_part_distance]
        else
          return self.multipart_forms[form][:parts].first
        end
      end

      # Gets the next multipart form part for the form or returns the current part if it is first
      #
      # @param [Symbol] form The name of the multipart form
      # @param [Symbol] part The name of the current part
      # @param [Boolean] skip_update_part If set to true, moves forward two parts instead of one
      # @returns [Symbol] The name of the previous part
      def get_next_multipart_form_part(form, part, skip_update_part = false)
        part_index = self.multipart_forms[form][:parts].index(part)

        if skip_update_part
          next_part_distance = 2
        else
          next_part_distance = 1
        end

        if part_index < self.multipart_forms[form][:parts].length - next_part_distance
          return self.multipart_forms[form][:parts][part_index + next_part_distance]
        else
          return part
        end
      end

      # Determines if the given multipart form part is the last part of the form
      #
      # @param [Symbol] form The name of the multipart form
      # @param [Symbol] part The name o the current part
      # @returns [Boolean] True if the given part matches the last part
      def last_multipart_form_part?(form, part)
        self.multipart_forms[form][:parts].last == part
      end

      # Determines if the given multipart form part is the first part of the form
      #
      # @param [Symbol] form The name of the multipart form
      # @param [Symbol] part The name o the current part
      # @returns [Boolean] True if the given part matches the first part
      def first_multipart_form_part?(form, part)
        self.multipart_forms[form][:parts].first == part
      end

      # Given a form name and a form subject id, it creates the form subject
      # The form subject is defined by the id and the multipart form's model attribute
      #
      # The subject is initialized with no values and it is not saved
      #
      # @param [Symbol] form_name The name of the multipart form
      # @param [Integer] form_dubject_id The id of the form subject (could be nil)
      # @return [FormSubject] The form subject in the database or a new form subject instance
      def find_or_initialize_multipart_form_subject(form_name, form_subject_id)
        # find or create the form subject
        model = self.multipart_forms[form_name][:model]
        if form_subject_id
          form_subject = model.constantize.find(form_subject_id)
        else
          form_subject = model.constantize.new()
        end
        return form_subject
      end

      # Returns the InProgressForm object when given the form name and subject
      #
      # Initializes but does not asve the InPorgressForm object if it doesn't exist for the given form name/form subject pair
      #
      # @param [Symbol] form_name The name of the multipart form
      # @param [FormSubject] form_subject The multipart form's subject
      # @returns [InProgressForm] The associated or new in progress form object
      def find_or_initialize_multipart_in_progress_form(form_name, form_subject)
        # find or create the in progress form
        # not sure why the polymorphic relationship isn't working here
        in_progress_form = MultipartForm::InProgressForm.where(
          :form_subject_id => form_subject.id,
          :form_subject_type => form_subject.class.to_s,
          :form_name => form_name.to_s).first

        # if the form subject is a new_record, in_progress_form should be nil
        # trying to stop weird edge cases from killing me (JH 5-15-2012)
        if form_subject.new_record? || !in_progress_form
          in_progress_form = MultipartForm::InProgressForm.new(
            :form_subject_id => form_subject.id,
            :form_subject_type => form_subject.class.to_s,
            :form_name => form_name.to_s,
            :last_completed_step => "none",
            :completed => false)
        end
        return in_progress_form
      end

      # Adds a redirect based on the information passed in.
      # If on the last part of the form, tries to redirect to the view page,
      # otherwise to the next form part.
      #
      # This method needs signficantly more testing (7-20-2011)
      #
      # @param [Sybmol] form_name The name of the form
      # @param [FormSubject] form_subject The subject of the form
      # @param [Symbol] part The current form part
      def redirect_to_next_multipart_form_part(form_name, form_subject, part)
        # set highest completed part to the current part4
        if(last_multipart_form_part?(form_name, part))
          # render the view page(not sure how to do this)
          redirect_to( send(self.multipart_forms[form_name][:show_route] + "_path", form_subject) )
          completed = true
        else
          # render the next page
          next_part = get_next_multipart_form_part(form_name, part)
          # maybe pass in a route
          redirect_to ( send(
            self.multipart_forms[form_name][:form_route] + "_path",
            :id => form_subject.id.to_s,
            :multipart_form_part => next_part.to_s))
          completed = false
        end
        return completed
      end

      # Gets the multipart form parts the user is allowed to directly link to
      # with respect to the config information.
      #
      # If the config option show_incomplete_parts is set to false, do not return parts past the in_progress_form's last completed step
      #
      # @param [Symbol] form_name The name of the form
      # @returns [Array] An array of form part symbols with no _update parts and other config restrictions
      def get_available_multipart_form_parts(form_name, last_completed_part)
        add_parts = true
        parts = []
        # loop over the parts
        self.multipart_forms[form_name][:parts].each do |part|
          if( add_parts && !part.match(/_update$/) )
            parts << { :name => part, :number => parts.length + 1 }
          end
          if !ActsAsMultipartForm.config.show_incomplete_parts && part.to_s == last_completed_part.to_s
            add_parts = false
          end
        end
        return parts
      end

    end
  end
end


text:
using System;
using System.IO;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace Demo
{
	class Program
	{
		protected static DateTime timestampStart;

		static public void TimeStampStart()
		{
			timestampStart = DateTime.Now;
		}

		static public void TimeStamp(string msg)
		{
			long elapsed = (long)(DateTime.Now - timestampStart).TotalMilliseconds;
			Console.WriteLine("{0} : {1}", elapsed, msg);
		}

		static SingleThreadedQueueingHandler handler;

		static void Main(string[] args)
		{
			// Supports 20 simultaneous connections.
			handler = new SingleThreadedQueueingHandler();
			HttpListener listener = new HttpListener();
			string url = "http://localhost/";
			listener.Prefixes.Add(url);
			listener.Start();

			Task.Run(() => WaitForConnection(listener));

			TimeStampStart();

			for (int i = 0; i < 10; i++)
			{
				Console.WriteLine("Request #" + i);
				MakeRequest(i);
			}

			Console.WriteLine("Press a key to exit the server.");
			Console.ReadLine();
		}

		/// <summary>
		/// Issue GET request to localhost/index.html
		/// </summary>
		static async void MakeRequest(int i)
		{
			TimeStamp("MakeRequest " + i + " start, Thread ID: " + Thread.CurrentThread.ManagedThreadId);
			string ret = await RequestIssuer.HttpGet("http://localhost/index.html");
			TimeStamp("MakeRequest " + i + " end, Thread ID: " + Thread.CurrentThread.ManagedThreadId);
		}

		/// <summary>
		/// Block until a connection is received.
		/// </summary>
		static void WaitForConnection(object objListener)
		{
			HttpListener listener = (HttpListener)objListener;

			while (true)
			{
				TimeStamp("StartConnectionListener Thread ID: " + Thread.CurrentThread.ManagedThreadId);
				HttpListenerContext context = listener.GetContext();
				handler.Process(context);
			}
		}
	}
}


text:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">

    <group android:checkableBehavior="single">
        <item
            android:id="@+id/nav_home"
            android:icon="@mipmap/ic_nav_home"
            android:title="Home" />
        <item
            android:id="@+id/nav_vereadores"
            android:icon="@mipmap/ic_nav_vereadores"
            android:title="Vereadores" />
        <item
            android:id="@+id/nav_dialoga"
            android:icon="@mipmap/ic_nav_dialoga"
            android:title="Dialoga, Cidadão!" />
        <item
            android:id="@+id/nav_projetos"
            android:icon="@mipmap/ic_nav_projetos"
            android:title="Projetos" />
        <item
            android:id="@+id/nav_camara"
            android:icon="@mipmap/ic_nav_camara"
            android:title="Câmara" />
    </group>

    <item android:title="Configuração">
        <menu>
            <item
                android:id="@+id/nav_trocar_cidade"
                android:icon="@android:drawable/ic_popup_sync"
                android:title="Trocar Cidade" />
            <item
                android:id="@+id/nav_sobre"
                android:icon="@mipmap/ic_nav_about"
                android:title="Sobre" />
        </menu>
    </item>

</menu>


text:
using ::testing::NiceMock;

namespace base {
class RunLoop;
}

namespace media {

class FakeEncryptedMedia;
class TestMediaSource;

// Empty MD5 hash string.  Used to verify empty video tracks.
extern const char kNullVideoHash[];

// Empty hash string.  Used to verify empty audio tracks.
extern const char kNullAudioHash[];

// Integration tests for Pipeline. Real demuxers, real decoders, and
// base renderer implementations are used to verify pipeline functionality. The
// renderers used in these tests rely heavily on the AudioRendererBase &
// VideoRendererImpl implementations which contain a majority of the code used
// in the real AudioRendererImpl & PaintCanvasVideoRenderer implementations used
// in the browser. The renderers in this test don't actually write data to a
// display or audio device. Both of these devices are simulated since they have
// little effect on verifying pipeline behavior and allow tests to run faster
// than real-time.
class PipelineIntegrationTestBase : public Pipeline::Client {
 public:
  PipelineIntegrationTestBase();

  PipelineIntegrationTestBase(const PipelineIntegrationTestBase&) = delete;
  PipelineIntegrationTestBase& operator=(const PipelineIntegrationTestBase&) =
      delete;

  virtual ~PipelineIntegrationTestBase();

  // Test types for advanced testing and benchmarking (e.g., underflow is
  // disabled to ensure consistent hashes). May be combined using the bitwise
  // or operator (and as such must have values that are powers of two).
  enum TestTypeFlags {
    kNormal = 0,
    kHashed = 1,
    kNoClockless = 2,
    kExpectDemuxerFailure = 4,
    kUnreliableDuration = 8,
    kWebAudio = 16,
    kMonoOutput = 32,
    kFuzzing = 64,
  };

  // Setup method to intialize various state according to flags.
  void ParseTestTypeFlags(uint8_t flags);

  // Starts the pipeline with a file specified by |filename|, optionally with a
  // CdmContext or a |test_type|, returning the final status code after it has
  // started. |filename| points at a test file located under media/test/data/.
  PipelineStatus Start(const std::string& filename);
  PipelineStatus Start(const std::string& filename, CdmContext* cdm_context);
  PipelineStatus Start(
      const std::string& filename,
      uint8_t test_type,
      CreateVideoDecodersCB prepend_video_decoders_cb = CreateVideoDecodersCB(),
      CreateAudioDecodersCB prepend_audio_decoders_cb =
          CreateAudioDecodersCB());

  // Starts the pipeline with |data| (with |size| bytes). The |data| will be
  // valid throughtout the lifetime of this test.
  PipelineStatus Start(const uint8_t* data, size_t size, uint8_t test_type);

  void Play();
  void Pause();
  bool Seek(base::TimeDelta seek_time);
  bool Suspend();
  bool Resume(base::TimeDelta seek_time);
  void Stop();

  // Fails the test with |status|.
  void FailTest(PipelineStatus status);

  bool WaitUntilCurrentTimeIsAfter(const base::TimeDelta& wait_time);
  bool WaitUntilOnEnded();
  PipelineStatus WaitUntilEndedOrError();

  // Returns the MD5 hash of all video frames seen.  Should only be called once
  // after playback completes.  First time hashes should be generated with
  // --video-threads=1 to ensure correctness.  Pipeline must have been started
  // with hashing enabled.
  std::string GetVideoHash();

  // Returns the hash of all audio frames seen.  Should only be called once
  // after playback completes.  Pipeline must have been started with hashing
  // enabled.
  std::string GetAudioHash();

  // Reset video hash to restart hashing from scratch (e.g. after a seek or
  // after disabling a media track).
  void ResetVideoHash();

  // Returns the time taken to render the complete audio file.
  // Pipeline must have been started with clockless playback enabled.
  base::TimeDelta GetAudioTime();

  // Sets a callback to handle EME "encrypted" event. Must be called to test
  // potentially encrypted media.
  void set_encrypted_media_init_data_cb(
      const Demuxer::EncryptedMediaInitDataCB& encrypted_media_init_data_cb) {
    encrypted_media_init_data_cb_ = encrypted_media_init_data_cb;
  }

  // Saves a test callback, ownership of which will be transferred to the next
  // AudioRendererImpl created by CreateDefaultRenderer().
  void set_audio_play_delay_cb(AudioRendererImpl::PlayDelayCBForTesting cb) {
    audio_play_delay_cb_ = std::move(cb);
  }

  std::unique_ptr<Renderer> CreateRenderer(
      absl::optional<RendererType> renderer_type);

 protected:
  NiceMock<MockMediaLog> media_log_;
  base::test::TaskEnvironment task_environment_;
  base::MD5Context md5_context_;
  bool hashing_enabled_;
  bool clockless_playback_;
  bool webaudio_attached_;
  bool mono_output_;
  bool fuzzing_;
#if defined(ADDRESS_SANITIZER) || defined(UNDEFINED_SANITIZER)
  // TODO(https://crbug.com/924030): ASAN causes Run() timeouts to be reached.
  const base::test::ScopedDisableRunLoopTimeout disable_run_timeout_;
#endif
  std::unique_ptr<Demuxer> demuxer_;
  std::unique_ptr<DataSource> data_source_;
  std::unique_ptr<PipelineImpl> pipeline_;
  scoped_refptr<NullAudioSink> audio_sink_;
  scoped_refptr<ClocklessAudioSink> clockless_audio_sink_;
  std::unique_ptr<NullVideoSink> video_sink_;
  bool ended_;
  PipelineStatus pipeline_status_;
  Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb_;
  VideoPixelFormat last_video_frame_format_;
  gfx::ColorSpace last_video_frame_color_space_;
  PipelineMetadata metadata_;
  scoped_refptr<VideoFrame> last_frame_;
  base::TimeDelta current_duration_;
  AudioRendererImpl::PlayDelayCBForTesting audio_play_delay_cb_;

  // By default RendererImpl will be created using CreateDefaultRenderer(). But
  // if |create_renderer_cb_| is set, it'll be used to create the Renderer
  // instead.
  using CreateRendererCB = base::RepeatingCallback<std::unique_ptr<Renderer>(
      absl::optional<RendererType> renderer_type)>;
  CreateRendererCB create_renderer_cb_;

  std::unique_ptr<Renderer> CreateDefaultRenderer(
      absl::optional<RendererType> renderer_type);

  // Sets |create_renderer_cb_| which will be used to wrap the Renderer created
  // by CreateDefaultRenderer().
  void SetCreateRendererCB(CreateRendererCB create_renderer_cb);

  PipelineStatus StartInternal(
      std::unique_ptr<DataSource> data_source,
      CdmContext* cdm_context,
      uint8_t test_type,
      CreateVideoDecodersCB prepend_video_decoders_cb = CreateVideoDecodersCB(),
      CreateAudioDecodersCB prepend_audio_decoders_cb =
          CreateAudioDecodersCB());

  PipelineStatus StartWithFile(
      const std::string& filename,
      CdmContext* cdm_context,
      uint8_t test_type,
      CreateVideoDecodersCB prepend_video_decoders_cb = CreateVideoDecodersCB(),
      CreateAudioDecodersCB prepend_audio_decoders_cb =
          CreateAudioDecodersCB());

  PipelineStatus StartPipelineWithMediaSource(TestMediaSource* source);
  PipelineStatus StartPipelineWithEncryptedMedia(
      TestMediaSource* source,
      FakeEncryptedMedia* encrypted_media);
  PipelineStatus StartPipelineWithMediaSource(
      TestMediaSource* source,
      uint8_t test_type,
      FakeEncryptedMedia* encrypted_media);
  PipelineStatus StartPipelineWithMediaSource(
      TestMediaSource* source,
      uint8_t test_type,
      CreateAudioDecodersCB prepend_audio_decoders_cb);

  void OnSeeked(base::TimeDelta seek_time, PipelineStatus status);
  void OnStatusCallback(const base::RepeatingClosure& quit_run_loop_closure,
                        PipelineStatus status);
  void DemuxerEncryptedMediaInitDataCB(EmeInitDataType type,
                                       const std::vector<uint8_t>& init_data);

  void DemuxerMediaTracksUpdatedCB(std::unique_ptr<MediaTracks> tracks);

  void QuitAfterCurrentTimeTask(base::TimeDelta quit_time,
                                base::OnceClosure quit_closure);

  // Creates Demuxer and sets |demuxer_|.
  void CreateDemuxer(std::unique_ptr<DataSource> data_source);

  void OnVideoFramePaint(scoped_refptr<VideoFrame> frame);

  void CheckDuration();

  // Return the media start time from |demuxer_|.
  base::TimeDelta GetStartTime();

  MOCK_METHOD1(DecryptorAttached, void(bool));

  // Pipeline::Client overrides.
  void OnError(PipelineStatus status) override;
  void OnFallback(PipelineStatus status) override;
  void OnEnded() override;
  MOCK_METHOD1(OnMetadata, void(const PipelineMetadata&));
  MOCK_METHOD2(OnBufferingStateChange,
               void(BufferingState, BufferingStateChangeReason));
  MOCK_METHOD0(OnDurationChange, void());
  MOCK_METHOD2(OnAddTextTrack,
               void(const TextTrackConfig& config, AddTextTrackDoneCB done_cb));
  MOCK_METHOD1(OnWaiting, void(WaitingReason));
  MOCK_METHOD1(OnVideoNaturalSizeChange, void(const gfx::Size&));
  MOCK_METHOD1(OnVideoConfigChange, void(const VideoDecoderConfig&));
  MOCK_METHOD1(OnAudioConfigChange, void(const AudioDecoderConfig&));
  MOCK_METHOD1(OnVideoOpacityChange, void(bool));
  MOCK_METHOD1(OnVideoFrameRateChange, void(absl::optional<int>));
  MOCK_METHOD0(OnVideoAverageKeyframeDistanceUpdate, void());
  MOCK_METHOD1(OnAudioPipelineInfoChange, void(const AudioPipelineInfo&));
  MOCK_METHOD1(OnVideoPipelineInfoChange, void(const VideoPipelineInfo&));
  MOCK_METHOD1(OnRemotePlayStateChange, void(MediaStatus::State state));

 private:
  // Runs |run_loop| until it is explicitly Quit() by some part of the calling
  // test fixture or when an error occurs (by setting |on_error_closure_|). The
  // |task_environment_| is RunUntilIdle() after the RunLoop finishes
  // running, before returning to the caller.
  void RunUntilQuitOrError(base::RunLoop* run_loop);

  // Configures |on_ended_closure_| to quit |run_loop| and then calls
  // RunUntilQuitOrError() on it.
  void RunUntilQuitOrEndedOrError(base::RunLoop* run_loop);

  CreateVideoDecodersCB prepend_video_decoders_cb_;
  CreateAudioDecodersCB prepend_audio_decoders_cb_;

  base::OnceClosure on_ended_closure_;
  base::OnceClosure on_error_closure_;
};

}  // namespace media

#endif  // MEDIA_TEST_PIPELINE_INTEGRATION_TEST_BASE_H_