text:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2012 the original author or authors. Licensed under the Apache
	License, Version 2.0 (the "License"); you may not use this file except in
	compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
	Unless required by applicable law or agreed to in writing, software distributed
	under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
	OR CONDITIONS OF ANY KIND, either express or implied. See the License for
	the specific language governing permissions and limitations under the License. -->
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

	<!-- Bean post processor to persist created beans -->
	<bean class="agentspring.graphdb.PersistingBeanPostProcessor" />

	<!-- Decarbonization Model -->
	<bean id="decarbonizationModel" class="emlab.gen.domain.agent.DecarbonizationModel"
		p:name="Decarbonization Model" p:simulationLength="${simulationLength}"
		p:co2TradingImplemented="false"
		p:realRenewableDataImplemented="false" p:iterationSpeedFactor="3"
		p:iterationSpeedCriterion="0.005" p:capDeviationCriterion="0.005" p:deletionOldPPDPBidsAndCashFlowsEnabled="true"
		p:deletionAge="2">
	</bean>

	<bean class="emlab.gen.trend.TriangularTrend" id="demandGrowthTrendNL"
		p:start="${demandGrowthNLStart}" p:min="${demandGrowthNLMin}" p:max="${demandGrowthNLMax}"
		p:top="${demandGrowthNLTop}" />
	<bean class="emlab.gen.trend.TriangularTrend" id="demandGrowthTrendDE"
		p:start="${demandGrowthDEStart}" p:min="${demandGrowthDEMin}" p:max="${demandGrowthDEMax}"
		p:top="${demandGrowthDETop}" />

	<!-- Substances -->
	<bean id="coal" class="emlab.gen.domain.technology.Substance" p:name="Coal"
		p:quality="1" p:energyDensity="28000" p:co2Density="3.0" />
	<bean id="naturalgas" class="emlab.gen.domain.technology.Substance"
		p:name="Natural Gas" p:quality="1" p:energyDensity="36" p:co2Density="0.00187" />
	<bean id="biomass" class="emlab.gen.domain.technology.Substance"
		p:name="Biomass" p:quality="0.5" p:energyDensity="25000" p:co2Density="0" />
	<bean id="uranium" class="emlab.gen.domain.technology.Substance"
		p:name="Uranium" p:quality="1" p:energyDensity="3888000000"
		p:co2Density="0" />
	<bean id="electricity" class="emlab.gen.domain.technology.Substance"
		p:name="Electricity" p:quality="1" p:energyDensity="0" p:co2Density="0" />
	<bean id="co2" class="emlab.gen.domain.technology.Substance" p:name="CO2"
		p:quality="1" p:energyDensity="0" p:co2Density="1" />

	<!-- Zones -->
	<bean id="nl" class="emlab.gen.domain.gis.Zone" p:name="Country A" />
	<bean id="de" class="emlab.gen.domain.gis.Zone" p:name="Country B" />

	<!-- PowerGrid -->
	<bean id="beneluxNode" class="emlab.gen.domain.technology.PowerGridNode"
	p:capacityMultiplicationFactor="1.0">
		<property name="zone" ref="nl" />
	</bean>
	<bean id="germanNode" class="emlab.gen.domain.technology.PowerGridNode"
	p:capacityMultiplicationFactor="1.0">
		<property name="zone" ref="de" />
	</bean>

	<bean id="interconnectorBeneluxGermany" class="emlab.gen.domain.technology.Interconnector"
		p:capacity="${interconnectorCapacity}">
		<property name="connections">
			<set>
				<ref bean="germanNode" />
				<ref bean="beneluxNode" />
			</set>
		</property>
	</bean>

	<!-- Segments of load duration curves -->
	<bean id="segment1" class="emlab.gen.domain.market.electricity.Segment" p:lengthInHours="2000"
		p:segmentID="5" />
	<bean id="segment2" class="emlab.gen.domain.market.electricity.Segment" p:lengthInHours="2000"
		p:segmentID="4" />
	<bean id="segment3" class="emlab.gen.domain.market.electricity.Segment" p:lengthInHours="2000"
		p:segmentID="3" />
	<bean id="segment4" class="emlab.gen.domain.market.electricity.Segment" p:lengthInHours="2000"
		p:segmentID="2" />
	<bean id="segment5" class="emlab.gen.domain.market.electricity.Segment" p:lengthInHours="760"
		p:segmentID="1" />

	<!-- Markets -->
	<!-- Electricity Spot -->
	<bean id="beneluxElectricitySpotMarket" class="emlab.gen.domain.market.electricity.ElectricitySpotMarket"
		p:name="Country A's electricity spot market" p:auction="false"
		p:referencePrice="40" p:valueOfLostLoad="500">
		<property name="substance" ref="electricity" />
		<property name="demandGrowthTrend" ref="demandGrowthTrendNL" />
		<property name="zone" ref="nl" />

		<property name="loadDurationCurve">
			<set>
				<ref bean="segment1nl" />
				<ref bean="segment2nl" />
				<ref bean="segment3nl" />
				<ref bean="segment4nl" />
				<ref bean="segment5nl" />
			</set>
		</property>
	</bean>

	<bean id="segment1nl" class="emlab.gen.domain.market.electricity.SegmentLoad"
		p:baseLoad="${segment1nl}">
		<property name="segment" ref="segment1" />
	</bean>
	<bean id="segment2nl" class="emlab.gen.domain.market.electricity.SegmentLoad"
		p:baseLoad="${segment2nl}">
		<property name="segment" ref="segment2" />
	</bean>
	<bean id="segment3nl" class="emlab.gen.domain.market.electricity.SegmentLoad"
		p:baseLoad="${segment3nl}">
		<property name="segment" ref="segment3" />
	</bean>
	<bean id="segment4nl" class="emlab.gen.domain.market.electricity.SegmentLoad"
		p:baseLoad="${segment4nl}">
		<property name="segment" ref="segment4" />
	</bean>
	<bean id="segment5nl" class="emlab.gen.domain.market.electricity.SegmentLoad"
		p:baseLoad="${segment5nl}">
		<property name="segment" ref="segment5" />
	</bean>

	<bean id="germanElectricitySpotMarket" class="emlab.gen.domain.market.electricity.ElectricitySpotMarket"
		p:name="Country B's electricity spot market" p:auction="false"
		p:referencePrice="40" p:valueOfLostLoad="500">
		<property name="substance" ref="electricity" />
		<property name="demandGrowthTrend" ref="demandGrowthTrendDE" />
		<property name="zone" ref="de" />

		<property name="loadDurationCurve">
			<set>
				<ref bean="segment1de" />
				<ref bean="segment2de" />
				<ref bean="segment3de" />
				<ref bean="segment4de" />
				<ref bean="segment5de" />
			</set>
		</property>
	</bean>

	<bean id="segment1de" class="emlab.gen.domain.market.electricity.SegmentLoad"
		p:baseLoad="${segment1de}">
		<property name="segment" ref="segment1" />
	</bean>
	<bean id="segment2de" class="emlab.gen.domain.market.electricity.SegmentLoad"
		p:baseLoad="${segment2de}">
		<property name="segment" ref="segment2" />
	</bean>
	<bean id="segment3de" class="emlab.gen.domain.market.electricity.SegmentLoad"
		p:baseLoad="${segment3de}">
		<property name="segment" ref="segment3" />
	</bean>
	<bean id="segment4de" class="emlab.gen.domain.market.electricity.SegmentLoad"
		p:baseLoad="${segment4de}">
		<property name="segment" ref="segment4" />
	</bean>
	<bean id="segment5de" class="emlab.gen.domain.market.electricity.SegmentLoad"
		p:baseLoad="${segment5de}">
		<property name="segment" ref="segment5" />
	</bean>

	<!-- Long term contract types -->
	<bean id="ltc1" class="emlab.gen.domain.contract.LongTermContractType"
		p:name="ltc1">
		<property name="segments">
			<set>
				<ref bean="segment1" />
				<ref bean="segment2" />
				<ref bean="segment3" />
				<ref bean="segment4" />
				<ref bean="segment5" />
			</set>
		</property>
	</bean>

	<bean id="ltc2" class="emlab.gen.domain.contract.LongTermContractType"
		p:name="ltc2">
		<property name="segments">
			<set>
				<ref bean="segment2" />
				<ref bean="segment3" />
				<ref bean="segment4" />
				<ref bean="segment5" />
			</set>
		</property>
	</bean>

	<bean id="ltc3" class="emlab.gen.domain.contract.LongTermContractType"
		p:name="ltc3">
		<property name="segments">
			<set>
				<ref bean="segment3" />
				<ref bean="segment4" />
				<ref bean="segment5" />
			</set>
		</property>
	</bean>

	<bean id="ltc4" class="emlab.gen.domain.contract.LongTermContractType"
		p:name="ltc4">
		<property name="segments">
			<set>
				<ref bean="segment4" />
				<ref bean="segment5" />
			</set>
		</property>
	</bean>

	<bean id="ltc5" class="emlab.gen.domain.contract.LongTermContractType"
		p:name="ltc5">
		<property name="segments">
			<set>
				<ref bean="segment5" />
			</set>
		</property>
	</bean>

	<!-- Long term contract types -->
	<bean id="ltcDuration1" class="emlab.gen.domain.contract.LongTermContractDuration"
		p:duration="1" />
	<bean id="ltcDuration5" class="emlab.gen.domain.contract.LongTermContractDuration"
		p:duration="5" />
	<bean id="ltcDuration10" class="emlab.gen.domain.contract.LongTermContractDuration"
		p:duration="10" />

	<!-- Commodity Markets -->
	<bean id="coalMarket" class="emlab.gen.domain.market.CommodityMarket"
		p:auction="false" p:name="Coal market">
		<property name="substance" ref="coal" />
	</bean>

	<bean id="naturalgasMarket" class="emlab.gen.domain.market.CommodityMarket"
		p:auction="false" p:name="Natural gas market">
		<property name="substance" ref="naturalgas" />
	</bean>

	<bean id="biomassMarket" class="emlab.gen.domain.market.CommodityMarket"
		p:auction="false" p:name="Biomass market">
		<property name="substance" ref="biomass" />
	</bean>

	<bean id="nuclearMarket" class="emlab.gen.domain.market.CommodityMarket"
		p:auction="false" p:name="Uranium market">
		<property name="substance" ref="uranium" />
	</bean>

	<!-- CO2 Auction -->
	<bean id="co2Auction" class="emlab.gen.domain.market.CO2Auction"
		p:auction="true" p:referencePrice="0" p:name="CO2 auction"
		p:substance-ref="co2" />

	<!-- Fuel Prices -->
	<bean id="coalPrice" class="emlab.gen.trend.TimeSeriesCSVReader" p:filename="/data/exampleCoalSingleColumn.csv" />
	<bean id="gasPrice" class="emlab.gen.trend.TimeSeriesCSVReader" p:filename="/data/exampleMultipleTimeSeries.csv" p:delimiter="," p:variableName="gasPrice" />
	<bean id="biomassPrice" class="emlab.gen.trend.TimeSeriesPropReader" p:timeSeriesStr="112.5,113.625,114.76125,115.9088625,117.067951125,118.2386306363,119.4210169426,120.615227112,121.8213793832,123.039593177,124.2699891088,125.5126889998,126.7678158898,128.0354940487,129.3158489892,130.6090074791,131.9150975539,133.2342485295,134.5665910148,135.9122569249,137.2713794941,138.6440932891,140.030534222,141.4308395642,142.8451479598,144.2735994394,145.7163354338,147.1734987882,148.6452337761,150.1316861138,151.633002975,153.1493330047,154.6808263347,156.2276345981,157.7899109441,159.3678100535,160.9614881541,162.5711030356,164.196814066,165.8387822066,167.4971700287,169.172141729,170.8638631463,172.5725017777,174.2982267955,176.0412090634,177.8016211541,179.5796373656,181.3754337393,183.1891880767,185.0210799574,186.871290757,188.7400036646,190.6274037012,192.5336777382,194.4590145156,196.4036046608,198.3676407074,200.3513171145,202.3548302856,204.3783785885" />
	<bean id="uraniumPrice" class="emlab.gen.trend.TimeSeriesPropReader" p:timeSeriesStr="${uraniumSeries}" />

	<!-- Agents -->
	<bean id="coalSupplier" class="emlab.gen.domain.agent.CommoditySupplier">
		<property name="name" value="Coal supplier" />
		<property name="substance" ref="coal" />
		<property name="priceOfCommodity" ref="coalPrice" />
	</bean>

	<bean id="gasSupplier" class="emlab.gen.domain.agent.CommoditySupplier">
		<property name="name" value="Gas supplier" />
		<property name="substance" ref="naturalgas" />
		<property name="priceOfCommodity" ref="gasPrice" />
	</bean>

	<bean id="biomassSupplier" class="emlab.gen.domain.agent.CommoditySupplier">
		<property name="name" value="Biomass supplier" />
		<property name="substance" ref="biomass" />
		<property name="priceOfCommodity" ref="biomassPrice" />
	</bean>

	<bean id="uraniumSupplier" class="emlab.gen.domain.agent.CommoditySupplier">
		<property name="name" value="Uranium supplier" />
		<property name="substance" ref="uranium" />
		<property name="priceOfCommodity" ref="uraniumPrice" />
	</bean>

	<bean id="energyConsumer" class="emlab.gen.domain.agent.EnergyConsumer"
		p:ltcMaximumCoverageFraction="0.8" p:contractDurationPreferenceFactor=".03"
		p:contractWillingnessToPayFactor="1.2">
		<property name="name" value="Energy consumer" />
	</bean>

	<bean id="energyProducerA" class="emlab.gen.domain.agent.EnergyProducer"
		p:name="Energy Producer A" p:cash="${startCash}"
		p:investmentRole-ref="standardInvestmentRole"
		p:longTermContractMargin="0.1" p:longTermContractPastTimeHorizon="3"
		p:investmentFutureTimeHorizon="10" p:pastTimeHorizon="5"
		p:equityInterestRate="0.12" p:loanInterestRate="0.09"
		p:debtRatioOfInvestments="0.7"
		p:dismantlingProlongingYearsAfterTechnicalLifetime="0"
		p:dismantlingRequiredOperatingProfit="0" p:downpaymentFractionOfCash="0.5"
		p:willingToInvest="true" p:priceMarkUp="${priceMarkUp}"
		p:numberOfYearsBacklookingForForecasting="${numberOfYearsBacklookingForForecasting}"
		p:investorMarket-ref="germanElectricitySpotMarket"/>
	<bean id="energyProducerB" class="emlab.gen.domain.agent.EnergyProducer"
		p:name="Energy Producer B" p:cash="${startCash}"
		p:investmentRole-ref="standardInvestmentRole"
		p:longTermContractMargin="0.1" p:longTermContractPastTimeHorizon="3"
		p:investmentFutureTimeHorizon="10" p:pastTimeHorizon="5"
		p:equityInterestRate="0.12" p:loanInterestRate="0.09"
		p:debtRatioOfInvestments="0.7"
		p:dismantlingProlongingYearsAfterTechnicalLifetime="0"
		p:dismantlingRequiredOperatingProfit="0" p:downpaymentFractionOfCash="0.5"
		p:willingToInvest="true" p:priceMarkUp="${priceMarkUp}"
		p:numberOfYearsBacklookingForForecasting="${numberOfYearsBacklookingForForecasting}"
		p:investorMarket-ref="germanElectricitySpotMarket"/>
	<bean id="energyProducerC" class="emlab.gen.domain.agent.EnergyProducer"
		p:investmentRole-ref="standardInvestmentRole"
		p:name="Energy Producer C" p:cash="${startCash}"
		p:longTermContractMargin="0.1" p:longTermContractPastTimeHorizon="3"
		p:investmentFutureTimeHorizon="10" p:pastTimeHorizon="5"
		p:equityInterestRate="0.12" p:loanInterestRate="0.09"
		p:debtRatioOfInvestments="0.7"
		p:dismantlingProlongingYearsAfterTechnicalLifetime="0"
		p:dismantlingRequiredOperatingProfit="0" p:downpaymentFractionOfCash="0.5"
		p:willingToInvest="true" p:priceMarkUp="${priceMarkUp}"
		p:numberOfYearsBacklookingForForecasting="${numberOfYearsBacklookingForForecasting}"
		p:investorMarket-ref="germanElectricitySpotMarket"/>
	<bean id="energyProducerD" class="emlab.gen.domain.agent.EnergyProducer"
		p:investmentRole-ref="standardInvestmentRole"
		p:name="Energy Producer D" p:cash="${startCash}"
		p:longTermContractMargin="0.1" p:longTermContractPastTimeHorizon="3"
		p:investmentFutureTimeHorizon="10" p:pastTimeHorizon="5"
		p:equityInterestRate="0.12" p:loanInterestRate="0.09"
		p:debtRatioOfInvestments="0.7"
		p:dismantlingProlongingYearsAfterTechnicalLifetime="0"
		p:dismantlingRequiredOperatingProfit="0" p:downpaymentFractionOfCash="0.5"
		p:willingToInvest="true" p:priceMarkUp="${priceMarkUp}"
		p:numberOfYearsBacklookingForForecasting="${numberOfYearsBacklookingForForecasting}"
		p:investorMarket-ref="germanElectricitySpotMarket"/>
	<bean id="energyProducerE" class="emlab.gen.domain.agent.EnergyProducer"
		p:investmentRole-ref="standardInvestmentRole"
		p:name="Energy Producer E" p:cash="${startCash}"
		p:longTermContractMargin="0.1" p:longTermContractPastTimeHorizon="3"
		p:investmentFutureTimeHorizon="10" p:pastTimeHorizon="5"
		p:equityInterestRate="0.12" p:loanInterestRate="0.09"
		p:debtRatioOfInvestments="0.7"
		p:dismantlingProlongingYearsAfterTechnicalLifetime="0"
		p:dismantlingRequiredOperatingProfit="0" p:downpaymentFractionOfCash="0.5"
		p:willingToInvest="true" p:priceMarkUp="${priceMarkUp}"
		p:numberOfYearsBacklookingForForecasting="${numberOfYearsBacklookingForForecasting}"
		p:investorMarket-ref="germanElectricitySpotMarket"/>
	<bean id="energyProducerF" class="emlab.gen.domain.agent.EnergyProducer"
		p:name="Energy Producer F" p:cash="${startCash}"
		p:investmentRole-ref="standardInvestmentRole"
		p:longTermContractMargin="0.1" p:longTermContractPastTimeHorizon="3"
		p:investmentFutureTimeHorizon="10" p:pastTimeHorizon="5"
		p:equityInterestRate="0.12" p:loanInterestRate="0.09"
		p:debtRatioOfInvestments="0.7"
		p:dismantlingProlongingYearsAfterTechnicalLifetime="0"
		p:dismantlingRequiredOperatingProfit="0" p:downpaymentFractionOfCash="0.5"
		p:willingToInvest="true" p:priceMarkUp="${priceMarkUp}"  p:numberOfYearsBacklookingForForecasting="${numberOfYearsBacklookingForForecasting}"
		p:investorMarket-ref="beneluxElectricitySpotMarket"/>
	<bean id="energyProducerG" class="emlab.gen.domain.agent.EnergyProducer"
		p:name="Energy Producer G" p:cash="${startCash}"
		p:investmentRole-ref="standardInvestmentRole"
		p:longTermContractMargin="0.1" p:longTermContractPastTimeHorizon="3"
		p:investmentFutureTimeHorizon="10" p:pastTimeHorizon="5"
		p:equityInterestRate="0.12" p:loanInterestRate="0.09"
		p:debtRatioOfInvestments="0.7"
		p:dismantlingProlongingYearsAfterTechnicalLifetime="0"
		p:dismantlingRequiredOperatingProfit="0" p:downpaymentFractionOfCash="0.5"
		p:willingToInvest="true" p:priceMarkUp="${priceMarkUp}"  p:numberOfYearsBacklookingForForecasting="${numberOfYearsBacklookingForForecasting}"
		p:investorMarket-ref="beneluxElectricitySpotMarket"/>
	<bean id="energyProducerH" class="emlab.gen.domain.agent.EnergyProducer"
		p:name="Energy Producer H" p:cash="${startCash}"
		p:investmentRole-ref="standardInvestmentRole"
		p:longTermContractMargin="0.1" p:longTermContractPastTimeHorizon="3"
		p:investmentFutureTimeHorizon="10" p:pastTimeHorizon="5"
		p:equityInterestRate="0.12" p:loanInterestRate="0.09"
		p:debtRatioOfInvestments="0.7"
		p:dismantlingProlongingYearsAfterTechnicalLifetime="0"
		p:dismantlingRequiredOperatingProfit="0" p:downpaymentFractionOfCash="0.5"
		p:willingToInvest="true" p:priceMarkUp="${priceMarkUp}"
		p:numberOfYearsBacklookingForForecasting="${numberOfYearsBacklookingForForecasting}"
		p:investorMarket-ref="beneluxElectricitySpotMarket"/>
	<bean id="energyProducerI" class="emlab.gen.domain.agent.EnergyProducer"
		p:name="Energy Producer I" p:cash="${startCash}"
		p:investmentRole-ref="standardInvestmentRole"
		p:longTermContractMargin="0.1" p:longTermContractPastTimeHorizon="3"
		p:investmentFutureTimeHorizon="10" p:pastTimeHorizon="5"
		p:equityInterestRate="0.12" p:loanInterestRate="0.09"
		p:debtRatioOfInvestments="0.7"
		p:dismantlingProlongingYearsAfterTechnicalLifetime="0"
		p:dismantlingRequiredOperatingProfit="0" p:downpaymentFractionOfCash="0.5"
		p:willingToInvest="true" p:priceMarkUp="${priceMarkUp}"
		p:numberOfYearsBacklookingForForecasting="${numberOfYearsBacklookingForForecasting}"
		p:investorMarket-ref="beneluxElectricitySpotMarket"/>

	<bean id="standardInvestmentRole" class="emlab.gen.role.investment.InvestInPowerGenerationTechnologiesRole"/>

	<bean id="powerPlantManufacturer" class="emlab.gen.domain.agent.PowerPlantManufacturer"
		p:name="Power Plant Manufacturer" />
	<bean id="bigBank" class="emlab.gen.domain.agent.BigBank" p:name="Big Bank" />
	<bean id="powerPlantMaintainer" class="emlab.gen.domain.agent.PowerPlantMaintainer"
		p:name="Power Plant Maintainer" />

	<bean id="beneluxPowerPortfolio" class="emlab.gen.domain.factory.ElectricityProducerFactory">
		<property name="capacityMargin" value="0.25" />
		<property name="portfolioShares">
			<map>
				<entry>
					<key>
						<ref bean="coalPulverized" />
					</key>
					<value>0.33</value>
				</entry>
				<entry>
					<key>
						<ref bean="gasConventional" />
					</key>
					<value>0.56</value>
				</entry>
				<entry>
					<key>
						<ref bean="biomassPGT" />
					</key>
					<value>0.01</value>
				</entry>
				<entry>
					<key>
						<ref bean="nuclearPGT" />
					</key>
					<value>0.03</value>
				</entry>
				<entry>
					<key>
						<ref bean="windPGT" />
					</key>
					<value>0.07</value>
				</entry>
			</map>
		</property>
		<property name="nodes">
			<set>
				<ref bean="beneluxNode" />
			</set>
		</property>
		<property name="market" ref="beneluxElectricitySpotMarket" />
		<property name="producers">
			<list>
				<ref bean="energyProducerF" />
				<ref bean="energyProducerG" />
				<ref bean="energyProducerH" />
				<ref bean="energyProducerI" />
			</list>
		</property>
	</bean>

	<bean id="germanPowerPortfolio" class="emlab.gen.domain.factory.ElectricityProducerFactory">
		<property name="capacityMargin" value="0.25" />
		<property name="portfolioShares">
			<map>
				<entry>
					<key>
						<ref bean="coalPulverized" />
					</key>
					<value>0.45</value>
				</entry>
				<entry>
					<key>
						<ref bean="gasConventional" />
					</key>
					<value>0.20</value>
				</entry>
				<entry>
					<key>
						<ref bean="biomassPGT" />
					</key>
					<value>0.05</value>
				</entry>
				<entry>
					<key>
						<ref bean="nuclearPGT" />
					</key>
					<value>0.20</value>
				</entry>
				<entry>
					<key>
						<ref bean="windPGT" />
					</key>
					<value>0.10</value>
				</entry>
			</map>
		</property>
		<property name="nodes">
			<set>
				<ref bean="germanNode" />
			</set>
		</property>
		<property name="market" ref="germanElectricitySpotMarket" />
		<property name="producers">
			<list>
				<ref bean="energyProducerA" />
				<ref bean="energyProducerB" />
				<ref bean="energyProducerC" />
				<ref bean="energyProducerD" />
				<ref bean="energyProducerE" />
			</list>
		</property>
	</bean>

	<!-- CO2 Tax -->
	<bean id="co2TaxTrend" class="emlab.gen.trend.StepTrend" p:start="${co2TaxStart}"
		p:duration="${co2TaxDuration}" p:increment="${co2TaxIncrement}"
		p:minValue="0" />

	<!-- CO2 Cap -->
	<bean id="co2CapTrend" class="emlab.gen.trend.StepTrend" p:start="${co2CapStart}"
		p:duration="${co2CapDuration}" p:increment="${co2CapIncrement}"
		p:minValue="0" />

	<!-- Minimum CO2 Price -->
	<bean id="minCo2PriceTrend" class="emlab.gen.trend.StepTrend" p:start="${minCo2PriceStart}"
		p:duration="${minCo2PriceDuration}" p:increment="${minCo2PriceIncrement}"
		p:minValue="0" />

	<bean id="minCo2PriceTrendNL" class="emlab.gen.trend.StepTrend" p:start="0"
		p:duration="1" p:increment="0"
		p:minValue="0" />

	<bean id="minCo2PriceTrendDE" class="emlab.gen.trend.StepTrend" p:start="0"
		p:duration="1" p:increment="2"
		p:minValue="0" />

	<!-- Government -->
	<bean id="government" class="emlab.gen.domain.agent.Government"
		p:name="European Government" p:co2Penalty="500">
		<property name="co2TaxTrend" ref="co2TaxTrend" />
		<property name="co2CapTrend" ref="co2CapTrend" />
		<property name="minCo2PriceTrend" ref="minCo2PriceTrend" />
	</bean>

		<bean id="governmentNL" class="emlab.gen.domain.agent.NationalGovernment"
		p:name="Country A Government">
		<property name="minNationalCo2PriceTrend" ref="minCo2PriceTrendNL" />
		<property name="governedZone" ref="nl" />
	</bean>

	<bean id="governmentDE" class="emlab.gen.domain.agent.NationalGovernment"
		p:name="Country B Government">
		<property name="minNationalCo2PriceTrend" ref="minCo2PriceTrendDE" />
		<property name="governedZone" ref="de" />
	</bean>

	<!-- Strategic Reserve -->

	<bean id="strategicReserveOperator1" class="emlab.gen.domain.agent.StrategicReserveOperator"
		p:name="StrategicReserveOperatorNL" p:cash="1000" p:reservePriceSR="1500"
		p:reserveVolumePercentSR="0.1">
		<property name="zone" ref="nl" />
	</bean>

	<bean id="strategicReserveOperator2" class="emlab.gen.domain.agent.StrategicReserveOperator"
		p:name="StrategicReserveOperatorDE" p:cash="1000" p:reservePriceSR="1200"
		p:reserveVolumePercentSR="0.1">
		<property name="zone" ref="de" />
	</bean>

	<!-- Power Genration Technologies -->

	<bean id="coalPulverized" class="emlab.gen.domain.technology.PowerGeneratingTechnology"
		p:name="CoalPulverized" p:capacity="758"
		p:co2CaptureEffciency="0"
		p:investmentCostTimeSeries-ref="coalPulverizedInvestmentCostTimeSeries"
		p:fixedOperatingCostTimeSeries-ref="coalPulverizedFixedOperatingCostTimeSeries"
		p:efficiencyTimeSeries-ref="coalPulverizedEfficiencyTimeSeries"
		p:depreciationTime="20" p:minimumRunningHours="5000"
		p:fixedOperatingCostModifierAfterLifetime=".05" p:expectedLifetime="40"
		p:expectedLeadtime="4" p:expectedPermittime="1" p:minimumFuelQuality=".9"
		p:maximumInstalledCapacityFractionInCountry="1"
		p:maximumInstalledCapacityFractionPerAgent="1"
		p:baseSegmentDependentAvailability="1"
		p:peakSegmentDependentAvailability="1"
		p:applicableForLongTermContract="true"
		p:intermittent="false">
		<property name="fuels">
			<set>
				<ref bean="coal" />
				<ref bean="biomass" />
			</set>
		</property>
	</bean>

	<bean id="coalPulverizedInvestmentCostTimeSeries" class="emlab.gen.trend.GeometricTrend" p:growthRate="-0.01" p:start="1509626.1442" />
	<bean id="coalPulverizedFixedOperatingCostTimeSeries" class="emlab.gen.trend.GeometricTrend" p:growthRate="0" p:start="61320" />
	<bean id="coalPulverizedEfficiencyTimeSeries" class="emlab.gen.trend.GeometricTrend" p:growthRate="0.004" p:start=".44" />

	<bean id="coalPulverizedCSS" class="emlab.gen.domain.technology.PowerGeneratingTechnology"
		p:name="CoalPulverizedCSS" p:capacity="676"
		p:co2CaptureEffciency="0"
		p:investmentCostTimeSeries-ref="coalPulverizedCSSInvestmentCostTimeSeries"
		p:fixedOperatingCostTimeSeries-ref="coalPulverizedCSSFixedOperatingCostTimeSeries"
		p:efficiencyTimeSeries-ref="coalPulverizedCSSEfficiencyTimeSeries"
		p:depreciationTime="20" p:minimumRunningHours="5000"
		p:fixedOperatingCostModifierAfterLifetime=".05" p:expectedLifetime="40"
		p:expectedLeadtime="7" p:expectedPermittime="1" p:minimumFuelQuality=".9"
		p:maximumInstalledCapacityFractionInCountry="1"
		p:maximumInstalledCapacityFractionPerAgent="1"
		p:baseSegmentDependentAvailability="1"
		p:peakSegmentDependentAvailability="1"
		p:applicableForLongTermContract="true"
		p:intermittent="false">
		<property name="fuels">
			<set>
				<ref bean="coal" />
				<ref bean="biomass" />
			</set>
		</property>
	</bean>

	<bean id="coalPulverizedCSSInvestmentCostTimeSeries" class="emlab.gen.trend.GeometricTrend" p:growthRate="-0.01" p:start="2650699.492" />
	<bean id="coalPulverizedCSSFixedOperatingCostTimeSeries" class="emlab.gen.trend.GeometricTrend" p:growthRate="0" p:start="105120" />
	<bean id="coalPulverizedCSSEfficiencyTimeSeries" class="emlab.gen.trend.GeometricTrend" p:growthRate="0.005" p:start=".35" />

	<bean id="gasConventional" class="emlab.gen.domain.technology.PowerGeneratingTechnology"
		p:name="GasConventional" p:capacity="776"
		p:co2CaptureEffciency="0"
		p:investmentCostTimeSeries-ref="gasConventionalInvestmentCostTimeSeries"
		p:fixedOperatingCostTimeSeries-ref="gasConventionalFixedOperatingCostTimeSeries"
		p:efficiencyTimeSeries-ref="gasConventionalEfficiencyTimeSeries"
		p:depreciationTime="15" p:minimumRunningHours="0"
		p:fixedOperatingCostModifierAfterLifetime=".05" p:expectedLifetime="30"
		p:expectedLeadtime="2" p:expectedPermittime="1" p:minimumFuelQuality="1"
		p:maximumInstalledCapacityFractionInCountry="1"
		p:maximumInstalledCapacityFractionPerAgent="1"
		p:baseSegmentDependentAvailability="1"
		p:peakSegmentDependentAvailability="1"
		p:applicableForLongTermContract="true"
		p:intermittent="false">
		<property name="fuels">
			<set>
				<ref bean="naturalgas" />
			</set>
		</property>
	</bean>

	<bean id="gasConventionalInvestmentCostTimeSeries" class="emlab.gen.trend.GeometricTrend" p:growthRate="-0.01" p:start="522793.2789" />
	<bean id="gasConventionalFixedOperatingCostTimeSeries" class="emlab.gen.trend.GeometricTrend" p:growthRate="0" p:start="17520" />
	<bean id="gasConventionalEfficiencyTimeSeries" class="emlab.gen.trend.GeometricTrend" p:growthRate="0.004" p:start=".56" />

	<bean id="biomassPGT" class="emlab.gen.domain.technology.PowerGeneratingTechnology"
		p:name="Biomass" p:capacity="500"
		p:co2CaptureEffciency="0"
		p:investmentCostTimeSeries-ref="biomassPGTInvestmentCostTimeSeries"
		p:fixedOperatingCostTimeSeries-ref="biomassPGTFixedOperatingCostTimeSeries"
		p:efficiencyTimeSeries-ref="biomassPGTEfficiencyTimeSeries"
		p:depreciationTime="15" p:minimumRunningHours="0"
		p:fixedOperatingCostModifierAfterLifetime=".05" p:expectedLifetime="30"
		p:expectedLeadtime="3" p:expectedPermittime="1" p:minimumFuelQuality="0.5"
		p:maximumInstalledCapacityFractionInCountry="1"
		p:maximumInstalledCapacityFractionPerAgent="1"
		p:baseSegmentDependentAvailability="1"
		p:peakSegmentDependentAvailability="1"
		p:applicableForLongTermContract="true"
		p:intermittent="false">
		<property name="fuels">
			<set>
				<ref bean="biomass" />
			</set>
		</property>
	</bean>

	<bean id="biomassPGTInvestmentCostTimeSeries" class="emlab.gen.trend.GeometricTrend" p:growthRate="-0.01" p:start="2500006.773" />
	<bean id="biomassPGTFixedOperatingCostTimeSeries" class="emlab.gen.trend.GeometricTrend" p:growthRate="0" p:start="35040" />
	<bean id="biomassPGTEfficiencyTimeSeries" class="emlab.gen.trend.GeometricTrend" p:growthRate="0.005" p:start=".35" />

	<bean id="windPGT" class="emlab.gen.domain.technology.PowerGeneratingTechnology"
		p:name="Wind" p:capacity="150"
		p:co2CaptureEffciency="0"
		p:investmentCostTimeSeries-ref="windPGTInvestmentCostTimeSeries"
		p:fixedOperatingCostTimeSeries-ref="windPGTFixedOperatingCostTimeSeries"
		p:efficiencyTimeSeries-ref="windPGTEfficiencyTimeSeries"
		p:depreciationTime="15" p:minimumRunningHours="0"
		p:fixedOperatingCostModifierAfterLifetime=".05" p:expectedLifetime="25"
		p:expectedLeadtime="2" p:expectedPermittime="1" p:minimumFuelQuality="1"
		p:maximumInstalledCapacityFractionInCountry="1"
		p:maximumInstalledCapacityFractionPerAgent="1"
		p:baseSegmentDependentAvailability="0.75"
		p:peakSegmentDependentAvailability="0.05"
		p:applicableForLongTermContract="false"
		p:intermittent="false" />

	<bean id="windPGTInvestmentCostTimeSeries" class="emlab.gen.trend.GeometricTrend" p:growthRate="-0.01" p:start="7666646.871" />
	<bean id="windPGTFixedOperatingCostTimeSeries" class="emlab.gen.trend.GeometricTrend" p:growthRate="0" p:start="26280" />
	<bean id="windPGTEfficiencyTimeSeries" class="emlab.gen.trend.GeometricTrend" p:growthRate="0" p:start="1" />

	<bean id="nuclearPGT" class="emlab.gen.domain.technology.PowerGeneratingTechnology"
		p:name="Nuclear" p:capacity="1000"
		p:co2CaptureEffciency="0"
		p:investmentCostTimeSeries-ref="nuclearPGTInvestmentCostTimeSeries"
		p:fixedOperatingCostTimeSeries-ref="nuclearPGTFixedOperatingCostTimeSeries"
		p:efficiencyTimeSeries-ref="nuclearPGTEfficiencyTimeSeries"
		p:depreciationTime="25" p:minimumRunningHours="5000"
		p:fixedOperatingCostModifierAfterLifetime=".05" p:expectedLifetime="40"
		p:expectedLeadtime="7" p:expectedPermittime="2" p:minimumFuelQuality="1"
		p:maximumInstalledCapacityFractionInCountry="1"
		p:maximumInstalledCapacityFractionPerAgent="1"
		p:baseSegmentDependentAvailability="1"
		p:peakSegmentDependentAvailability="1"
		p:applicableForLongTermContract="true"
		p:intermittent="false">
		<property name="fuels">
			<set>
				<ref bean="uranium" />
			</set>
		</property>
	</bean>

	<bean id="nuclearPGTInvestmentCostTimeSeries" class="emlab.gen.trend.GeometricTrend" p:growthRate="-0.01" p:start="2996796.244" />
	<bean id="nuclearPGTFixedOperatingCostTimeSeries" class="emlab.gen.trend.GeometricTrend" p:growthRate="0" p:start="43800" />
	<bean id="nuclearPGTEfficiencyTimeSeries" class="emlab.gen.trend.GeometricTrend" p:growthRate="0" p:start=".3" />

	<!-- Parameter file -->
	<bean id="projectPropertyConfigurer"
		class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
		<property name="location"
			value="classpath:scenarios/parametersA-Old.properties" />
	</bean>

