XmlBean usage and the clone() method.

I'm trying to use the XmlBean class as the superclass for all our business objects and we have an issue with the usage of the clone method.
Basically our business objects all throw the CloneNotSupportedException (as per Object.clone() signature) while XmlBean.clone() does not throw it. Introducing XmlBean into the hierarchy will cause quite a bit of effort to change clone() signatures for a lot of classes. So, we were wondering if there is any alternative to subclassing XmlBean while at the same time using the efficient caching that it gives us. I guess I'm looking for a "composition" approach rathe than an "inheritance" approach that might work.
Has anyone faced this issue and is there any other workaround?
Thanks,
--Das                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

The reason that I asked is that the exception is "old baggage" from a design flaw in the original JDK 1.0 .. it is a checked exception that can never happen on an object that implements Cloneable, so if you don't throw it, and you implement Cloneable, then it won't be thrown on clone().
Peace,
Cameron Purdy
Tangosol, Inc.
Coherence: Shared Memories for J2EE Clusters

Similar Messages

  • When I try to use the clone stamp another layer of my picture is copied on the photo I'm working on.  Is this a defect or is there a tool I can use to stop it and return to normal usage of the clone stamp?

    When I try to use the clone stamp another layer of my picture is copied on the photo I'm working on.  Is this a de@@@@fect or is there a tool I can use to stop it and return to normal usage of the clone stamp?

    The "Sample Field" letters are very dim.  After punching several times the right click revels "Clone stamp mode".  The next little circle has a line through it and after several right clicks, it says: "turn on to ignore adjustment layers when cloning,"  Despite this I cannot get any kind of a response to change any of the existing entries.  Bob
    Robert Mcdonough
    [email protected]

  • When I use the Alt key and the clone tool, I get a message that I did not use the Alt key to define

    Whe I use the Alt key with the clone tool, I get a message that I have to use the Alt key to define the area to be copied. What am I doing wrong?

    I tried to check the alined box, but it would not work. I was able to check
    the Sample box, but they they give you about 5 choices to check and I have
    no  idea what they are all about. I appreciate your help.
    Dino
    In a message dated 9/18/2012 11:09:06 A.M. Eastern Daylight Time, 
    [email protected] writes:
    Re:  When I use the Alt key and the clone tool, I get a message that I did 
    not use the Alt key to define
    created by hatstead (http://forums.adobe.com/people/hatstead)  in 
    Photoshop Elements - View the full  discussion
    (http://forums.adobe.com/message/4707426#4707426)

  • Hey guys, i get the message "Your Apple ID was deaktivated" I have changed my password and the pay method too but nothing happens

    Hey guys, i get the message "Your Apple ID was deaktivated" I have changed my password and the pay method too but nothing happens

    After resetting your password have you tried logging out of your account on your phone by tapping on your id in Settings > iTunes & App Store and then logging back in to see if that 'refreshes' the account on it and if it then works ?
    If that doesn't fix it then you might need to contact iTunes Support : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page

  • Why doesn't reflection reveal the clone() method in arrays?

    I was surprised to discover that the following code does not reveal the method "clone()", even though you can call "clone()" on an Object[]. Can anyone explain why this is? I was hoping to use the Reflect API to clone an arbitrary object if it was Cloneable, and to throw an Exception otherwise. How can I do this?
    import java.lang.reflect.Method;
    public class Test {
         public static void main(String[] args) throws Exception {
              Object x;
              //pick a class
              x = new Object[] {};
              //is it Cloneable?
              System.out.print("The class " + x.getClass().getCanonicalName() + " is ");
              if(!(x instanceof Cloneable)) System.out.print("NOT ");
              System.out.println("Cloneable");
              System.out.println("-------");
              //what methods are available?
              Method[] meths = x.getClass().getMethods();
              for(Method m : meths) {
                   System.out.println(m.getName());
              System.out.println("-------");
    }

    Just to clarify. I know that clone() is protected in Object, but it is certainly a public method in array objects such as int[], float[], Object[] etc. Test: call clone() on any of these objects! Also, I realize that Cloneable does not itself guarantee the method clone(). Nevertheless, if you take a regular Cloneable object, such as a String, then typically, if you ran myObject.getClass().getMethods() on that object, you'd find the method clone() in the resulting list. i.e., that Class has overwritten Object's protected clone() method with a public clone() method. So since int[], float[] and all the rest have a clearly public clone() method, then why doesn't myFloatArray.getClass().getMethods() show me a method called "clone"? I guess it would have to have something to do with the fact that arrays are funny kinds of classes that are not properly handled by the Reflection API, but is it on purpose that clone() isn't available?

  • I dont know what to do!!! I pulled out my headphones and then saw that my sound was not working correctly. I was horrified to find a piece of the headphone never came out. I have heard how much it costs to repair and the other methods are not working.

    Please help, i am so scared that i will never get my laptop back the way it was.

    "the other methods aren't working"
    Well, what other methods have you tried that didn't work?  Frankly, your post reads as a hoax, but I have some extra time on my hands, and an idea.  Make an appointment with the Apple Genius at your local Apple store.  You could also bring your MBP to an AASP.  Regardless, either one should be able to remove the bottom cover, and use a plastic thingy (dang, what is that tool called?) to push out the offending bit.

  • Understanding Comparable and the compareTo( ) method

    I have a Contact object which lists a person's information for a "phone book" program.
    I am trying to sort the Contact objects in a Vector by way of their last name fields.
    I am having a hell of a time trying to use this compareTo( ) method.
    I'm really struggling with understanding how to go about making the method work with a comparison. Most of the examples which I find compare "numbers' and not strings which make it more difficult to understand.
    I have implimented the comparable Interface at the start of my class. To sort my Vector, I'm attempting to use the compareTo( ) method to determine which Last name field has the lower value. I keep going back and forth working through the error messages I receive and I'm just stumped trying to figure out how to get this thing to work. Can someone please point out the mistakes without writing too much code? I don't want someone to do the work for me. Here is the code:
    import java.io.*;
    import java.util.*;
    class PhoneBook implements Comparable{
         private static Vector v = new Vector();
         private static Iterator iter = v.iterator();
         private static int num, index;
         private static Contact firstContact, secondContact, temp;  //"static" to be referenced from main
         public static void main(String arg[])throws Exception {
              Contact c;
              String str;
              BufferedReader br = new BufferedReader(
          new InputStreamReader(
               new FileInputStream(
                                           new File("contacts.txt"))));
              while((str = br.readLine()) != null){
               v.add(c= new Contact(br.readLine()));
               num = v.size();
               for(int i=0; i < num; i++){
          firstContact = (Contact)v.elementAt(i);
               if(v.elementAt(++i) == null)
                    break;
               else
                    secondContact = (Contact)v.elementAt(++i);
               index = compareTo(firstContact);
               if(index == 1){
                       temp = (Contact)v.elementAt(i);
                       v.setElementAt(v.elementAt(++i), i);
                       v.setElementAt(temp, ++i);
              public static int compareTo(Object person){
         int x = ((Contact)person).getLName().compareTo(secondContact.getLName());
         return x;
    }yet still I get the following compiler error:
    PhoneBook.java:4: compareTo(java.lang.Object) in PhoneBook cannot implement compareTo(java.lang.Object) in java.lang.Comparable; compareTo(java.lang.Object) and compareTo(java.lang.Object) are static
    class PhoneBook implements Comparable{
    ^
    1 error

    You are pretty close here except for one incorrect basic assumption. Your compiler error is because you are trying to implement compareTo() with a static method. However, this is irrelevant because it is not the PhoneBook class that should implement Comparable, but the Contact class.
    The idea is that other functions can call the compareTo() method on an instance of Contact and pass a reference to a second instance. Based on the result, the relative sort order of the two objects can be determined.
    e.g.Contact c1 = new Contact("Smith", "John");
    Contact c2 = new Contact("Jones", "Alan");
    int x = c1.compareTo(c2);In your example, you can implement compareTo() to use the corresponding method in String. For compatibility, you should also implement equals().
    public class Contact implements Comparable {
       public int compareTo(Object otherContact) {
           Contact otherC = (Contact) otherContact;  // could throw exception
           return getLName().compareTo(otherC.getLName());
       public boolean equals(Object otherContact) {
           Contact otherC = (Contact) otherContact;  // could throw exception
           return getLName().equals(otherC.getLName());
    } // end of class Contact I haven't compiled or tested the above code nor does it deal with exceptions (e.g. otherContact is not an instance of Contact) - I'll leave that to you! You'll also need to change your PhoneBook sort routine to invoke firstContact.compareTo(secondContact)
    FYI - I understand that this is an academic exercise and so you may need to code the sort yourself, but once Contact implements Comparable, you could sort the Vector using standard Java methods. Check out java.util.Collections - there is a method that will perform your sort in one line of code.
    Good Luck.

  • Re: fortecgi and the POST method

    DAVID A. TRIGO wrote:
    Has anyone successfully used the forte CGI program using the POST
    method from a form? I've had success with PUT, but fortecgi seems to
    have a problem when the HTML form uses POST.
    I'm running Netscape Enterprise Server 3.0 on Solaris 2.5
    thanks,
    David Trigo
    Allmerica FinancialDavid --
    Can you be a little more specific about what you mean by "fortecgi
    seems to have a problem when the HTML form uses POST"? What kind of error
    messages do you get? What do they say?
    For instance, the following code works fine:
    tag code in "somepage.htm" ...
    <form method="POST" action="$$FORTE.ExecURL">
    <input type="hidden" name="ServiceName" value="SomeService">
    <input type="hidden" name="TemplateName" value="next_page.htm">
    <input type="hidden" name="HiddenParam" value="dog">
    <div align="center"><center><p>
    Type some junk here: <input type="text" name="junkTxt"
    size="20">
    </p></center></div>
    <div align="center"><center><p>
    <input type="submit" value="Submit" name="submitBtn">
    <input type="reset" value="Reset" name="resetBtn">
    </p></center></div>
    </form>
    in "next_page.htm" ...
    <?forte execute TestThis ResultSet="StuffRS">
    <table border="1" width="43%">
    <tr>
    <td width="100%"><p align="center"><strong>STUFF</strong></td>
    </tr>
    <tr>
    <td width="100%"><p align="center">$$StuffRS.firstWord</td>
    </tr>
    <tr>
    <td width="100%"><p align="center">$$StuffRS.secondWord</td>
    </tr>
    </table>
    up in Forte World, in your HandleTag method ...
    firstItem:TextData=new;
    secondItem:TextData=new;
    if Tag.Compare('TestThis', ignorecase=TRUE) = 0 then
    firstItem = request.FindNameValue('junkTxt');
    secondItem = request.FindNameValue('HiddenParam');
    rset.Add('firstWord',firstItem);
    rset.Add('secondWord',seconditem);
    The end result should be a table with 2 entries -- whatever you typed in
    the text box and the hidden string "dog"
    Dr. Daniel Marcus
    Sage IT Partners, Inc.
    353 Sacramento St., Suite 1360
    San Francisco, CA 94111
    415.392.7243 x357
    [email protected]

    This works:
    <FORM METHOD="post" ACTION="http://localhost:9704/analytics/saw.dll?" ENCTYPE="application/x-www-form-urlencoded">
    <input type=hidden name=Cmd value=Answers>
    <input type=hidden name=nqUser value=Administrator>
    <input type=hidden name=nqPassword value=Administrator>
    <input type=submit value="Answers">
    </FORM>

  • The new keyword and the newInstance method

    Hi friends
    Can any one tell me the difference between creating an instance of a class by the new keyword and creating an instance of a class by the newInstance method in java.
    Also how do I decide which method to use for a given condition?

    Hi friends
    Can any one tell me the difference between creating an
    instance of a class by the new keyword and creating an
    instance of a class by the newInstance method in java.
    Also how do I decide which method to use for a given
    condition?Hello,
    in the todays java technology newsletter there was a interesting and useful task for the newInstance-method.
    You can compile any class at runtime and start this program with newInstance.
    If you want to develop your own IDE it would be very useful ;)
    import java.awt.*;
       import java.awt.event.*;
       import javax.swing.*;
       import java.io.*;
       import java.lang.reflect.*;
       public class RunIt extends JFrame {
         JPanel contentPane;
         JScrollPane jScrollPane1 = new JScrollPane();
         JTextArea source = new JTextArea();
         JPanel jPanel1 = new JPanel();
         JLabel classNameLabel = new JLabel("Class Name");
         GridLayout gridLayout1 = new GridLayout(2,1);
         JTextField className = new JTextField();
            JButton compile = new JButton("Go");
      Font boldFont = new java.awt.Font("SansSerif", 1, 11);
         public RunIt() {
           super("Editor");
           setDefaultCloseOperation(EXIT_ON_CLOSE);
           contentPane = (JPanel) this.getContentPane();
           this.setSize(400, 300);
           classNameLabel.setFont(boldFont);
           jPanel1.setLayout(gridLayout1);
           compile.setFont(boldFont);
           compile.setForeground(Color.black);
           compile.addActionListener(new ActionListener() {
             public void actionPerformed(ActionEvent e) {
               try {
                 doCompile();
               } catch (Exception ex) {
                 System.err.println(
                       "Error during save/compile: " + ex);
                 ex.printStackTrace();
           contentPane.add(jScrollPane1, BorderLayout.CENTER);
           contentPane.add(jPanel1, BorderLayout.NORTH);
           jPanel1.add(classNameLabel);
           jPanel1.add(className);
           jScrollPane1.getViewport().add(source);
           contentPane.add(compile, BorderLayout.SOUTH);
         public static void main(String[] args) {
           Frame frame = new RunIt();
           // Center screen
           Dimension screenSize =
             Toolkit.getDefaultToolkit().getScreenSize();
           Dimension frameSize = frame.getSize();
           if (frameSize.height > screenSize.height) {
             frameSize.height = screenSize.height;
           if (frameSize.width > screenSize.width) {
             frameSize.width = screenSize.width;
           frame.setLocation(
             (screenSize.width - frameSize.width) / 2,
             (screenSize.height - frameSize.height) / 2);
           frame.show();
         private void doCompile() throws Exception {
           // write source to file
           String sourceFile = className.getText() + ".java";
           FileWriter fw = new FileWriter(sourceFile);
           fw.write(source.getText());
           fw.close();
           // compile it
           int compileReturnCode =
             com.sun.tools.javac.Main.compile(
                 new String[] {sourceFile});
           if (compileReturnCode == 0) {
             // run it
             Object objectParameters[] = {new String[]{}};
             Class classParameters[] =
                         {objectParameters[0].getClass()};
             Class aClass =
                       Class.forName(className.getText());
             Object instance = aClass.newInstance();
             Method theMethod = aClass.getDeclaredMethod(
                                  "main", classParameters);
             theMethod.invoke(instance, objectParameters);
       }regards,
    Tim

  • Time consumption by the stub and the service methods

    There is a performance issue with the web services which is reported recently. The Service method i.e. in my case AccountBalanceService.initFactory is taking 380 milliseconds while the stub method is taking i.e. in my case availableBalanceServiceStub.availableBalance is taking 2 seconds. QA people reported about why it is taking more time while the service method is quick. What might be the cause here? For me, it's seems that it might be the networking issues, marshalling and unmarshalling of the soap files and the JVM settings on the machines.

    Hello Pranali,
    the time spent by a user (which is the difference between login and logout) is <b>not</b> stored anywhere.
    STAD and/or ST03 will not help here as only the time of the login could be determined from the workload statistics. The time of the logout cannot be retrieved from the workload data (as this action doesn't contain any "logout specific" information).
    As a workaround you can use the Security Audit Log (sm19) to protocol the logon and logoff of the users. Based on this information you should be able to calculate the time a user was logged on.
    About the number of transactions:
    the workload analysis only uses dialog steps. As the number how often a transaction was called doesn't contain any useful information this information is <b>not</b> collected.
    E.g. you can call su01 to create 100 user accounts or call ten times su01 to create one user. The workload creating 100 users will be higher than the workload of the remaining ten transactions...
    So the figures 1 transaction vs. 10 transactions doesn't provide any useful information.
    Regards, Michael

  • Scanner and the reset() method

    After reading all the way through a scanner, is there a way to return back to the front/beginning of it?

    No. Note that the reset() method of Scanner doesn't rewind you to the beginning of a file.
    Simply create another Scanner with the same file.
    edit: What is your Scanner's input? I was assuming it was from a File.

  • Where's the clone() method implementation?

    this was all i could get from src.jar..
    protected native Object clone() throws CloneNotSupportedException;
    where is the implementation?
    thank you

    So the implementation is in some library. And you have already seen the (Java) source. The native code is probably written in C or C++; I don't see any source like that in my Windows SDK so you probably don't have it in yours either.

  • CPU Usage and the X-Fi Xtreme Gam

    I've seen threads similar, but the problem is a little different. I just installed the basic driver and nothing else. And Ive even deleted the other files that aren't required that came with it. But my problem persists. I still see -27% of CPU usage after installing the driver from the website, immediately after installing it. (Had no driver previously). The thing is, in my processes list, my Idle is 99, and everything else on the list shows 00. Its really killing my gaming. Any answers?

    Hi Jayk88,
    I think GreggH is talking about the one released on the 29th of May. This beta driver is meant for the X-Fi Xtreme Audio PCI version only. The latest beta driver for the PCI-e card dates back to 6th Feb.
    Message Edited by KokChoy-CL on <span class='local-date'> 06-02-2009<span class='local-time'> :5 [email protected]

  • Internet usage and the CDDB

    Hi,
    Could anybody please give me an indication of the internet usage of itunes when importing CD's and getting the track names automatically from the CDDB? The reason I ask is that I seem to be using a massive amount of download for very little music. Last year I imported about 8gb of music from CD's on a dial-up connection and I didn't use much of my download, now on a differeent computer I'm looking at 20mb per CD??? Any ideas? I would have thought the whole CD track name thing from CDDB would use very little bandwidth.
    Cheers

    What does this have to do with JAR's?
    Try posing in the Java Programming section of the forum, you will get a better response there.

  • HT201263 Ipod is disabled and the normal method wont work

    I started the prosess like it said on the website on how to restore it. To hold down the middle busson intill the connect to Itunes picyure came up. Then plug it in and press restore. It was downloading the updates then its stopped and said that I could not access the Ipod without putting in the password. Which I cant! So what can I do to stop my Ipod being disabled?

    Place the iOS device in Recovery Mode and then connect to your computer and restore via iTunes. The iPod will be erased.
    iOS: Wrong passcode results in red disabled screen
    If recovery mode does not work try DFU mode.
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings

Maybe you are looking for

  • Can I download and install CS3 (NOT TRIAL - full version)?

    I have the original CDs and serial #s but no optical drive on my new laptop. I have it installed on my iMac, and it may be on my OLD laptop, which is dead. I understand you may only have Adobe products on two machines, so I would want to deactivate i

  • Streaming Internet Screems

    When I connect an HDMI cable from my computer to the TV it reproduces exactly what is on my screen.  I use this to watch a TV program I may have missed that is streamed over the internet once it is aired, including the evening news.  Can the Apple TV

  • How to copy procedure to sql plus window.

    I am trying to copy my procedure from note pad to sql plus window and some of the texts are being cut off. How can I copy the entire procedure to sql plus window. thanks

  • In which program is table USR41 updated?

    Hi All, can anybody please tell me in which program , the contents of table USR41 are updated? Specifically i want to know where the field LOGON_TIME and LOGON_DATE are updated. Thankyou in advance. Regards, Rohit Gupta

  • Nikon 1 Raw(Nef) - Aperture

    Hello, after importing Black/White Photos into Aperture, the Photos are converted in color. Why?