Lines 71-81
Link Here
|
71 |
|
71 |
|
72 |
public Iterator packages() { |
72 |
public Iterator packages() { |
73 |
return new EnumIterator(jar.entries()) { |
73 |
return new EnumIterator(jar.entries()) { |
|
|
74 |
Set known = new HashSet(); |
75 |
|
74 |
protected Object process(Object o) { |
76 |
protected Object process(Object o) { |
75 |
JarEntry e = (JarEntry)o; |
77 |
JarEntry e = (JarEntry)o; |
76 |
if (e.isDirectory()) { |
78 |
if (e.isDirectory()) { |
77 |
return e.getName(); |
79 |
return null; |
78 |
} else { |
80 |
} else { |
|
|
81 |
String itm = e.getName(); |
82 |
int slash=itm.lastIndexOf('/'); |
83 |
String pkg = itm.substring(0, slash+1); |
84 |
if (known.add(pkg)) return pkg; |
79 |
return null; |
85 |
return null; |
80 |
} |
86 |
} |
81 |
} |
87 |
} |
Lines 131-140
Link Here
|
131 |
private final Enumeration e; |
137 |
private final Enumeration e; |
132 |
|
138 |
|
133 |
private Object lookahead; |
139 |
private Object lookahead; |
|
|
140 |
boolean slurped; |
134 |
|
141 |
|
135 |
EnumIterator(Enumeration e) { |
142 |
EnumIterator(Enumeration e) { |
136 |
this.e = e; |
143 |
this.e = e; |
137 |
slurp(); |
|
|
138 |
} |
144 |
} |
139 |
|
145 |
|
140 |
/** |
146 |
/** |
Lines 145-154
Link Here
|
145 |
protected abstract Object process(Object o); |
151 |
protected abstract Object process(Object o); |
146 |
|
152 |
|
147 |
public boolean hasNext() { |
153 |
public boolean hasNext() { |
|
|
154 |
if (!slurped) slurp(); |
148 |
return lookahead != null; |
155 |
return lookahead != null; |
149 |
} |
156 |
} |
150 |
|
157 |
|
151 |
public Object next() { |
158 |
public Object next() { |
|
|
159 |
if (!slurped) slurp(); |
152 |
if (lookahead == null) throw new NoSuchElementException(); |
160 |
if (lookahead == null) throw new NoSuchElementException(); |
153 |
Object o = lookahead; |
161 |
Object o = lookahead; |
154 |
slurp(); |
162 |
slurp(); |
Lines 160-165
Link Here
|
160 |
} |
168 |
} |
161 |
|
169 |
|
162 |
private void slurp() { |
170 |
private void slurp() { |
|
|
171 |
slurped = true; |
163 |
while (e.hasMoreElements()) { |
172 |
while (e.hasMoreElements()) { |
164 |
lookahead = process(e.nextElement()); |
173 |
lookahead = process(e.nextElement()); |
165 |
if (lookahead != null) { |
174 |
if (lookahead != null) { |