</beans>


text:
namespace net {
class NetLog;
};

namespace media {
namespace cast {
namespace test {

// A single UDP packet.
// Technically, our UDP proxy should really chop UDP packets
// into MTU-sized chunks and then do all the horribly things it
// does to those chunks, but since cast *should* normally only
// send packets that are sized below the MTU limit, we should
// be able to ignore that.
struct Packet : public base::RefCountedThreadSafe<Packet> {
  explicit Packet(size_t size);
  std::vector<unsigned char> data;
 private:
  friend class base::RefCountedThreadSafe<Packet>;
  ~Packet();
};

class PacketPipe {
 public:
  PacketPipe();
  virtual ~PacketPipe();
  virtual void Send(scoped_refptr<Packet> packet) = 0;
  virtual void InitOnIOThread();
  virtual void AppendToPipe(scoped_ptr<PacketPipe> pipe);
 protected:
  scoped_ptr<PacketPipe> pipe_;
};

// A UDPProxy will set up a UDP socket and bind to |local_port|.
// Packets send to that port will be forwarded to |destination|.
// Packets send from |destination| to |local_port| will be returned
// to whoever sent a packet to |local_port| last. (Not counting packets
// from |destination|.) The UDPProxy will run a separate thread to
// do the forwarding of packets, and will keep doing so until destroyed.
// You can insert delays and packet drops by supplying a PacketPipe.
// The PacketPipes may also be NULL if you just want to forward packets.
class UDPProxy {
 public:
  virtual ~UDPProxy() {}
  static scoped_ptr<UDPProxy> Create(const net::IPEndPoint& local_port,
                                     const net::IPEndPoint& destination,
                                     scoped_ptr<PacketPipe> to_dest_pipe,
                                     scoped_ptr<PacketPipe> from_dest_pipe,
                                     net::NetLog* net_log);
};

// The following functions create PacketPipes which can be linked
// together (with AppendToPipe) and passed into UdpProxy::Create below.

// This PacketPipe emulates a buffer of a given size. Limits our output
// from the buffer at a rate given by |bandwidth| (in megabits per second).
// Packets entering the buffer will be dropped if there is not enough
// room for them.
scoped_ptr<PacketPipe> NewBuffer(size_t buffer_size, double bandwidth);

// Randomly drops |drop_fraction|*100% of packets.
scoped_ptr<PacketPipe> NewRandomDrop(double drop_fraction);

// Delays each packet by |delay_seconds|.
scoped_ptr<PacketPipe> NewConstantDelay(double delay_seconds);

// Delays packets by a random amount between zero and |delay|.
// This PacketPipe can reorder packets.
scoped_ptr<PacketPipe> NewRandomUnsortedDelay(double delay);

// This PacketPipe inserts a random delay between each packet.
// This PacketPipe cannot re-order packets. The delay between each
// packet is asically |min_delay| + random( |random_delay| )
// However, every now and then a delay of |big_delay| will be
// inserted (roughly every |seconds_between_big_delay| seconds).
scoped_ptr<PacketPipe> NewRandomSortedDelay(double random_delay,
                                            double big_delay,
                                            double seconds_between_big_delay);

// This PacketPipe emulates network outages. It basically waits
// for 0-2*|average_work_time| seconds, then kills the network for
// 0-|2*average_outage_time| seconds. Then it starts over again.
scoped_ptr<PacketPipe> NewNetworkGlitchPipe(double average_work_time,
                                            double average_outage_time);

// This method builds a stack of PacketPipes to emulate a reasonably
// good wifi network. ~5mbit, 1% packet loss, ~3ms latency.
scoped_ptr<PacketPipe> WifiNetwork();

// This method builds a stack of PacketPipes to emulate a crappy wifi network.
// ~1mbit, 20% packet loss, ~40ms latency and packets can get reordered.
scoped_ptr<PacketPipe> EvilNetwork();

}  // namespace test
}  // namespace cast
}  // namespace media

