How to creat odjects with dynamivc class name

hi i have a problem with class names. i have in my program one father class and a lot of extend classes in the father class. one of this classes is a test class. I want to create an object and the object class must be given dynamic from the keyboard and to be one of the extended classes. how i can do that

It is possible to create an object of a class whose name is known at runtime (as above, the Class.forName() thing) but it's messy and complete overkill for what you are trying to do.
These days when I have to distinguish a limited number of words (e.g. car, van,..) I use an enum. You can use MyEnum.valueOf(String name) to find the enum value from an input string, catch IllegalArgumentException to deal with an unmatched input.
Try something like:
public enum VehicleType {
    car { public Father create() { return new Car(); }},
    plane { public Father create() { return new Plane();} }.
      .. etc.
  public abstract Father create();
try {
    Father vehicle = VehicleType.valueOf(vehicleTypeName.toLowerCase()).create();
  } catch(IllegalArgumentException ex) {
     System.out.println("Unknown type " + vehicleTypeName);
}

Similar Messages

  • How to create object by getting class name as input

    hi
    i need to create object for the existing classes by getting class name as input from the user at run time.
    how can i do it.
    for exapmle ExpnEvaluation is a class, i will get this class name as input and store it in a string
    String classname = "ExpnEvaluation";
    now how can i create object for the class ExpnEvaluation by using the string classname in which the class name is storted
    Thanks in advance

    i think we have to cast it, can u help me how to cast
    the obj to the classname that i get as inputThat's exactly the point why you shouldn't be doing this. You can't have a dynamic cast at compile time already. It doesn't make sense. Which is also the reason why class.forName().newInstance() is a very nice but also often very useless tool, unless the classes loaded all share a mutual interface.

  • How to create a weblink to Contact name ?

    Hi experts ,
    How to create a weblink to contact name in report, so that when in i click the Link it show the Contact Detail page.
    We want to do in Data Format in with Custom Text Format .
    please Say how to edit this
    @[html]"{a href=""@H""}"@"{/a}"
    {=<
    }=>
    Thanks in advance
    Edited by: Uthaya on Feb 8, 2011 3:25 AM
    Edited by: Uthaya on Feb 8, 2011 3:37 AM

    Hi,
    I am not sure whether you have something specific in mind by using weblink or do you just want a clickable Contact Name in the report.
    If you just need a report with contact names (and whatever other fields and filters you may want) and when clicked on they take you to the actual record then you can use Action Links
    In your report Add the FullName/Contact Name column and to its immediate right add the Contact ID column (you can make it hidden on the display but it is needed for the action links)
    1. Click on properties for the Contact name column
    2. On the style tab Click on Custom  CSS Style Options (HTML Only) & mark the Use Custrom CSS Class checkbox and type in ActionLink
    3. Go the data format tab and override with Custom Text Format and type/paste in
    @[html]"<span onClick=\"javascript:LinkOccam (this, 'contact');\">"@"</span>"
    The contact names should be clickable and should take you to the actual record when clicked on
    Hoep it helps
    -Gaurav
    Edited by: Gaurav Shah on Feb 8, 2011 12:18 PM

  • How to create Rules with Flex Field mapping in the bpm worklist

    I Have created a flex field label and was able to map to the flex field attributes .
    But when i try to create a rules , I don't see the label or the flex attributes in the task payload .
    Can someone please help is understanding how to create Rules with Flex Field mapping in the bpm worklist .
    Even I am also searching for any scripts which will take the flex fields prompts and can directly create a label in the bpm worklist .
    Any pointers or suggestion is highly appreciated .

    Hi,
    SE38 -> Enter program
    Select Variants button and display. In the next screen, enter a variant name, (If not existing , press Create to create new one), else click on Change.
    Now the selection screen will display with a button "Variant Attributes" at the top.
    Click on that button.
    In the next screen, go to the selection variable column of the date field. Press F4 or drop down and select 'D' for date maintenance.
    In the column "Name of Variable (Input Only Using F4)" press F4 or drop down, select whichever kind of date calculation you want and save the variant.
    Now whenever you run the prgrm with this variant, date will be displayed by default.
    Regards,
    Subramanian

  • How to create a model access class ???

    HI,
          Can somebody tell me how to create a Model Access Class. In the Application Set, i can find the Model Access folder, but it has a list of application sets which is already created and the system asks to select a Application set. I need to create a new application set. Please help.
    Regards,
    Shiny

