View Javadoc

1   /**
2    * Copyright 2010-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.common.util.spring;
17  
18  import java.util.ArrayList;
19  import java.util.Arrays;
20  import java.util.List;
21  
22  import org.kuali.common.util.Project;
23  import org.kuali.common.util.ProjectContext;
24  import org.kuali.common.util.ProjectUtils;
25  import org.kuali.common.util.property.ProjectProperties;
26  import org.kuali.common.util.property.PropertiesContext;
27  
28  public class ConfigUtils {
29  
30  	public static List<ProjectProperties> getProjectProperties(List<ProjectContext> contexts) {
31  		List<ProjectProperties> list = new ArrayList<ProjectProperties>();
32  		for (ProjectContext context : contexts) {
33  			Project project = ProjectUtils.loadProject(context);
34  			ProjectProperties pp = getProjectProperties(project, context.getPropertyLocations());
35  			list.add(pp);
36  		}
37  		return list;
38  	}
39  
40  	public static List<ProjectProperties> getProjectProperties(ProjectContext... contexts) {
41  		return getProjectProperties(Arrays.asList(contexts));
42  	}
43  
44  	public static ProjectProperties getProjectProperties(ProjectContext context) {
45  		Project project = ProjectUtils.loadProject(context);
46  		return getProjectProperties(project, context.getPropertyLocations());
47  	}
48  
49  	public static ProjectProperties getProjectProperties(Project project, List<String> locations) {
50  		PropertiesContext pc = new PropertiesContext();
51  		pc.setEncoding(project.getEncoding());
52  		pc.setLocations(locations);
53  		return new ProjectProperties(project, pc);
54  	}
55  }