1. /*
  2. * Copyright 1999-2001,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.jexl.util;
  17. import java.util.Iterator;
  18. import java.util.Enumeration;
  19. /**
  20. * An Iterator wrapper for an Enumeration.
  21. *
  22. * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
  23. * @version $Id: EnumerationIterator.java,v 1.3 2004/02/28 13:45:21 yoavs Exp $
  24. */
  25. public class EnumerationIterator implements Iterator
  26. {
  27. /**
  28. * The enumeration to iterate.
  29. */
  30. private Enumeration enum = null;
  31. /**
  32. * Creates a new iteratorwrapper instance for the specified
  33. * Enumeration.
  34. *
  35. * @param enum The Enumeration to wrap.
  36. */
  37. public EnumerationIterator( Enumeration enum)
  38. {
  39. this.enum = enum;
  40. }
  41. /**
  42. * Move to next element in the array.
  43. *
  44. * @return The next object in the array.
  45. */
  46. public Object next()
  47. {
  48. return enum.nextElement();
  49. }
  50. /**
  51. * Check to see if there is another element in the array.
  52. *
  53. * @return Whether there is another element.
  54. */
  55. public boolean hasNext()
  56. {
  57. return enum.hasMoreElements();
  58. }
  59. /**
  60. * Unimplemented. No analogy in Enumeration
  61. */
  62. public void remove()
  63. {
  64. // not implemented
  65. }
  66. }