A different way to create a new object?

Hi all!
I have an array of type Object were I'm inserting different data types (String,Integer and so on..) now I want to go over this array and I want to create
a new object that is not(!) a clone of the object in a given position but is the same type (the downcasted type)
I want to implement it in a single command but not in series of if (.. instance of ..)
The new value should be inserted into an array of Object too so I assume it will implicitly downcast it automatically.
how can I do that? I hope you understand the problem..
thanks
omer
Edited by: omerkap on Dec 29, 2009 8:27 AM

omerkap wrote:
what do you want?!To engage in a reasonable discussion. How about you?
I came here to ask a very specific question about a way to implement something.Many folks do. And they often ask how to implement their solution in a way that is impractical or inefficient. Sometimes, they attempt to incorporate better ideas when given suggestions for better implementations. Sometimes, they just throw miniature temper tantrums.
You purposed another way? ok, thanks, but I need to know how to do it in the original way I asked.Well, no. You said what you wanted to do. Now that it's a need, my advice is different.
I proposed an idea for a simple solution to accomplish the general requirements you originally mentioned. If you have design restrictions that mandate you write code in a certain way or to fulfill a particular design, then you should comply with those restrictions. Personally, I like to guide folks toward a useful design. If you don't want to be guided that way, that's certainly your prerogative.
As it stands now, it sounds like you have an assignment. And I suspect that assignment isn't intended to test your ability to copy a solution someone gave you on an internet forum. It sounds like the assignment requires the use of a lengthy if chain. I recommend you comply with your requirements.
As an aside, you could use a Map<String, InstructionBuilder>(), but you'd be getting into some serious class bloat for what I presume is a relatively small, simple app. You could also probably hack up something with reflection, but that's probably out-of-bounds with your requirements as well.
You don't want to answer? Don't know where you got that idea. I post here only when I want to.
~

