KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > util > EnumerationWrapper


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.util;
5
6 import com.tc.object.bytecode.ManagerUtil;
7 import com.tc.object.lockmanager.api.LockLevel;
8
9 import java.util.Enumeration JavaDoc;
10 import java.util.Vector JavaDoc;
11
12 public class EnumerationWrapper implements Enumeration JavaDoc {
13
14   private final Vector JavaDoc vector;
15   private final Enumeration JavaDoc realEnumeration;
16
17   public EnumerationWrapper(Vector JavaDoc vector, Enumeration JavaDoc realEnumeration) {
18     this.vector = vector;
19     this.realEnumeration = realEnumeration;
20   }
21
22   public final boolean hasMoreElements() {
23     return realEnumeration.hasMoreElements();
24   }
25
26   public final Object JavaDoc nextElement() {
27     ManagerUtil.monitorEnter(vector, LockLevel.WRITE);
28     Object JavaDoc o = null;
29     try {
30       o = realEnumeration.nextElement();
31     } finally {
32       ManagerUtil.monitorExit(vector);
33     }
34     return o;
35   }
36 }
37
Popular Tags