    Hi Shiny,
    I would suggest you not to create a new application set.
    If you are enhancing a standard PCUI application, i would suggest you to create new model access classes and assign them to the same application set which is assigned with the standard model access class for that application.
    Creating a model access class can be done through the transaction SE24(like any other Z-class).
    Go to transaction CRMC_BLUEPRINT_C and you could assign this newly created Model access class to the standard application set. This can be done under Application Element->Application Set->MOdel Access Class.
    If you still feel the need to create a new application set altogether, it can be done from Trx CRMC_BLUEPRINT_C->Layout of PCUI-> Application Element->Application set.
    I hope it helps.
    Cheers,
    Gyan.

  • How to create CATALOG with MS SQL Server?

    Connection class has getCatalog(strCatalog) method. In order to use it, we must create CATALOG in Database?
    How to create CATALOG with MS SQL Server?
    Help me, please!!!

    You do not create these for any database, this is part of the Connection metadata.
    The Catalog is the third level of table-like database object qualification as in "Catalog.Schema.Table". For SQLServer the qualification scheme is "Database.Owner.Table" and I would be surprised if they reported anything for the current connections getCatalog() method call.
    What many people do is avoid table qualification altogether by setting the connection's context in a database proprietary manner and then keeping the SQL as clean as possible. For many ODBC and JDBC drivers this can be set in the configuration. For MS SQLServer you can also execute a "USE dbname" statement on the connection to avoid table qualification.

  • How to creat javadoc with userdefine methods

    hi
    how to creat javadocs with user define class && methods ....
    we did like that
    javadocs filename..
    we are not geting my oun methods..
    pls help me
    regards
    kedar

    Hi,
    javadoc creates documentation for packages, not for single files - and you have to comment out every class, method, fields in a special form using javadoc tags - an example
    package MyPackage;
    import java.util.Vector;
    * This class is only an example, how to create javadocs for a package.
    public class MyClass extends Object {
    * an example for a public field holding a Vector
    public Vector aVector = new Vector(3,3);
    * Constructs a MyClass instance.
    public MyClass() { super(); }
    * Constructs a MyClass instance using the passed Vector in the {@link aVector} field.
    * @param vec a Vector, that replaces the Vector in field {@link aVector}
    public MyClass(Vector vec) { super(); aVector = vec; }
    * gets the Vector in field {@link aVector}.
    * @return a Vector, held in field {@link aVector}
    public Vector getVector() { return aVector; }
    }// end of classNow you can create your javadoc from the classpath with "javadoc MyPackage"
    hope, this helps
    greetings Marsian

  • How to create messages with parameters In ADF model.

    In ADF model, How to create messages with parameters?

    To Create messages in message bundles with parameters, perform the steps as given below
    Scenario: To Create a message as "Department Name XXXXXXX is already existing "
    Step#1: For the given entity object “DepartmentEO”, Go to “overview” tab and click “Business Rules” finger tab.
    Step#2: Select “Entity Validators” in the list & click “+” to add a new entity level validation rule.
    Step#3: Now go to “Failure Handling” tab, and click the Magnifier Icon.
    Step#4: Now in the “Display Value” field, enter the message with flower-braces as below.
    Department Name {department_name} is already existing
    Step#5: Also modify the Key & Description fields as needed. And click “Save and Select” button.
    Step#6: Now go to “Token Message Expressions” section, double-click the Expression field corresponding to "department_name" & give the relevant Attribute names say "DepartmentName"
    Step#7: Now click “OK”.

  • How to create complaints with reference to ECC Billing document (CRM 7.0)

