Passing enums to functions without knowing the specific enum type

My application needs the function invocation feature by using reflection mechanism. The function parameters are restricted to string, int, float and enums. I am facing problems with enums.
Is there a way to invoke the function by passing specific enum type as parameter to the function.
For eg:
public void doProcess(int i, COLOR.RED){
I should be able to invoke the above function using reflections. How dynamic casting to COLOR can be done is the question here?

The application takes XML file as an input. This file has processing instructions. The processing instruction provides data about the class name, function name and parameters specifications like
Classname_FunctionName("String param", 123, COLOR.RED)
The application should invoke the corresponding library function by passing these parameters after assessing the correct types.

Similar Messages

  • Loading a class via reflection without knowing the full qualified path ?

    Hi there
    I d like to load a class via reflection and call the constructor of the class object. My problem is that I dont know the full qulified name e.g. org.xyz.Classname bur only the Classname.
    I tried different things but none seem to work:
         1. Class c = Class.forName("Classname");  //does not suffice, full qualified name required
    2. ClassLoader classloader = java.lang.ClassLoader.getSystemClassLoader();
             try {
               Class cl = classloader.loadClass(stripFileType(Filename));//if i do not pass the full qualified name i get a ClassNotFoundException
    3. I tried to consruct a class object with my own classloader , calling:
              Class cl = super.defineClass(null, b, 0, b.length );     b is of type byte[]This almost works. I get a class Object without knowing the full qulified path. I can transform a filename into a raw array of bytes and I get the class out of it. But there is still a problem: If there are more than on classes defined in the same textfile I get an InvocationTargetException.
    It looks like this:
    package org.eml.adaptiveUI.demo;
    import com.borland.jbcl.layout.*;
    import java.awt.*;
    import org.eml.adaptiveUI.layout.*;
    import javax.swing.*;
    import java.awt.event.*;
    * <p>Title: </p>
    * <p>Description: </p>
    * <p>Copyright: Copyright (c) 2003</p>
    * <p>Company: </p>
    * @author not attributable
    * @version 1.0
    public class twoButtons extends JFrame {
      SPanel sPanel1 = new SPanel();
      JButton jButton1 = new JButton();
      GridBagLayout gridBagLayout1 = new GridBagLayout();
      GridBagLayout gridBagLayout2 = new GridBagLayout();
      public twoButtons() throws HeadlessException {
        try {
          jbInit();
        catch(Exception e) {
          e.printStackTrace();
      public static void main(String args[]){
        twoButtons twob = new twoButtons();
        twob.pack();
        twob.show();
      private void jbInit() throws Exception {
        this.getContentPane().setLayout(gridBagLayout1);
        jButton1.setText("button 1");
        jButton1.addActionListener(new TransformationDemo_jButton1_actionAdapter(this));
        this.getContentPane().add(sPanel1,  new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0
                ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(57, 52, 94, 108), 35, 44));
        sPanel1.add(jButton1,  new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
                ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 41, 0, 0), 0, 0));
      void jButton1_actionPerformed(ActionEvent e) {
        System.out.println("button 1 source: " + e.getSource());
        System.out.println("d: " + e.getID());
       System.out.println("/n commmand: " + e.getActionCommand());
    class TransformationDemo_jButton1_actionAdapter implements java.awt.event.ActionListener {
      twoButtons adaptee;
      TransformationDemo_jButton1_actionAdapter(twoButtons adaptee) {
        this.adaptee = adaptee;
      public void actionPerformed(ActionEvent e) {
        adaptee.jButton1_actionPerformed(e);
    }As you can see there is the class TransformationDemo_jButton1_actionAdapter class defined in the same classfile. The problem is now that the twoButtons constructor calls the TransfomationDemo_jButton1_actionAdapter constructor and this leads to InvocationTargetException. I dont know if this is a java bug because it should be possible.
    Can you help me?

    hi thanks at first,
    the thing you mentioned could be a problem, but I dont think it is.
    If I have the full qualified name (which I havent) then everything goes normal. I only have to load the "twoButtons" class and not the other (actionadapter class), so I dont think this is the point. In this case the twoButtons constructor constructs an object of the actionadapter class and everything goes well. The bad thing is though that I do not have the full qulified name :(
    Invocation target exception tells me (in own words): Tried to acces the constructor of the actionadapter class (which is not public) out of class reflectionTest class .
    reflectionTest is the class where the reflection stuff happens and the twoButttons class is defineClass() ed.
    The problem is, only twoButtons class has the rights to call methods from the actionadapter class, the reflection class does not. BUT: I do not call the actionadapter methods from the reflection class. I call them only from the twoButtons class.
    I hope somebody understands my problem :)

  • Can we send a request without knowing the actual url..

    Tomcat is running at the back.
    I know the port no on which the server is running now.
    Can we send a request to the server even if we dont know the exact url
    for example I developed a form which authenticates the user, after authenticating the url will be some thing like this
    http://localhost:8090/temp/AdminRegister?uname=user?pass=user123now can the user login even without knowing the exact username and password by manipulating the url..

    it is your own risk to your applets to communicate with DBs because nobody suggests that. I agree with the Javascript story and the frames. It can be done but i thought he wanted to do that in one single page. And finally, i dont trust frames that much. I have seen many times the 404 error found on pages and because i use dynamic pages i have to make connection for each frame. and with throusands users being online it is bad for my server (traffic).

  • But how do I create a new iTunes backup password without knowing the previous one?

    In case anyone keeps track of such things, I'm among those folks who really doesn't recall ever being asked to create an iTunes backup password, but that's irrelevant to my question.
    I'm not in any bind. I don't need my backup files to restore anything. I will shed no tears as they are moved to the Recycle Bin (indeed, I will gladly do the deed myself).
    That said, it appears impossible to create a new backup password without knowing the previous one.
    If the only "solution" is to wipe my iPhone's memory and start from scratch, I will be a sad camper.
    Any help? Are backups to iCloud encrypted?
    Cheers...

    Additionally:
    Be super critical & meticulous (and whatever other synonym I missed) when you get a new password:
    Write it onto your bedroom wall, or someplace off of a computer that you will always find.
    If you active 2-step verification, the key is VERY important. Lose it & you may be toast.
    If you don’t 2 step verify, & use the Security Question instead --> do not lose, or forget the answers.
    Very nearly the same outcome!!!!!:  Bad experience.
    If you add a 2nd email address, make sure its a RESCUE address not just an alternate address.
    If you lose these, you lose access to your 3rd party purchases via Appstore for future upgrade. That will make you VEWY, VEWY UNHAPPY. Apple new OS versions do update, but add a new device & likely you will be unable to use your content on that device. It will never load if the ID locks up.

  • I forgot my password for my apple ID. Any ideas on how to put in a new one without knowing the old one?

    I forgot my password for my Apple ID. Anyone have a solution on how to put in a new one without knowing the old one?
    Thanks

    Welcome to Apple Support Communities
    You have to reset your password. You can do this in this site > http://iforgot.apple.com

  • Is it possible to delete extended properties without knowing the id?

    Hello,
    Can you delete any custom extended properties without knowing their ID?
    I took over managing a feature that used EWS to send emails to customers.The current code creates a new GUID, and thus new Extended Property, every time an email is sent.
    // Create a custom extended property and add it to the message.
    var myExtendedPropertyDefinition = new ExtendedPropertyDefinition(Guid.NewGuid(), "MyGuidId", MapiPropertyType.String);
    mail.SetExtendedProperty(myExtendedPropertyDefinition, "MyGuidId");
    // Send and save a copy
    mail.SendAndSaveCopy();
    Is there a way to delete any of the custom extended propeties without knowing the IDs?
    Thank you

    No you can't do that in EWS you need to know the details of the property you want to Read/Write or delete. EWS has no method of enumerating all extended properties either you would need to use MAPI to do this.
    >>The current code creates a new GUID, and thus new Extended Property, every time an email is sent.
     I'd question the design of this what where they trying to acheive ? Why not have ths same property with a different Value ? else using an X-header would be better idea at least then it will persist ouside of your Exchange infrastructure and even
    inside would be more discoverable.
    Cheers
    Glen

  • How to know the specific size of a field in oracle table

    Hello,
    oracle 11.2.0.3 on redhat
    i have three tables with same structure, table0, table50, table100:
    create table table0 (id number, shipment RAW(2000), options RAW(2000));
    i inserted 10000 rows in each but with some differences:
    table0 has 10000 id, but shipment and options has null values
    table50 has 10000 id, but shipment and options has only 5000 rows, the other 5000 are null values
    table100 has 10000 rows of id, shipment and options. No null values.
    I want to know the specific size of each column, also the size of each row, to know the exactly size of the field.
    for example:
    row 1, column options of table100 has "asdfasdfagasdgasbabsdgoasdpgiahnwe1129u412094u12"
    row 2, column options of table100 has "a".
    both are raw datatype, but i think its space will has different size (bytes), how to know it? any query?
    I found this query:
    select owner,tablespace_name,segment_name,sum((bytes/1024/1024)) Bytes
    from sys.dba_extents
    where owner in 'MAA' and segment_type='TABLE' and segment_name ='TABLE00'
    group by tablespace_name,owner,segment_name
    order by owner,tablespace_name,segment_name, bytes; but i think it isn't my solution.

    thx mr. sb92075
    i tried with vsize too but same result:
    with table50
    SELECT VSIZE(OPTIONS) FROM TABLE00;
    VSIZE(OPTIONS)
                 1000
                 1000
                 1000
                 1000
                   *with table100
    SELECT VSIZE(OPTIONS) FROM TABLE100;
    VSIZE(C_ELECCION)
                 2000
                 2000
                 2000
                 2000
                      *it's the same size for 'a' like 'abcasdfjañldngaosnbaposnbpaosuqroiwejrklasndiaoshbaposdjgajs'?? It's hard for me to believe.
    data is saved in blocks, a extents is a contiguos number of blocks and a group of extensions are segments. If you insert some text in a table field, Oracle create a extension and insert there the data but depend the bytes you insert Oracle will create one or more extents. How to know this specific space in that field?

  • How can I reset my administrator password, without knowing the original administrator password?

    Hi guys,
    I use a MacBook Pro with OS X 10.8 Mountain Lion. A few months ago I reset my administrator password and have not been able to remember it since. Consequently, I haven’t been able to do any software updates, my computer is running slow and I'm getting a lot of pop-up junk on my screen. I’m the only user on my computer, apart from the Guest User (Sharing only).
    How can I reset my administrator password, without knowing the original password?
    Thanks.

    Resetting Password and/or Home Folder Permissions

  • How do i reset an admin password without knowing the original?

    How can i reset my admin password on my macbook pro without knowing the original password?

    Insert a compatible Mac OS X DVD, restart with the Option key held down, and use its Reset Password utility. If the computer has a firmware password set, you need to know that.
    (58431)

  • HT4113 how to unlock an ipod touch without knowing the password

    how to unlock an ipod touch without knowing the password

    Connect the iPod to your computer and restore via iTunes. Place the iPod in Recovery mode if necessary to allow the restore.

  • How do you reset an ipad mini without knowing the password?

    I have just recently changed my password, but know i have forgot the new one. How do you reset the ipad without knowing the password?

    If you mean the passcode to unlock the iPad then you will need to connect it to the computer that you normally sync to and you should then be able to reset the iPad and restore/re-sync your content to it (http://support.apple.com/kb/HT1212) - you may need to put the iPad into recovery mode in order to be able to reset it : http://support.apple.com/kb/ht1808
    If you do it via a different computer then :
    If you restore on a different computer that was never synced with the device, you will be able to unlock the device for use and remove the passcode, but your data will not be present.

  • HT4865 How to delete the preowner icloud account without knowing the password?

    How to delete icloud account from pre owner without knowing the password?

    II'm in the same situation. Purchased a refurbished IPhone 5. I had to do a factory reset and when I reset it again, itunes tells me that the phone is linked to someone else. Called the company I bought the phone from and they say iTunes can do a master reset to link my iTunes account to the phone. Have any of you heard of this being possible?

  • How do you unlock an ipod touch without knowing the password

    How do you unlock a ipod touch 4th generation without knowing the password?

    Connect the iOS device to your computer and restore via iTunes. Place the iOS device in Recovery Mode if necessary to allow the restore.
    If recovery mode does not work try DFU mode.
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
    For how to restore:
    iTunes: Restoring iOS software
    To restore from backup see:
    iOS: How to back up
    If you restore from iCloud backup the apps will be automatically downloaded. If you restore from iTunes backup the apps and music have to be in the iTunes library since synced media like apps and music are not included in the backup of the iOS device that iTunes makes.
    You can redownload iTunes purchases by:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store

  • How do i restart my admin password without knowing the old one

    i just got a macbook air and wasnt paying attention to the password i used.. can anyone help me to reset the password without knowing the old one.and also that doesnt require a disk.

    Restart. Hold down cmd-r at the chime. When the Recovery partition boots, choose terminal from the Utilities menu.
    Type, resetpassword and hit return
    Select the disk and follow the instructions to reset the password.
    Note that you will not be able to recover your keychain. You'll have to create a new login keychain in Keychain Access and set the password the same as your new password to have it auto-unlock on login.

  • Cursor works when passing over a command without touching the Touchpad

    The cursor on my iMac regularly engages by merely passing over a command without clicking the touch pad.  All i can do is force stop the machine because the cursor performs unwanted commands before I can get the cursor to restart or Shut Down.

    tjk wrote:
    Hi s,
    First try a PRAM Reset: http://docs.info.apple.com/article.html?artnum=2238
    If no luck, try an SMC Reset: http://support.apple.com/kb/HT3964
    In some cases, the battery can interfere with a cable between it and the inside of the MBP, causing keyboard and/or trackpad issues. Shut down the MBP, disconnect the power adapter, remove the battery, take a piece of something semi-soft (like a paper napkin foldedover a couple times), place it over the cable you see in the battery compartment, and tape it down. Replace the battery and see how things go. If this works, you'll eventually want to replace the keyboard/trackpad cable (about $25 if you can do the work yourself). Note that if you go to a repair shop, they usually want to replace the entire top case assembly, which is much more costly.
    If the issue persists, shut down, disconnect the power adapter, remove the battery, connect the power adapter, boot the MBP and see if the issue persists without the battery in place (but remember to save a lot, because if the power adapter gets pulled out the MBP will immediately shut down and any unsaved work will be lost).
    Also look at the battery to see if it has any signs of deformity/bulging, in which case do not use it again (it may be pushing on the keyboard/trackpad cable and causing the issue); it must be replaced.
    First off Sir or lady tjk, I do a PRAM reset weekly and it's never fixed diddly for this issue, I'm sorry to report. The cursor going awry usually happens in Mail when composing or replying to emails, so I wondered if Mail was corrupted, but alas, no. Still happens.
    Upon inspecting the battery and the compartment, both appear normal. No bulging or binding either (a brazzier reference).
    I did the SMC reset before I read your post, but apparently not to Apple's spec so will try it again. Then will see what's up doc.

Maybe you are looking for