blob: 6165b2d4fcc3354a763ef21af27d33f086df2f1b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
/* Copyright (C) 1999 Red Hat, Inc.
This file is part of libgcj.
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package gnu.gcj.util;
import java.util.Enumeration;
import java.util.NoSuchElementException;
public class EnumerationChain implements Enumeration
{
private Enumeration first_;
private Enumeration second_;
public EnumerationChain (Enumeration first, Enumeration second)
{
if (first == null
|| second == null)
throw new NullPointerException();
first_ = first;
second_ = second;
}
public synchronized boolean hasMoreElements()
{
if (first_ == null)
return false;
else
return first_.hasMoreElements();
}
public synchronized Object nextElement() throws NoSuchElementException
{
while (first_ != null)
{
if (! first_.hasMoreElements())
{
first_ = second_;
second_ = null;
}
else
return first_.nextElement();
}
throw new NoSuchElementException();
}
}
|