Getting the instance of a super class

Hi, I'm in a class that extends another class. I'm trying to create a new instance of the super class and set it = to the current instance of the super class. I tried the following but am getting a CloneNotSupportedException
SuperClass sc = super.clone();
Does anyone know how to do this? Thanks

I want to do it because the super class is nothing more than a set of properties for another framework, I have a factory that extends the properties class so the user can more easily create a config object for the framework. When the factory returns the config object it needs to pass it an instance of the super properties class.
The more I think about it, I might be able to pass it an instance of the factory class but cast it as the super properties class.

Similar Messages

  • How to get the subclass from a super class( or interface)

    hi,
    I want to get subclass from a super class (or a interface), how to do that? the subclass of a interface means the class implementing the interface.
    for example;
    List ls;
    I want to get the subclass of ls, i.e., LinkedList, Stack, Vector......
    AbstractList al;
    the subclass of al, i.e., ArrayList, Vector.......
    thanks
    Aiwu

    List ls = new ArrayList();Since ls has been declared as a List we can only use List methods
    with it. This is a good thing because we might later want to change
    it to some other sort of List.
    I want to get subclass from a super class (or a interface), how to do
    that?The instance of the subclass declared above did not really come
    from the super class. A class "knows nothing" about its
    subclasses: many sub classes would not even exist at the time
    the class was written.

  • Getting the Instance of a Class

    I have this program where each user had there own prefences stored in there directory. A class called UserPrefences load the prefences into the data members of that class.
    The problem is I want to get the instance of that prefences which was loaded to be accessed by other classes. I don't want to have to reload all the prefences again from a text file but rather get the instance of UserPrefences from different class. So how do I get the instance of that one class without creating a new object each time I access prefences from a different class?

    Singleton????It's a design pattern you use when you want exactly one instance of something to exist.
    Can there be a static class? Top level classes cannot be static, but you can have a class full of static member variables.
    Because there are many
    fields in these prefences.Not sure how that's relevant.
    You've given almost no information about your requirements, so I can't really give you any more specific help.

  • Reflection: get an instance of a internal class by default constructor

    Hi there
    first the structure (reduced):
    public class ConvertionFactors { //singelton
    private HashMap<String,Class> factors = new HashMap<String,Class>();
    private class M_TO_FT implements DataFilter{
    public double convert(double value) {
    return value*M_IN_FT;
    public DataFilter getFilter(String from, String to)
    String name = from.toUpperCase()+convertionMethodNameSeparator+to.toUpperCase();
    Class c = factors.get(name); //retrieve the class
    Object o = c.newInstance(); //generate a instance.... not working
    return (DataFilter)o;
    The problem i want an instance of the internal class without defining a construktor like
    public M_TO_FT(){} because there are many classes like this one :-(
    (that was already working with a constructor that wants an instance of the container class.... thats what i am missing in the call c.newInstance() which uses the default constructor (i gues))
    i want something like
    new M_TO_FT() ; just the reflection version of it which calls the default constructor
    thanks for help

    well i get a Exception like this:
    java.lang.InstantiationException: com.eads.jpinfinity.data.unit.ConvertionFactors$M_TO_FT
         at java.lang.Class.newInstance0(Class.java:335)
         at java.lang.Class.newInstance(Class.java:303)
         at com.eads.jpinfinity.data.unit.ConvertionFactors.getFilter(ConvertionFactors.java:315)
         at com.eads.jpinfinity.data.unit.junit.ConvertionFactorsTest.testGetFilter(ConvertionFactorsTest.java:50)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at junit.framework.TestCase.runTest(TestCase.java:154)
         at junit.framework.TestCase.runBare(TestCase.java:127)
         at junit.framework.TestResult$1.protect(TestResult.java:106)
         at junit.framework.TestResult.runProtected(TestResult.java:124)
         at junit.framework.TestResult.run(TestResult.java:109)
         at junit.framework.TestCase.run(TestCase.java:118)
         at junit.framework.TestSuite.runTest(TestSuite.java:208)
         at junit.framework.TestSuite.run(TestSuite.java:203)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
    i think because i never told the method which is the containing class for this internal class. if i defina a constructor in the inner class it always needs a instance of the containter. by calling c.newInstance() there is no relation to the container class and because the inner class cant exist without the outer class it may not be constructed.
    It is possible to get an instance with "new FT_TO_M();" (the traditional way) with the default constructor but jet i have not found a way to get a instance of a inner class with reflection without defining a constructor.

  • Unable to get the Text proerty of Range class

    Hi,
    I am using the Text property of Range class for excel template development using VSTO.While reloading the template i am getting the error "Unable to get the Text proerty of Range class".If i skip this line of code,i am getting similar kind of errors while accessing the properties of Range class(like Range.copy() ,Range.Locked, Range.EntireRow.Hidden).In all these cases i am getting the similar kind of error "unable to get the property of Range Class".
    Waiting for a quick response...
    Thanks in advance..

    Hi Besse,
    Actully, the error is coming when i try to populate datatable with the the range values in one of the sheet.
    I am using the below code.
    //"wsInteropMetadata"  is the sheet object.
    //"RangeName" is the range name in the sheet.
    rngConfig = wsInteropMetadata.get_Range("RangeName", Type.Missing);
    for (int iRow = 1; iRow <= iRowCnt; iRow++)
        dRNew = dTMetadataTable.NewRow();
        for (int iCol = 1; iCol <= iColCnt; iCol++)
          rngCell = (Excel.Range)rngConfig.Cells[iRow, iCol];
          dRNew[iCol - 1] = rngCell.Text.ToString();
       dTMetadataTable.Rows.Add(dRNew);
    In the first load of the template,this code is working fine.In the reload i am getting the error at "rngCell.Text".If i see in quickwatch,most of the properties of  "rngCell" object are throwing "System.Runtime.InteropServices.COMException".See the below exception information.
     Exception Information
     Exception Type: System.Runtime.InteropServices.COMException
    Message: Unable to get the Text property of the Range class
    Source: Microsoft Office Excel
    ErrorCode: -2146827284
    Thanks
    Krishna.

  • How do I get the directory name that a class is located in?

    How do I get the directory name that a class is located in? I have a class located under /com/dhcmc and I want to be able to retrieve the "/com/dhcmc" that the class is residing under so that I can then use this directoy name to build a relative path name for the other directories supporting the application such as the images directory etc i.e.
    |---com
    |   \---dhcmc       (my class resides here)
    |       +---images  (supporting app dirs under the class dir)
    |       +---config  (supporting app dirs under the class dir)

    You can try the methods.
    Class.getClassLoader()
    Class.getResourceAsStream()
    Class.getResource()
    You probably wont get the complete directory path, but you might
    be able to load the files relative to your classes directory.

  • How to retreive the instance name of a class

    Hello,
    Does anyone know how you can retreive the instance name of a
    class ?
    For example my class is:
    class Example{
    public static var createdClasses:Array;
    function Example() {
    createdClasses.push(this);
    trace("how can i trace the original name of the class ?");
    and in my fla file i have:
    var someName:Example = new Example();
    var anotherName:Example = new Example();
    So, what i would like to know is, the name of the class.. in
    this case it is 'someName' and 'anotherName'.
    Does anyone know how?
    Thanks,
    Micheal.

    there is no instance name of a class. class members can have
    instance names and that's an assignable property for classes that
    have instance names.

  • Get the instance names of clips attached to a movieclip

    I want to get the instance names of all the cmovieclips that
    are attached to a movieclip.
    Is there a simple way to do this.
    I imagine this is something that can be done with AS3 but can
    it be done with AS2?
    regards J

    you're welcome.
    FYI: a for...in loop loops through all the accesible
    properties (in the broadest sense of the meaning, includes
    methods/functions and variables etc). Each time it finds one it (in
    this case) assigns the property name to the variable 'unknown'
    the code inside the loop just checks
    a) is it a property that references a movieclip instance and
    b) is it the same property name as the movieclip instance's
    _name property (this is to avoid listing additional references to
    the same movieclip instance that may be set up as variables in your
    McA's scope).
    I just read that and I'm wondering if it actually will help
    you understand... its quite complicated to describe,sorry...
    although its simple to understand once you get used to it. To learn
    you should experiment with a few for.. in loops on different
    objects and see what trace outputs you get.

  • How do I get the java code from a class file ?

    I want to know how to findout the java code from a .class file . Is there any utility or any way to get the java code from a .class file. If so , please let me know the step by step procedure .
    Thanks
    Shiva

    Check out Mocha (http://www.brouhaha.com/~eric/computers/mocha.html)
    It's free!

  • Getting the JAXB exception like "Two classes have the same XML type name-"

    Getting the JAXB exception like "Two classes have the same XML type name...",
    Here is the exception details:
    Exception in thread "main" com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions Two classes have the same XML type name "city". Use @XmlType.name and @XmlType.namespace to assign different names to them. this problem is related to the following location: at com.model.City at public com.model.City com.model.Address.getCurrentCity() at com.model.Address this problem is related to the following location: at com.common.City at public com.common.City com.model.Address.getPreviousCity() at com.model.Address
    at com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(Unknown Source) at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(Unknown Source) at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.(Unknown Source) at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(Unknown Source) at com.sun.xml.internal.bind.v2.ContextFactory.createContext(Unknown Source) at com.sun.xml.internal.bind.v2.ContextFactory.createContext(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at javax.xml.bind.ContextFinder.newInstance(Unknown Source) at javax.xml.bind.ContextFinder.find(Unknown Source) at javax.xml.bind.JAXBContext.newInstance(Unknown Source) at javax.xml.bind.JAXBContext.newInstance(Unknown Source) at com.PojoToXSD.main(PojoToXSD.java:17)
    I took the example like:
    package com.model; ---->this package contains 'Address' class and 'City' class
    public class Address {
    private String areaName; private City currentCity; private com.common.City previousCity;
    package com.model;
    public class City {
    private String cityName;
    Another city class in "com.common" package.
    package com.common;
    public class City {
    private String pinCode;
    We need to create XSDs and needs to do the Marshalling and unmarshalling with the existing code in our project(like as above example code), code does not have any annotations like "@XmlRootElement/@XmlType" and we can not able to change the source code.
    I would like to know is there any solution to fix the above issue or any other ways to create XSDs and marshaling/unmarshalling(like MOXy..etc)?
    It would be great if i can get the solution from any one....May thanks in advance.
    Thanks,
    Satya.

    Getting the JAXB exception like "Two classes have the same XML type name...",
    Here is the exception details:
    Exception in thread "main" com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions Two classes have the same XML type name "city". Use @XmlType.name and @XmlType.namespace to assign different names to them. this problem is related to the following location: at com.model.City at public com.model.City com.model.Address.getCurrentCity() at com.model.Address this problem is related to the following location: at com.common.City at public com.common.City com.model.Address.getPreviousCity() at com.model.Address
    at com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(Unknown Source) at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(Unknown Source) at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.(Unknown Source) at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(Unknown Source) at com.sun.xml.internal.bind.v2.ContextFactory.createContext(Unknown Source) at com.sun.xml.internal.bind.v2.ContextFactory.createContext(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at javax.xml.bind.ContextFinder.newInstance(Unknown Source) at javax.xml.bind.ContextFinder.find(Unknown Source) at javax.xml.bind.JAXBContext.newInstance(Unknown Source) at javax.xml.bind.JAXBContext.newInstance(Unknown Source) at com.PojoToXSD.main(PojoToXSD.java:17)
    I took the example like:
    package com.model; ---->this package contains 'Address' class and 'City' class
    public class Address {
    private String areaName; private City currentCity; private com.common.City previousCity;
    package com.model;
    public class City {
    private String cityName;
    Another city class in "com.common" package.
    package com.common;
    public class City {
    private String pinCode;
    We need to create XSDs and needs to do the Marshalling and unmarshalling with the existing code in our project(like as above example code), code does not have any annotations like "@XmlRootElement/@XmlType" and we can not able to change the source code.
    I would like to know is there any solution to fix the above issue or any other ways to create XSDs and marshaling/unmarshalling(like MOXy..etc)?
    It would be great if i can get the solution from any one....May thanks in advance.
    Thanks,
    Satya.

  • How do I get the instance of a serviceticket in ICCMP_BTPARTNER?!

    Hi all,
    I want to find out which instance/ibase is currently set in a serviceticket. I am in the component "ICCMP_BTPARTNER" in the view "PARTNERTABLE".
    I thought I might get the instance of the serviceticket in the global data context in GDC_CURRENTIBASE or GDC_CURRENTSERVICETICKET. But the CURRENTIBASE is initial and in SERVICETICKET the only information I get is the CRM_GUID. 
    I tried something like this...
      CLEAR: lr_gdc.
      TRY.
          lr_gdc ?= cl_crm_ui_data_context_srv=>get_instance( iv_controller = me ).
        CATCH cx_root.
      ENDTRY.
      CHECK lr_gdc IS BOUND.
      CALL METHOD lr_gdc->get_entity
        EXPORTING
          name  = if_iccmp_global_data_cont_con=>gdc_currentibase
        RECEIVING
          value = lr_serviceticket.
      CHECK lr_ibase IS BOUND.
    So, does anyone know how to get the current instance of a serviceticket in any other components view (here ICCMP_BTPARTNER/PartnerTable)?
    Thanks for your help.
    Best regards.
    Ben

    Done.
      DATA: lr_gdc             TYPE REF TO if_crm_ui_data_context.
      DATA: lr_serviceticket   TYPE REF TO if_bol_bo_property_access.
      DATA: lr_entity          TYPE REF TO cl_crm_bol_entity.
      DATA: lv_instance        TYPE ib_instance.
      CLEAR: lr_gdc.
      TRY.
          lr_gdc ?= cl_crm_ui_data_context_srv=>get_instance( iv_controller = me ).
        CATCH cx_root.
      ENDTRY.
      CHECK lr_gdc IS BOUND.
      CALL METHOD lr_gdc->get_entity
        EXPORTING
          name  = if_iccmp_global_data_cont_con=>gdc_currentserviceticket
        RECEIVING
          value = lr_serviceticket.
      CHECK lr_serviceticket IS BOUND.
      CLEAR: lr_entity.
      lr_entity ?= lr_serviceticket.
      CHECK lr_entity IS BOUND.
      CLEAR: lv_instance.
      TRY.
          lr_entity = lr_entity->get_related_entity( 'BTOrderHeader' ).
          CHECK lr_entity IS BOUND.
          lr_entity = lr_entity->get_related_entity( iv_relation_name = 'BTHeaderBOSSet' ).
          CHECK lr_entity IS BOUND.
          lr_entity = lr_entity->get_related_entity( iv_relation_name = 'BTRefObjSet_A' ).
          CHECK lr_entity IS BOUND.
          lr_entity = lr_entity->get_related_entity( iv_relation_name = 'BTRefObjectComponentsAll' ).
          CHECK lr_entity IS BOUND.
          lv_instance = lr_entity->if_bol_bo_property_access~get_property_as_string( 'IB_INSTANCE' ).
        CATCH cx_crm_genil_model_error cx_root.
      ENDTRY.

  • I get the "unable to load data class information" why I try and sync

    I get the "unable to load data class information" when I try and sync with my iPad.  Tried uninstall and reset sync history, still doesn't work.  Help.

    Hey Mike Urwin
    Start with the article below for troubleshooting syncing issues with Sync Services.
    Advanced troubleshooting for Sync Services on Windows with Microsoft Outlook 2003, Outlook 2007, or Outlook 2010
    http://support.apple.com/kb/TS2776
    Regards,
    -Norm G.

  • How can I use evaluate to get the instance variable in customized tag

    1.
    At first , I create a class called bean,and declared several params in it and do not define any getter function for the param.
    class bean{
    String param = "test";
    SomeClass scObj = new SomeClass();
    2.
    The second ,I use
    request.setAttribute("beanObj",new bean());
    3.
    And then I wanna use the customized tag to show a text box , then initialize it's value.
    <salt:text name="param" value="beanObj.param">
    <salt:text name="obj" value="beanObj.scObj.func()">
    4.
    I tried the evaluator provided by JexlContext ,Struts, JSTL and it seems that if I do not define the getter for the variable ,I can not get the bean's instance variable's value.
    Expression e = ExpressionFactory.createExpression( value );
    JexlContext jc = JexlHelper.createContext();
    jc.getVars().put(strInitBeanName, request.getAttribute("beanObj"));
    Object obj = e.evaluate(jc);
    the result of the obj is null....
    Can anybody recommand some other evaluator can get the value of a instance variable from an object?

    do you have any other suggestion ? Nops, somebody else may have though. AFAIK, all lookups of the type
    beanName.propertyNameuse reflection on the getXXX() methods to access the property.
    Having said that, I guess you could write one though in a custom tag, using the same - reflection (you will ahve to rely on the java.lang.reflect.Field class quite heavily) - but that would be reinventing the wheel for most other functionality that you would have to include (like looking up the bean in scope etc)
    cheers,
    ram.

  • Is there a way to refer to/call the method of a super class' super class?

    Is there any way to essentially do what this pseudo code does?
    public void someMethod()
    return super.super.someMethod();
    }

    Imagine you had a class called C that extends class B, and class B extends class A. They all declare an instance variable called i. In the case of accessing an instance variable you could do this in class C:
    ((A)this).iThis is because super means the same as a cast of this.
    This is not true for for method invocation though. The cast to type A does not change the method that is invoked, because the instance method to be invoked is chosen according to the run-time class of the object referred to by this. A cast does not change the class of an object; it only checks that the class is compatible with the specified type.
    This is all in the JLS.

  • Get the handler for GUIBB Feeder class from Genil implementation class

    Hello,
    In BOL based GUIBB, the feeder class will call correspondence Genil implementation class, may I know if it is possible to get the handler or instance of the feeder class in the Genil implementation class, then we can call the method of the feeder class get some information about the feeder, e.g. the value of the parameter.
    Thank you very much.
    Best regards,
    Shumin

    Hello,
    In BOL based GUIBB, the feeder class will call correspondence Genil implementation class, may I know if it is possible to get the handler or instance of the feeder class in the Genil implementation class, then we can call the method of the feeder class get some information about the feeder, e.g. the value of the parameter.
    Thank you very much.
    Best regards,
    Shumin

Maybe you are looking for