    Hi experts!
    I use ECC 6.0 and CRM 7.0.
    I have to create CRM complaints (ZCLR - CLRP) with reference to ecc billing documents.
    I read the following topics and help:
    1. How to create complaints with referenceto ECC Billing document
    2. Re: How can we transfer billing documents from SAP ERP to CRM 2007?
    3. http://help.sap.com/saphelp_crm70/helpdata/en/46/029ba32e675c1ae10000000a1553f6/frameset.htm
    Made these settings:
    1. Define the Business object type
    Goto SPRO>CRM>Transaction>Settings for Complaints>Integration>Trnsaction Referencing>Define Object types for Transaction reference
    2. Assign Business Object Types to Transaction Types
    Goto SPRO>CRM>Transaction>Settings for Complaints>Integration>Trnsaction Referencing>Assign Business Object Types to Transaction Types
    3. Implement a BADI - CRM_COPY_BADI_EXTERN.Check Implementation CRM_COPY_BADI_BILLDO for more information on the coding for referencing the ECC Billing document.
    Goto SPRO>CRM>Transaction>Settings for Complaints>Integration>Trnsaction Referencing>BAdI: Create Complaint with Reference to External Transaction.
    but still do not know,
    1) if I should pre-replicate billing documents into CRM ?
    2) Or, the system uses the RFC to find these documents in ECC to create reference?
    Please help me.
    Best regards Kostya.
    Edited by: Kostya Khveshchenik on Oct 20, 2010 2:09 PM

    not resolved =(
    Edited by: Kostya Khveshchenik on Nov 19, 2010 8:50 AM

  • How to create Matrix with Group report layout in xml

    Hi,
    i would be glad if anyone could tell me How to create Matrix with Group report layout in xml?
    Here i am attaching the required design doc
    below is the code
    select COST_CMPNTCLS_CODE,
    -- crd.RESOURCES,
    NOMINAL_COST,
    cmm.COST_MTHD_CODE,
    -- crd.COST_TYPE_ID,
    gps.period_code
    -- ORGANIZATION_ID
    from CM_RSRC_DTL crd,
    gmf_period_statuses gps,
    CM_MTHD_MST cmm,
    CR_RSRC_MST crm,
    CM_CMPT_MST ccm
    where gps.period_id = crd.PERIOD_ID
    and crd.cost_type_id = cmm.cost_type_id
    and crd.RESOURCES = crm.RESOURCES
    and crm.COST_CMPNTCLS_ID = ccm.COST_CMPNTCLS_ID
    and gps.period_code in (:p_period1, :p_period2, :p_period3)
    group by COST_CMPNTCLS_CODE, cmm.COST_MTHD_CODE, gps.period_code,NOMINAL_COST
    order by 1,2,3,4.
    The o/p of the report shoud be as given below
              Period-1     Period-2     Period-3     Period-4
    COMPONENT                         
    LABOUR - DIRECT                         
         Actual     1     2     3     4
         Actual Rate     10     10     10     10
         Standard Rate                    
         Var%                    
    DEPRICIATION-DIRECT                         
         Actual                    
         Actual Rate                    
         Standard Rate                    
         Var%                    
    OVERHEAD - DIRECT                         
         Actual                    
         Actual Rate                    
         Standard Rate                    
         Var%                    
    LABOUR - IN DIRECT                         
         Actual                    
         Actual Rate                    
         Standard Rate                    
         Var%                    
    Thanks in advance

    Your friend is obviously not a reliable source of HTML
    information.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "Mr.Ghost" <[email protected]> wrote in
    message
    news:f060vi$npp$[email protected]..
    > One of my friends advised me to develop my whole site on
    the layout mode
    > as its
    > better than the standard as he says
    > but I couldnot make an ordinary table with rows and
    columns in th layout
    > mode
    > is there any one who can tell me how to?
    > thanx alot
    >

  • How to create PDF with Form Builder (T-Code:SPF) and how to use it?

    How to create PDF with Form Builder (T-Code:SPF) and how to use it? Is there anyone can show me some doc. or PA material ? << removed >>  Thank you very much!!
    Edited by: Rob Burbank on Nov 11, 2010 1:04 PM

    PDF forms also known as Adobe From or Interactive Forms.
    Check this link -
    Interactive Forms
    REG:ADOBE FORM
    Adobe forms
    Regards,
    Amit

  • CREATE INDEX WITH DUPLICATE COLUMN NAME

    Hi,
    i need to interface our application with an Orale Bridge to CREATE INDEX with duplcate column Name.
    For Example
    CREATE index NLOT_FOURNLOT_idx ON NLOT(FOURNISSEUR ,NOLOT ,FOURNISSEUR ,NOBLFOUNISSEUR,NOLIGNEBL ,NOLOT ,QTECOLISRECUES ,CODENONQUALITE ,QTECOLISACCEPTE);
    CREATE table NLOT(
    FOURNISSEUR VARCHAR2(09)
    ,NOBLFOURNISSEUR VARCHAR2(13)
    ,NOLIGNEBL VARCHAR2(03)
    ,NOLOT VARCHAR2(20)
    ,QTECOLISRECUES VARCHAR2(10)
    ,CODENONQUALITE VARCHAR2(02)
    ,QTECOLISACCEPTE VARCHAR2(10)
    ,NOMBREDECOLISRE VARCHAR2(10)
    ,NOMBREDECOLISAC VARCHAR2(10)
    ,FILLER VARCHAR2(1)
    ,FILLE1 VARCHAR2(1)
    ,TYPEREFERENCE VARCHAR2(01)
    ,REFERENC1 VARCHAR2(15)
    ,CONTROLERECEPTI VARCHAR2(01)
    ,DATEDEPEREMPTIO VARCHAR2(8)
    ,CONTROLEPROCHAI VARCHAR2(1)
    Thanks
    Philippe

    Well, you can't do it. ORA-957 is one of those irrevocable errors for which the solution is to remove the duplicate name from the SQL statement.
    But, anyway, why do you want to do this? I would guess there's no performance benefit from having the same column indexed twice (of course it's impossible to test this, so it's just my opinion).
    Cheers, APC

  • How to create folder with sub folder ?

    How to create folder with sub folder ?

    Hi,
    Questions. 17 / 17 unresolved -> very bad reputation
    but ok - let's help anyway ...
    1. create everything in Screen Painter
    2. set FromPane and ToPane property correct.
    example:
    Items in MainFolder: FromPane & ToPane: 1 to 3
    Items in SubFolderA (From 2 To 2) - SubFolderB (From 3 To 3)
    shouldn't be that difficult
    in your Code set oForm.PaneLevel when the user clicks on the Folder
    lg David

  • How to create file with APDU

    Hello everybody,
    It's my first time using Java Card ^_^,I want to create a file and fill the fill with binary data.but i don't know how to create file with APDU commands,so I need help here.
    I think that there must be a Manual of the JavaCard's OS in this world,can someone tell me where to download it??
    Thanks.
    the fllowing is my card:
    Samsung S1
    Model:TiEx-32J
    EEPROM size:32k
    Platform Version:OP 2.0.1
    Card Manager Status:OP_READY
    KMC:40~4F/No derivation
    Message was edited by:
    AllenHuang

    If you look around the forum for a bit, you will see that there is no notion of file systems on JavaCards (lexdabear posted this information less than two hours ago :-)). To store files, you will have to write an applet to hold byte arrays of the required size and handle receiving and sending of these.
    As for documentation, you should have a look at the GP (General Platform) specification at http://www.globalplatform.org/, which defines communication between smart cards and other devices, as well as Sun's own JavaCard pages (http://java.sun.com/products/javacard/), which contain several useful resources on JavaCards.
    Message was edited by:
    Lillesand

  • How to create Vector with reference to Collection

    hello experts,
    can someone let me know how to create vector with reference to Collection interface.
    Collection is an interface. and we cant create an instance of it. i'm not clear of what to pass in that constructor.
    Vector v = new Vector (Collection c);
    what are the possible objects of 'c'
    post some example code please.
    thanks

    Ever heard of reading the javadocs?
    "Collection is an interface. and we cant create an instance of it." - you don't understand interfaces, then.
    // I certainly can create a Collection - here's one
    Collection c = new ArrayList();
    // Now I'll add some Strings to my Collection.
    c.add("foo");
    c.add("bar");
    c.add("baz");
    // Now I'll make a Vector out of it.
    Vector v = new Vector(c);%

Maybe you are looking for

  • Split Amount, Account 552970 in company code 7175 is not a one-time account

    Dear Experts, Extremely urgent. I'm working on the 4.6c release. I've activated the split amount in the MIRO transaction, but I'm getting the following error: "Account xxxxxx in company code xxxx is not a one-time account". It's a normal vendor not a

  • Lenovo T60p no longer boots

    Greetings, Well, now that I have repaired the fan problem, I am afraid I have created one. My T60p originally had a drive with two partitions on it. A 90GB primary partition, and a 5GB secondary partition. Since I had to re-install the OS, the 5GB pa

  • ABAP WEBDYNPRO - What is it all about ?

    Hi Guys & Gals, I am doing ABAP for last 5 years. Planning to learn ABAP WEBDYNPRO from any SAP education partner. But i don't know JAVA and Classes and Methods(Scared of these). 1. Can i cope with ABAP WEBDYNPRO ? 2. Is it more programming or layout

  • 2006 Intel iMac with new Mac Mini?

    I have a 2006 Intel iMac (MA200X/A) running Snow Leopard. It's finally gotten to the stage that it's running too slow to work on, so I was looking at the Mac Minis. Is it possible to use my iMac as a display for the Mac Mini? The iMac only has mini-D

  • Reports for Changes to VMM

    Hi, Could you help to advise is there any other reports in SAP that we can download for Changes done to Vendors information? Currently we are using S_ALR_87012089 to download the report and we would like to explore other reports (if any) that are muc