aspose file tools*
The moose likes Java in General and the fly likes copy from one enumeration into another!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "copy from one enumeration into another!!" Watch "copy from one enumeration into another!!" New topic
Author

copy from one enumeration into another!!

Ravi Kumar Ravuru
Ranch Hand

Joined: Apr 18, 2002
Posts: 176
Hello Folks,
Can i copy the contents of one enumeration into another enumeration.Please help me out.
Thanks in Advance.
Ravi
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
An Enumeration is an (old) interface. Nothing in that interfacce allows you to store new elements in that enumeration. You could of course catenate two (or more) enumerations as follows:

kind regards
Ravi Kumar Ravuru
Ranch Hand

Joined: Apr 18, 2002
Posts: 176
Hello Jos Horsmeier,
Thanks for ur reply.But i need to copy the elements of one enumeration to another enumeration. Is it possible.
Ravi
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
No, it's not possible, like I wrote in my previous reply: an enumeration is simply an interface, nobody knows whether or not the implementing class is able to 'store' additional objects in it. All you can do is iterate over the two enumerations and store the retrieved objects in, say, an ArrayList or Vector or similar.
For the sake of the argument, assume that the 'other' enumeration, where you want to store additional values, is implemented as:

This silly class makes up a perfectly valid Enumeration, but you sure cannot store any elements in it ...
kind regards
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61437
    
  67

What you can do is to copy each element of the original enumeration to a Vector, and then get an enumeration of the vectored elements via the elements() method.
hth,
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: copy from one enumeration into another!!