/emf-2.8.0/org.eclipse.emf.gwt.common/src/org/eclipse/emf/common/util/DelegatingEList.java

# · Java · 991 lines · 486 code · 93 blank · 412 comment · 21 complexity · 592cc96a3bf05423c59a046afc89078a MD5 · raw file

  1. /**
  2. * Copyright (c) 2002-2010 IBM Corporation and others.
  3. * All rights reserved. This program and the accompanying materials
  4. * are made available under the terms of the Eclipse Public License v1.0
  5. * which accompanies this distribution, and is available at
  6. * http://www.eclipse.org/legal/epl-v10.html
  7. *
  8. * Contributors:
  9. * IBM - Initial API and implementation
  10. */
  11. package org.eclipse.emf.common.util;
  12. import java.io.Serializable;
  13. import java.util.Collection;
  14. import java.util.Iterator;
  15. import java.util.List;
  16. import java.util.ListIterator;
  17. /**
  18. * A highly extensible delegating list implementation.
  19. */
  20. public abstract class DelegatingEList<E> extends AbstractEList<E> implements Cloneable, Serializable
  21. {
  22. private static final long serialVersionUID = 1L;
  23. /**
  24. * Creates an empty instance.
  25. */
  26. public DelegatingEList()
  27. {
  28. super();
  29. }
  30. /**
  31. * Creates an instance that is a copy of the collection.
  32. * @param collection the initial contents of the list.
  33. */
  34. public DelegatingEList(Collection<? extends E> collection)
  35. {
  36. addAll(collection);
  37. }
  38. /**
  39. * Returns the list that acts as the backing store.
  40. * @return the list that acts as the backing store.
  41. */
  42. protected abstract List<E> delegateList();
  43. /**
  44. * Returns the number of objects in the list.
  45. * @return the number of objects in the list.
  46. */
  47. @Override
  48. public int size()
  49. {
  50. return delegateSize();
  51. }
  52. /**
  53. * Returns the number of objects in the backing store list.
  54. * @return the number of objects in the backing store list.
  55. */
  56. protected int delegateSize()
  57. {
  58. return delegateList().size();
  59. }
  60. /**
  61. * Returns whether the list has zero size.
  62. * @return whether the list has zero size.
  63. */
  64. @Override
  65. public boolean isEmpty()
  66. {
  67. return delegateIsEmpty();
  68. }
  69. /**
  70. * Returns whether the backing store list has zero size.
  71. * @return whether the backing store list has zero size.
  72. */
  73. protected boolean delegateIsEmpty()
  74. {
  75. return delegateList().isEmpty();
  76. }
  77. /**
  78. * Returns whether the list contains the object.
  79. * @param object the object in question.
  80. * @return whether the list contains the object.
  81. */
  82. @Override
  83. public boolean contains(Object object)
  84. {
  85. return delegateContains(object);
  86. }
  87. /**
  88. * Returns whether the backing store list contains the object.
  89. * @param object the object in question.
  90. * @return whether the backing store list contains the object.
  91. */
  92. protected boolean delegateContains(Object object)
  93. {
  94. return delegateList().contains(object);
  95. }
  96. /**
  97. * Returns whether the list contains each object in the collection.
  98. * @return whether the list contains each object in the collection.
  99. * @see #contains
  100. * @see #useEquals
  101. */
  102. @Override
  103. public boolean containsAll(Collection<?> collection)
  104. {
  105. return delegateContainsAll(collection);
  106. }
  107. /**
  108. * Returns whether the backing store list contains each object in the collection.
  109. * @return whether the backing store list contains each object in the collection.
  110. * @see #contains
  111. * @see #useEquals
  112. */
  113. protected boolean delegateContainsAll(Collection<?> collection)
  114. {
  115. return delegateList().containsAll(collection);
  116. }
  117. /**
  118. * Returns the position of the first occurrence of the object in the list.
  119. * @param object the object in question.
  120. * @return the position of the first occurrence of the object in the list.
  121. */
  122. @Override
  123. public int indexOf(Object object)
  124. {
  125. return delegateIndexOf(object);
  126. }
  127. /**
  128. * Returns the position of the first occurrence of the object in the backing store list.
  129. * @param object the object in question.
  130. * @return the position of the first occurrence of the object in the backing store list.
  131. */
  132. protected int delegateIndexOf(Object object)
  133. {
  134. return delegateList().indexOf(object);
  135. }
  136. /**
  137. * Returns the position of the last occurrence of the object in the list.
  138. * @param object the object in question.
  139. * @return the position of the last occurrence of the object in the list.
  140. */
  141. @Override
  142. public int lastIndexOf(Object object)
  143. {
  144. return delegateLastIndexOf(object);
  145. }
  146. /**
  147. * Returns the position of the last occurrence of the object in the backing store list.
  148. * @param object the object in question.
  149. * @return the position of the last occurrence of the object in the backing store list.
  150. */
  151. protected int delegateLastIndexOf(Object object)
  152. {
  153. return delegateList().lastIndexOf(object);
  154. }
  155. /**
  156. * Returns an array containing all the objects in sequence.
  157. * @return an array containing all the objects in sequence.
  158. */
  159. @Override
  160. public Object[] toArray()
  161. {
  162. return delegateToArray();
  163. }
  164. /**
  165. * Returns an array containing all the objects in the backing store list in sequence.
  166. * @return an array containing all the objects in the backing store list in sequence.
  167. */
  168. protected Object[] delegateToArray()
  169. {
  170. return delegateList().toArray();
  171. }
  172. /**
  173. * Returns an array containing all the objects in sequence.
  174. * @param array the array that will be filled and returned, if it's big enough;
  175. * otherwise, a suitably large array of the same type will be allocated and used instead.
  176. * @return an array containing all the objects in sequence.
  177. */
  178. @Override
  179. public <T> T[] toArray(T[] array)
  180. {
  181. return delegateToArray(array);
  182. }
  183. /**
  184. * Returns an array containing all the objects in the backing store list in sequence.
  185. * @param array the array that will be filled and returned, if it's big enough;
  186. * otherwise, a suitably large array of the same type will be allocated and used instead.
  187. * @return an array containing all the objects in sequence.
  188. */
  189. protected <T> T[] delegateToArray(T[] array)
  190. {
  191. return delegateList().toArray(array);
  192. }
  193. /**
  194. * Returns the object at the index.
  195. * This implementation delegates to {@link #resolve resolve}
  196. * so that clients may transform the fetched object.
  197. * @param index the position in question.
  198. * @return the object at the index.
  199. * @exception IndexOutOfBoundsException if the index isn't within the size range.
  200. * @see #resolve
  201. * @see #basicGet
  202. */
  203. @Override
  204. public E get(int index)
  205. {
  206. return resolve(index, delegateGet(index));
  207. }
  208. /**
  209. * Returns the object at the index in the backing store list.
  210. * @param index the position in question.
  211. * @return the object at the index.
  212. * @exception IndexOutOfBoundsException if the index isn't within the size range.
  213. */
  214. protected E delegateGet(int index)
  215. {
  216. return delegateList().get(index);
  217. }
  218. /**
  219. * Returns the object at the index without {@link #resolve resolving} it.
  220. * @param index the position in question.
  221. * @return the object at the index.
  222. * @exception IndexOutOfBoundsException if the index isn't within the size range.
  223. * @see #resolve
  224. * @see #get
  225. */
  226. @Override
  227. protected E basicGet(int index)
  228. {
  229. return delegateGet(index);
  230. }
  231. @Override
  232. protected E primitiveGet(int index)
  233. {
  234. return delegateGet(index);
  235. }
  236. /**
  237. * Sets the object at the index
  238. * and returns the old object at the index;
  239. * it does no ranging checking or uniqueness checking.
  240. * This implementation delegates to {@link #didSet didSet} and {@link #didChange didChange}.
  241. * @param index the position in question.
  242. * @param object the object to set.
  243. * @return the old object at the index.
  244. * @see #set
  245. */
  246. @Override
  247. public E setUnique(int index, E object)
  248. {
  249. E oldObject = delegateSet(index, validate(index, object));
  250. didSet(index, object, oldObject);
  251. didChange();
  252. return oldObject;
  253. }
  254. /**
  255. * Sets the object at the index in the backing store list
  256. * and returns the old object at the index.
  257. * @param object the object to set.
  258. * @return the old object at the index.
  259. */
  260. protected E delegateSet(int index, E object)
  261. {
  262. return delegateList().set(index, object);
  263. }
  264. /**
  265. * Adds the object at the end of the list;
  266. * it does no uniqueness checking.
  267. * This implementation delegates to {@link #didAdd didAdd} and {@link #didChange didChange}.
  268. * after uniqueness checking.
  269. * @param object the object to be added.
  270. * @see #add(Object)
  271. */
  272. @Override
  273. public void addUnique(E object)
  274. {
  275. int size = size();
  276. delegateAdd(validate(size, object));
  277. didAdd(size, object);
  278. didChange();
  279. }
  280. /**
  281. * Adds the object at the end of the backing store list.
  282. * @param object the object to be added.
  283. */
  284. protected void delegateAdd(E object)
  285. {
  286. delegateList().add(object);
  287. }
  288. /**
  289. * Adds the object at the given index in the list;
  290. * it does no ranging checking or uniqueness checking.
  291. * This implementation delegates to {@link #didAdd didAdd} and {@link #didChange didChange}.
  292. * @param object the object to be added.
  293. * @see #add(int, Object)
  294. */
  295. @Override
  296. public void addUnique(int index, E object)
  297. {
  298. delegateAdd(index, validate(index, object));
  299. didAdd(index, object);
  300. didChange();
  301. }
  302. /**
  303. * Adds the object at the given index in the backing store list.
  304. * @param object the object to be added.
  305. */
  306. protected void delegateAdd(int index, E object)
  307. {
  308. delegateList().add(index, object);
  309. }
  310. /**
  311. * Adds each object of the collection to the end of the list;
  312. * it does no uniqueness checking.
  313. * This implementation delegates to {@link #didAdd didAdd} and {@link #didChange didChange}.
  314. * @param collection the collection of objects to be added.
  315. * @see #addAll(Collection)
  316. */
  317. @Override
  318. public boolean addAllUnique(Collection<? extends E> collection)
  319. {
  320. if (collection.isEmpty())
  321. {
  322. return false;
  323. }
  324. else
  325. {
  326. int i = size();
  327. for (E object : collection)
  328. {
  329. delegateAdd(validate(i, object));
  330. didAdd(i, object);
  331. didChange();
  332. i++;
  333. }
  334. return true;
  335. }
  336. }
  337. /**
  338. * Adds each object of the collection at each successive index in the list
  339. * and returns whether any objects were added;
  340. * it does no ranging checking or uniqueness checking.
  341. * This implementation delegates to {@link #didAdd didAdd} and {@link #didChange didChange}.
  342. * @param index the index at which to add.
  343. * @param collection the collection of objects to be added.
  344. * @return whether any objects were added.
  345. * @see #addAll(int, Collection)
  346. */
  347. @Override
  348. public boolean addAllUnique(int index, Collection<? extends E> collection)
  349. {
  350. if (collection.isEmpty())
  351. {
  352. return false;
  353. }
  354. else
  355. {
  356. for (E object : collection)
  357. {
  358. delegateAdd(index, validate(index, object));
  359. didAdd(index, object);
  360. didChange();
  361. index++;
  362. }
  363. return true;
  364. }
  365. }
  366. /**
  367. * Adds each object from start to end of the array at the index of list
  368. * and returns whether any objects were added;
  369. * it does no ranging checking or uniqueness checking.
  370. * This implementation delegates to {@link #delegateAdd(Object) delegatedAdd}, {@link #didAdd didAdd}, and {@link #didChange didChange}.
  371. * @param objects the objects to be added.
  372. * @param start the index of first object to be added.
  373. * @param end the index past the last object to be added.
  374. * @return whether any objects were added.
  375. * @see #addAllUnique(int, Object[], int, int)
  376. */
  377. @Override
  378. public boolean addAllUnique(Object [] objects, int start, int end)
  379. {
  380. int growth = end - start;
  381. if (growth == 0)
  382. {
  383. return false;
  384. }
  385. else
  386. {
  387. int index = size();
  388. for (int i = start; i < end; ++i, ++index)
  389. {
  390. @SuppressWarnings("unchecked") E object = (E)objects[i];
  391. delegateAdd(validate(index, object));
  392. didAdd(index, object);
  393. didChange();
  394. }
  395. return true;
  396. }
  397. }
  398. /**
  399. * Adds each object from start to end of the array at each successive index in the list
  400. * and returns whether any objects were added;
  401. * it does no ranging checking or uniqueness checking.
  402. * This implementation delegates to {@link #delegateAdd(int, Object) delegatedAdd}, {@link #didAdd didAdd}, and {@link #didChange didChange}.
  403. * @param index the index at which to add.
  404. * @param objects the objects to be added.
  405. * @param start the index of first object to be added.
  406. * @param end the index past the last object to be added.
  407. * @return whether any objects were added.
  408. * @see #addAllUnique(Object[], int, int)
  409. */
  410. @Override
  411. public boolean addAllUnique(int index, Object [] objects, int start, int end)
  412. {
  413. int growth = end - start;
  414. if (growth == 0)
  415. {
  416. return false;
  417. }
  418. else
  419. {
  420. for (int i = start; i < end; ++i, ++index)
  421. {
  422. @SuppressWarnings("unchecked") E object = (E)objects[i];
  423. delegateAdd(validate(index, object));
  424. didAdd(index, object);
  425. didChange();
  426. }
  427. return true;
  428. }
  429. }
  430. /**
  431. * Removes the object from the list and returns whether the object was actually contained by the list.
  432. * This implementation uses {@link #indexOf indexOf} to find the object
  433. * and delegates to {@link #remove(int) remove(int)}
  434. * in the case that it finds the object.
  435. * @param object the object to be removed.
  436. * @return whether the object was actually contained by the list.
  437. */
  438. @Override
  439. public boolean remove(Object object)
  440. {
  441. int index = indexOf(object);
  442. if (index >= 0)
  443. {
  444. remove(index);
  445. return true;
  446. }
  447. else
  448. {
  449. return false;
  450. }
  451. }
  452. /**
  453. * Removes each object of the collection from the list and returns whether any object was actually contained by the list.
  454. * @param collection the collection of objects to be removed.
  455. * @return whether any object was actually contained by the list.
  456. */
  457. @Override
  458. public boolean removeAll(Collection<?> collection)
  459. {
  460. boolean modified = false;
  461. for (ListIterator<?> i = listIterator(); i.hasNext(); )
  462. {
  463. if (collection.contains(i.next()))
  464. {
  465. i.remove();
  466. modified = true;
  467. }
  468. }
  469. return modified;
  470. }
  471. /**
  472. * Removes the object at the index from the list and returns it.
  473. * This implementation delegates to {@link #didRemove didRemove} and {@link #didChange didChange}.
  474. * @param index the position of the object to remove.
  475. * @return the removed object.
  476. * @exception IndexOutOfBoundsException if the index isn't within the size range.
  477. */
  478. @Override
  479. public E remove(int index)
  480. {
  481. E oldObject = delegateRemove(index);
  482. didRemove(index, oldObject);
  483. didChange();
  484. return oldObject;
  485. }
  486. /**
  487. * Removes the object at the index from the backing store list and returns it.
  488. * @return the removed object.
  489. * @exception IndexOutOfBoundsException if the index isn't within the size range.
  490. */
  491. protected E delegateRemove(int index)
  492. {
  493. return delegateList().remove(index);
  494. }
  495. /**
  496. * Removes from the list each object not contained by the collection
  497. * and returns whether any object was actually removed.
  498. * This delegates to {@link #remove(int) remove(int)}
  499. * in the case that it finds an object that isn't retained.
  500. * @param collection the collection of objects to be retained.
  501. * @return whether any object was actually removed.
  502. */
  503. @Override
  504. public boolean retainAll(Collection<?> collection)
  505. {
  506. boolean modified = false;
  507. for (ListIterator<?> i = listIterator(); i.hasNext(); )
  508. {
  509. if (!collection.contains(i.next()))
  510. {
  511. i.remove();
  512. modified = true;
  513. }
  514. }
  515. return modified;
  516. }
  517. /**
  518. * Clears the list of all objects.
  519. */
  520. @Override
  521. public void clear()
  522. {
  523. doClear(size(), delegateToArray());
  524. }
  525. /**
  526. * Does the actual job of clearing all the objects.
  527. * @param oldSize the size of the list before it is cleared.
  528. * @param oldData old values of the list before it is cleared.
  529. */
  530. protected void doClear(int oldSize, Object [] oldData)
  531. {
  532. delegateClear();
  533. didClear(oldSize, oldData);
  534. didChange();
  535. }
  536. /**
  537. * Clears the backing store list of all objects.
  538. */
  539. protected void delegateClear()
  540. {
  541. delegateList().clear();
  542. }
  543. /**
  544. * Moves the object at the source index of the list to the target index of the list
  545. * and returns the moved object.
  546. * This implementation delegates to {@link #didMove didMove} and {@link #didChange didChange}.
  547. * @param targetIndex the new position for the object in the list.
  548. * @param sourceIndex the old position of the object in the list.
  549. * @return the moved object.
  550. * @exception IndexOutOfBoundsException if either index isn't within the size range.
  551. */
  552. @Override
  553. public E move(int targetIndex, int sourceIndex)
  554. {
  555. int size = size();
  556. if (targetIndex >= size || targetIndex < 0)
  557. throw new IndexOutOfBoundsException("targetIndex=" + targetIndex + ", size=" + size);
  558. if (sourceIndex >= size || sourceIndex < 0)
  559. throw new IndexOutOfBoundsException("sourceIndex=" + sourceIndex + ", size=" + size);
  560. E object;
  561. if (targetIndex != sourceIndex)
  562. {
  563. object = delegateMove(targetIndex, sourceIndex);
  564. didMove(targetIndex, object, sourceIndex);
  565. didChange();
  566. }
  567. else
  568. {
  569. object = delegateGet(sourceIndex);
  570. }
  571. return object;
  572. }
  573. /**
  574. * Moves the object at the source index in the backing store list by removing it and adding it at the new target index.
  575. * @param targetIndex the new position for the object in the list.
  576. * @param sourceIndex the old position of the object in the list.
  577. * @return the moved object.
  578. * @exception IndexOutOfBoundsException if either index isn't within the size range.
  579. * @since 2.3
  580. */
  581. protected E delegateMove(int targetIndex, int sourceIndex)
  582. {
  583. E result = delegateRemove(sourceIndex);
  584. delegateAdd(targetIndex, result);
  585. return result;
  586. }
  587. /**
  588. * Returns whether the object is a list with corresponding equal objects.
  589. * This implementation uses either <code>equals</code> or <code>"=="</code> depending on {@link #useEquals useEquals}.
  590. * @return whether the object is a list with corresponding equal objects.
  591. * @see #useEquals
  592. */
  593. @Override
  594. public boolean equals(Object object)
  595. {
  596. return delegateEquals(object);
  597. }
  598. /**
  599. * Returns whether the object is a list with corresponding equal objects to those in the backing store list.
  600. * @return whether the object is a list with corresponding equal objects.
  601. */
  602. protected boolean delegateEquals(Object object)
  603. {
  604. return delegateList().equals(object);
  605. }
  606. /**
  607. * Returns a hash code computed from each object's hash code.
  608. * @return a hash code.
  609. */
  610. @Override
  611. public int hashCode()
  612. {
  613. return delegateHashCode();
  614. }
  615. /**
  616. * Returns the hash code of the backing store list.
  617. * @return a hash code.
  618. */
  619. protected int delegateHashCode()
  620. {
  621. return delegateList().hashCode();
  622. }
  623. /**
  624. * Returns a string of the form <code>"[object1, object2]"</code>.
  625. * @return a string of the form <code>"[object1, object2]"</code>.
  626. */
  627. @Override
  628. public String toString()
  629. {
  630. return delegateToString();
  631. }
  632. /**
  633. * Returns a the string form of the backing store list.
  634. * @return a the string form of the backing store list.
  635. */
  636. protected String delegateToString()
  637. {
  638. return delegateList().toString();
  639. }
  640. /**
  641. * Returns an iterator over the backing store list.
  642. * @return an iterator.
  643. */
  644. protected Iterator<E> delegateIterator()
  645. {
  646. return delegateList().iterator();
  647. }
  648. /**
  649. * An extensible iterator implementation.
  650. * @deprecated
  651. * @see AbstractEList.EIterator
  652. */
  653. @Deprecated
  654. protected class EIterator<E1> extends AbstractEList<E>.EIterator<E1>
  655. {
  656. // Pointless extension
  657. }
  658. /**
  659. * An extended read-only iterator that does not {@link DelegatingEList#resolve resolve} objects.
  660. * @deprecated
  661. * @see AbstractEList.NonResolvingEIterator
  662. */
  663. @Deprecated
  664. protected class NonResolvingEIterator<E1> extends AbstractEList<E>.NonResolvingEIterator<E1>
  665. {
  666. // Pointless extension
  667. }
  668. /**
  669. * Returns a list iterator over the backing store list.
  670. * @return a list iterator.
  671. */
  672. protected ListIterator<E> delegateListIterator()
  673. {
  674. return delegateList().listIterator();
  675. }
  676. /**
  677. * An extensible list iterator implementation.
  678. * @deprecated
  679. * @see AbstractEList.EListIterator
  680. */
  681. @Deprecated
  682. protected class EListIterator<E1> extends AbstractEList<E>.EListIterator<E1>
  683. {
  684. /**
  685. * Creates an instance.
  686. */
  687. public EListIterator()
  688. {
  689. super();
  690. }
  691. /**
  692. * Creates an instance advanced to the index.
  693. * @param index the starting index.
  694. */
  695. public EListIterator(int index)
  696. {
  697. super(index);
  698. }
  699. }
  700. /**
  701. * An extended read-only list iterator that does not {@link DelegatingEList#resolve resolve} objects.
  702. * @deprecated
  703. * @see AbstractEList.NonResolvingEListIterator
  704. */
  705. @Deprecated
  706. protected class NonResolvingEListIterator<E1> extends AbstractEList<E>.NonResolvingEListIterator<E1>
  707. {
  708. /**
  709. * Creates an instance.
  710. */
  711. public NonResolvingEListIterator()
  712. {
  713. super();
  714. }
  715. /**
  716. * Creates an instance advanced to the index.
  717. * @param index the starting index.
  718. */
  719. public NonResolvingEListIterator(int index)
  720. {
  721. super(index);
  722. }
  723. }
  724. /**
  725. * An unmodifiable version of {@link DelegatingEList}.
  726. */
  727. public static class UnmodifiableEList<E> extends DelegatingEList<E>
  728. {
  729. private static final long serialVersionUID = 1L;
  730. protected List<E> underlyingList;
  731. /**
  732. * Creates an initialized instance.
  733. * @param underlyingList the backing store list.
  734. */
  735. public UnmodifiableEList(List<E> underlyingList)
  736. {
  737. this.underlyingList = underlyingList;
  738. }
  739. @Override
  740. protected List<E> delegateList()
  741. {
  742. return underlyingList;
  743. }
  744. /**
  745. * Throws an exception.
  746. * @exception UnsupportedOperationException always because it's not supported.
  747. */
  748. @Override
  749. public E set(int index, E object)
  750. {
  751. throw new UnsupportedOperationException();
  752. }
  753. /**
  754. * Throws an exception.
  755. * @exception UnsupportedOperationException always because it's not supported.
  756. */
  757. @Override
  758. public boolean add(E object)
  759. {
  760. throw new UnsupportedOperationException();
  761. }
  762. /**
  763. * Throws an exception.
  764. * @exception UnsupportedOperationException always because it's not supported.
  765. */
  766. @Override
  767. public void add(int index, E object)
  768. {
  769. throw new UnsupportedOperationException();
  770. }
  771. /**
  772. * Throws an exception.
  773. * @exception UnsupportedOperationException always because it's not supported.
  774. */
  775. @Override
  776. public boolean addAll(Collection<? extends E> collection)
  777. {
  778. throw new UnsupportedOperationException();
  779. }
  780. /**
  781. * Throws an exception.
  782. * @exception UnsupportedOperationException always because it's not supported.
  783. */
  784. @Override
  785. public boolean addAll(int index, Collection<? extends E> collection)
  786. {
  787. throw new UnsupportedOperationException();
  788. }
  789. /**
  790. * Throws an exception.
  791. * @exception UnsupportedOperationException always because it's not supported.
  792. */
  793. @Override
  794. public boolean remove(Object object)
  795. {
  796. throw new UnsupportedOperationException();
  797. }
  798. /**
  799. * Throws an exception.
  800. * @exception UnsupportedOperationException always because it's not supported.
  801. */
  802. @Override
  803. public E remove(int index)
  804. {
  805. throw new UnsupportedOperationException();
  806. }
  807. /**
  808. * Throws an exception.
  809. * @exception UnsupportedOperationException always because it's not supported.
  810. */
  811. @Override
  812. public boolean removeAll(Collection<?> collection)
  813. {
  814. throw new UnsupportedOperationException();
  815. }
  816. /**
  817. * Throws an exception.
  818. * @exception UnsupportedOperationException always because it's not supported.
  819. */
  820. @Override
  821. public boolean retainAll(Collection<?> collection)
  822. {
  823. throw new UnsupportedOperationException();
  824. }
  825. /**
  826. * Throws an exception.
  827. * @exception UnsupportedOperationException always because it's not supported.
  828. */
  829. @Override
  830. public void clear()
  831. {
  832. throw new UnsupportedOperationException();
  833. }
  834. /**
  835. * Throws an exception.
  836. * @exception UnsupportedOperationException always because it's not supported.
  837. */
  838. @Override
  839. public void move(int index, E object)
  840. {
  841. throw new UnsupportedOperationException();
  842. }
  843. /**
  844. * Throws an exception.
  845. * @exception UnsupportedOperationException always because it's not supported.
  846. */
  847. @Override
  848. public E move(int targetIndex, int sourceIndex)
  849. {
  850. throw new UnsupportedOperationException();
  851. }
  852. /**
  853. * Returns the {@link DelegatingEList#basicIterator basic iterator}.
  854. * @return the basic iterator.
  855. */
  856. @Override
  857. public Iterator<E> iterator()
  858. {
  859. return basicIterator();
  860. }
  861. /**
  862. * Returns the {@link #basicListIterator() basic list iterator}.
  863. * @return the basic list iterator.
  864. */
  865. @Override
  866. public ListIterator<E> listIterator()
  867. {
  868. return basicListIterator();
  869. }
  870. /**
  871. * Returns the {@link #basicListIterator(int) basic list iterator} advanced to the index.
  872. * @param index the starting index.
  873. * @return the basic list iterator.
  874. */
  875. @Override
  876. public ListIterator<E> listIterator(int index)
  877. {
  878. return basicListIterator(index);
  879. }
  880. }
  881. /**
  882. * Returns an <b>unsafe</b> list that provides a {@link #resolve non-resolving} view of the backing store list.
  883. * @return an <b>unsafe</b> list that provides a non-resolving view of the backing store list.
  884. */
  885. @Override
  886. protected List<E> basicList()
  887. {
  888. return delegateBasicList();
  889. }
  890. /**
  891. * Returns an <b>unsafe</b> list that provides a {@link #resolve non-resolving} view of the backing store list.
  892. * @return an <b>unsafe</b> list that provides a non-resolving view of the backing store list.
  893. */
  894. protected List<E> delegateBasicList()
  895. {
  896. return delegateList();
  897. }
  898. }