001// Copyright 2006 by Basil Vandegriend. All rights reserved. 002 003package com.basilv.envgen; 004 005import java.util.*; 006 007import com.basilv.core.Assert; 008 009/** 010 * Holds a set of properties (as a map) for each environment. 011 * 012 */ 013public class EnvironmentProperties 014{ 015 016 private List envPropertiesList = new ArrayList(); 017 018 public EnvironmentProperties(int environmentCount) { 019 Assert.greaterThanZero("environmentCount", environmentCount); 020 021 for (int i = 0; i < environmentCount; i++) { 022 Map propertyMap = new HashMap(); 023 envPropertiesList.add(propertyMap); 024 } 025 } 026 027 public void addProperty(int environment, String property, String value) { 028 Assert.notNegative("environment", environment); 029 030 Map envProperties = getPropertiesForEnvironment(environment); 031 envProperties.put(property, value); 032 033 } 034 035 public int getNumberOfEnvironments() { 036 return envPropertiesList.size(); 037 } 038 039 public List getEnvPropertiesList() { 040 return envPropertiesList; 041 } 042 043 public Map getPropertiesForEnvironment(int environment) { 044 Assert.notNegative("environment", environment); 045 046 Map envProperties = (Map) envPropertiesList.get(environment); 047 return envProperties; 048 } 049 050}