Getting the name of the generic class?

I have a generic class declared as such:
public class MyClass<T>
and I want to access the name of the <T> class a member function in that class? I just can't figure out which syntax to use.
Thank you!
Joshua

Sorry, I'm a little bit confused at your answer.
I cannot seem to instantiate an object of class T, like: T item = new T();does not work. If I can't create an object of type T, then I can't get it's type. I need to get the class even if I don't have any instantiated objects (or if I can create a blank one), so that I can use the name to fetch the objects from the persistence engine. Here is the class, so you can see what I'm talking about. I have in there now what seems like it should be right, but doesn't compile.
A small example of solution please?
public class PersistentSelectorCellEditor<T> extends AbstractCellEditor
          implements TableCellEditor {
     JComboBox control;
     List<T> choices;
     Session session;
     public PersistentSelectorCellEditor() {
          initializeComponents();
     public PersistentSelectorCellEditor(Object value) {
          initializeComponents();
          this.control.setSelectedItem(value);
     private void initializePersistence() {
          session = LabApp.getSession();
          session.beginTransaction();
     private void initializeComponents() {
          initializePersistence();
          populateList();     //query for selections to fill combo box
          control = new JComboBox((ComboBoxModel)choices);
     private void populateList() {
          //query to populate drop down lists
          Query query = session.createQuery("from " + T.class.getName());
          choices = query.list();
     public void setValue(T value) {
          control.setSelectedItem(value);
     public T getValue() {
          return (T)control.getSelectedItem();
     //interface members
     public Object getCellEditorValue() {
          return control.getSelectedItem();
     public Component getTableCellEditorComponent(JTable table, Object value,
               boolean isSelected, int row, int column) {
          return control;
}Thank you!
Joshua

Similar Messages

  • How to get the name of the class which is currently in use

    Hi all,
    I have two classes Mother and Child, and I use this code to print the name of the class in use
      DATA m TYPE REF TO zmother.
      DATA class_name type string VALUE 'CHILD'.
      CREATE OBJECT m TYPE (class_name).
      CALL METHOD m->PrintName .
    So, what is the source code that I have to put in the PrintName methode?
    Thanks.

    Ok, but how can I get the name of the object class that calls the methode!
    REPORT  ztest_method.
    *       CLASS c1 DEFINITION
    CLASS c1 DEFINITION.
      PUBLIC SECTION.
        METHODS: get_data.
    ENDCLASS.                    "c1 DEFINITION
    *       CLASS c1 IMPLEMENTATION
    CLASS c1 IMPLEMENTATION.
      METHOD get_data.
    ****** What is the code to put here to know the name of this Class?*
      ENDMETHOD.                    "get_data
    ENDCLASS.                    "c1 IMPLEMENTATION
    DATA oref TYPE REF TO object.
    DATA: method TYPE string.
    DATA: cla_name(20).
    START-OF-SELECTION.
      cla_name = 'C1'.
      CREATE OBJECT oref TYPE (cla_name).
      BREAK-POINT.
      CALL METHOD oref->(method).

  • Getting the name of a calling Class

    Hi,
    Is there anyway I can get the name of the Class that calls a Class in the Class that is being called?
    Cheers
    SS

    write this into your called class
    this.getClass().getDeclaringClass()

  • How to get the name of the file parent

    Hi,
    i have a file in this location
    File file = new File(MyFile.doc)
    file.getParent(); returns
    C:\Documents and Settings\Administrator\xyz
    now from the string obtained i just want to get the value "xyz".i.e. i want to get the name of the parent directory.
    how is it possible

    You may use String.indexOf()if(file.getParent().indexOf("/myProject/myPackage") != -1) {
        ...Or you might use regular expressions and Matcher class (or String.matches()) in case of higher complexity.

  • Getting the name of the column using MDM API

    Hi I want to know the Column name from fieldId, can any one help me on this. I am using the following code to get the data but i nedd column name to which the data is refering
    ArrayList mdmData=new ArrayList();
    RecordResultSet rs=(RecordResultSet)obj;
    FieldId field[];
    for(int i=0;i<rs.getRecords().length;i++)
           field=rs.getRecords()<i>.getFields();
                for(int j=0;j<field.length;j++)
                    mdmData.add(rs.getRecords()<i>.getFieldValue(field[j]));
    Regards,
    Sandeep

    Hi Sandeep,
    When you fetched the FieldID from FieldProperties object. There is one more method to this class named FieldProp.getName(). This returns you the Name of the Field. You can store that too if you need it later.
    Thanks
    Namrata

  • I know the name of an object - how do I get the name of the object that contains it?

    If I have a Movieclip, I can trace the name of the Movieclip
    that contains it using the _parent property.
    With a generic object, is there a way to trace the name of
    the object that contains it?
    Please, please tell me - this will be a huge help.
    Thanks

    Thanks for these comments - my problem isn't with MovieClips.
    I need to know if there is something which is the generic Objects
    equivalent to the MovieClips _parent property.
    Here's some code that hopefully will help explain further:
    class MyClass extends Object {
    var myObject:Object;
    function MyClass (){
    myFirstObject = new Object();
    myFirstObject.theParent = this;
    private function getNameOfParent(p_object:Object){
    // Some code to return the name of the object that contains
    p_object
    trace(p_object.__proto__); // Output: [object Object]
    trace(p_object._parent); // Output: undefined
    trace(p_object.theParent); // Output: [object Object]
    return ???
    public function doSomething(p_num:Number){
    var parentName = getNameOfParent(myObject);
    // do some more action...
    Timeline code:
    var myClass1 = new MyClass();
    myClass1.doSomething();

  • Can I get the name of the jnlp file used to launch my application

    Does anyone know if there is a way to get the name of the jnlp file used to launch the currently executing code?
    Essentially in the code below a way to set myAppFileName without hard coding the string. i.e. code could exist in a utility class used by many jnlp applications.
                String myAppFileName = "myApp.jnlp";
                BasicService bs = (BasicService) ServiceManager.lookup("javax.jnlp.BasicService");
                String url = bs.getCodeBase() + myAppFileName;Seems reasonable that if the jnlp API's know about the codebase that maybe it could hold the file name somewhere too? I hope, I hope ....
    Thanks
    Mike

    Ok. Bravo
    Please mark this as 'Answered' - it will help others on the forum -

  • How to get domain name for the userId?

    There is a generic way to get userID
    System.getProperty( "user.name" ).
    In case of windows it's a name you login in.
    Is any way in Java to figure out domain name of that particular user by Java code?
    Igor

    You can dojava.net.InetAddress.getLocalHost().getHostName()to get the name of the computer. But this will not give you the "domain name of the user". In Windows, for example, when I sign on to my computer, that user name only means something to my computer. There's no "domain", in the Internet sense, involved.

  • Mail running under LIon no longer grays out the name of the sender of an email that has been read.  How can I get that to happen?

    Under the old version of Mail, when an e-mail was read, the name of the sender was greted out so that I knew I had read that email.  This does not seem to happen under the new Mail thaqt came with Lion.  Help!?
    Chuck Humphrey
    [email protected]
    303-997-2755

    Kirk,
    Thanks again for your suggestions. No, I don't get an
    error message. In fact nothing happens. My name and
    key are typed in and from what I understand, once you
    do that with a real key it directs you to the
    registration page. When I get done entering the
    information the window just sits there without any
    button or option to continue.
    QT Pro is already in the QT (non-pro) you installed and the key (which is a hash of your name in part) allows the Pro features to work.
    No redirect, internet, nothing like that. As such many people have activated and think they haven't. Just look at the menu items and see if the "Pro" logo is shown next to a few (which are greyed out and not available without Pro). If not you are done.

  • Any Function module or BAPIs are available to get scheme name for the inter

    I have internal order no value in table  AUFK-AUFNR ,  and the internal order corresponding Scheme value is available in IMPR-PRNAM . Now I want to inner join both the tables to extract the data , but there is no common field . Is there any Function module or BAPIs are available to get scheme name for the internal orders?

    look at DB-VIEW  "V_IVP_OR".
    Regards,
    Laurent

  • Just updated my iphone. Now I can se I have two? iCloud accounts? One of them appears on my phone, and I have forgotten the password. When I try to add the other account, I get the message that this account is already added, but with the name of the first

    Just updated my iphone. Now I can se I have two! iCloud accounts? One of them appears on my phone, and I have forgotten the password. When I try to add the other account, I get the message that this account is already added, but with the name of the first account where there is no available password. I have tried several times to reset the password, bun I don't get the information I need - I have no access to email. What can I do?

    Hi, thanks for the suggestion. I have tried as you suggested, and when opening the "purchased" apps some have the icloud logo next to them, but I only have "OPEN" against "Find My iPhone". When opening it up, it goes through the same routine; needs to be updated before proceeding, and wouldn't update because I don't have IOS8.
    Anything else I could try, or am I doomed!
    All of your help is much appreciated, thanks

  • How can i get my name on the finder bar?

    How do i get my name on the top right corner next to the search bar? I have OS X Mountain Lion 10.8.5

    System Preferences > Users & Groups
    Click the lock to unlock it, if you have to.
    Click "Login Options".
    Enable " Show fast user switching menu as" and select "Full Name".
    Best.

  • Need of a Webservice to get the name of the file in a Folder

    Hi All,
    I am in need of a Web service which should get the name of the file in a folder.
    Note :  Folder is created in the MOSS server.
    Thanks.

    Just to add, Mac in intergrated into AD and all I need is help in creating the script
    Thanks

  • Installed office for mac (trial version). now I got 2 excel files, which cannot be deleted. I googled the names of the sheets and found chinese websites I never visited. Are those dialers? How can I get rid of them? system is mac lion(with win 7 parallel)

    now I got 2 excel files, which cannot be deleted on my desktop. I can't open them, either. I googled the names of the sheets and found chinese websites I never visited. Are those dialers? How can I get rid of them? system is mac lion (with win 7 parallel)

    The people who make that stuff have their own forums you can also search/ask in:
    http://answers.microsoft.com/en-us/mac/forum

  • How to get the name of the current tab.

    Hi Experts,
    I have two tabs in my tab strip and a button common to both the tabs.Can you please let me know how to get the name of the current tab in the event method of the push button.
    Thanks in advance.
    Regards,
    Arun

    1.Declare an Action for OnSelect event of Tabstrip. This event is triggered whenever any change in tab occurs.
    2. Declare an Import Parameter in this method
       Tab type String.
    3. This parameter has value of the selected TAB.
    4. You can set this value in some Attribute in Attribute Tab in this event only (OnSelect):
         wd_this->Att  = Tab.
    Att is the attribute created by you in Attributes Tab of View. ( of type String)
    5. Now the selected Tab ID is stored in this Attribute Att.
    6. In the Onaction of Button , retrieve the selected tab value from this attribute using :
               Data : lv type string.
                lv =  wd_this->Att
    Now lv has your selected TAB ID.
    I hope it would help you.
    Edited by: Saurav Mago on Oct 13, 2009 2:22 PM

Maybe you are looking for

  • Two iPhone same AppleiD moving to iCloud using different account. What happens to the app ?

    Here is the scenario. Me and my wife have two different iphone with the same AppleiD. She has her own mail, her music playlist, her photoalbum and of course we share some of the apps bought with my AppleiD. Now that we are moving to iCloud I was wond

  • Intermittent problems with iphone 3g "charging not supported"

    I notice quite a few complaints about intermittent 'charging not supported' messages. I have been getting the same message on my iphone 3g. I have ELIMINATED the cord and plug as the problem in this case by the following method: I found that by LOWER

  • ITunes 9.0.2.25 doesnt work on Windows 7 64-Bit!!! Have looked everywhere!!

    I first started to install iTunes 64-bit and the installation seemed to work well, but when i plugged in my iPod Touch this message showed up: "This iPod cannot be used because the required software is not installed. Run the iTunes installer to remov

  • G4 Mirror Help!

    hello! I have been searching for help to get my machine to work. i found a link that is similar with my problem but it is not working right because it won't start up. I shut it dow for a day due to go over to my in laws for christmas and came back to

  • How to create TCode for Sapquery

    Hi Everyone, I would like to create a Tcode for a SapQuery i would like my users to use. Is it possible? Can i use SE93 for this and it is, how do i use it? Thanks in advance