Doing without Generics - ideas??

HI everyone,
I (unfortunately) can not use Generics in the current project I'm working on but am facing a problem that I feel would be best solved by Generics. In fact, the existing C++ versions works a charm using the parameterized approach.
Problem: C++ Objects are created from XML specifications of classes. Want to now create from these specs, Java objects.
small example,
<class name="Foo">
<field name="SomeVar">
<type = "list">
<list-subtype type="string">
</list>
</field>
</class>
This would create Foo.{cpp,h} with
std::list<std::string> SomeVar;
The other side of the problem is turning the object back into
the XML specification.
I have been thinking about how best to design for this problem, but keep
getting stuck on aspects such as lists of maps. IN c++ you know the element types in the list (or can work it out), but in Java it's a different story.
Should I implement type-safe classes such as StringList, IntegerList
etc.. which restrict access to the LinkedList they each hold? Or should I just rely on reflection and subsequently call (possible) hundreds of different methods. A speed is a major consideration, the fewer calls the better.
I would appreciate any input you have on this point.
Cheers

i dont't fully understand the problem. how would these generated classes be used, by human programmers or by generated code? supposing human programmers, is the contents of collections your only problem? if this is so and you want to guarantee the content type, there's a simple solution. write wrappers for the collection interfaces you use that type-check elements, keys and values on input to the backing collection. make the constructor take the backing collection and the element type(s) (Class object(s)) as arguments, and every time an element, key or value is to be inserted into the collection, validate them using something like:
if (!type.isInstance(obj))
     if (obj == null) throw new NullPointerException();
     else throw new ClassCastException();
or:
if (!type.isInstance(obj) && obj != null) throw new ClassCastException();
if you want to accept nulls. of course, when you get objects from the collection you'll have to cast, but the collection contents will be sort of type-safe.
as i said i dont't fully understand the problem, and don't think this will help much, but if it does, let me give you some pointers. safe wrapper implementations may be a bit trickier than you think, specially the MAP wrapper which involves wrapping several views, iterators and MAP.ENTRYs, and has to witstand subtle attacks like evil equals() implementations. use the source code for the Collections.unmodifiableXxx() wrappers as a starting point. these wrappers stop all mods, so you'll just have to put the tests in and you are done. then you can generate code like:
List someVar = TypedCollections.typedList(String.class, new ArrayList());
alternatively you may use factories. using factories, if you later find that typed LinkedLists are used a lot and the wrapping impacts performance, you could optimize by making the factory return a specilized typed implementation for that case (based on/extending LinkedList), but i really don't think it would be worth the effort.
you may later need type info from the collection, so maybe you want say interface TypedCollection (extending Collection) and TypedMap (extending Map) implemented by these wrappers. the interfaces have getters to return element, key or value type info. but note that if you use other wappers (like unmodifiable) you'll lose the chance to query this info (unless you extend those wrappers yourself, of course).
i hope some of this stuff helps, but it probably won't. so what? cheers!!

