1. /*
  2. * Copyright 2003-2004 The Apache Software Foundation
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package org.apache.commons.collections.buffer;
  17. import org.apache.commons.collections.Buffer;
  18. import org.apache.commons.collections.collection.AbstractCollectionDecorator;
  19. /**
  20. * Decorates another <code>Buffer</code> to provide additional behaviour.
  21. * <p>
  22. * Methods are forwarded directly to the decorated buffer.
  23. *
  24. * @since Commons Collections 3.0
  25. * @version $Revision: 1.4 $ $Date: 2004/06/02 21:53:02 $
  26. *
  27. * @author Stephen Colebourne
  28. */
  29. public abstract class AbstractBufferDecorator extends AbstractCollectionDecorator implements Buffer {
  30. /**
  31. * Constructor only used in deserialization, do not use otherwise.
  32. * @since Commons Collections 3.1
  33. */
  34. protected AbstractBufferDecorator() {
  35. super();
  36. }
  37. /**
  38. * Constructor that wraps (not copies).
  39. *
  40. * @param buffer the buffer to decorate, must not be null
  41. * @throws IllegalArgumentException if list is null
  42. */
  43. protected AbstractBufferDecorator(Buffer buffer) {
  44. super(buffer);
  45. }
  46. /**
  47. * Gets the buffer being decorated.
  48. *
  49. * @return the decorated buffer
  50. */
  51. protected Buffer getBuffer() {
  52. return (Buffer) getCollection();
  53. }
  54. //-----------------------------------------------------------------------
  55. public Object get() {
  56. return getBuffer().get();
  57. }
  58. public Object remove() {
  59. return getBuffer().remove();
  60. }
  61. }