#endif  // MEDIA_CAST_TEST_UTILITY_UDP_PROXY_H_

redpajama_set_name: RedPajamaGithub


text:
//
//  reverseString.h
//  Blank Project
//
//  Created by Hongsen Liu on 4/23/13.
//
//

#ifndef __Blank_Project__reverseString__
#define __Blank_Project__reverseString__

#include <iostream>
#include <string>

std::string reverseString(std::string s);

#endif /* defined(__Blank_Project__reverseString__) */


text:
var express = require('express');
var bodyParser = require('body-parser');

module.exports  =function(){
  console.log('init expesss...');
  var app = express();

  app.use(bodyParser.json());
  app.use(express.static("./public"));

  // 利用中间件,将数据集合附加到请求对象中
  app.use(function(req, res, next){
    req.models = app.get('models');

    next();
  });

  require('../app/routes/post.server.routes')(app);
  //require('../app/routes/news.server.routes')(app);

  // 处理所有未知的请求
  app.use(function(req, res, next){
    res.status(404);
    try {
      return res.json('Not Found');
    } catch(e) {
      console.error('404 set header after sent');
    }
  });

  // 统一处理出错的情况
  app.use(function(err, req, res, next){
    if(!err) {return next()}
    res.status(500);
    try {
      return res.json(err.message || 'server error');
    } catch(e) {
      console.error('500 set header after sent');
    }
  });

  return app;
};


