KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > portal > pluto > om > common > ResourceRefSet


1 /*
2  * Copyright 2003-2005 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 package org.apache.cocoon.portal.pluto.om.common;
17
18 import java.util.Iterator JavaDoc;
19
20 /**
21  * Resource Reference Set as defined by the web.xml as
22  * <resourse-ref>.
23  *
24  * @version $Id: ResourceRefSet.java 326883 2005-10-20 11:01:21Z cziegeler $
25  */

26 public class ResourceRefSet
27     extends AbstractSupportSet
28     implements java.io.Serializable JavaDoc, Support {
29
30     /**
31      * Retrieve the Resource Reference
32      */

33     public ResourceRef get(String JavaDoc name) {
34         Iterator JavaDoc it = this.iterator();
35         while(it.hasNext()) {
36             ResourceRef ref = (ResourceRef)it.next();
37             if(ref.getName().equals(name)) {
38                 return ref;
39             }
40         }
41         return null;
42     }
43
44     public ResourceRef add(ResourceRef ref) {
45         return this.add(ref);
46     }
47
48     public ResourceRef remove(ResourceRef ref) {
49         Iterator JavaDoc it = this.iterator();
50         while(it.hasNext()) {
51             ResourceRef internal = (ResourceRef)it.next();
52             if(internal.equals(ref)) {
53                 it.remove();
54                 return internal;
55             }
56         }
57         return null;
58     }
59 }
60
Popular Tags