Enumeration---methods implementation

for handling vector elements,we use enumeration interface.normally
one interface can have the sign of the methods only.but for handling
the vector,we use the methods nextElement() and hasMoreElements()
methods which are declared in enumeration interface.
my question is where such methods of enumeration are implemented.

they must be implementd in Vector, otherwise Vector would not compile

Similar Messages

  • Accessing Sender parameter attribute in event hander method implementation

    Hello knowledgeable friends.
    I would like a single event handler to manage two alv grid objects.  There is a parameter SENDER that is available in the method implementations to say which object triggered the event.  I would like to get at the attribute MT_OUTTAB but this syntax does not work:
    local_variable = sender->mt_outtab
    Any help would be greatly appreciated

    Ok, MT_OUTTAB is a protected Attribute.  I would settle for just the name of the Sender.  This code checks:
        call method sender->get_name RECEIVING name = l_name.
    but l_name is empty.  I was hoping for 'GRID1'; when I created the object I used:
        CREATE OBJECT alvgrid
          EXPORTING
            i_parent = container_top
            i_name = 'GRID1'.

  • Creating shared library of native method implementation using gcc

    Hi
    I am using Dev-C++ IDE for writing and compiling C Programs. It supports gcc.
    I have to build a shared library of a native method implementation using gcc compiler.
    In JNI tutorial build script is given for VC++ which is as follows
    cl -Ic:\java\include -Ic:\java\include\win32
    -LD HelloWorldImp.c -Fehello.dll
    Similarly I wanted build script for gcc compiler.
    Thanks
    Shailesh

    Here is an example of building a library from one module with CygWin's gcc:
    # Must set JAVA_HOME and LIBRARY_MODULE before
    gcc -mno-cygwin -D__int64="long long" -I $JAVA_HOME/include/win32 -I $JAVA_HOME/include -shared -Wl,--kill-at -o $LIBRARY_MODULE.dll $LIBRARY_MODULE.c

  • Understanding method implementation for LinkedList class

    Hello
    I'm new to java and just trying to get my head around data structures, particularly ArrayList and LinkedList implementations. I've looked at the Sun API for both classes, but would like to see how the methods are implmented so I can venture into writing my own versions of these classes..
    Does anyone know if there is a resource showing the full method implementation so I can view how they work?
    thanks,

    a really strange licence: look but don't touch, and it's still under copyrightThis license seems to make sense: you can look at it and learn from it but you are not supposed to make an own, incomptabile version.

  • Enums with constant-specific method implementation

    Just faced the following problem. I have a persistent class with one of the fields of it is enum with constant-specific method implementation:
    @Persistent
    public class Message
       static public enum Type
           DEFAULT
               @Override
               public String getDescription() { return "Some description"; }
           public abstract String getDescription();
       private Type type;
    }When I try to store the record, I get the exception:
    java.lang.IllegalArgumentException: Class could not be loaded or is not persistent: messages.Message$Type$1The problem seem to be in that compiler creates a separate class, namely Message$Type$1.class for the DEFAULT instance and this class is not known by BDB..
    If I remove the constant-specific method from enum, everything's working fine (as the ..$1.class is not created by compiler).. Except the fact that I'd like to have constant-specific methods there..
    Any ideas on this? Maybe it's a bad idea to create constant-specific methods if it means that each constant would get own class file (and they would bloat the storage routines)?

    Hi Mikhail,
    I recreated the problem here and you're right, constant-specific methods aren't working. This isn't something we thought about, to be honest, or tested.
    Just based on an initial quick look I see that for the compiler generated class, the Class.isEnum method returns false, which is why we don't recognize this as an enum and eventually why we throw the exception you're seeing. But assuming that we can identify the class as an enum (that shouldn't be too difficult) I don't know what other problems we will run into in trying to support this.
    For now I think the best thing is to avoid using the constant-specific methods. I have opened a ticket (#18357) so that we'll remember to look into this in more detail and see whether it can be supported in the future.
    If we are able to support it, then I'm hoping that we won't to store extra metadata for constants that have methods. In other words, I'm hoping that we won't have to add any extra storage or processing overhead.
    --mark                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How do I create this generic enumeration method?

    I am storing enumeration values as classname/name. When I come to read them back in I have the following code:     public Enum<?> asEnum (String className, String value) throws ClassNotFoundException, ClassCastException {
              return Enum.valueOf (Class.forName (className).asSubclass (Enum.class), value);
         }But I get a warning on the valueOf call:"unchecked method invocation: <T> valueOf(java.lan.Class<T>,java.lang.String) in java.lang.Enum is applied to (java.lang.Class<capture of ? extends java.lang.Enum>,java.lang.String)"I don't really understand the warning, if I'm honest ... is there any way to re-write this method so that it compiles without insults?

    if I understand your program correctly then you are
    trying to load ANY class and treat it
    as subclass of Enum without any checking. Of course
    and thank you God, that's not
    possible in Java. Please try this: Well, it is not safe, but the original code demonstrates that it is possible. The code you wrote doesn't seem to do anything the valueOf() method doesn't already do:
    public final class CookEnum {
        enum Directions {
            NORTH, SOUTH, EAST, WEST;       
        public static void main(String[] argv) {
            Directions d = Enum.valueOf(Directions.class, "EAST");
            System.out.println(d);       
    }It is not possible to write the function RGibson wants because he is trying to start with a String containing a class name and get to an enum instance without any warnings. This can't be safe because as andrejin says, the String could be anything at all, and it isn't known until runtime, so how could the compiler ever check it?
    RGibson: if you insist on writing the code this way, I don't think there's a way to avoid the warning. It was recently indicated in this formum that @SuppressWarnings is unlikely to be implemented on any Java5 release.
    Two design questions: do you really need to be able to reconstitute any arbitrary enum type? If you can know the class at compile time, you can reconstitute the enum for its name easily.
    Secondly, is there a reason you're resisting using serialization to persist and recreate the enum? I believe using serialization does mean you can't remove or re-order the enum constants in the future without breaking compatibility or writing custom code, but you can add new values to the end of the set.
    Or are you trying to persist the enums to some medium where you need a purely textual representation like a user readable config file?

  • How to use enumeration method deal with sets?

    hi,
    friends, i have some troubles to compile my program on deal with Set.
    here is the problem:
    A:\>javac Set.java
    Set.java:145: Reference to variable set2 in class Set as if it were a method.
    if (set1.contains(elem) != set2(elem))
    ^
    Set.java:189: Wrong number of arguments in method.
    loadResult(set1.complement(set2));
    ^
    Set.java:191: Wrong number of arguments in method.
    loadResult(set1.symmetricComplement(set2));
    ^
    3 errors
    i marked the related part with ???. please help.
    thank you very much.
    my program as following:
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    import java.util.*;
    import java.io.*;
    public class Set extends Applet implements ActionListener,                               ItemListener{
    Button add, union, intersect, clear, complement,symmetricComplement;
         List set1List, set2List, activeList, resultList;
         Checkbox set1Selector, set2Selector;
         CheckboxGroup selectorGroup;
         TextField value;
         Set set1, set2, activeSet;
         Vector vector;
         private Button makeButton(String label, Color color) {
              Button b = new Button(label);
              b.setBackground(color);
              b.setFont(new Font("Courier", Font.BOLD, 10));
              return b;
         private Panel makePanel(LayoutManager lm, Color c) {
              Panel p = new Panel();
              p.setLayout(lm);
              p.setBackground(c);
              return p;
         public void init () {
         set1 = new Set();
         set2 = new Set();     //componets
         setLayout(new BorderLayout());
                        //checkboxes
         set1Selector = new Checkbox("Set 1");
         set1Selector.addItemListener(this);
         set2Selector = new Checkbox("Set 2");
         set2Selector.addItemListener(this);
         selectorGroup = new CheckboxGroup();
         set1Selector.setCheckboxGroup(selectorGroup);
         set2Selector.setCheckboxGroup(selectorGroup);
         Panel p = new Panel();
         p.add(set1Selector);
         p.add(set2Selector);
         add("North", p);
                        //Lists
         set1List = new List();
         set1List.setBackground(Color.white);
         set2List = new List();
         set2List.setBackground(Color.white);
         resultList = new List();
         resultList.setBackground(Color.white);
         p = new Panel();
         p.add(new Label("Set1"));
         p.add(set1List);
         p.add(new Label("Set2"));
         p.add(set2List);
         p.add(new Label("Result"));
         p.add(resultList);
         add("Center", p);
                        //Buttons
         add = new Button("Add:");
         add.addActionListener(this);
         value = new TextField(5);
         clear = new Button("Clear");
         clear.addActionListener(this);
         union = new Button("Union");
         union.addActionListener(this);
         intersect = new Button("Intersect");
         intersect.addActionListener(this);
         complement = new Button("Complement");
         complement.addActionListener(this);
         symmetricComplement = new Button("SymmetricComplement");
         symmetricComplement.addActionListener(this);
         p = new Panel();
         p.add(add);
         p.add(value);
         p.add(clear);
         p.add(union);
         p.add(intersect);
         p.add(complement);
         p.add(symmetricComplement);
         add("South", p);
                   //set active checkbox
         selectorGroup.setSelectedCheckbox(set1Selector);
         setActive();
         public Set() {
              vector = new Vector();
         public boolean isEmpty() {
         return vector.isEmpty();
         //public size() {
         //return vector.size();
         public boolean contains(Object o) {
         Enumeration enum = vector.elements();
         while (enum.hasMoreElements()) {
         Object elem = enum.nextElement();
         if (elem.equals(o))
         return true;
         return false;
         public void addElement(Object o) {
              if (!contains(o))
                   vector.addElement(o);
         public Object copy() {
              Set destSet = new Set();
              Enumeration enum = vector.elements();
              while (enum.hasMoreElements())
                   destSet.addElement(enum.nextElement());
              return destSet;
         public Set union(Set s) {
              Set unionSet = (Set)s.copy();
              Enumeration enum = vector.elements();
              while (enum.hasMoreElements())
                   unionSet.addElement(enum.nextElement());
                   return unionSet;
         public Set intersection(Set s) {
              Set interSet = new Set();
              Enumeration enum = this.vector.elements();
         while (enum.hasMoreElements()) {
                   Object elem = enum.nextElement();
                   if (s.contains(elem))
                   interSet.addElement(elem);
              return interSet;
         public Set complement (Set set1, Set set2) {     //???
              Set complementSet = new Set();
              Enumeration enum = this.vector.elements();
         while (enum.hasMoreElements()) {
                   Object elem = enum.nextElement();
              if (set1.contains(elem) != set2(elem))
                   complementSet.addElement(elem);
              return complementSet;
         public Set symmetricComplement (Set set1, Set set2) { //???
              Set symmetricComplementSet = new Set();
              Enumeration enum = this.vector.elements();
         while (enum.hasMoreElements()) {
              Object elem = enum.nextElement();
              if (elem != set1.set2)
              symmetricComplementSet.addElement(elem);
              return symmetricComplementSet;
         void removeAllElements() {
         vector.removeAllElements();          //differ
         Enumeration elements() {
         return vector.elements();
         public void print(PrintStream ps) {
              String PrintStream;
              Enumeration enum = vector.elements();
              while (enum.hasMoreElements()) {
                   ps.print(enum.nextElement().toString());
                   ps.print(" ");
              //handles action events generated by the buttons
         public void actionPerformed(ActionEvent ae){
              if (ae.getSource() == add) {
              addElement();
              repaint();
              else if (ae.getSource() == union)          
              loadResult(set1.union(set2));
              else if (ae.getSource() == intersect)
              loadResult(set1.intersection(set2));
              else if (ae.getSource() == complement)
              loadResult(set1.complement(set2));     //???
              else if (ae.getSource() == symmetricComplement)
              loadResult(set1.symmetricComplement(set2)); //???
              else if (ae.getSource() == clear) {
              activeSet.removeAllElements();
              activeList.removeAll();
              //handles item events generated by the Checkboxes
         public void itemStateChanged(ItemEvent ie) {
              setActive();
         private void addElement() {
              int i = Integer.parseInt (value.getText());
              activeSet.addElement (new Integer(i));
              activeList.addItem (Integer.toString(i));
         private void setActive() {
              List newActiveList;
              if (selectorGroup.getSelectedCheckbox() ==                               set1Selector){
                   activeList = set1List;
                   activeSet = set1;
              else {
                   activeList = set2List;
                   activeSet = set2;
         private void loadResult(Set resultSet){
              resultList.removeAll();
              Enumeration enum = resultSet.elements();
              while (enum.hasMoreElements())
              resultList.addItem (enum.nextElement().toString());
              repaint();

    public Set complement (Set set1, Set set2) {
       Set complementSet = new Set();
       Enumeration enum = this.vector.elements();
       while (enum.hasMoreElements()) {
          Object elem = enum.nextElement();
          if (set1.contains(elem) != set2(elem))
             complementSet.addElement(elem);
       return complementSet;
    }I'm not sure what you think you are doing with the set2(elem) call. You are treating a variable as if it were a method.
    All you have to do is change set2(elem) to set2.contains(elem) and things would be fine. This is especially weird since you knew that for set1.

  • Interface method implementation

    While Implementing a method gety() i am getting follwing error -
    gety() in class B cannot implement gety() I ;attempting to assign weaker access privilees; was public
    class B extends A implements I {
    int i;
    public B(int a,int b) {
    int q = super.i;
    System.out.println(q);
    i = b;
    void show() {
    System.out.println(X);
    System.out.println("i in subclass:" +i);
    void gety() {
    System.out.println("my");
    interface I {
    public static final int X=3;
    abstract void gety();
    }

    If interface I says gety is public, then code that
    uses an I expects it to have a public gety method.
    Since B "is-a" I (by virtue of the fact that it
    implements I), it has to do everything I promisesto
    do.Nice class names... it makes it sound like you just
    have really bad grammar :)Just following what the OP had. But yeah, I noticed that as I was typing, but couldn't be bothered to change it.

  • Can a method implemented from interface be native ?

    This is a bit of a SCJP question.
    interface One
    public void someMethod();
    public class One_impl implements One
    public native void someMethod();
    Assuming that the native method is not provided in any local library, an attempt to compile and run the above lines
    of code will cause
    1. Compilation error - implimentations can never be native.
    2. Compilation error - method not found in local libraries.
    3. Runtime Exception - method not found in local libraries.
    4. Compilation successfull but runtime error is thrown if and only if the method someMethod of class One_impl is
    called
    My question is can a implemented method be native ?
    I am totally blank about native methods in Java.(Does this dismiss the right to put a question and study native methods in Java first ?)
    Thanks.

    ejp wrote:
    My question is can a implemented method be native ?Yes.
    I am totally blank about native methods in Java. (Does this dismiss the right to put a question and study native methods in Java first ?)It does suggest that you could have read the JLS first.Maybe reading native methods in JLS would clear things for me.
    Thanks.

  • Debbuger never stop in BADI 'BBP_WFL_APPROV_BADI' 's Method Implementation

    Hi Experts,
    We are implementing the PO n-step BADI workflow WS14000145 . I have implemented the method 'GET_REMAING_APPROVERS' of BADI 'BBP_WFL_APPROV_BADI', but when I put a break-point, the debbuger never stop!!!... please help about it!.
    Thanks in advance.

    Hello,
    Try the following:
    - Set a breakpoint at function BBP_PDH_WFL_DB_UPDATE;
    - Craete the cart. Breakpoint should stop in FM above;
    - Change variable IV_IN_DIALOG to X (it is blank originally);
    - Set a breakpoint at BBP_WFL_DIN_APPR_BY_RULE_GET. In here the badi to determine the approvers is called;
    - F6 down until the call of this badi, i.e. CALL METHOD lv_wfl_appr_list_exit->get_remaing_approvers.
    Regards,
    Ricardo

  • Using SEO_METHOD_ACTIVATE with methods implemented from Interface

    Hi,
    I'm trying to create a class and activate it using some ABAP code. I began by copying a template class into a new class called ZKMOD_COPY.
    Now I want to activate this class. I tried SEO_METHOD_ACTIVATE but all it does is set the flag to 'A' in the table. It doesn't really activate the whole class I see in SE24.
    Going through the forums, I came across ABAP Objects where someone said to call these in order: SEO_ATTRIBUTE_ACTIVATE, SEO_EVENT_ACTIVATE,  SEO_METHOD_ACTIVATE, SEO_TYPE_ACTIVATE
    Now my class does not contain any attributes, events or types. It contains just one method, so I suppose except SEO_METHOD_ACTIVATE I don't really need the others.
    Now this method (called EXIT) is implemented from an Interface IF_RSCNV_EXIT. In the class definition of ZKMOD_COPY, it shows this method by the name IF_RSCNV_EXIT~EXIT.
    The problem is that I'm not able to activate this method. I can't figure out what parameters to give in CIFKEYand  MTDKEYS
    I tried all permutations of "zkmod_copy", "if_rscnv_exit" as classes, "exit" and "if_rscnv_exit~exit" as the methods, but it kept throwing exceptions like not specified or not existing. Debugging the FM also did not give me any clues.
    So what I really need is, what parameters should I give there? Alternatively, is there any way I can programmatically activate my class? This may sound a silly question, since I'm a BI guy with not too much ABAP knowledge, but I'd be really grateful if someone could help out with this.

    Matt,
    We have some Customer Exits in BI. I'm trying to develop a kind of program that will generate the code for a customer exit class. So probably I would have an FM take some params, create the class with some static member attributes (not yet fully designed), so that it is ready to be used as a customer exit.
    It's all still nebulous - I'm finding the various things that I feel I will need.
    CIFKEYS I think is the -> IF_RSCNV_EXIT
    MTDKEYS-CLSNAME is IF_RSCNV_EXIT
    MTDKEYS-CMPNAME is EXIT.
    In this, the name of the class ZKMOD_COPY is not used anywhere. But IF_RSCNV_EXIT is an interface, it can be implemented by any number of classes. So shouldn't the class name (ZKMOD_COPY) be mentioned somewhere? How would the system know which implementation of IF_RSCNV_EXIT should be activated?
    At present I'm not in front of a system; I'll try this on Monday and get back to you. Thanks for the help anyway, Matthew!

  • Regarding Interface methods implementation

    Hi,
    I have a interface with 3 methods.
    public interface test{
    public void A();
    public void B();
    public void C();
    public class IntImpl implements test{
    public void B(){
    //implementation
    Can we implement an interface with out implementing all the methods of interface .instead implementing a few methods in the interface?
    i came to know that we can do the above one with out any exceptions? So any of you can resolve this issue ..
    Thanks in advance
    Sri

    Can we implement an interface with out implementing
    all the methods of interface .instead implementing a
    few methods in the interface?In other words: can we implement an interface without implementing it?
    The answer should be obvious.
    i came to know that we can do the above one with out
    any exceptions? Sure, it's quite easy, you already did it. The stuff above won't compile, hence it won't throw an exception when running.
    Or you can also avoid compiler errors by declaring IntImpl as abstract. Which means you didn't implement the interface though.

  • Methods Implemented in Other Classes

    Dear all,
    In our system I found such a class. In t-code SE24, some of its method names are displayed in blue fonds, instead of ordinary black fonds. When I double click on the method names, a pop-up window indicates "Method xxx is implemented in class yyy". I have no idea about the relationship between the original class and the class yyy. Can anybody explain such a situation?
    Thanks + Best Regards
    Jerome

    Hello Jerome
    If you display class CL_GUI_ALV_GRID in transaction SE80 and open the folder "Methods" you will see which method will be displayed in "blue":
    - all methods in sub-folder <b>Inherited Methods</b> are shown in blue
    - some of these inherited methods have been redefined within the class (folder Redfinitions) and are displayed in "ordinary" black font
    Which is the superclass of CL_GUI_ALV_GRID? Simply display the <b>Properties </b>tabstrip of the class. There you see that CL_GUI_ALV_GRID_BASE is the superclass.
    Thus, all methods displayed in blue are methods inherited from the superclass that have not been redefined.
    Regards
      Uwe

  • Forced method implementation

    Where do I go to suggest modifications to the Java language?
    I sometimes have a method that I wish to implement in a class and force all sub-classes to implement this method as well. There is not really any way in java to do this.
    A good example (although I could give many more) is the clone() method. I want a super-class to be able to implement the clone() method to copy all of it's fields. I then want a sub-class to implement the clone() methd to copy the fields specific to that sub-class. The problem is that if the sub-class doesn't implement the clone method, everything still compiles just fine, you just blow up at run-time wondering why you only have half an object.
    I first thought that you could simply revise the rules surrounding the abstract keyword so that it allows you to provide implementation in an abstract base class and still require sub-classes to implement, but this doesn't work if your base class is concrete as well.
    As this is the opposite of final, I looked up final in a Thesaurus and ended up with "elementary." Any other suggestions?
    Where do I write this up?
    thanks.

    Are you kidding me?
    I mean, I know that deep inheritance chains are clues to a bad design, but often? Take a look at the java libraries, bub! Reader and InputStream, e.g.
    Take a look at the most basic example of inheritance: shape. A line is a shape. So is a circle, but they both sub-class the draw method. A rectangle is also a shape, but it has sides unlike a line or a circle, so it has extra properties. Every math textbook I've ever seen says that a rectangle is a special case of square, and you're telling me it might not be a sub-class because it needs to store the values of it's sides separately?
    I'm not defending my design, because I don't feel like I have to. This is not an exception type of thing. There's far too many good reasons to do something like this for you to tell me this is a bad idea without me even providing an example.
    But sense I'm a fair guy, I will anyway.
    I have a Person class. Person is important in our system because it is a container of name, address, social security number, etc. Lots of information. It is a concrete class because there are people in our system who simply pass in and out without us doing anything with them.
    Extended from person are classes Administrator and Participant, which, even though they are siblings, they are as different as night and day. An administrator is a contact point, not even a user, with special business rules. A participant is the person we're interested in in our app with specialized business rules and state that evolves over the course of time, sometimes years.
    Do either of these seem like they're not people because they have lots of additional information other than what the person class does? Or maybe you think that simply because it has a concrete base class it shouldn't have a clone method?
    Because if I don't implement the clone method at the person level, both sub-classes have to know all that stuff about their super-class which breaks encapsulation.
    How about asking a question or two next time before jumping to conclusions about other people's code?

  • Org.jcp.xml.dsig.internal.dom.DOMKeyInfo equals() method implementation

    I use something like this:
    if(myKeyInfo.equals(anotherKeyInfo))
    //I believe two signers are same. It seems correct.
    Behind the scene the KeyInfo is implemented by org.jcp.xml.dsig.internal.dom.DOMKeyInfo.
    I would like to have a look at org.jcp.xml.dsig.internal.dom.DOMKeyInfo to find out how its equals method is implemented.
    Basically I would like to make sure wether myKeyInfo.equals(anotherKeyInfo) is the right way to ascertain the signer.

    You can find the source in a few different places, either in the Apache XML Security project repository or the JDK 6 and OpenJDK projects on java.net. Here is a pointer to the JDK 6 source:
    https://jdk-jrl-sources.dev.java.net/source/browse/jdk-jrl-sources/jdk6/trunk/j2se/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfo.java?rev=3&view=log

Maybe you are looking for