text:
ROOT = ../../../../..

DIR = Providers/ManagedSystem/UNIXProviders/ComponentCS

include $(ROOT)/mak/config.mak

LIBRARY = UNIX_ComponentCS

EXTRA_INCLUDES += -I/usr/local/include -I./..

SOURCES = \
	../CIMHelper.cpp \
	UNIX_ComponentCS.cpp \
	UNIX_ComponentCSProvider.cpp \
	UNIX_ComponentCSMain.cpp
ifeq ($(OS), aix)
	SOURCES += UNIX_ComponentCS_AIX.cpp
endif
ifeq ($(OS), darwin)
	SOURCES += UNIX_ComponentCS_DARWIN.cpp
endif
ifeq ($(OS), freebsd)
	SOURCES += UNIX_ComponentCS_FREEBSD.cpp
endif
ifeq ($(OS), hpux)
	SOURCES += UNIX_ComponentCS_HPUX.cpp
endif
ifeq ($(OS), linux)
	SOURCES += UNIX_ComponentCS_LINUX.cpp
endif
ifeq ($(OS), solaris)
	SOURCES += UNIX_ComponentCS_SOLARIS.cpp
endif
ifeq ($(OS), tru64)
	SOURCES += UNIX_ComponentCS_TRU64.cpp
endif
ifeq ($(OS), vms)
	SOURCES += UNIX_ComponentCS_VMS.cpp
endif
ifeq ($(OS), win32)
	SOURCES += UNIX_ComponentCS_WIN32.cpp
endif
ifeq ($(OS), zos)
	SOURCES += UNIX_ComponentCS_ZOS.cpp
endif
ifeq (, $(filter aix,darwin,freebsd,hpux,linux,solaris,tru64,vms,win32,zos $(OS)))

else
	SOURCES += UNIX_ComponentCS_STUB.cpp
endif

LIBRARIES = \
	pegprovider \
	pegclient \
	pegcommon \
	pegquerycommon \
	pegqueryexpression \
	pegcql \
	pegwql

EXTRA_LIBRARIES = \
	-pthread \
	-lutil \
	-lgeom \
	-lkvm \
	-lcam

include $(ROOT)/mak/dynamic-library.mak


text:
import os

from flask import session, redirect, url_for, escape, request, render_template
from piculiar import app
from db import execute, query, fetch

@app.route("/")
def home():
	return redirect(url_for('login'))

@app.route("/signup", methods=["GET", "POST"])
def signup():
	if request.method == "POST":
		# Save user info to database
		name = request.form["username"]
		email = request.form["email"]
		pwd = request.form["pwd"]
		confirm_pwd = request.form["confirm_pwd"]

		if name != "" and email != "" and pwd != "" and pwd == confirm_pwd:
			# SELECT * FROM users WHERE email LIKE ? LIMIT 1
			create_user_sql = "INSERT INTO users (name, email, pwd) VALUES (%s, %s, md5(%s));"
			params = (name, email, pwd)

			execute(create_user_sql, params)

			select_new_user = "SELECT MAX(id) FROM users;"
			result = fetch(select_new_user)

			session["user_id"] = result[0]

			return redirect(url_for("profile"))
	else:
		# Show sign-up page
		return render_template("signup.html")

@app.route("/login", methods=["GET", "POST"])
def login():
	if request.method == "POST":
		# Starting session for user
		email = request.form["username"]
		pwd = request.form["pwd"]

		if email != "" and pwd != "":
			sql = "SELECT id FROM users WHERE name LIKE %s AND pwd LIKE md5(%s) LIMIT 1;"
			params = (email, pwd)
			result = fetch(sql, params)

			session["user_id"] = result[0]

			return redirect(url_for("profile"))
	else:
		# Show sign-up page
		return render_template("login.html")

@app.route("/logout", methods=["POST"])
def logout():
	if request.method == "POST":
		# Destroy user session
		session.pop("user_id", None)

		return redirect(url_for("login"))

@app.route("/profile", methods=["GET", "POST", "DELETE"])
def profile():
	select_user_sql = "SELECT name, email FROM users WHERE id=%s;"
	user_info = fetch(select_user_sql, session["user_id"]) # 0: name, 1: email

	if request.method == "POST":
		# Update user information
		name = request.form["username"]
		email = request.form["email"]

		if name != "" and email != "":
			# SELECT * FROM users WHERE email LIKE ? LIMIT 1
			update_user_sql = "UPDATE users SET name=%s, email=%s WHERE id=%s;"
			update_user_params = (name, email, session["user_id"])

			execute(update_user_sql, update_user_params)

			return redirect(url_for("profile"))
	elif request.method == "DELETE":
		# Delete user information (and images)
		# DELETE FROM images WHERE user_id=?;
		delete_user_sql = "DELETE FROM users WHERE id=%s;"

		execute(delete_user_sql, session["user_id"])

		session.pop("user_id", None)

		return redirect(url_for("signup"))
	else:
		# Show profile information
		return render_template("profile.html", name=user_info[0], email=user_info[1])

# i.e. www.picflick.com/profile/password
@app.route("/profile/password", methods=["POST"])
def password():
	if request.method == "POST":
		# Update user password
		pwd = request.form["pwd"]
		confirm_pwd = request.form["pwd_confirm"]

		if pwd != "" and pwd == confirm_pwd:
			sql = "UPDATE users SET pwd=md5(%s) WHERE id=%s;"
			params = (pwd, session["user_id"])

			execute(sql, params)

			return redirect(url_for("profile"))
		else:
			return render_template("profile.html")

def allowed_file(filename):
	allowed_extensions = set(["jpg", "jpeg", "png", "gif"])

	return '.' in filename and filename.rsplit('.', 1)[1] in allowed_extensions

# i.e. www.picflick.com/upload
@app.route("/upload", methods=["GET", "POST"])
def upload():
	if request.method == "POST":
		# Upload image to server
		file = request.files["image"]
		if file and allowed_file(file.filename):
			sql = """INSERT INTO images (user_id, file_name, year_created, month_created)
				VALUES (%s, %s, YEAR(NOW()), MONTHNAME(NOW()));"""
			params = (session["user_id"], file.filename)

			execute(sql, params)

			select_new_image = "SELECT id, year_created, month_created FROM images WHERE user_id=%s ORDER BY id DESC LIMIT 1;"
			image_info = fetch(select_new_image, session["user_id"])

			upload_folder = app.config["UPLOAD_FOLDER"]
			year_folder = upload_folder + "/" + image_info[1]
			month_folder = year_folder + "/" + image_info[2]

			if not os.path.exists(year_folder):
				os.makedirs(year_folder)

			if not os.path.exists(month_folder):
				os.makedirs(month_folder)

			file.save(os.path.join(month_folder, file.filename))

			return redirect(url_for("gallery", user_id=session["user_id"]))

	return render_template("upload.html")

# i.e. www.picflick.com/gallery/5
@app.route("/gallery/<user_id>")
def gallery(user_id):
	select_user_sql = "SELECT name, email FROM users WHERE id=%s LIMIT 1;"
	user_info = fetch(select_user_sql, user_id)

	# Show image gallery
	select_images_sql = "SELECT id, file_name, year_created, month_created FROM images WHERE user_id=%s;"
	images = query(select_images_sql, user_id)

	return render_template("gallery.html", user_info=user_info, images=images)

# i.e. www.picflick.com/gallery/5/image/42
@app.route("/gallery/<user_id>/image/<image_id>", methods=["GET", "DELETE"])
def image(user_id, image_id):
	if request.method == "DELETE":
		# Delete an image
		sql = "DELETE FROM images WHERE id=%s;"

		execute(sql, image_id)

		return redirect(url_for("gallery"))
	else:
		# Show the specific image
		sql = "SELECT * FROM images WHERE user_id=%s;"
		images = query(sql, user_id)

		return render_template("show.html")


text:
'use strict';

// MODULES //

var partial = require( './partial.js' );

// CDF //