Similar Messages

  • My macbook pro keeps crashing and emitting a beeping noise when it does.  Any ideas why?

    my macbook pro keeps crashing and emitting a beeping noise when it does.  Any ideas why?

    3 beeps = no good banks. You will have to go to the Apple Store for immediate service. If you would rather do it yourself, go to https://selfsolve.apple.com/GetWarranty.do. If you want Apple's help (without having to go to the Apple store), go to https://expresslane.apple.com/GetproductgroupList.do?PRKEYS=SG1.

  • Every device (iphone4, iphone4s, ipad2) I try to hook up to iTunes gives me a message "this device cannot connect because the apple mobile device service is not setup" does anyone have ideas as to why it keeps popping up? It just started doing this.

    Every device (iphone4, iphone4s, ipad2) I try to hook up to iTunes gives me a message "this device cannot connect because the apple mobile device service is not setup" does anyone have ideas as to why it keeps popping up? It just started doing this.

    I'd start with the following document with that one:
    iPhone, iPad, iPod touch: How to restart the Apple Mobile Device Service (AMDS) on Windows

  • ADF basic application without any IDE

    Hi,
    I want to create a very simple page using ADF but without JDeveloper or any other IDE (not even eclipse).
    Later i want to deploy the same to tomcat server. As we can do using servlets or JSF.
    Is it possible to create all directory structures and files manually using simple notepad and then run that ADF application from tomcat server?
    --Sushant                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Hi,
    For clarification on what exactly happens behind the scene while using JDeveloper, i just want to create a simple search page but without any IDE.
    Simply by creating folder structures and files manually and later deploy the same on my local tomcat server.
    I did that while learning JSF as well: http://java2apps2fusion.in/creating-first-jsf-application-without-using-any-ide/
    This is exactly what i want but in ADF.
    --Sushant                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Does anyone have idea on subscreens in IW21 transaction ?

    Does anyone have idea on subscreens in IW21 transaction ?
    When I go through the available user-extis for IW21 I can see QQMA0008,
    QQMA0010, QQMA0011 and QQMA0012 as the user exit for notification item, cause, task and activity respectively.
    My requirement is to assign user specific data ( pre-structure in Z-table) to these catalog codes instead of selecting directly in iw21(by using F4). Do you think the above mentioned user-exits will help me out in this case?
    Can you please brief idea on how to work on these subscreen user exits ?
    Grateful to your help.
    responses will be rewarded

    Hi,
    Have you tried Transaction Variants in your scenario?
    Transaction variants simplify transaction flow by:
    Inserting default values in fields
    Changing the ready for input status of fields
    Hiding various screen elements and menu functions, or even entire screens
    Adjusting table control settings
    For more information on this pls refer":
    http://help.sap.com/saphelp_nw04/helpdata/en/bf/ec07845db911d295ae0000e82de14a/frameset.htm
    Regards,
    Renjith Michael.

  • Compile .fla files without Flash IDE

    i need to know whether this can be possible or not....
    My aim is to compile bulk FLA's (say 50). can we compile .FLA's without using Flash IDE using command Line?
    If so how it can be done. please provide with an example.
    I have used JSFL concept for publishing bulk FLA's. But it will work using Flash IDE. This is not what i need.
    I need to compile or publish the FLA's using CommandLine or Batch Files.
    Please reply to the post ASAP

    I've been looking fro the same answer for quite some time, I do not think compiling without the IDE is possible ( if you absolutely need the assets from your flas, that is), I have since changed my workflow to accomodate foe this shortcoming.

  • I reset my iPhone 3gs to factory. Now it stuck in iOs 4.2. I try to upgrade but it does not, any idea?

    I reset my iPhone 3gs to factory. Now it stuck in iOs 4.2. I try to upgrade but it does not, any idea?

    I am not sure but it may be 3G. How to find out? Actually I wanted to download watsapp and when I tried I got message "It requires iOs ver 4.3 or above." And together I get box asking to upgarde, but it does not.

  • When I plug my ipod into my mac it does nothing. any ideas?

    when I plug my ipod into my mac it does nothing. any ideas?

    Try a different USB port on your computer. If your using a PC, the port on a keyboard is not strong enough; plug it into a USB port on the computer tower. 
    Be sure to wait awhile; mine sometimes takes a couple minutes to connect.
    Another tip would be to open i-tunes before plugging ipod in.
    If it still doesn't work, try resetting your ipod by turning the hold button on and off, then pressing and holding the center and menu buttons until the Apple logo shows up. When ipod returns to main screen, plug it into the computer again.
    If nothing works, you may have a bad connection cord.

  • Help in making this GUI without using IDE (snapshot attached)

    [Layout image| [https://rapidshare.com/files/2954811682/layout.JPG]]
    hi, i am new java swing library and i want to create a layout just like a image posted above without using IDE.
    i need some idea/help regarding two issues which i m facing at the moment one how to set the size of the button and how im suppose to set the alignment of labels,textboxes and buttons according to the image here is the source code below :
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.FlowLayout;
    import java.awt.Font;
    import java.awt.GridLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JButton;
    import javax.swing.JCheckBox;
    import javax.swing.JComboBox;
    import javax.swing.JFileChooser;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JPasswordField;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    import javax.swing.JTextField;
    import javax.swing.border.TitledBorder;
    public class Form extends JFrame {
    private JLabel lblUserName;
    private JLabel lblNewPassword;
    private JTextField txtUserName;
    private JPasswordField txtNewPassword;
    private JButton btnLogin;
    private JButton btnClear;
    private JPanel mainPanel;
    private JPanel centerPanel;
    public Form() {
    // initialize the components
    initComponents();
         // add the components
    addComponents();
         // add the listeners
    //addListeners();
    // display components
    displayComponents();
    private void initComponents() {
    getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER, 10, 10));
    mainPanel = new JPanel(new BorderLayout());
    centerPanel = new JPanel(new GridLayout(3, 4, 20, 5));
    lblUserName = new JLabel("Username : ");
    lblNewPassword = new JLabel("password : ");
    txtUserName = new JTextField(15);
    txtNewPassword = new JPasswordField(15);
    btnLogin = new JButton("Login");
    btnLogin.setPreferredSize(new Dimension(2,2));
    btnClear = new JButton("Clear");
    btnClear.setPreferredSize(new Dimension(2,2));
    private void addComponents() {
    centerPanel.add(lblUserName);
    centerPanel.add(txtUserName);
    centerPanel.add(new JLabel(""));
    centerPanel.add(lblNewPassword);
    centerPanel.add(txtNewPassword);
    centerPanel.add(new JLabel(""));
    centerPanel.add(new JLabel(""));
    centerPanel.add(btnLogin);
    centerPanel.add(btnClear);
    Font titleFont = new Font("San Serif",Font.PLAIN,12);
    Color titleColor = Color.blue;
    mainPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Admin Login",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,titleFont,titleColor));
    mainPanel.add(centerPanel, BorderLayout.CENTER);
    getContentPane().add(mainPanel);
    private void displayComponents() {
    setTitle("Form");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(600, 200);
    setVisible(true);
    public void actionPerformed_BtnUpdate(ActionEvent e) {
    JOptionPane.showMessageDialog(this, "Your profile has been updated successfully.");
    public void actionPerformed_BtnBrowse(ActionEvent e) {
    JFileChooser fileChooser = new JFileChooser();
    fileChooser.showOpenDialog(this);
    public static void main(String[] args) {
    try {
    Form myForm = new Form();
         catch (Exception exception) {
    System.err.println("ERROR - " + exception.getMessage());
    Edited by: 932179 on May 4, 2012 1:30 PM
    Edited by: 932179 on May 4, 2012 1:30 PM

    Welcome to the forum.
    Take the list of +"All Known Implementing Classes"+ from here http://docs.oracle.com/javase/7/docs/api/java/awt/LayoutManager.html and find out what combination best fits your needs.
    I usually have some nested BorderLayouts and GridLayouts.
    When I need lables and input fields aligned I use GroupLayout (which I personally prefer over GridBagLayout...).
    Anyway, you may have got better answers if you postet this in the right place:
    Swing
    bye
    TPD

  • Array of Maps without generic or warnings?

    How would I create an array of maps without getting an error about a generic type or a warning?
    This will give me an error.
    HashMap<Integer,Integer> test = new HashMap<Integer,Integer>[5];This will give me a warning.
    HashMap<Integer,Integer> test = new HashMap[5];

    Dennis_Martinez wrote:
    Could I see an example? I'm a little lost on doing so.I suspect you know how to use lists and ask for an example demonstrating the inherent unsafety. So here it is:
    List<String>[] generic = new List<String>[1]; // assume this works
    List<Integer> ints = new ArrayList<Integer>();
    ints.add(42);
    Object[] o = generic;
    o[0] = ints; // this should not work, but it does (erasure)
    List<String> strings = generic[0]; // really it's a list of Integers, ohoh
    // now you pass that list somewhere completely unrelated and try to get an element:
    String s = strings.get(0); // ClassCastExceptionCompare this to:
    String[] strings = new String[1];
    Object[] objects = strings;
    objects[0] = 42; // ArrayStoreExceptionWith kind regards
    Ben

  • TS1741 I have done everything in the Apple help artcle but my iphone 4S remote app doesn't connect to itunes, but my iPad does. Any ideas?

    Hi
    My Remote app has stopped working on my iphone, I kep getting nthe message to turn on homesharing.  However homesharing is on, and it works on my iPad Any ideas, all software versions are up to date, although I haven't yet updated the iPad.  Hmmmm

    I have the same thing. I couldn't get either the iPhone 4 or the iPad 2 to connect until I did a full restart of my wireless router. After doing this, the iPad connected automatically but the iPhone won't. Can't think what else to try. They are both on the same wireless network. Same apple ids being used. Nothing jailbroken, all software is up to date.

  • How do I set up SATA HD without any IDE HD?

    Hi.
    I'm a newbie in the process of building a new computer.
    It's been fun -putting together components physically- but...
    ...I'm stuck here ---> My plan is to use just one HD for now -Raptor 36.7gb- along with a 3.5" floppy diskette drive and a DVD Recorder.
    The 3.5" drive is connected.
    My Raptor HD is connected to "SATA1" on the board.
    But I'm a little puzzled when trying to figure the IDE cable placement for my DVD Recorder- Do I connect it to "PRI IDE" or "SEC IDE"?
    And does it matter that I will not have an IDE HD installed?
    (And I'm guessing the IDE LED on my case will never be lit?)
    I thank you in advance for any help.

    Don't worry about the lack of DOS prompt - XP doesn't use DOS at all!    That's why you boot straight from CD; in the old days you'd have to boot to DOS from a floppy to load CD drivers, and only then could you start Wndows setup from CD.
    You don't need to press F6 to load drivers, the SATA controller should just work, and you can load all the chipset drivers, etc, that you need from the motherboard CD or whatever once XP's in.    XP has a lot of drivers in it anyhow, I think that's partly why the install's four times bigger than 98!
    Why is the setup not working?   Is is not recognising the hard drive?   It should say something like "Checking drive XXXX on XXX", and it'll say how big the drive is and that, and a yellow bar goes across!
    I've got my Seagate SATA HDD on the same controller as you (SATA 1), and XP Pro saw it no problem.
    If Setup just isn't seeing the HDD, you may want to check in the BIOS and make sure the SATA controller is enabled:
    - under "Integrated Peripherals", select the "On-Chip IDE configuration" menu
    (... er .... hang on, got to reboot my machine to check - I'll get back and edit this! ....)
    Okay, back now, where was!?   Ah, yes.   Basically there's a number of configurations of this, and it also depends which BIOS version you've got.   With XP you can use either Legacy or Native mode - Native uses extra interrupts which older OS's can't handle, so as I'm running 98 as well, I use Legacy.   I'll give you my settings, using BIOS 1.7:
    Mode - Legacy
    Configuration - P-ATA+S-ATA
    P-ATA keep enabled - Yes
    Combined modde option - S-ATA 1st channel
    Configure S-ATA as RAID - No
    I've got a feeling this disables one of the normal IDE channels though ... anyway persevere with various combinations until both the DVD drive and the HDD appear on the "Standard CMOS Setup page of the BIOS.
    Try searching the forum for older posts on this - this has been a hot topic of discussion, there are many posts describing the various combinations!
    Then, it'll also be worth checking "Boot device select" under "Advanced BIOS features", and make sure the HDD is set as a boot device in there.    Once you've got past the initial Setup stages, you can remove the CD from the boot list again.
    Let us know how it goes, don't hesitate to keep asking questions!

  • HBO GO suddenly freezing on sign-in with Comcast/Xfinity. Other browsers installed will work, but after a system update Firefox no longer does. Any ideas?

    After a routine Windows 7 update, Firefox will not load the HBO GO content when you attempt to sign in. Normally, I do not have to sign in unless I log into the account via my Droid or other PC. I tried it in Google Chrome and works fine on my Droid. Also, now when going to full screen option, Flash opens a new window and have lost the options to control the display ratio and toolbars. Any ideas?

    It sounds like we've got a number of *different* problems on this thread.  I'll try and respond to a few of them.
    @filter 2.5 and everyone else running into a green screen issue.  Please try the solution outlined in the post below to see if it will allow you to use hardware acceleration.  The other alternative is to try a different ATI driver.
    http://forums.adobe.com/message/4865912#4865912#4865912#4865912
    @pipseer - Somehow Internet Explorer's activex filtering was enabled on your system.  This troubleshooting is also described in this FAQ: ActiveX Filtering in Internet Explorer
    @Sahloknir - For the sound issue, we're going to want your system specs.  Please start a new thread with:
    Operating   system  
    Browser  
    Flash   Player version
    Dxdiag Report Instructions
    Sometimes video and audio problems are caused at a lower level and not directly related to Flash Player.  I recommend trying both of the links below to see how they perform.  If the problem exists with both, then Flash Player is most likely not the culprit as the HTML5 video link does not use Flash Player when playing.  You can verify the use of HTML5 by right clicking the HTML5 video and looking for the words "About HTML5" at the bottom of the context menu.
    HTML5   video  
    Non-HTML5 video
    @mem2013 - The Flash Player update service will not impact Flash Player's performance.  This is a separate service that runs for just an instant on your system once an hour (if you have automatic updates enabled.)  Changing it from manual to automatic shouldn't make any difference.

  • Is Eloqua actually doing anything with Ideas Exchange?

    I don't want this post to come across as brash, just wanted to spark some discussion.
    I'm a fairly new Eloqua customer, and part of the onboarding included promotion about the new topliners community and the Salesforce.com driven Ideas Exchange.
    I was looking through the ideas that had more than 100 points, and I couldn't find any where a (identified) representative from Eloqua has openly commented.  Additionally, it does not appear that any suggested idea has ever come to fruition.  Is this a misperception?  It seems like there used to be another solution in place before they went to this new platform - what have some of you long time users experienced?
    I've periodically voted, commented, and posted a couple ideas of my own; I'm trying to figure out my expectations and don't want to judge too hastily.
    Thoughts and experieces with feature requests / suggestions?

    They do, as we have received news about their roadmap and some of the ideas in the Exchange are in it (the one I'm thinking about specifically is better security around assets, including Themes--yea!).  As someone who works in the development/solutions side of the business, it gets complicated so I understand that the top rated ideas may not always make it immediately into the next release.
    But on a side note, it is also my understanding that the higher the promotion points are, the more likely it will also end up in front of the product managers to consider. 
    Of course, as anyone in marketing knows , the object is to drive your "customer" to an action... you have to SELL your idea to get it promoted. 
    I've read many ideas out there that I wonder exactly what the person means or wants because it's so vague.  That does not exactly encourage me to promote an idea. (I do semi-regularly surf through them to see if there are any my users that I support would be able to use or need, etc..)  You can't just assume that everyone knows what you're talking about--or what the value add is of that particular idea.
    And even if ELQ product managers do look through all of the ideas, like any developer, they do also need to see the value add as well.
    Just my two cents...

  • Auto things apple does without user permission-use pop-up questions instead

    with ipod classics [and not sure about their other programs] - and having about 65 gigs of info or more on your ipod - auto syncing when plugging into computer is a real pain - had to buy a huge back up drive to store all my music folder stuff - ipod won't open from that drive of course - will only use the c drive - which has no space - so must copy the files from back up drive to c drive if i want to add something new - then if i unclicked open itunes when ipod is plugged into computer - god forbid! - the syncing of my ipod starts without my control - apple needs to stop being like microsoft with the automatic crap computers do - leave the controls in the users hands always - no one wants the computer doing things through apple programs on its own - stop anything automatic on your products - and make changing settings easier for consumer/user - apple programs should have pop-ups ask us what we want to do [or not do] instead!

    had to buy a huge back up drive to store all my music folder stuff - ipod won't open from that drive of course
    ??? iPods don't open from any drive.
    so must copy the files from back up drive to c drive if i want to add something new
    No you don't. You can store everything on the external and use it just fine.
    -> iTunes for Windows: Moving your iTunes Media folder
    apple programs should have pop-ups ask us what we want to do or not do instead!
    Are you sure?

Maybe you are looking for