How to find a classes attributes at runtime?

Hi,
I need to write a program that inspects a class and finds out what attributes it has and then converts them to an XML string. Any idea how to get the classes attributes at runtime? I want this to work with 3rd party API's hence the reason I don't just either code a toXML function in each class or have a method to return the attribute names.
Thanks
Andre

Hi,
I need to write a program that inspects a class and
finds out what attributes it has and then converts
them to an XML string. Any idea how to get the classes
attributes at runtime? I want this to work with 3rd
party API's hence the reason I don't just either code
a toXML function in each class or have a method to
return the attribute names.
Thanks
AndreYou might want to take a look at Java's reflection mechanism:
http://java.sun.com/docs/books/tutorial/reflect/index.html

Similar Messages

  • Anyone know how to find available classes in a package?

    Anyone know how to find available classes in a package?
    Given a String like "java.io" I would like to write a method to extract the available classes in this package. I can't seem to find a method for this anywhere in the docs. The package class does not seem to have a method like this.

    Here is some code I tried.
    I'm not very familiar with manipulating JARs The code below is what I tried, but how do I access the packages like "java.io" in the JarFile? and then get the available classes?
    import java.io.*;
    import java.util.*;
    import java.util.jar.*;
    class Tester
         public static void main(String args[])
              try {
                   JarFile jf = new JarFile("c:/jdk1.3/lib/dt.jar");/* usually rt.jar (and 1.4)*/
                   Enumeration e = jf.entries();
                        while (e.hasMoreElements())
                             Object current = e.nextElement();
                             System.out.println(current.toString() + "class:"+current.getClass());
                             try {
                                  Thread.sleep(300);
                             } catch (InterruptedException ie) {}
              } catch (IOException ioe) {System.out.println(ioe.toString());}
                   /*also tried      ClassLoader cl = ClassLoader.getSystemClassLoader();
              try {
                   Enumeration e = cl.getResources("c:/jdk1.3/lib/dt.jar");
                   System.out.println(e.nextElement());
                   while (e.hasMoreElements())
                   System.out.println(e.nextElement());
              } catch (IOException ioe) {System.out.println(ioe.toString());}

  • How to find the unindexed attributes

    Hi friends,
    We migrated from 5.1sp3 to 5.1 sp4.
    After migration i am facing the error unindex search error.
    how to find the unindex attributes.

    You can compare what is indexed against your complete list of all allowed attributes in your schema. Or cheat and use the console.
    To generate a list of all indexed attributes, use ldapsearch:
    ldapsearch -h <host> -p <port> -D "cn=Directory Manager" -w <password> -b "cn=index,cn=userRoot,cn=ldbm database,cn=plugins,cn=config" objectclass=*
    Each common name (cn) returned is the name of an indexed attribute. Note this will also return the type of indexes defined, which is handy. You can save this to a text file for future reference.
    You can dump your schema using the following search:
    ldapsearch -h <host> -p <port> -b cn=schema objectclass=*
    Look for "attributeTypes" entries. Note: there are a lot of system attributes.
    You can also login to the Administration Console and under the Configuration tab, expand Data and then select your suffix. In the right hand pane, you will be taken to the Indexes tab by default, here all indexed attributes are listed. Those attributes not indexed can be viewed in a list by clicking the Add attribute... button at the bottom of the screen. You'll be presented with a list of all attributes not currently indexed.
    Cheers,
    sn3ak3rp1mp

  • How to find the class name of the  BO

    HI
      How to find out a class for a business object.
    For example for the Business Object FORMABSENC i want to find out the class name.
    iam not able to find out from se24 or swo1.
    Or please suggest me how can i use the method createbapistructure of this businessobject.
    Regards
    vijaya

    Hello Vijay
    When you double-click on "method" AbsenceForm.CreateBapiStructure (transaction SWO1) and switch to tab ABAP you see (on ERP 6.0) that the field Name is empty meaning this BO "method" has not yet been implemented.
    Other methods are implemented by modules of function group SWXA. Checking package SWX you will see that there are no suitable classes around for this object.
    Final remark: Methods of business objects has just a semantic meaning and has nothing to do with object orientation (i.e. classes).
    Regards
      Uwe

  • How to find missing classes for an applet ?

    I'm trying to run a swing JApplet but I get a ClassNotFoundException - how can I find what class is missing ? IE6.
    Craig

    may you need the JavaPlugin for JApplet
    and which class is not found?

  • How to find the Class Type of a Class ?

    Hi,
    Can anyone tell how can I find a Class Type of a Class?
    e.g. I know the Class name as "Z_ABC" but do not know its Class Type, therefore, not able to display it in CL01.
    Regards,
    Lucky

    Hi,
    Just by entering the Class name in CL02 does not display the data because system asks to enter the Class Type as well.
    Rammohan - Thanks for thissolution however, when I executed after entering the Class Name, table displyed no entries found..... message but this class is being used in the PO Release Strategy. May be the data is being saved in some other table. Is there any other way to find this?
    Regards.

  • [SOLVED] Awesome WM autostart questions/how to find program "class"

    Hi there,
    Right so I'm using Awesome WM and want to auto start programs into specific tags.
    This is the code I have, and everything is working as expected:
    --Autostart Programs
    awful.util.spawn_with_shell("chromium")
    awful.util.spawn_with_shell("skype")
    awful.util.spawn_with_shell("spotify")
    -- {{{ Rules
    awful.rules.rules = {
    -- All clients will match this rule.
    { rule = { },
    properties = { border_width = beautiful.border_width,
    border_color = beautiful.border_normal,
    focus = true,
    keys = clientkeys,
    buttons = clientbuttons } },
    { rule = { class = "Chromium" },
    properties = { tag = tags[1][6] } },
    { rule = { class = "Skype" },
    properties = { tag = [1][3]} },
    { rule = { class = "Spotify" },
    properties = { tag = [1][4] } },
    So what I'm wondering is how do I find out what the class of programs for this section: "{ rule = { class = "  " },"?
    I installed Arch on my chromebook and I've been using a lot of the programs such as Evernote and Trello. I have the chrome app drawer (http://www.omgchrome.com/enable-chrome- … her-linux/).
    I created a shortcut and can auto launch programs such as evernote using the chrome app drawer using the command we can see from the desktop entry:
    awful.util.spawn_with_shell("/usr/bin/chromium --profile-directory=Default --app-id=lbfehkoinhhcknnbdgnnmjhiladcgbol")
    However, the issue is that it always opens on whatever tab I'm using. I cannot find the class to add to the rules.
    None of these work:
    { rule = { class = "chrome-lbfehkoinhhcknnbdgnnmjhiladcgbol-Default.desktop" },
    properties = { tag = tags[1][6] } },
    { rule = { class = "Evernote Web" },
    properties = { tag = tags[1][6] } },
    { rule = { class = "/usr/bin/chromium --profile-directory=Default --app-id=lbfehkoinhhcknnbdgnnmjhiladcgbol" },
    properties = { tag = tags[1][6] } },
    Any suggestions on what I can do to find the "class"?
    Last edited by Gwynplaine (2014-11-14 00:24:01)

    run 'xprop' in a terminal and your cursor will change to a cross.  Click anywhere on the app you want to identify and the class will be sent to the screen (along with a ton of other stuff)
    It's in the xorg-xprop pkg
    Last edited by oliver (2014-11-14 00:16:08)

  • How to Find Controller class of  BSP application for particular Iview

    Hi  All,
    Any one please  help me  to find a Controlller class of BSP for an  I view.
    http://Host Name :Port No/sap/bc/gui/sap/its/wosm-cr-->this is for sap retail,
    My requirement  is to change some source code in that particular iview.
    i goine with SE80 Tcode
    with package called WOSM>ITS service>Topic 90-->which contain Mime Objects,Html Templates.
    but i dint find any
    Point will be given!!!

    Hi All,
    My question is where should i find Controller class ?
    i gone with Tcode  SE80>packages>WOST>ITS service>WOSM>Topic90>which contain Mime Objects,HTML Templates.
    i dint find any controller class.
    regards
    Naresh

  • How to find batch class based on material number

    Hi experts,
    Can any one say how to get Batch class number by giving material number as input
    regards
    subbu

    Hi ,
    check in MCH1 table.....
    or  try this way..
    By using this function module you can get the batch class related to material..
    * Retrieve Material Batch Classes
      CALL FUNCTION 'CLAF_CLASSIFICATION_OF_OBJECTS'
        EXPORTING
          classtype          = zc7b1_batch_class_type
          features           = 'X'
          language           = 'E'
          object             = w_object             "Pass material Number with leading zeros
          objecttable        = 'MCH1'              "Pass table MCH1
          initial_charact    = 'X'
        TABLES
          t_class            = t_lclass             " check here what are all the classes related to material
          t_objectdata       = t_objectdata
        EXCEPTIONS
          no_classification  = 1
          no_classtypes      = 2
          invalid_class_type = 3
          OTHERS             = 4.
    Prabhudas

  • Content server - using RSIRPIRL - how to find PHIO classes?

    Hi all
    I'm just trying to clarify how to go about tidying up our SOFFCONT1 and BDS_CONT1 tables by migrating documents from the database to a Content Server.
    Apparently Content Server is set up (via OAC0) and 'new' documents/attachments are successfully being stored in Content Server rather than the database.
    But historically this was not so, and we have a huge amount of documents stored at DB level.
    I've read note "1634908 - Reduce the size of table SOFFCONT1" and "389366 - Relocation of documents" and plan to use report RSIRPIRL to do this.
    It looks like PHIO class SOFFPHIO should be used for the SOFFCONT1 entries and "All classes which start with BDS_P" for the BDS side; but you can't enter BDS_P* in the report and I can't find a list of PHIO classes anywhere - anyone have any ideas?
    Also, I've been told that dependant on the type of document, they should go to a different repository - for example, billing documents should go to a different repository. Is this possible? There's the 'Document Area' selection but I don't think you can specify this here?
    Some notes/posts about this process also mention transaction SKPR08 - how does this fit in here? The application consultant who has set up Content Server hadn't come across it and didn't have access to run it either - is it relevant in this case?
    Is there any way of knowing how many documents there are (and their size) to be migrated? I can count the number of rows returned by RSIRPIRL in test mode but this gives me no idea of size. As there's a huge volume (the tables are about 200GB each) we need to ensure there is sufficient space in the Repository.
    Please bear in mind that I have a SAP Basis background rather than a Functional one so I'm struggling to understand this process fully and what all the different document types and classes etc mean.
    Thanks
    Ross

    Ok I've got my head around some of this...
    It seems OAC0 is used to create a Repository, say, ZH, with a Document Area, say, ARCHLINK.
    OAC3 is used to map a Document Type, say, EDXORDPDFS (purchase order PDF), to a Repository, say, ZH.
    OACT is used to map a Category, say, ZSOFFHTTP, to a Repository, say, ZH (and it's Document Area, ARCHLINK).
    SKPR08 seems to be used to map a Class, say SOFFPHIO, to a Category, say, SZOFFHTTP.
    So...
    It looks like currently OAC0 and OAC3 are used successfully to store 'new' documents in a Repository (Content Server).
    If I want to move 'old' documents to a different Repository (i.e. Content Server) then I use report RSIRPIRL which requires the following input:
    Document Area (believe this can be left blank)
    PHIO Class (for example, SOFFPHIO)
    Source Category (for example, SOFFDB)
    to move to:
    Target Category (for example, SZOFFHTTP)
    I.e. for my purposes - i.e. wishing to move things out of table SOFFCONT1 (and BDS_CONT1) - I just need to use report RSIRPIRL and to know the PHIO Class, Source & Target Categories.
    It seems that the PHIO Class I want for SOFFCONT1 entries is SOFFPHIO, but I still need to know what to use for BDS docs.
    It seems that the Source Category for SOFFCONT1 entries is SOFFDB, but again, I still don't know what it is for BDS docs.
    Target Category will be the relevant Category that's mapped in OACT to the Repository we want to use.
    I believe I don't need to use SKPR08 as I don't need to map any Classes to any Categories (report RSIRPIRL will move the Class I enter to the Category I enter).
    I believe there is no way I can use RSIRPIRL to move particular Document Types (i.e. purchase order) to different Repositories - it's done at a 'higher level' i.e. by Class, not Document Type.
    Right??
    Still struggling to understand the differences/purposes of Document Type, Category and Class though!!

  • How can update my class instance at runtime?

    What would happen if at runtime I update a class file?
    Will the JVM know to use that instead?
    How can I use the updated class at runtime?
    Who can give me an example?
    thanks all!

    yes,I write it like these:
    //MyClassLoader.java
    import java.io.*;
    public class MyClassLoader extends ClassLoader
         public Class loadClass(String name,boolean resolve)
              throws ClassNotFoundException{
              //return super.loadClass(name,resolve);
              Class c=findClass(name);
              resolveClass(c);
              return c;
         public Class loadClass(String name)
              throws ClassNotFoundException{
              return loadClass(name,true);
    public Class findClass(String name) {
    byte[] b = loadClassData(name+".class");
    //return defineClass(name, b, 0, b.length);
              Class c=null;
              System.out.println("load--class--data--success!");
              c=defineClass(name,b,0,b.length);
              System.out.println("define class success!");
              return c;
    private byte[] loadClassData(String name) {
    // load the class data from the connection
         byte[] b=null;
         try{
              //DataInputStream in =
    //new DataInputStream(
              BufferedInputStream in=
    new BufferedInputStream(
    new FileInputStream(name));
              int len=in.available();
              b=new byte[len];
              in.read(b,0,len);
              System.out.println("load "+name+" is success!\n"+name+"'s length is"+len);
         }catch(Exception e){System.out.println("load--"+name+"--data error:"+e);}
         return b;
    //Client.java
    import java.io.*;
    public class Client
         public static void main(String[] args)
         try{
              System.out.println("����������Load��������������");
              DataInputStream input=new DataInputStream(System.in);//��������������Load��������������
              MyClassLoader loader=new MyClassLoader();
              Load load=(Load)loader.loadClass(input.readLine()).newInstance();
              while(true){
                   load.print(); //print a sentence here! I will modify it when Client is runing!
                   input=new DataInputStream(System.in);
                   String inStr=input.readLine();
                   if(inStr!=null && inStr.trim()!=null)
                        load = (Load)loader.loadClass(inStr).newInstance();
         }catch(Exception e){System.out.println("main error:"+e);}
    I skip the Load interface and it's sub class,it's easy.
    MyClassLoader can load my class from the disk!
    why?

  • How to find out class name

    Hi folks,
    Can anybody help me, I got stuck on this problem.
    I need to find out the className of the class, which is specified
    by ordinary filename.
    In other words:
    User gives me filename (something.class) and I need to find out
    classname (I just need to create an instance of this class)
    Thanks a lot.
    sgtPepper

    This will read the class name from a class file.
    * @author Ian Schneider
    public class JavaClassName {
        public static void main(String[] args) throws Exception {
            DataInputStream din = new DataInputStream(new FileInputStream(args[0]));
            int cafebabe = din.readInt();
            if (cafebabe != 0xcafebabe)
                throw new Exception("Not class file");
            din.skip(4);
            int cnt = din.readShort() - 1;
            Object[] info = new Object[cnt];
            for (int i = 0; i < cnt; i++) {
                int b = din.readByte();
                switch (b) {
                    case 1:
                        info[i] = din.readUTF(); break;
                    case 3: case 4: case 9: case 10: case 11: case 12:
                        din.skip(4); break;
                    case 5: case 6:
                        i++;
                        din.skip(8); break;
                    case 7: case 8:
                        info[i] = Short.valueOf(din.readShort()); break;
                    default:
                        assert false;
            din.skip(2);
            int off = din.readShort();
            Number ptr = (Number) info[off - 1];
            System.out.println(info[ptr.intValue() - 1]);
            din.close();
    }

  • How to find out what attributes were really changed in AD?

    It it possible to find out what changes were really made in Active Directory resource?
    Example:
    I set two attributes: 'groups' and 'company'. One of groups doesn't exist or user(specified in resource configuration) dosn't have permission to add this group. Result of provisioning: idm set company, set other groups and there is error message in WF_CASE_RESULT. In audit log I see correct data - all attempted groups are in 'attempted value' and saved groups are in 'new value'.
    So the question is:
    Is it possible to find out what really happend - what groups were saved and what groups weren't (or maybe none of attributes were saved)?

    When one of groups doesn't exists I got "Error opening object 'LDAP://CN=...,OU=...': ADsOpenObject(): 0X80072030: , 0000208D: NameErr: DSID-031001CD, problem 2001 (NO_OBJECT), data 0, best match of: 'OU=...' , There is no such object on the server. "
    The problem is: WF_CASE_RESULT doesn't contain what groups were added and what groups weren't (at least I can't find this information). Maybe I can find it by analyzing errors, but I don't think it's good solution because there are a lot of errors that can happen and I need to know error messages for all of them.

  • How to find the class name, the location from where it invoked a method

    Hi,
    I have a class A. The caller calls A.someMethod(), whenever this method is invoked, I want to find out the caller info, which class invoked this method, from where this class was loaded (may be the jar file name). Any help will be appreciated.
    Thanks.

    However since version 1.4 there is an easier way to extract that information from the Throwable:
    java.lang.Throwable
    public StackTraceElement[] getStackTrace()
    Provides programmatic access to the stack trace information printed by printStackTrace(). Returns an array of stack trace elements, each representing one stack frame.

  • How to find target class/method

    Hi,
    I am new in OAF. I am opening a page from form.
    In Application -> Function that function name has HTML Call as below
    OA.jsp?akRegionCode=WFNTFDETAILSFNPAGE&akRegionApplicationId=601&OAFunc=FND_WFNTF_DETAILSURL on opened web page is
    https://host:port/OA_HTML/RF.jsp?function_id=16181&resp_id=51043&resp_appl_id=20003&security_group_id=0&lang_code=US&params=4XiL5F17oKK5MU.FgMDZFWoDyPgv5Ejey36oYszIUcg&oas=9SqEGPzammZ4QL08DZ-W9A..Here OA.jsp is redirecting to RF.jsp and this page invokes a RunFunction inside jsp.
    I need to know what class this RunFunction invokes further to show the page?
    Also in which directory I can find Java source codes?
    Thanks and regards,
    Kuldeep

    Hi,
    1) To enable 'About This Page' link, we need to set profile option "FND: Diagnostics" value to "Yes".
    2) To call an OAF page from AOL function we need to mention the page name and path in the 'HTML Call' property (e.g. page name and path: OA.jsp?page=/oracle/apps/xxx/xxx/xxx/webui/xxxPG). Here OA.jsp takes care of showing the page.
    3) All the event handling of the page is taken care by controller class. Regarding this I have already shared some info.
    Refer DevGuide for furthur info.
    Regards,
    Anand

Maybe you are looking for

  • Stream dvd to Mac mini

    I am trying to use the disc drive in a iMac to stream video to a Mac mini I manage to find the remote disc fr.o.m. Mac mini and start it in the DVD player, I can hear sound but the picture is distorted by colored squares. It looks like there is some

  • Progress bar completion function

    How do we control the progress bar completion functions @ the end of the pages, so they reflect reasonably correct amounts?

  • MI sync error

    Hi, I have this error during sync. No data downloaded and no dump is generated in the synchronization. Please help. Points will be given. Thanks. 20080314 09:16:54:546] I [MI/API/Logging ] ***** LOG / TRACE SWITCHED ON  [20080314 09:16:54:546] I [MI/

  • Visio 2010 Connector disapears

    When I create a electrical drawing with a connector which has a cabeling to another connector, about 16 to 20 connections. Then I want to resize or move the complete drawing i lose a number of connections(they disapear from the drawing). I set the "b

  • Profiling targets 24x36 vs 4 x 5

    Hi guys, I'm profiling an Epson V750 flatbedscanner for filmscanning/transparency. I'm using PMP5 and film IT8 targets in the size of 24x 36 mm and 4 x 5" with the correct refsfiles for each of them. The It8 targets are actually from bundled packages