/**
* FUNCTION: cdf( out, arr, alpha, beta, accessor )
*	Evaluates the cumulative distribution function (CDF) for a Beta distribution with first shape parameter `alpha` and second shape parameter `beta` using an accessor function.
*
* @param {Array|Int8Array|Uint8Array|Uint8ClampedArray|Int16Array|Uint16Array|Int32Array|Uint32Array|Float32Array|Float64Array} out - output array
* @param {Array} arr - input array
* @param {Number} alpha - first shape parameter
* @param {Number} beta - second shape parameter
* @param {Function} accessor - accessor function for accessing array values
* @returns {Number[]|Int8Array|Uint8Array|Uint8ClampedArray|Int16Array|Uint16Array|Int32Array|Uint32Array|Float32Array|Float64Array} output array
*/
function cdf( y, x, alpha, beta, clbk ) {
	var len = x.length,
		fcn,
		v, i;

	fcn = partial( alpha, beta );
	for ( i = 0; i < len; i++ ) {
		v = clbk( x[ i ], i );
		if ( typeof v === 'number' ) {
			y[ i ] = fcn( v );
		} else {
			y[ i ] = NaN;
		}
	}
	return y;
} // end FUNCTION cdf()

// EXPORTS //

module.exports = cdf;


text:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <android.support.v7.widget.CardView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="0dp"
        android:layout_marginLeft="9dp"
        android:layout_marginRight="9dp"
        android:layout_marginTop="9dp"
        card_view:cardCornerRadius="3dp"
        card_view:cardElevation="0.01dp"
        android:background="?android:attr/selectableItemBackground">

        <RelativeLayout
            android:id="@+id/top_layout"
            android:layout_width="match_parent"
            android:layout_height="338dp">

            <ImageView
                android:id="@+id/img_thumbnail"
                android:layout_width="match_parent"
                android:layout_height="250dp"
                android:layout_marginBottom="50dp"
                android:scaleType="fitXY" />
<!--图书名字-->
            <TextView
                android:id="@+id/tv_nature"
                android:layout_width="match_parent"
                android:layout_height="50dp"
                android:layout_alignBottom="@+id/img_thumbnail"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true"
                android:layout_gravity="bottom"
                android:alpha="0.8"
                android:background="#5c1b1b1b"
                android:gravity="center_vertical"
                android:paddingLeft="@dimen/activity_horizontal_margin"
                android:paddingRight="@dimen/activity_horizontal_margin"
                android:text="@string/app_name"
                android:textColor="#fff"
                android:textSize="26sp"
                />
<!--图书信息简单介绍
            <TextView
                android:id="@+id/tv_des_nature"
                android:layout_width="match_parent"
                android:layout_height="@dimen/item_touch_helper_max_drag_scroll_per_frame"
                android:layout_alignParentBottom="true"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true"
                android:layout_below="@+id/tv_nature"
                android:alpha="0.8"
                android:paddingBottom="2dp"
                android:paddingLeft="@dimen/activity_horizontal_margin"
                android:paddingRight="@dimen/activity_horizontal_margin"
                android:paddingTop="5dp"
                android:text="@string/app_name"
                android:textColor="#ff272727"
                android:textSize="17sp"
                android:background="@android:color/white"
                android:ellipsize="end"
                android:fadeScrollbars="false"
                android:lines="4"/>-->
        </RelativeLayout>

    </android.support.v7.widget.CardView>
</LinearLayout>


text:
#ifndef CARTOGRAPHER_MAPPING_INTERNAL_3D_SCAN_MATCHING_INTENSITY_COST_FUNCTION_3D_H_
#define CARTOGRAPHER_MAPPING_INTERNAL_3D_SCAN_MATCHING_INTENSITY_COST_FUNCTION_3D_H_

#include "Eigen/Core"
#include "cartographer/mapping/3d/hybrid_grid.h"
#include "cartographer/mapping/internal/3d/scan_matching/interpolated_grid.h"
#include "cartographer/sensor/point_cloud.h"
#include "cartographer/transform/rigid_transform.h"
#include "cartographer/transform/transform.h"
#include "ceres/ceres.h"

namespace cartographer {
namespace mapping {
namespace scan_matching {

// Computes a cost for matching the 'point_cloud' to the 'hybrid_grid' with a
// 'translation' and 'rotation'. The cost increases when points fall into space
// for which different intensity has been observed, i.e. at voxels with different
// values. Only points up to a certain threshold are evaluated which is intended
// to ignore data from retroreflections.
class IntensityCostFunction3D {
 public:
  static ceres::CostFunction* CreateAutoDiffCostFunction(
      const double scaling_factor, const float intensity_threshold,
      const sensor::PointCloud& point_cloud,
      const IntensityHybridGrid& hybrid_grid);

  template <typename T>
  bool operator()(const T* const translation, const T* const rotation,
                  T* const residual) const {
    const transform::Rigid3<T> transform(
        Eigen::Map<const Eigen::Matrix<T, 3, 1>>(translation),
        Eigen::Quaternion<T>(rotation[0], rotation[1], rotation[2],
                             rotation[3]));
    return Evaluate(transform, residual);
  }

 private:
  IntensityCostFunction3D(const double scaling_factor,
                          const float intensity_threshold,
                          const sensor::PointCloud& point_cloud,
                          const IntensityHybridGrid& hybrid_grid)
      : scaling_factor_(scaling_factor),
        intensity_threshold_(intensity_threshold),
        point_cloud_(point_cloud),
        interpolated_grid_(hybrid_grid) {}

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

  template <typename T>
  bool Evaluate(const transform::Rigid3<T>& transform,
                T* const residual) const {
    for (size_t i = 0; i < point_cloud_.size(); ++i) {
      if (point_cloud_.intensities()[i] > intensity_threshold_) {
        residual[i] = T(0.f);
      } else {
        const Eigen::Matrix<T, 3, 1> point = point_cloud_[i].position.cast<T>();
        const T intensity = T(point_cloud_.intensities()[i]);

        const Eigen::Matrix<T, 3, 1> world = transform * point;
        const T interpolated_intensity =
            interpolated_grid_.GetInterpolatedValue(world[0], world[1],
                                                    world[2]);
        residual[i] = scaling_factor_ * (interpolated_intensity - intensity);
      }
    }
    return true;
  }

  const double scaling_factor_;
  // We will ignore returns with intensity above this threshold.
  const float intensity_threshold_;
  const sensor::PointCloud& point_cloud_;
  const InterpolatedIntensityGrid interpolated_grid_;
};

}  // namespace scan_matching
}  // namespace mapping
}  // namespace cartographer

#endif  // CARTOGRAPHER_MAPPING_INTERNAL_3D_SCAN_MATCHING_INTENSITY_COST_FUNCTION_3D_H_


text:
/*
 * This file is part of FFmpeg.
 *
 * FFmpeg is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * FFmpeg is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with FFmpeg; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

#include "config.h"
#include "file.h"
#include "internal.h"
#include "log.h"
#include "mem.h"
#include <fcntl.h>
#include <sys/stat.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#if HAVE_IO_H
#include <io.h>
#endif
#if HAVE_MMAP
#include <sys/mman.h>
#elif HAVE_MAPVIEWOFFILE
#include <windows.h>
#endif

typedef struct FileLogContext {
    const AVClass *class;
    int   log_offset;
    void *log_ctx;
} FileLogContext;

static const AVClass file_log_ctx_class = {
    "FILE", av_default_item_name, NULL, LIBAVUTIL_VERSION_INT,
    offsetof(FileLogContext, log_offset), offsetof(FileLogContext, log_ctx)
};

int av_file_map(const char *filename, uint8_t **bufptr, size_t *size,
                int log_offset, void *log_ctx)
{
    FileLogContext file_log_ctx = { &file_log_ctx_class, log_offset, log_ctx };
    int err, fd = avpriv_open(filename, O_RDONLY);
    struct stat st;
    av_unused void *ptr;
    off_t off_size;
    char errbuf[128];
    *bufptr = NULL;

    if (fd < 0) {
        err = AVERROR(errno);
        av_strerror(err, errbuf, sizeof(errbuf));
        av_log(&file_log_ctx, AV_LOG_ERROR, "Cannot read file '%s': %s\n", filename, errbuf);
        return err;
    }

    if (fstat(fd, &st) < 0) {
        err = AVERROR(errno);
        av_strerror(err, errbuf, sizeof(errbuf));
        av_log(&file_log_ctx, AV_LOG_ERROR, "Error occurred in fstat(): %s\n", errbuf);
        close(fd);
        return err;
    }

    off_size = st.st_size;
    if (off_size > SIZE_MAX) {
        av_log(&file_log_ctx, AV_LOG_ERROR,
               "File size for file '%s' is too big\n", filename);
        close(fd);
        return AVERROR(EINVAL);
    }
    *size = off_size;

#if HAVE_MMAP
    ptr = mmap(NULL, *size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
    if (ptr == MAP_FAILED) {
        err = AVERROR(errno);
        av_strerror(err, errbuf, sizeof(errbuf));
        av_log(&file_log_ctx, AV_LOG_ERROR, "Error occurred in mmap(): %s\n", errbuf);
        close(fd);
        return err;
    }
    *bufptr = ptr;
#elif HAVE_MAPVIEWOFFILE
    {
        HANDLE mh, fh = (HANDLE)_get_osfhandle(fd);

        mh = CreateFileMapping(fh, NULL, PAGE_READONLY, 0, 0, NULL);
        if (!mh) {
            av_log(&file_log_ctx, AV_LOG_ERROR, "Error occurred in CreateFileMapping()\n");
            close(fd);
            return -1;
        }

        ptr = MapViewOfFile(mh, FILE_MAP_READ, 0, 0, *size);
        CloseHandle(mh);
        if (!ptr) {
            av_log(&file_log_ctx, AV_LOG_ERROR, "Error occurred in MapViewOfFile()\n");
            close(fd);
            return -1;
        }

        *bufptr = ptr;
    }
#else
    *bufptr = av_malloc(*size);
    if (!*bufptr) {
        av_log(&file_log_ctx, AV_LOG_ERROR, "Memory allocation error occurred\n");
        close(fd);
        return AVERROR(ENOMEM);
    }
    read(fd, *bufptr, *size);
#endif

    close(fd);
    return 0;
}

void av_file_unmap(uint8_t *bufptr, size_t size)
{
#if HAVE_MMAP
    munmap(bufptr, size);
#elif HAVE_MAPVIEWOFFILE
    UnmapViewOfFile(bufptr);
#else
    av_free(bufptr);
#endif
}

int av_tempfile(const char *prefix, char **filename, int log_offset, void *log_ctx) {
    return avpriv_tempfile(prefix, filename, log_offset, log_ctx);
}


text:
//
//  Page.java
//  blogwt
//
//  Created by William Shakour (billy1380) on 23 Jan 2018.
//  Copyright © 2018 WillShex Limited. All rights reserved.
//
package com.willshex.blogwt.shared.api.page;

/**
 * @author William Shakour (billy1380)
 *
 */
public interface Page {
	public static final String PATH = "/api/page";
}


text:
package org.fcrepo.client.test;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.InputStream;
import java.io.PrintStream;

import java.util.ArrayList;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import java.math.BigDecimal;

import org.apache.axis.types.NonNegativeInteger;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.httpclient.methods.GetMethod;

import org.fcrepo.client.FedoraClient;

import org.fcrepo.common.Constants;

import org.fcrepo.server.access.FedoraAPIA;
import org.fcrepo.server.management.FedoraAPIM;

/**
 * Performs test to determine the time necessary to execute
 * various repository activities.
 *
 * @author Bill Branan
 */
