KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > netui > tools > testrecorder > shared > config > Webapps


1 /*
2  * Copyright 2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache 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.apache.org/licenses/LICENSE-2.0
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  * $Header:$
17  */

18
19 package org.apache.beehive.netui.tools.testrecorder.shared.config;
20
21 import org.apache.beehive.netui.tools.testrecorder.shared.util.StringHelper;
22
23 import java.util.List JavaDoc;
24 import java.util.Map JavaDoc;
25 import java.util.HashMap JavaDoc;
26 import java.util.Collections JavaDoc;
27
28 /**
29  * User: ozzy
30  * Date: Apr 12, 2004
31  * Time: 5:35:43 PM
32  */

33 public class Webapps {
34
35     // List of WebappConfig objects
36
private List JavaDoc webappList;
37     // name -> WebappConfig
38
private Map JavaDoc webappNameMap;
39
40     public Webapps( List JavaDoc webappList ) {
41         this.webappList = webappList;
42         webappNameMap = new HashMap JavaDoc();
43         init();
44     }
45
46     private void init() {
47         WebappConfig webapp = null;
48         for ( int i = 0; i < webappList.size(); i++ ) {
49             webapp = (WebappConfig) webappList.get( i );
50             webappNameMap.put( webapp.getName(), webapp );
51         }
52     }
53
54     public List JavaDoc getWebappList() {
55         return Collections.unmodifiableList( webappList );
56     }
57
58     private Map JavaDoc getWebappNameMap() {
59         return webappNameMap;
60     }
61
62     public WebappConfig getWebapp( String JavaDoc name ) {
63         return (WebappConfig) getWebappNameMap().get( name );
64     }
65
66     public String JavaDoc toString() {
67         StringBuffer JavaDoc sb = new StringBuffer JavaDoc( 256 );
68         sb.append( "[ " );
69         sb.append( ", webappList( " + StringHelper.toString( getWebappList(), "\n", "\n\t" ) + " )" );
70         sb.append( " ]" );
71         return sb.toString();
72     }
73
74 }
75
Popular Tags