001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.cocoon.portal.pluto.om.common;
018:
019: import java.io.Serializable;
020: import java.util.Collection;
021: import java.util.Iterator;
022: import java.util.Set;
023:
024: /**
025: *
026: *
027: * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
028: *
029: * @version CVS $Id: UnmodifiableSet.java 433543 2006-08-22 06:22:54Z crossley $
030: */
031: public class UnmodifiableSet implements Set, Serializable {
032:
033: // use serialVersionUID from JDK 1.2.2 for interoperability
034: private static final long serialVersionUID = 1820017752578914078L;
035:
036: protected Set c;
037:
038: public UnmodifiableSet(Set c) {
039: if (c == null) {
040: throw new NullPointerException();
041: }
042: this .c = c;
043: }
044:
045: public int size() {
046: return c.size();
047: }
048:
049: public boolean isEmpty() {
050: return c.isEmpty();
051: }
052:
053: public boolean contains(Object o) {
054: return c.contains(o);
055: }
056:
057: public Object[] toArray() {
058: return c.toArray();
059: }
060:
061: public Object[] toArray(Object[] a) {
062: return c.toArray(a);
063: }
064:
065: public String toString() {
066: return c.toString();
067: }
068:
069: public Iterator iterator() {
070: return new Iterator() {
071: Iterator i = c.iterator();
072:
073: public boolean hasNext() {
074: return i.hasNext();
075: }
076:
077: public Object next() {
078: return i.next();
079: }
080:
081: public void remove() {
082: throw new UnsupportedOperationException();
083: }
084: };
085: }
086:
087: public boolean add(Object o) {
088: throw new UnsupportedOperationException();
089: }
090:
091: public boolean remove(Object o) {
092: throw new UnsupportedOperationException();
093: }
094:
095: public boolean containsAll(Collection coll) {
096: return c.containsAll(coll);
097: }
098:
099: public boolean addAll(Collection coll) {
100: throw new UnsupportedOperationException();
101: }
102:
103: public boolean removeAll(Collection coll) {
104: throw new UnsupportedOperationException();
105: }
106:
107: public boolean retainAll(Collection coll) {
108: throw new UnsupportedOperationException();
109: }
110:
111: public void clear() {
112: throw new UnsupportedOperationException();
113: }
114:
115: public boolean equals(Object o) {
116: return c.equals(o);
117: }
118:
119: public int hashCode() {
120: return c.hashCode();
121: }
122:
123: // additional methods.
124:
125: /**
126: * This method is only used by the ControllerFactoryImpl
127: * to unwrap the unmodifiable Set and allow to
128: * modify the set via controllers
129: *
130: * @return the modifiable set
131: */
132: public Set getModifiableSet() {
133: return c;
134: }
135: }
|