Class represents a dynamically typesafe view of the specified entry set.
| 3307 | * set. |
| 3308 | */ |
| 3309 | private static class CheckedEntrySet<K, V> implements |
| 3310 | Set<Map.Entry<K, V>> { |
| 3311 | |
| 3312 | Set<Map.Entry<K, V>> s; |
| 3313 | |
| 3314 | Class<V> valueType; |
| 3315 | |
| 3316 | /** |
| 3317 | * Constructs a dynamically typesafe view of the specified entry |
| 3318 | * set. |
| 3319 | * |
| 3320 | * @param s - |
| 3321 | * the entry set for which a dynamically typesafe view is |
| 3322 | * to be constructed. |
| 3323 | */ |
| 3324 | public CheckedEntrySet(Set<Map.Entry<K, V>> s, Class<V> valueType) { |
| 3325 | this.s = s; |
| 3326 | this.valueType = valueType; |
| 3327 | } |
| 3328 | |
| 3329 | /** |
| 3330 | * @see java.util.Set#iterator() |
| 3331 | */ |
| 3332 | public Iterator<Map.Entry<K, V>> iterator() { |
| 3333 | return new CheckedEntryIterator<K, V>(s.iterator(), valueType); |
| 3334 | } |
| 3335 | |
| 3336 | /** |
| 3337 | * @see java.util.Set#toArray() |
| 3338 | */ |
| 3339 | public Object[] toArray() { |
| 3340 | int thisSize = size(); |
| 3341 | Object[] array = new Object[thisSize]; |
| 3342 | Iterator<?> it = iterator(); |
| 3343 | for (int i = 0; i < thisSize; i++) { |
| 3344 | array[i] = it.next(); |
| 3345 | } |
| 3346 | return array; |
| 3347 | } |
| 3348 | |
| 3349 | /** |
| 3350 | * @see java.util.Set#toArray(Object[]) |
| 3351 | */ |
| 3352 | @SuppressWarnings("unchecked") |
| 3353 | public <T> T[] toArray(T[] array) { |
| 3354 | int thisSize = size(); |
| 3355 | if (array.length < thisSize) { |
| 3356 | Class<?> ct = array.getClass().getComponentType(); |
| 3357 | array = (T[]) Array.newInstance(ct, thisSize); |
| 3358 | } |
| 3359 | Iterator<?> it = iterator(); |
| 3360 | for (int i = 0; i < thisSize; i++) { |
| 3361 | array[i] = (T) it.next(); |
| 3362 | } |
| 3363 | if (thisSize < array.length) { |
| 3364 | array[thisSize] = null; |
| 3365 | } |
| 3366 | return array; |
nothing calls this directly
no outgoing calls
no test coverage detected