public class PerformanceTests
        implements Constants {

    private FedoraAPIM apim;
    private FedoraAPIA apia;

    private static int iterations = 10;
    private static int threads = 10;

    private static final String pid = "demo:performance";

    private static String DEMO_FOXML_TEXT;

    private static String datastream =
            "http://local.fedora.server/fedora-demo/simple-image-demo/coliseum-thumb.jpg";

    private String host;
    private String port;
    private String context;
    private String username;
    private String password;

    private String[] PIDS;
    private byte[][] FOXML;

    static {
        // Test FOXML object
        StringBuilder sb = new StringBuilder();
        sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
        sb.append("<foxml:digitalObject PID=\"" + pid +
                  "\" VERSION=\"1.1\" xmlns:foxml=\"info:fedora/fedora-system:def/foxml#\"");
        sb.append(
                "  xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"info:fedora/fedora-system:def/foxml# http://www.fedora.info/definitions/1/0/foxml1-1.xsd\">");
        sb.append("  <foxml:objectProperties>");
        sb.append("    <foxml:property NAME=\"info:fedora/fedora-system:def/model#state\" VALUE=\"Active\"/>");
        sb.append("    <foxml:property NAME=\"info:fedora/fedora-system:def/model#label\" VALUE=\"Test Object\"/>");
        sb.append("    <foxml:property NAME=\"info:fedora/fedora-system:def/model#ownerId\" VALUE=\"fedoraAdmin\"/>");
        sb.append(
                "    <foxml:property NAME=\"info:fedora/fedora-system:def/model#createdDate\" VALUE=\"2008-07-09T19:28:04.890Z\"/>");
        sb.append(
                "    <foxml:property NAME=\"info:fedora/fedora-system:def/view#lastModifiedDate\" VALUE=\"2008-07-09T19:32:31.750Z\"/>");
        sb.append("  </foxml:objectProperties>");
        sb.append("  <foxml:datastream CONTROL_GROUP=\"X\" ID=\"AUDIT\" STATE=\"A\" VERSIONABLE=\"false\">");
        sb.append("    <foxml:datastreamVersion CREATED=\"2008-07-09T19:28:04.890Z\"");
        sb.append(
                "      FORMAT_URI=\"info:fedora/fedora-system:format/xml.fedora.audit\" ID=\"AUDIT.0\" LABEL=\"Fedora Object Audit Trail\" MIMETYPE=\"text/xml\">");
        sb.append("      <foxml:xmlContent>");
        sb.append("        <audit:auditTrail xmlns:audit=\"info:fedora/fedora-system:def/audit#\">");
        sb.append("          <audit:record ID=\"AUDREC1\">");
        sb.append("            <audit:process type=\"Fedora API-M\"/>");
        sb.append("            <audit:action>ingest</audit:action>");
        sb.append("            <audit:componentID/>");
        sb.append("            <audit:responsibility>fedoraAdmin</audit:responsibility>");
        sb.append("            <audit:date>2008-07-09T19:28:04.890Z</audit:date>");
        sb.append("            <audit:justification>Created New Object</audit:justification>");
        sb.append("          </audit:record>");
        sb.append("        </audit:auditTrail>");
        sb.append("      </foxml:xmlContent>");
        sb.append("    </foxml:datastreamVersion>");
        sb.append("  </foxml:datastream>");
        sb.append("  <foxml:datastream CONTROL_GROUP=\"X\" ID=\"DC\" STATE=\"A\" VERSIONABLE=\"true\">");
        sb.append(
                "    <foxml:datastreamVersion CREATED=\"2008-07-09T19:28:04.890Z\" ID=\"DC1.0\" LABEL=\"Dublin Core Metadata\"");
        sb.append("      MIMETYPE=\"text/xml\" SIZE=\"226\">");
        sb.append("      <foxml:contentDigest DIGEST=\"none\" TYPE=\"DISABLED\"/>");
        sb.append("      <foxml:xmlContent>");
        sb.append(
                "        <oai_dc:dc xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:oai_dc=\"http://www.openarchives.org/OAI/2.0/oai_dc/\">");
        sb.append("          <dc:title>Test Object</dc:title>");
        sb.append("          <dc:identifier>" + pid + "</dc:identifier>");
        sb.append("        </oai_dc:dc>");
        sb.append("      </foxml:xmlContent>");
        sb.append("    </foxml:datastreamVersion>");
        sb.append("  </foxml:datastream>");
        sb.append("  <foxml:datastream CONTROL_GROUP=\"X\" ID=\"XDS1\" STATE=\"A\" VERSIONABLE=\"true\">");
        sb.append(
                "    <foxml:datastreamVersion CREATED=\"2008-07-09T19:28:58.125Z\" ID=\"XDS1.0\" LABEL=\"XML Datastream 1\" MIMETYPE=\"text/xml\" SIZE=\"41\">");
        sb.append("      <foxml:contentDigest DIGEST=\"none\" TYPE=\"DISABLED\"/>");
        sb.append("      <foxml:xmlContent>");
        sb.append("        <xml>Datastream Content</xml>");
        sb.append("      </foxml:xmlContent>");
        sb.append("    </foxml:datastreamVersion>");
        sb.append("  </foxml:datastream>");
        sb.append("  <foxml:datastream CONTROL_GROUP=\"X\" ID=\"XDS2\" STATE=\"A\" VERSIONABLE=\"true\">");
        sb.append(
                "    <foxml:datastreamVersion CREATED=\"2008-07-09T19:29:33.609Z\" ID=\"XDS2.0\" LABEL=\"XML Datastream 2\" MIMETYPE=\"text/xml\" SIZE=\"41\">");
        sb.append("      <foxml:contentDigest DIGEST=\"none\" TYPE=\"DISABLED\"/>");
        sb.append("      <foxml:xmlContent>");
        sb.append("        <xml>Datastream Content</xml>");
        sb.append("      </foxml:xmlContent>");
        sb.append("    </foxml:datastreamVersion>");
        sb.append("  </foxml:datastream>");
        sb.append("  <foxml:datastream CONTROL_GROUP=\"M\" ID=\"MDS1\" STATE=\"A\" VERSIONABLE=\"true\">");
        sb.append(
                "    <foxml:datastreamVersion CREATED=\"2008-07-09T19:31:57.593Z\" ID=\"MDS1.0\" LABEL=\"Managed Datastream 1\" MIMETYPE=\"text/xml\" SIZE=\"0\">");
        sb.append("      <foxml:contentDigest DIGEST=\"none\" TYPE=\"DISABLED\"/>");
        sb.append("      <foxml:binaryContent>");
        sb.append("              PHhtbD5EYXRhc3RyZWFtIENvbnRlbnQ8L3htbD4=");
        sb.append("            </foxml:binaryContent>");
        sb.append("    </foxml:datastreamVersion>");
        sb.append("  </foxml:datastream>");
        sb.append("  <foxml:datastream CONTROL_GROUP=\"M\" ID=\"MDS2\" STATE=\"A\" VERSIONABLE=\"true\">");
        sb.append(
                "    <foxml:datastreamVersion CREATED=\"2008-07-09T19:32:31.750Z\" ID=\"MDS2.0\" LABEL=\"Managed Datastream 2\" MIMETYPE=\"text/xml\" SIZE=\"0\">");
        sb.append("      <foxml:contentDigest DIGEST=\"none\" TYPE=\"DISABLED\"/>");
        sb.append("      <foxml:binaryContent>");
        sb.append("              PHhtbD5EYXRhc3RyZWFtIENvbnRlbnQ8L3htbD4=");
        sb.append("            </foxml:binaryContent>");
        sb.append("    </foxml:datastreamVersion>");
        sb.append("  </foxml:datastream>");
        sb.append("</foxml:digitalObject>");

        DEMO_FOXML_TEXT = sb.toString();
    }

    public void init(String host, String port, String context, String username, String password) throws Exception {
        this.host = host;
        this.port = port;
        this.username = username;
        this.password = password;
        this.context = context;

        String baseURL = "http://" + host + ":" + port + "/" + context;
        FedoraClient fedoraClient = new FedoraClient(baseURL, username, password);
        apim = fedoraClient.getAPIM();
        apia = fedoraClient.getAPIA();

        PIDS = apim.getNextPID(new NonNegativeInteger(Integer.valueOf(iterations).toString()), "demo");
        FOXML = new byte[iterations][];
        for (int i = 0; i < iterations; i++) {
            FOXML[i] = DEMO_FOXML_TEXT.replaceAll(pid, PIDS[i]).getBytes("UTF-8");
        }
    }

    private void runIngest(byte[] foxml) throws Exception {
        apim.ingest(foxml, FOXML1_1.uri, "Ingest Test");
    }

    private void runAddDatastream(String pid, String dsId) throws Exception {
        apim.addDatastream(pid,
                           dsId,
                           null,
                           "New Datastream",
                           true,
                           "text/xml",
                           null,
                           datastream,
                           "M",
                           "A",
                           null,
                           null,
                           "Adding Test Datastream");
    }

    private void runModifyDatastreamByRef(String pid) throws Exception {
        apim.modifyDatastreamByReference(pid,
                                         "MDS1",
                                         null,
                                         "New Label",
                                         "text/xml",
                                         null,
                                         datastream,
                                         null,
                                         null,
                                         "Modify Datastream Test",
                                         false);
    }

    private void runModifyDatastreamByValue(String pid) throws Exception {
        String dsContent = "<xml>Updated Content</xml>";
        apim.modifyDatastreamByValue(pid,
                                     "XDS1",
                                     null,
                                     "New Label",
                                     "text/xml",
                                     null,
                                     dsContent.getBytes(),
                                     null,
                                     null,
                                     "Modify Datastream Test",
                                     false);
    }

    private void runPurgeDatastream(String pid, String dsId) throws Exception {
        apim.purgeDatastream(pid, dsId, null, null, "Purge Datastream Test", false);
    }

    private void runPurgeObject(String pid) throws Exception {
        apim.purgeObject(pid, "Removing Test Object", false);
    }

    private void runGetDatastream(String pid) throws Exception {
        apia.getDatastreamDissemination(pid, "MDS1", null);
    }

    private void runGetDatastreamRest(String pid) throws Exception {
        HttpMethod httpMethod = getHttpMethod(pid);
        HttpClient client = getHttpClient();
        client.executeMethod(httpMethod);
        InputStream in = httpMethod.getResponseBodyAsStream();
        int input = in.read();
        while (input > 0) {
            input = in.read();
        }
    }

    /**
     * @return average run time for a single operation
     */
    public long runIngestTest() throws Exception {
        long totalTime = 0;
        long startTime = 0;
        long stopTime = 0;
        for (int i = 0; i < iterations; i++) {
            startTime = System.currentTimeMillis();
            runIngest(FOXML[0]);
            stopTime = System.currentTimeMillis();
            totalTime += (stopTime - startTime);
            runPurgeObject(PIDS[0]);
        }
        long average = totalTime / iterations;
        return average;
    }

    /**
     * @return average run time for a single operation
     */
    public long runAddDatastreamTest() throws Exception {
        long totalTime = 0;
        long startTime = 0;
        long stopTime = 0;
        runIngest(FOXML[0]);
        for (int i = 0; i < iterations; i++) {
            startTime = System.currentTimeMillis();
            runAddDatastream(PIDS[0], "MDS3");
            stopTime = System.currentTimeMillis();
            totalTime += (stopTime - startTime);
            runPurgeDatastream(PIDS[0], "MDS3");
        }
        runPurgeObject(PIDS[0]);
        long average = totalTime / iterations;
        return average;
    }

    /**
     * @return average run time for a single operation
     */
    public long runModifyDatastreamByRefTest() throws Exception {
        long totalTime = 0;
        long startTime = 0;
        long stopTime = 0;
        runIngest(FOXML[0]);
        for (int i = 0; i < iterations; i++) {
            startTime = System.currentTimeMillis();
            runModifyDatastreamByRef(PIDS[0]);
            stopTime = System.currentTimeMillis();
            totalTime += (stopTime - startTime);
        }
        runPurgeObject(PIDS[0]);
        long average = totalTime / iterations;
        return average;
    }

    /**
     * @return average run time for a single operation
     */
    public long runModifyDatastreamByValueTest() throws Exception {
        long totalTime = 0;
        long startTime = 0;
        long stopTime = 0;
        runIngest(FOXML[0]);
        for (int i = 0; i < iterations; i++) {
            startTime = System.currentTimeMillis();
            runModifyDatastreamByValue(PIDS[0]);
            stopTime = System.currentTimeMillis();
            totalTime += (stopTime - startTime);
        }
        runPurgeObject(PIDS[0]);
        long average = totalTime / iterations;
        return average;
    }

    /**
     * @return average run time for a single operation
     */
    public long runPurgeDatastreamTest() throws Exception {
        long totalTime = 0;
        long startTime = 0;
        long stopTime = 0;
        runIngest(FOXML[0]);
        for (int i = 0; i < iterations; i++) {
            runAddDatastream(PIDS[0], "MDS3");
            startTime = System.currentTimeMillis();
            runPurgeDatastream(PIDS[0], "MDS3");
            stopTime = System.currentTimeMillis();
            totalTime += (stopTime - startTime);
        }
        runPurgeObject(PIDS[0]);
        long average = totalTime / iterations;
        return average;
    }

    /**
     * @return average run time for a single operation
     */
    public long runPurgeObjectTest() throws Exception {
        long totalTime = 0;
        long startTime = 0;
        long stopTime = 0;
        for (int i = 0; i < iterations; i++) {
            runIngest(FOXML[0]);
            startTime = System.currentTimeMillis();
            runPurgeObject(PIDS[0]);
            stopTime = System.currentTimeMillis();
            totalTime += (stopTime - startTime);
        }
        long average = totalTime / iterations;
        return average;
    }

    /**
     * @return total time to run all iterations
     */
    public long runGetDatastreamTest() throws Exception {
        long totalTime = 0;
        long startTime = 0;
        long stopTime = 0;
        runIngest(FOXML[0]);
        startTime = System.currentTimeMillis();
        for (int i = 0; i < iterations; i++) {
            runGetDatastream(PIDS[0]);
        }
        stopTime = System.currentTimeMillis();
        totalTime = (stopTime - startTime);
        runPurgeObject(PIDS[0]);

        return totalTime;
    }

    /**
     * @return total time to run all iterations
     */
    public long runGetDatastreamRestTest() throws Exception {
        long totalTime = 0;
        long startTime = 0;
        long stopTime = 0;
        runIngest(FOXML[0]);
        HttpMethod httpMethod = getHttpMethod(PIDS[0]);
        HttpClient client = getHttpClient();
        startTime = System.currentTimeMillis();
        for (int i = 0; i < iterations; i++) {
            client.executeMethod(httpMethod);
            InputStream in = httpMethod.getResponseBodyAsStream();
            int input = in.read();
            while (input > 0) {
                input = in.read();
            }
        }
        stopTime = System.currentTimeMillis();
        totalTime = (stopTime - startTime);
        runPurgeObject(PIDS[0]);

        return totalTime;
    }

    private HttpMethod getHttpMethod(String pid) {
        String url = "http://" + host + ":" + port + "/" + context + "/get/" + pid + "/" + "MDS1";
        HttpMethod httpMethod = new GetMethod(url);
        httpMethod.setDoAuthentication(true);
        httpMethod.getParams().setParameter("Connection", "Keep-Alive");
        return httpMethod;
    }

    private HttpClient getHttpClient() {
        HttpClient client = new HttpClient();
        client.getParams().setAuthenticationPreemptive(true);
        client.getState().setCredentials(
                new AuthScope(host, Integer.valueOf(port), "realm"),
                new UsernamePasswordCredentials(username, password));
        return client;
    }

    /**
     * @return total time to run all iterations
     *         {ingest, addDatastream, modifyDatastreamByReference,
     *         modifyDatastreamByValue, purgeDatastream, purgeObject}
     */
    public long[] runThroughputTests() throws Exception {
        long ingestTime = 0;
        long addDsTime = 0;
        long modifyRefTime = 0;
        long modifyValTime = 0;
        long purgeDsTime = 0;
        long purgeObjectTime = 0;
        long startTime = 0;
        long stopTime = 0;

        // Ingest
        startTime = System.currentTimeMillis();
        for (int i = 0; i < iterations; i++) {
            runIngest(FOXML[i]);
        }
        stopTime = System.currentTimeMillis();
        ingestTime = (stopTime - startTime);

        // Add Datastream
        startTime = System.currentTimeMillis();
        for (int i = 0; i < iterations; i++) {
            runAddDatastream(PIDS[i], "MDS3");
        }
        stopTime = System.currentTimeMillis();
        addDsTime = (stopTime - startTime);

        // Modify Datastream By Reference
        startTime = System.currentTimeMillis();
        for (int i = 0; i < iterations; i++) {
            runModifyDatastreamByRef(PIDS[i]);
        }
        stopTime = System.currentTimeMillis();
        modifyRefTime = (stopTime - startTime);

        // Modify Datastream By Value
        startTime = System.currentTimeMillis();
        for (int i = 0; i < iterations; i++) {
            runModifyDatastreamByValue(PIDS[i]);
        }
        stopTime = System.currentTimeMillis();
        modifyValTime = (stopTime - startTime);

        // Purge Datastream
        startTime = System.currentTimeMillis();
        for (int i = 0; i < iterations; i++) {
            runPurgeDatastream(PIDS[i], "MDS1");
        }
        stopTime = System.currentTimeMillis();
        purgeDsTime = (stopTime - startTime);

        // Purge Object
        startTime = System.currentTimeMillis();
        for (int i = 0; i < iterations; i++) {
            runPurgeObject(PIDS[i]);
        }
        stopTime = System.currentTimeMillis();
        purgeObjectTime = (stopTime - startTime);

        // Get Datastream and Get Datastream REST results
        // do not change from round-trip tests

        long[] totals = {ingestTime,
                         addDsTime,
                         modifyRefTime,
                         modifyValTime,
                         purgeDsTime,
                         purgeObjectTime};
        return totals;
    }

    /**
     * @return total time to run all iterations with threading
     *         {ingest, addDatastream, modifyDatastreamByReference,
     *         modifyDatastreamByValue, purgeDatastream, purgeObject,
     *         getDatastream, getDatastreamREST}
     */
    public long[] runThreadedThroughputTests() throws Exception {
        long ingestTime = 0;
        long addDsTime = 0;
        long modifyRefTime = 0;
        long modifyValTime = 0;
        long purgeDsTime = 0;
        long purgeObjectTime = 0;
        long getDatastreamTime = 0;
        long getDatastreamRestTime = 0;
        long startTime = 0;
        long stopTime = 0;

        ExecutorService threadPool = Executors.newFixedThreadPool(threads);

        // Ingest
        ArrayList<Callable<Boolean>> ingestRunnerList = new ArrayList<Callable<Boolean>>();
        for (int i = 0; i < iterations; i++) {
            ingestRunnerList.add(new MethodRunner(MethodType.INGEST, i));
        }
        startTime = System.currentTimeMillis();
        threadPool.invokeAll(ingestRunnerList);
        stopTime = System.currentTimeMillis();
        ingestTime = (stopTime - startTime);

        // Add Datastream
        ArrayList<Callable<Boolean>> addDatastreamRunnerList = new ArrayList<Callable<Boolean>>();
        for (int i = 0; i < iterations; i++) {
            addDatastreamRunnerList.add(new MethodRunner(MethodType.ADD_DATASTREAM, i));
        }
        startTime = System.currentTimeMillis();
        threadPool.invokeAll(addDatastreamRunnerList);
        stopTime = System.currentTimeMillis();
        addDsTime = (stopTime - startTime);

        // Modify Datastream By Reference
        ArrayList<Callable<Boolean>> modDatastreamRefRunnerList = new ArrayList<Callable<Boolean>>();
        for (int i = 0; i < iterations; i++) {
            modDatastreamRefRunnerList.add(new MethodRunner(MethodType.MODIFY_DATASTREAM_REF, i));
        }
        startTime = System.currentTimeMillis();
        threadPool.invokeAll(modDatastreamRefRunnerList);
        stopTime = System.currentTimeMillis();
        modifyRefTime = (stopTime - startTime);

        // Modify Datastream By Value
        ArrayList<Callable<Boolean>> modDatastreamValRunnerList = new ArrayList<Callable<Boolean>>();
        for (int i = 0; i < iterations; i++) {
            modDatastreamValRunnerList.add(new MethodRunner(MethodType.MODIFY_DATASTREAM_VAL, i));
        }
        startTime = System.currentTimeMillis();
        threadPool.invokeAll(modDatastreamValRunnerList);
        stopTime = System.currentTimeMillis();
        modifyValTime = (stopTime - startTime);

        // Purge Datastream
        ArrayList<Callable<Boolean>> purgeDatastreamRunnerList = new ArrayList<Callable<Boolean>>();
        for (int i = 0; i < iterations; i++) {
            purgeDatastreamRunnerList.add(new MethodRunner(MethodType.PURGE_DATASTREAM, i));
        }
        startTime = System.currentTimeMillis();
        threadPool.invokeAll(purgeDatastreamRunnerList);
        stopTime = System.currentTimeMillis();
        purgeDsTime = (stopTime - startTime);

        // Purge Object
        ArrayList<Callable<Boolean>> purgeObjectRunnerList = new ArrayList<Callable<Boolean>>();
        for (int i = 0; i < iterations; i++) {
            purgeObjectRunnerList.add(new MethodRunner(MethodType.PURGE_OBJECT, i));
        }
        startTime = System.currentTimeMillis();
        threadPool.invokeAll(purgeObjectRunnerList);
        stopTime = System.currentTimeMillis();
        purgeObjectTime = (stopTime - startTime);

        // Get Datastream
        ArrayList<Callable<Boolean>> getDatastreamRunnerList = new ArrayList<Callable<Boolean>>();
        for (int i = 0; i < iterations; i++) {
            getDatastreamRunnerList.add(new MethodRunner(MethodType.GET_DATASTREAM, i));
        }
        startTime = System.currentTimeMillis();
        threadPool.invokeAll(getDatastreamRunnerList);
        stopTime = System.currentTimeMillis();
        getDatastreamTime = (stopTime - startTime);

        // Get Datastream REST
        ArrayList<Callable<Boolean>> getDatastreamRestRunnerList = new ArrayList<Callable<Boolean>>();
        for (int i = 0; i < iterations; i++) {
            getDatastreamRestRunnerList.add(new MethodRunner(MethodType.GET_DATASTREAM_REST, i));
        }
        startTime = System.currentTimeMillis();
        threadPool.invokeAll(getDatastreamRestRunnerList);
        stopTime = System.currentTimeMillis();
        getDatastreamRestTime = (stopTime - startTime);

        long[] totals = {ingestTime,
                         addDsTime,
                         modifyRefTime,
                         modifyValTime,
                         purgeDsTime,
                         purgeObjectTime,
                         getDatastreamTime,
                         getDatastreamRestTime};
        return totals;
    }

    private enum MethodType {
        INGEST,
        ADD_DATASTREAM,
        MODIFY_DATASTREAM_REF,
        MODIFY_DATASTREAM_VAL,
        PURGE_DATASTREAM,
        PURGE_OBJECT,
        GET_DATASTREAM,
        GET_DATASTREAM_REST;
    }

    /*
     * Runnable class to use within threads. Executes a
     * Fedora method based on the MethodType defined.
     */

    private class MethodRunner implements Callable<Boolean> {

        MethodType methodType;
        int index;

        public MethodRunner(MethodType methodType, int index) {
            this.methodType = methodType;
            this.index = index;
        }

        public Boolean call() throws Exception {
            if (methodType.equals(MethodType.INGEST)) {
                runIngest(FOXML[index]);
            } else if (methodType.equals(MethodType.ADD_DATASTREAM)) {
                runAddDatastream(PIDS[index], "MDS3");
            } else if (methodType.equals(MethodType.MODIFY_DATASTREAM_REF)) {
                runModifyDatastreamByRef(PIDS[index]);
            } else if (methodType.equals(MethodType.MODIFY_DATASTREAM_VAL)) {
                runModifyDatastreamByValue(PIDS[index]);
            } else if (methodType.equals(MethodType.PURGE_DATASTREAM)) {
                runPurgeDatastream(PIDS[index], "MDS1");
            } else if (methodType.equals(MethodType.PURGE_OBJECT)) {
                runPurgeObject(PIDS[index]);
            } else if (methodType.equals(MethodType.GET_DATASTREAM)) {
                runGetDatastream(PIDS[index]);
            } else if (methodType.equals(MethodType.GET_DATASTREAM_REST)) {
                runGetDatastreamRest(PIDS[index]);
            }
            return new Boolean(true);
        }
    }

    private static double round(double d) {
        int decimalPlace = 5;
        BigDecimal bd = new BigDecimal(Double.toString(d));
        bd = bd.setScale(decimalPlace, BigDecimal.ROUND_HALF_UP);
        return bd.doubleValue();
    }

    private static void usage() {
        System.out.println("Runs a set of performance tests over a running Fedora repository.");
        System.out.println("USAGE: ant performance-tests " +
                           "-Dhost=HOST " +
                           "-Dport=PORT " +
                           "-Dusername=USERNAME " +
                           "-Dpassword=PASSWORD " +
                           "-Diterations=NUM-ITERATIONS " +
                           "-Dthreads=NUM-THREADS " +
                           "-Dfile=OUTPUT-FILE " +
                           "-Dname=TEST-NAME" +
                           "[-Dcontext=CONTEXT]");
        System.out.println("Where:");
        System.out.println("  HOST = Host on which Fedora server is running.");
        System.out.println("  PORT = Port on which the Fedora server APIs can be accessed.");
        System.out.println("  USERNAME = A fedora user with administrative privileges.");
        System.out.println("  PASSWORD = The fedora user's password.");
        System.out.println("  NUM-ITERATIONS = The number of times to perform each operation.");
        System.out.println("  NUM-THREADS = The number of threads to use in the thread pool");
        System.out.println("                when running threaded tests.");
        System.out.println("  OUTPUT-FILE = The file to which the test results will be written.");
        System.out.println("                If the file does not exist, it will be created, if the");
        System.out.println("                file does exist the new results will be appended.");
        System.out.println("  TEST-NAME   = A name for this test run.");
        System.out.println(
                "  CONTEXT     = The application server context Fedora is deployed in. This parameter is optional");
        System.out.println("Example:");
        System.out.println("ant performance-tests " +
                           "-Dhost=localhost " +
                           "-Dport=8080 " +
                           "-Dusername=fedoraAdmin " +
                           "-Dpassword=fedoraAdmin " +
                           "-Diterations=100 " +
                           "-Dthreads=10 " +
                           "-Dfile=C:\\temp\\performance_testing_output.txt " +
                           "-Dname=\"Test 1\"" +
                           "-Dcontext=my-fedora");
        System.exit(1);
    }

    public static void main(String[] args) throws Exception {

        if (args.length < 8 || args.length > 9) {
            usage();
        }

        String host = args[0];
        String port = args[1];
        String username = args[2];
        String password = args[3];
        String itr = args[4];
        String thrds = args[5];
        String output = args[6];
        String name = args[7];
        String context = Constants.FEDORA_DEFAULT_APP_CONTEXT;

        if (args.length == 9 && !args[8].equals("")) {
            context = args[8];
        }

        if (host == null || host.startsWith("$") ||
            port == null || port.startsWith("$") ||
            username == null || username.startsWith("$") ||
            password == null || password.startsWith("$") ||
            itr == null || itr.startsWith("$") ||
            thrds == null || thrds.startsWith("$") ||
            output == null || output.startsWith("$") ||
            name == null || name.startsWith("$")) {
            usage();
        }
        name = name.replaceAll(",", ";");
        iterations = Integer.parseInt(itr);
        threads = Integer.parseInt(thrds);

        boolean newFile = true;
        File outputFile = new File(output);

        File tempFile = null;
        BufferedReader reader = null;
        String line = "";
        if (outputFile.exists()) {
            newFile = false;

            // Create a copy of the file to read from
            tempFile = File.createTempFile("performance-test", "tmp");
            BufferedReader input = new BufferedReader(new FileReader(outputFile));
            PrintStream tempOut = new PrintStream(tempFile);

            while ((line = input.readLine()) != null) {
                tempOut.println(line);
            }
            input.close();
            tempOut.close();

            reader = new BufferedReader(new FileReader(tempFile));
        }
        PrintStream out = new PrintStream(outputFile);

        if (newFile) {
            out.println("--------------------------------------------------------------" +
                        " Performance Test Results " +
                        "--------------------------------------------------------------");
        }

        PerformanceTests tests = new PerformanceTests();
        tests.init(host, port, context, username, password);
        System.out.println("Running Ingest Round-Trip Test...");
        long ingestResults = tests.runIngestTest();
        System.out.println("Running AddDatastream Round-Trip Test...");
        long addDsResults = tests.runAddDatastreamTest();
        System.out.println("Running ModifyDatastreamByReference Round-Trip Test...");
        long modifyRefResults = tests.runModifyDatastreamByRefTest();
        System.out.println("Running ModifyDatastreamByValue Round-Trip Test...");
        long modifyValResults = tests.runModifyDatastreamByValueTest();
        System.out.println("Running PurgeDatastream Round-Trip Test...");
        long purgeDsResults = tests.runPurgeDatastreamTest();
        System.out.println("Running PurgeObject Round-Trip Test...");
        long purgeObjectResults = tests.runPurgeObjectTest();
        System.out.println("Running GetDatastream Round-Trip Test...");
        long getDatastreamResults = tests.runGetDatastreamTest();
        System.out.println("Running GetDatastreamREST Round-Trip Test...");
        long getDatastreamRestResults = tests.runGetDatastreamRestTest();
        System.out.println("Running Throughput Tests...");
        long[] tpResults = tests.runThroughputTests();
        System.out.println("Running Threaded Throughput Tests...");
        long[] tptResults = tests.runThreadedThroughputTests();

        if (newFile) {
            out.println(
                    "1. Test performing each operation in isolation. Time (in ms) is the average required to perform each operation.");
            out.println(
                    "test name, ingest, addDatastream, modifyDatastreamByReference, modifyDatastreamByValue, purgeDatastream, purgeObject, getDatastream, getDatastreamREST");
        } else {
            line = reader.readLine();
            while (line != null && line.length() > 2) {
                out.println(line);
                line = reader.readLine();
            }
        }
        out.println(name + ", " +
                    ingestResults + ", " +
                    addDsResults + ", " +
                    modifyRefResults + ", " +
                    modifyValResults + ", " +
                    purgeDsResults + ", " +
                    purgeObjectResults + ", " +
                    getDatastreamResults / iterations + ", " +
                    getDatastreamRestResults / iterations);

        out.println();
        if (newFile) {
            out.println("2. Operations-Per-Second based on results listed in item 1.");
            out.println(
                    "test name, ingest, addDatastream, modifyDatastreamByReference, modifyDatastreamByValue, purgeDatastream, purgeObject, getDatastream, getDatastreamREST");
        } else {
            line = reader.readLine();
            while (line != null && line.length() > 2) {
                out.println(line);
                line = reader.readLine();
            }
        }
        double ingestPerSecond = 1000 / (double) ingestResults;
        double addDsPerSecond = 1000 / (double) addDsResults;
        double modifyRefPerSecond = 1000 / (double) modifyRefResults;
        double modifyValPerSecond = 1000 / (double) modifyValResults;
        double purgeDsPerSecond = 1000 / (double) purgeDsResults;
        double purgeObjPerSecond = 1000 / (double) purgeObjectResults;
        double getDatastreamPerSecond = 1000 / ((double) getDatastreamResults / iterations);
        double getDatastreamRestPerSecond = 1000 / ((double) getDatastreamRestResults / iterations);
        out.println(name + ", " +
                    round(ingestPerSecond) + ", " +
                    round(addDsPerSecond) + ", " +
                    round(modifyRefPerSecond) + ", " +
                    round(modifyValPerSecond) + ", " +
                    round(purgeDsPerSecond) + ", " +
                    round(purgeObjPerSecond) + ", " +
                    round(getDatastreamPerSecond) + ", " +
                    round(getDatastreamRestPerSecond));

        out.println();
        if (newFile) {
            out.println(
                    "3. Test performing operations back-to-back. Time (in ms) is that required to perform all iterations.");
            out.println(
                    "test name, ingest, addDatastream, modifyDatastreamByReference, modifyDatastreamByValue, purgeDatastream, purgeObject, getDatastream, getDatastreamREST");
        } else {
            line = reader.readLine();
            while (line != null && line.length() > 2) {
                out.println(line);
                line = reader.readLine();
            }
        }
        out.println(name + ", " +
                    tpResults[0] + ", " +
                    tpResults[1] + ", " +
                    tpResults[2] + ", " +
                    tpResults[3] + ", " +
                    tpResults[4] + ", " +
                    tpResults[5] + ", " +
                    getDatastreamResults + ", " +
                    getDatastreamRestResults);

        out.println();
        if (newFile) {
            out.println("4. Operations-Per-Second based on results listed in item 3.");
            out.println(
                    "test name, ingest, addDatastream, modifyDatastreamByReference, modifyDatastreamByValue, purgeDatastream, purgeObject, getDatastream, getDatastreamREST");
        } else {
            line = reader.readLine();
            while (line != null && line.length() > 2) {
                out.println(line);
                line = reader.readLine();
            }
        }
        double ingestItPerSecond = (double) (iterations * 1000) / tpResults[0];
        double addDsItPerSecond = (double) (iterations * 1000) / tpResults[1];
        double modifyRefItPerSecond = (double) (iterations * 1000) / tpResults[2];
        double modifyValItPerSecond = (double) (iterations * 1000) / tpResults[3];
        double purgeDsItPerSecond = (double) (iterations * 1000) / tpResults[4];
        double purgeObjItPerSecond = (double) (iterations * 1000) / tpResults[5];
        double getDsItPerSecond = (double) (iterations * 1000) / getDatastreamResults;
        double getDsRestItPerSecond = (double) (iterations * 1000) / getDatastreamRestResults;
        out.println(name + ", " +
                    round(ingestItPerSecond) + ", " +
                    round(addDsItPerSecond) + ", " +
                    round(modifyRefItPerSecond) + ", " +
                    round(modifyValItPerSecond) + ", " +
                    round(purgeDsItPerSecond) + ", " +
                    round(purgeObjItPerSecond) + ", " +
                    round(getDsItPerSecond) + ", " +
                    round(getDsRestItPerSecond));

        out.println();
        if (newFile) {
            out.println(
                    "5. Test performing operations using a thread pool. Time (in ms) is that required to perform all iterations.");
            out.println(
                    "test name, ingest, addDatastream, modifyDatastreamByReference, modifyDatastreamByValue, purgeDatastream, purgeObject, getDatastream, getDatastreamREST");
        } else {
            line = reader.readLine();
            while (line != null && line.length() > 2) {
                out.println(line);
                line = reader.readLine();
            }
        }
        out.println(name + ", " +
                    tptResults[0] + ", " +
                    tptResults[1] + ", " +
                    tptResults[2] + ", " +
                    tptResults[3] + ", " +
                    tptResults[4] + ", " +
                    tptResults[5] + ", " +
                    tptResults[6] + ", " +
                    tptResults[7]);

        out.println();
        if (newFile) {
            out.println("6. Operations-Per-Second based on results listed in item 5.");
            out.println(
                    "test name, ingest, addDatastream, modifyDatastreamByReference, modifyDatastreamByValue, purgeDatastream, purgeObject, getDatastream, getDatastreamREST");
        } else {
            line = reader.readLine();
            while (line != null && line.length() > 2) {
                out.println(line);
                line = reader.readLine();
            }
        }
        double thrdIngestItPerSecond = (double) (iterations * 1000) / tptResults[0];
        double thrdAddDsItPerSecond = (double) (iterations * 1000) / tptResults[1];
        double thrdModifyRefItPerSecond = (double) (iterations * 1000) / tptResults[2];
        double thrdModifyValItPerSecond = (double) (iterations * 1000) / tptResults[3];
        double thrdPurgeDsItPerSecond = (double) (iterations * 1000) / tptResults[4];
        double thrdPurgeObjItPerSecond = (double) (iterations * 1000) / tptResults[5];
        double thrdGetDsItPerSecond = (double) (iterations * 1000) / tptResults[6];
        double thrdGetDsRestItPerSecond = (double) (iterations * 1000) / tptResults[7];
        out.println(name + ", " +
                    round(thrdIngestItPerSecond) + ", " +
                    round(thrdAddDsItPerSecond) + ", " +
                    round(thrdModifyRefItPerSecond) + ", " +
                    round(thrdModifyValItPerSecond) + ", " +
                    round(thrdPurgeDsItPerSecond) + ", " +
                    round(thrdPurgeObjItPerSecond) + ", " +
                    round(thrdGetDsItPerSecond) + ", " +
                    round(thrdGetDsRestItPerSecond));

        if (!newFile) {
            reader.close();
            tempFile.delete();
        }
        out.close();

        System.out.println("Performance Tests Complete.");
    }

}


text:
using System;

namespace Mensura.Length
{
  /// <summary>
  /// Represents the Internal System of Units (SI) Decametre
  /// </summary>
  public sealed class Decametre
  : UnitOfLength<Decametre>
  {
    /// <summary>
    /// Initializes a new instance of <see cref="Decametre"/>
    /// </summary>
    public Decametre()
      : base()
    { }

    /// <summary>
    /// Initializes a new instance of <see cref="Decametre"/> with the
    /// specified value
    /// </summary>
    /// <param name="value">
    /// The value
    /// </param>
    public Decametre(decimal value)
      : base(value)
    {
    }

    /// <summary>
    /// Initializes a new instance of <see cref="Decametre"/> with the
    /// specified value and <see cref="ValueType"/>
    /// </summary>
    /// <param name="value">
    /// The value
    /// </param>
    /// <param name="type">
    /// The <see cref="ValueType"/> of the value
    /// </param>
    public Decametre(decimal value, ValueType type)
      : base(value, type)
    {
    }

    /// <summary>
    /// Convert the specified native value to the corresponding Internal System
    /// of Units (SI) value
    /// </summary>
    /// <param name="nativeValue">
    /// The native value
    /// </param>
    /// <returns>
    /// The native value, converted to the Internal System of Units (SI) value
    /// </returns>
    protected override decimal ToSI(decimal nativeValue)
    {
      var result = nativeValue * 10;

      return result;
    }

    /// <summary>
    /// Convert the specified Internal System of Units (SI) value to the
    /// corresponding native value
    /// </summary>
    /// <param name="siValue">
    /// The Internal System of Units (SI) value
    /// </param>
    /// <returns>
    /// The specified Internal System of Units (SI) value, converted to the
    /// corresponding native value
    /// </returns>
    protected override decimal FromSI(decimal siValue)
    {
      var result = siValue / 10;

      return result;
    }
  }
}


text:
/*
 * MinIO Javascript Library for Amazon S3 Compatible Cloud Storage, (C) 2015 MinIO, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

 // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-bucketname and my-prefixname
 // are dummy values, please replace them with original values.

var Minio = require('minio')

var s3Client = new Minio.Client({
    endPoint: 's3.amazonaws.com',
    accessKey: 'YOUR-ACCESSKEYID',
    secretKey: 'YOUR-SECRETACCESSKEY'
})

// List all object paths in bucket my-bucketname that begins with my-prefixname.
var incompleteObjectsStream = s3Client.listIncompleteUploads('my-bucketname', 'my-prefixname', true)
incompleteObjectsStream.on('data', function(obj) {
  console.log(obj)
})
incompleteObjectsStream.on('error', function(e) {
  console.log(e)
})