Similar Messages

  • URGENT Different ways of creating portals (Daniel & subbu Have a look and answer)

    Hi all,
         My primary aim is to run an existing application in a portal server.
    My application is running in weblogic6.1. I need to provide a link to that application
    from a portlet.
    I was going thro' the newsgroups and I found out the following responses for my
    requirement,
    I am not clear with these answers.
    1) I need to know what is an IFRAME and some more steps to execute the answer
    given by
    Daniel selman.
    2) Can I convert an URL into portlet?
         This URL content should be shown as it, without has to write any code from the
    side of developer.
    Plz give me some detailed steps to execute this.
    If you guyz can give me some good reference document probably a cook book sort
    of thing, then I will feel more comfortable.
    Thanx in advance,
    Prasanna
    Different ways of creating portlets
    Answered By Daniel selman.
    You can also use an IFRAME inside a Portlet to "include" an external URL within
    a Portlet page.
    I have attached an example of doing this (content.jsp for the portlet uses an
    IFRAME to include www.google.com).
    Can I convert an URL into portlet?
    Answered By Subbu Allamaraju <subbuATBeaDOTCom>
    This URL content should be shown as it, without has to write any code from the
    side of developer. The example provided in portal installation needs demonstrates
    this feature to some extent. But the developer is supposed to extract HTML content
    he/she wants to see and put it in the JSP.
    If the URL is pointing to a page in the same web app, it is straight forward
    to make it a portlet.
    I have few JSPs running in a machine that is remote to the portal node, and which
    is accessible through a proxy from portal. Can I convert these applications into
    portlets?
    Answered By Subbu Allamaraju <subbuATBeaDOTCom>
    The easiest approach is make those remote apps available as web services. Please
    look at the portal wizard that can create portlets to talk to web services. The
    same wizard will also help convering remote
    URLs to portlets.
    I have a full fledged webapplication running on weblogic server. But for some
    additional features (commercial services) I need to used portal server. How do
    i modify the existing site for the desired
    change?
    Answered By Subbu Allamaraju <subbuATBeaDOTCom>
    This will involve some amount of redesign since you're converint a regular web
    site into a portal (the domain/portal wizards will help you do this). You'll then
    need to create a new portal app, and convert those web apps into portlets, and
    add these portlets to the new portal app.

    Prasanna,
    It is impossible to answer this question is a general way, it all depends on
    what the other web application is doing. If it is just returning static HTML
    then a home-grown solution (scrape taglib / IFRAME) and some URL rewriting
    will suffice. If the remote application requires authentication, uses SSL,
    cookies, Javascript, displays pop-ups etc. then things can get complicated
    extremely quickly. At that point you probably need to use a 3rd-party web
    scraping engine (Kapow for example. Peter Laird posted a list of many
    others.)
    There are network throughput, single sign-on, and performance issues to
    consider. Obviously the most performant solution entails converting your
    exisitng WLS application into a Portal application, by refactoring its JSPs,
    deploying its EJBs etc. Alternatively making remote calls into your business
    objects (EJBs) or deploying WebServices to extract the DATA from the remote
    application independent of the presentation may be an option for well
    architected applications.
    So, sorry, I'm afraid it is very hard to generalize these things into much
    more than a list of issues that you should consider as you work through the
    possible solutions.
    FYI: IFRAME is supported by IE 5+ and Netscape 6.x:
    http://www.webreview.com/browsers/browser_implementation.shtml
    Sincerely,
    Daniel Selman
    "Prasanna" <[email protected]> wrote in message
    news:[email protected]...
    >
    Hi all,
    My primary aim is to run an existing application in a portal server.
    My application is running in weblogic6.1. I need to provide a link tothat application
    from a portlet.
    I was going thro' the newsgroups and I found out the following responsesfor my
    requirement,
    I am not clear with these answers.
    1) I need to know what is an IFRAME and some more steps to execute theanswer
    given by
    Daniel selman.
    2) Can I convert an URL into portlet?
    This URL content should be shown as it, without has to write any code fromthe
    side of developer.
    Plz give me some detailed steps to execute this.
    If you guyz can give me some good reference document probably a cook booksort
    of thing, then I will feel more comfortable.
    Thanx in advance,
    Prasanna
    Different ways of creating portlets
    Answered By Daniel selman.
    You can also use an IFRAME inside a Portlet to "include" an external URLwithin
    a Portlet page.
    I have attached an example of doing this (content.jsp for the portlet usesan
    IFRAME to include www.google.com).
    Can I convert an URL into portlet?
    Answered By Subbu Allamaraju <subbuATBeaDOTCom>
    This URL content should be shown as it, without has to write any code fromthe
    side of developer. The example provided in portal installation needsdemonstrates
    this feature to some extent. But the developer is supposed to extract HTMLcontent
    he/she wants to see and put it in the JSP.
    If the URL is pointing to a page in the same web app, it isstraight forward
    to make it a portlet.
    I have few JSPs running in a machine that is remote to the portal node,and which
    is accessible through a proxy from portal. Can I convert theseapplications into
    portlets?
    Answered By Subbu Allamaraju <subbuATBeaDOTCom>
    The easiest approach is make those remote apps available as web services.Please
    look at the portal wizard that can create portlets to talk to webservices. The
    same wizard will also help converingremote
    URLs to portlets.
    I have a full fledged webapplication running on weblogic server. But forsome
    additional features (commercial services) I need to used portal server.How do
    i modify the existing site for thedesired
    change?
    Answered By Subbu Allamaraju <subbuATBeaDOTCom>
    This will involve some amount of redesign since you're converint a regularweb
    site into a portal (the domain/portal wizards will help you do this).You'll then
    need to create a new portal app, and convert those web apps into portlets,and
    add these portlets to the new portal app.

  • Which is the best way to create a connection object

    hi,
    Eventhough i am not new to java I just wanted to know that which is the best way for creating sql connection object.
    Is it using the DriverManager.getConnection(..,..,..) or using a datasource and getting the connection.
    Which is more efficient or Is there any other way to create sql connection which is even more better.
    thanks in advance.
    pradeepbhargav

    AFAIK all connections, DataSource ones included are created by calling the DriverManager. A DataSource is a factory for Connection objects (from JavaDocs)
    If you're talking about managing connections then it depends on the application. A DataSource is great for apps that can support many clients or are multi-threaded, but may require a JNDI implementation to get to it.
    If however you have an single threaded app that hits the database in a serial fashion, then DataSource is probably an overkill.
    Dave

  • Difference between "clone" and creating a new object

    Hi experts,
    What on earth is the difference between:
    1)creating a new object by using the "clone()" method and
    2) just creating a new object?
    Let me be a bit more specific:
    if there's a class called "Book" and suppose we've already created an object called "japaneseBook", any difference between "Book spanishBook = new Book();" and "Book spanishbook = japaneseBook.clone()"?
    Thank you.
    Eileen

    The purpose is very obvious. At anytime in the running application, when Objects have been changed, and you desire to make another one of the same kind, you can't use new. You would use clone. The newer Object would have the same values in the variables. Now i got a question.. an important issue.
    public class XYZ{   
      public static int t = 10;
    } // default constructor is present by default.
                     //In another portion i have the following..
    private XYZ x = new XYZ( );  // private Object!!
         // Now what about this one????
    public XYZ x1 = x.clone( );  // public !!, well
    What impact of this code can be there to break the rules of good OOP design??? Is it that a clone Object would have the same access of itself (not of its variables) or different one?????????

  • Is there a way to create a new Calendar that replicates all events

    Is there a way to create a new Calendar that replicates all events from a subscribed calendar ? Mobile Me is great but my most important Calendar is technically in the "Subscriptions" category so it doesn't get pushed to me iPhone. I want to create a new Calendar and have it just automatically copy all the events from the subscribed calendar and keep up to date with that one.

    lincolnroadjeff,
    I subscribed to a Holiday calendar that I also wanted to be published, and the only workaround that I found was to export the calendar, delete the subscription, and then import the calendar.
    This obviously will only work with a subscription that is not often updated/subject to change.
    ;~)

  • Is there a way to create a new directory or file in application install directory programatically

    Hi to all,
    Is there a way to create a new directory or file in
    application install directory programatically.
    I want a xml file to be created with in the application
    install directory programatically(not the application storage
    directory)
    I have used the following code snippet:
    var file:File = new File();
    file = File.applicationDirectory;
    file = file.resolvePath("assets");
    if(!file.exists)
    file.createDirectory()
    I am thrown an exception when using this .....Security
    Exception

    Thanks, but my main problem is to delete the locally stored
    data that is stored in the application storage directory when the
    application is uninstalled.
    The data is not being deleted automatically when the
    application is uninstalled, thats why I want to write some file to
    application directory.
    My application is remembering the login username and password
    even I uninstall the application and reinstall the next
    time.

  • Is there a way to create a new folder in the Save As dialog box?

    I could do this on my PC in Windows - I find it hard to believe there isn't a way to create a new folder when I'm saving a document?  Perhaps I'm missing something...

    Cool. BTW because you are recent switcher from the Windows world you may find these URL's useful.
    Mac 101
    Switch 101
    Find Out How Video tutorials
    List of Useful URLs for switchers

  • It will not parse! Creating a new object in the universe

    Hi, we have a universe and BO reports. They work fine for our clients. We are on BO XI r3.1. Now, one client captures an additional piece of info. They would like to report against this and add it high up on our drilling heirarchy. "Sure, no problem". For the following I was logged in as administrator.
    The additional data field is a 3 character code.
    1) We added an additional column to the actual database table.
    2) In Universe Designer, I refreshed universe structure and could see the additional column
    3) Created an object 'Acode' that refers to db.new_field
    4) Exported universe
    Maybe worth mentioning that I can see this object and use it in reports fine in Infoview.
    Now, I need to create a new object that will be one of 2 strings based on the 3 character code (Acode) i.e. the 'Atype' can be X or Y.
    Here's my code and it just will not parse:
    CASE
    WHEN @Select(AFolder\Acode) = 'CEL'
    THEN 'X'
    ELSE u2018Yu2019
    END
    Error I get is:
    Parse failed:Eception:DBD ODBC SQL Server driverStatement could not be prepared.State 42000
    I'd appreciate any help, believe me I have searched the forums!
    Thanks, Eddie

    Look at following SAP NOtes.
    1373739
    1184304
    Regards,
    Bashir Awan

  • How to create a new object for a particular class?

    Hi,
      Can anybody please tell  the steps for creating a new object for a particular class.
    Thanks,
    Sreeja

    Declare the object as TYPE REF TO the class and use the CREATE OBJECT statement to create an object.
    DATA <obj_name> TYPE REF TO <class_name>.
    CREATE OBJECT <obj_name>.
    Please mark points if the solution was useful.
    Regards,
    Manoj

  • Different ways in Creating BP

    Hi,
      Can somebody brief me the different ways for Creating BP in cProjects?
    If i create a BP in SAP R/3 which BP role do i need to use for creating an external resource as Business Partner?
    With path for creation will be appriciated
    Rgds
    Sudhir Reddy

    Hi,
    We had this scenario where we had a separate ERP system and a standalone CRPXRPM system. The replication was done via ALE.
    The report RHALEINI (T-Code - PFAL) was used to move the HR Master data to the cProjects sytem.
    The BPs are created with 'Employee' role. Not very sure, but I think its BUP0003. However, you need to maintain these BPs in the 'Resource' role if you want to maintain their cost/revenue rates.
    We used the field 'BP Type' to differentiate external employees.
    Let me know if you found this helpful.
    Regards,
    Vivek

  • Organizational structure : create a new object type

    Hi all,
    i need to create a new object type in Organizational Management, anyone have documentation, link or some helps to this subject.
    Thanks,
    Cheers

    Small correction
    Personnel ManagementOrganizational Management-Basic settings-Data Model Enhancement--Maintain Object Types
    T-code OOOT
    Edited by: Sikindar on Jul 30, 2008 3:57 PM

  • How to create a new object subtype?

    Hi Experts ,
    I have created a z component in my crm 2007 .
    And now I want to change my configuration of display based on some condition .
    Kindly guide me how can I create a new object subtype so that i would be able to change the configuration .
    Thanks in advance,
    Sergey Kozyrev

    hi
    tx spro
    Navigate to
    SAP Implementation Guide
    Customer Relationship Management
    UI Framework
    UI Framework Definition
    and execute "Define UI Object Types".
    Best regards
    Pankaj Kumar

  • Different ways to create an object

    Hi All,
    I am a new bie to java programming. I know the way to create an object for a class will be something like
    A b = new A(); // A is the class name and b is the object name.
    But i am not sure what the following code means, I know it is also creating an object but how and why in that manner.
    CaptureSearchForm userBean = (CaptureSearchForm) form;
    A b = (A) c;
    If b is the object name, then what is c here?Can anyone please explain me in detail.
    Also,
    java.util.List pageList = new ArrayList();
    Why should we give in the above manner? what does it mean?
    Thanks in advance....,,,,

    auto wrote:
    But i am not sure what the following code means, I know it is also creating an object but how and why in that manner.
    CaptureSearchForm userBean = (CaptureSearchForm) form;This does not create an object. It takes the value in the reference variable foram and copies it into the refernce variable userBean, so that userBean and form both point to the same object. The (CaptureSearchForm) is called a cast. It tells the compiler that even though form may not be declared to be of type CaptureSearchForm or a subclass, you the programmer know that the object it points to will be a CaptureSearchForm or a subclass, and to treat it as such. If at runtime this is not the case, you'll get a ClassCastException.
    A b = (A) c;
    If b is the object name, then what is c here?Can anyone please explain me in detail. b is not the object name. Objects do not have names. b and c are both variable names.
    Also,
    java.util.List pageList = new ArrayList();
    Why should we give in the above manner? what does it mean?It's known as programming to the interface. On the LHS, you're saying that pageList must point to an object that implements List. You don't cae if it's an ArrayList or LinkedList or something else. It's a way to decouple your code from the specific implementations of the types it uses.

  • Error when trying to create a new object that begins with Z

    Hi forum,
    When I try to create a new BW object that begins with Z (infofuente, infoarea, component application), I skip the following error.
    Namespace''is not a valid namespace BI
    Message no. R7017
    Diagnosis
    Namespace''must be entered in both the BI RSNSPACE table and the basic table TRSNSPACE or the view V_TRNSPACE. You also have to enter the relevant generation namespace '& V2' in TRNSPACE table. This value is taken from table RSNSPACE.
    Both namespaces must be set to 'Changeable' - providing they are not empty.
    Response System
    You can not edit or create an object in this namespace.
    Procedure
    Use a different name.
    Or contacct your system administrator. He / she can switch to the namespaces' Changeable 'using SE06 transaction, or - if they do not already exist - enter them in the table above named using sm30 transaction.
    If the namespace '& V1' is empty, then the problem is with the generation namespace '/ BIC /'.
    Procedure for System Administration
    I've been following steps said to me, and yet I still persisted error. I am probably missing something ... that may be?
    A greeting,

    Hi,
    Try to create the objects again and take the screenshot of SU53 when you get the error and see the authorization object for which you are getting the error here.
    It is possible that you dont have development authorization.
    Also the issue could be that the system is not configured to create the objects begining with Z.
    Check this with basis as well.
    Thanks
    Ajeet

  • Create a new object that surrounds the selected objects

    Is there anyway in illustrator to create a new vector object from selected objects?
    IE if i have three rectangles selected, can I make a new vector path that surrounds them all.
    I dont mean welding a group of vectors together or offsetting a path...which isnt exactly what i need.
    What Im needing to do is create cut lines around complex vector art quickly.
    Thanks in advance.

    Mike i need to make an outline around a logo but if the logo has many elements that make up the edge of the logo does that method work?
    As the cut line needs to be a closed path
    Ideally i want to avoid tracing around the logo with the pen tool or add to shape area in pathfinder tab.
    I sure theres a really easy way to do this.
    Kurt its an interesting discussion however in need a closed path to surrond artwork and live paint does just the opposite :)

Maybe you are looking for