Clone /w Generics

Hi,
I appreciate there's probably a good reason for this, but could someone explain why this won't compile:
public class Copy<NAME extends Cloneable>{
   NAME _obj;
   public Copy(NAME obj){
      _obj = obj;
   public NAME getNext(){
      try{
         return (NAME) (_obj.clone());
      }catch(Exception e){
         throw new Error("Clone failed");
}throwing back at me:
Copy.java:12: cannot find symbol
symbol : method clone()
location: interface java.lang.Cloneable
return (NAME) (_obj.clone());
^
1 error
I know cloneable doesn't define clone, but last I checked Cloneable implicitly inherited from Object ....?
I know that you can get partial success with :
return (NAME) (_obj.getClass().getMethod("clone",null).invoke(_obj,null));
but then (as another thread discusses) you get unchecked exceptions.
Just wondering if there is a way to do what I want nicely?
Cheers.

This slightly modified program also does not compile, but it will help you to better understand what is happening here.
public class Copy<NAME extends Object & Cloneable>{
     NAME _obj;
     public Copy(NAME obj){
          _obj = obj;
     public NAME getNext(){
          try{
               return (NAME) (_obj.clone());
          }catch(Exception e){
               throw new Error("Clone failed");
}The error is:
Copy.java:9: clone() has protected access in java.lang.Object
                        return (NAME) (_obj.clone());
                                           ^
Note: Copy.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 errorYou are assuming that you can call directly clone in any Object, but not all classes have a public method clone available. A class must override clone AND make it public to enable you to call clone.

Similar Messages

  • How do I define Embedded image in FLT XML?

    Hi,
    Let's say I have embedded an image like this:
    package
        public final class Resource
            [Embed (source="/assets/images/1.gif" )]
            public static const image_1:Class;
    How would I call this from FLT XML for the source to be correctly mapped to my image?
    <TextFlow xmlns="http://ns.adobe.com/textLayout/2008">
       <p>
           <img source="  ??  "/>
       </p>
    </TextFlow>
    Thanks in advance!

    There is no built in way to do that.  It can, however, be done in several ways.
    One way is to supply a custom Configuration to the importer that converts the XML to a TextFlow.  That configuration would include an inlineGraphicResolver function that would convert your markup to a DisplayObject.
    Another possibility would be to simply walk the markup after the import and modify the source of the various ILG objects.
    I'm kind of wondering though - can you new "StringNameOfClass"?
    The class and DisplayObject source specifications for ILGs are there mostly because it works.  They do have limitations with cut/copy/paste.  Class works within a SWF but not to an external swf.  There is no way in Flash to "clone" a generic DisplayObject.
    Hope that helps,
    Richard

  • Generics and clone().

    I am trying to do
    ArrayList<Integer> tempList = (ArrayList <Integer>) list.clone();but I get the unchecked warning. list is defined as ArrayList<Integer> list.
    Basically, I am trying to cast the clone of list so that list remains unchanged by my method, so I am creating a templist using the clone. I am confused with respect to how to go about doing this cast using generics.
    Thanks in advance.

    This version gives the warning:
    public class Test {
        public static void main(String[] arguments) {
            ArrayList<Integer> list = new ArrayList<Integer>();
            ArrayList<Integer> clone = (ArrayList<Integer>)list.clone();
    }However, Drake_Dun is right, you probably want to copy the
    list rather than cloning it. If you insist on using clone without a
    warning, you loose the type information:
    public class Test {
        public static void main(String[] arguments) {
            ArrayList<Integer> list = new ArrayList<Integer>();
            ArrayList<?> clone = (ArrayList<?>)list.clone();
    }

  • How to clone generic instance variables?

    Hi guys,
    If I have private class Item<T>
            private T value;
            private int priority;
            public Item(T value, int priority)
                this.value = value;
                this.priority = priority;
            @Override
            public Object clone()
                try           
                    Item copy = (Item)super.clone();
                    copy.value = (T)value.clone();       //compiler errors, says: "clone has protected access in java.lang.Object"
                    return copy;
                catch (CloneNotSupportedException e)
                    return null;
        }So if the instance variable is of mutable type e.g. Person, how can I make sure that value.clone() is called on a Person object?

    [http://www.angelikalanger.com/GenericsFAQ/FAQSections/ProgrammingIdioms.html#FAQ502|http://www.angelikalanger.com/GenericsFAQ/FAQSections/ProgrammingIdioms.html#FAQ502]

  • Generic working in eclipse compiler but not through builds

    The following code snippet works fine in my eclipse development environment (1.6.0_06), but the build system running 1.6.0_06 throws exception:
    MyClass:343: incompatible types
    found : java.util.List<C>
    required: java.util.List<B>
    entries = createListFromSmartCopy(myAList, new B(), true);
    Types:
    A is an interface
    B is an interface of A
    C is an implementation of B
    List<A> aList = new ArrayList<A>();
    aList.add(new A());
    List<B> return = createListFromSmartCopy(aList, new C(), true);
        * <p>Creates a copy of a list where the source list could be an ancestor
        * type of the returned list. It also uses a reference object to actually
        * construct the objects that populate the return list.</p>
        * @param <T> - The ancestor type of the source list
        * @param <R> - The derived type of the destination list
        * @param <S> - The more derived type of the prototype object used to
        * construct the list of R's
        * @param sourceList - The source list
        * @param referenceObject - The object used to construct the return list
        * @param deepCopy - Deep copy serializable objects instead of just copying
        * the reference
        * @return a list of R's (as defined by the caller) of entries with the
        * object constructed as a copy of referenceObject with the properties of the
        * sourceList copyied in after construction
    public static <T extends Serializable, R extends T, S extends R> List<R> createListFromSmartCopy(
                List<T> sourceList, S referenceObject, boolean deepCopy)
          List<R> retr = new ArrayList<R>();
          for(int i = 0; i < sourceList.size(); i++)
             retr.add(copyOf(referenceObject));
             copyInto(sourceList.get(i), retr.get(i), deepCopy);
          return retr;
       }Any thoughts on either:
    1. How does this pass the compiler validation inside eclipse, even through 'R' has not been defined? I believe that the code is doing some sort of return type inference to return the exactly correct type of list as referred by the return result or else it is simply ignoring the invariant capture of R all together and silently dropping the error. The funny thing is that the code does work just fine in practice in my development system without an issue.
    or
    2. Why if the code is valid does the independent build system disallow this generic return type 'inference' to occur? Are there compiler flags I can use to withhold this special condition?

    Thanks for the response, I wasn't trying to show a full example but just my implementation's snippet. I'll list one now:
    package test;
    import java.io.ByteArrayInputStream;
    import java.io.ByteArrayOutputStream;
    import java.io.IOException;
    import java.io.ObjectInputStream;
    import java.io.ObjectOutputStream;
    import java.io.Serializable;
    import java.util.ArrayList;
    import java.util.List;
    public class TestMe
        * <p>This method performs a deep copy of an object by serializing and
        * deserialzing the object in question.</p>
        * @param <T> - The type of data to copy
        * @param original - The original object to copy
        * @return The object who's state should be the same as the original. This
        * call uses serialization to guarantee this copy is fully separate from the
        * original, so all sub-object references are also deep copies of their
        * originals
       @SuppressWarnings("unchecked")
       public static <T extends Serializable> T clone(T original)
          T obj = null;
          try
             ByteArrayOutputStream bos = new ByteArrayOutputStream();
             ObjectOutputStream out = new ObjectOutputStream(bos);
             out.writeObject(original);
             out.flush();
             out.close();
             ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(
                      bos.toByteArray()));
             obj = (T)in.readObject();
          catch(IOException e)
             e.printStackTrace();
          catch(ClassNotFoundException cnfe)
             cnfe.printStackTrace();
          return obj;
        * <p>Copies the properties from one object to another. The destined object
        * in this method must be derived from the source object. This allows for a
        * faster and smoother transition.</p>
        * @param <T> The type of source
        * @param <R> The type of destination
        * @param source - The source object
        * @param destination - The destination object
        * @param deepCopy - Copies the reference objects instead of just passing
        * back the reference pointer reference
       public static <T, R extends T> void copyInto(T source, R destination,
                boolean deepCopy)
       // Stubbed because it links into a ton of unnecessary methods
        * <p>Copies the values of a list of an ancestor class into the values of
        * another list who's value is derived from the ancestor.</p>
        * @param <T> - The ancestor type of the source list
        * @param <R> - The derived type of the destination list
        * @param sourceList - The source list
        * @param destinationList - The destination list
        * @param deepCopy - Deep copy serializable objects instead of just copying
        * the reference
       public static <T, R extends T> void copyIntoList(List<T> sourceList,
                List<R> destinationList, boolean deepCopy)
          if(sourceList.size() > destinationList.size())
             throw new IllegalArgumentException(
                      "Cannot copy entire source set into destination list");
          for(int i = 0; i < sourceList.size(); i++)
             copyInto(sourceList.get(i), destinationList.get(i), deepCopy);
        * <p>Creates a copy of a list where the source list could be an ancestor
        * type of the returned list. It also uses a reference object to actually
        * construct the objects that populate the return list.</p>
        * @param <T> - The ancestor type of the source list
        * @param <R> - The derived type of the destination list
        * @param <S> - The more derived type of the prototype object used to
        * construct the list of R's
        * @param sourceList - The source list
        * @param referenceObject - The object used to construct the return list
        * @param deepCopy - Deep copy serializable objects instead of just copying
        * the reference
        * @return a list of R's (as defined by the caller) of entries with the
        * object constructed as a copy of referenceObject with the properties of the
        * sourceList copyied in after construction
       public static <T extends Serializable, R extends T, S extends R> List<R> createListFromSmartCopy(
                List<T> sourceList, S referenceObject, boolean deepCopy)
          List<R> retr = new ArrayList<R>();
          for(int i = 0; i < sourceList.size(); i++)
             retr.add(clone(referenceObject));
             copyInto(sourceList.get(i), retr.get(i), deepCopy);
          return retr;
       public static void main(String[] args)
          List<A> aList = new ArrayList<A>();
          aList.add(new AImpl());
          aList.add(new AImpl());
          List<B> bList = createListFromSmartCopy(aList, new C(), true);
          for(B bItem : bList)
             System.out.println("My String = "
                      + bItem.getString() + " and my number = " + bItem.getInt());
       public static interface A extends Serializable
          public void setString(String string);
          public String getString();
       public static class AImpl implements A
          private static final long serialVersionUID = 1L;
          @Override
          public void setString(String string)
          @Override
          public String getString()
             return null;
       public static interface B extends A
          public void setInt(int number);
          public String getInt();
       public static class C implements B
          private static final long serialVersionUID = 1L;
          public C()
          @Override
          public String getInt()
             return null;
          @Override
          public void setInt(int number)
          @Override
          public String getString()
             return null;
          @Override
          public void setString(String string)
    }In my eclipse (20090920-1017), this compiles and runs just fine. I stripped out the functional pieces that weren't pertinent to the discussion.

  • HTTP 500 Internal Server Error while starting AppsTier post-clone

    Hello,
    Adcfgclone scripts on both DB and App Tiers, as well as Adautocfg scripts, complete successfully but I am faced with a "HTTP 500 Internal Server Error" and "The website cannot display the page" through IE when starting R12 Apps post clone. So far I have run a script on the cloned environment to synchronize the Workflow tables with APPS user, and re-ran autoconfig on both DB and App Tiers, but I still see the 500 error.
    Any other pointers? Thanks in advance!

    Adcfgclone scripts on both DB and App Tiers, as well as Adautocfg scripts, complete successfully but I am faced with a "HTTP 500 Internal Server Error" and "The website cannot display the page" through IE when starting R12 Apps post clone. So far I have run a script on the cloned environment to synchronize the Workflow tables with APPS user, and re-ran autoconfig on both DB and App Tiers, but I still see the 500 error.
    Any other pointers? Thanks in advance!What does "adopmnctl.sh status" return?
    The error you are getting "HTTP 500 Internal Server Error" is a generic one, please check Apache log files and the application.log file for details about the error.
    R12: Troubleshooting 500 Internal Server Error in Oracle E-Business suite [ID 813523.1]
    Http 500 : Internal Server Error When Login To A New Cloned Environment [ID 781413.1]
    Also, please confirm that you have no errors in the database log file.
    Thanks,
    Hussein

  • UltraNav version for non-IBM clone PC to run IBM Travel PS/2 Keyboard, 89P8500, SK-8840?

    My beloved IBM T42, circa 2005, has been retired from work duties and soldiers on in limited duty at home. I have recently attempted to re-create the well-designed keyboard, particularly the Synaptics touchpad and the TrackPoint, for my office PC, which is a clone (but with 'name-brand' internals, an Intel motherboard and processor, Kingston RAM, OCZ SSD) running 64-bit Windows 7 Professional, SP1.
    So, for the princely sum of $35 I purchased a new keyboard, an IBM Part No. 89P8500 and IBM Model No. SK-8840. It's labeled IBM, not Lenovo. The keyboard's cord ends in two PS/2 plugs, one for the keyboard and one for the mouse, the latter I believe refers to the integrated Synaptics touchpad, and the integrated Trackpoint. My office PC has no PS/2 inputs, so I purchased a Ziotek PS/2 Keyboard and Mouse to USB Adapter (ZT1040444) to make the connection between the keyboard and the PC.
    The keyboard does achieve basic functionality by simply plugging it into the PC through the Ziotek adapter. But the Synaptics touchpad and the TrackPoint are capable of considerably more functionality. I know this because on my T42 the touchpad and TrackPoint were controlled by UltraNav software, which created a tab in the Mouse Properties in Control Panel. There, many adjustments and customizations were possible.
    But having spent more hours than I will admit to (yes, it's in double digits), I am still unable to achieve UltraNav levels of functionality. Worse, and even though the keyboard functions, if I open Control Panel, Mouse Properties an error message appears saying:
    "Unable to connect to the Synaptics Pointing Device Driver.
    If you have installed another PS/2 Pointing Device Driver please uninstall the Synaptics driver by clicking on the Yes button. You then need to reinstall your pointing device driver for your external device again.
    Do you want to uninstall the Synaptics driver now?"
    I select "No" and the Mouse Properties dialogue box opens, sans any indication of UltraNav or any functionality beyond the basic functions provided in Windows.
    It finally dawned on me that the UltraNav software is IBM's proprietary version of Synaptics' generic touchpad / trackpoint driver. And it just doesn't want to and/or isn't going to work on my clone PC. I have literally tried dozens of USB and PS/2 drivers from Lenovo's website. The generic Synaptics driver from Synaptics' website imparts none of the UltraNav functionality, as best as I can tell.
    My guess is that IBM probably didn't plan on selling enough of the now-priced-at-$35 keyboard (89P8500 / SK-8840) to merit going to the trouble and expense of preparing an UltraNav driver for non-IBM computers to run the thing. But, is there a version of UltraNav that will run on non-IBM/Lenovo PCs? I haven't found it.
    The keyboard uses PS/2 and the Ziotek adapter, at least in theory, maps the PS/2 interface over to work with the USB interface. But is Windows 7 Professional 64-bit treating the Ziotek adapter-connected keyboard as a PS/2 device (which it is), or does the Ziotek adapter cause windows to treat the keyboard as a USB device? Thus, is the adapter's mapping over process so complete that the PS/2 device is now treated as a USB device? I have inquired with Ziotek and I am awaiting a response, which may never come.
    I posted here in desperation. Please help, if you are able.
    Thank you,
    Dennis

    IBM sourced their keyboards from another company for a long time, and that company not only still exists, but still sells the keyboard you're using (though for much more). Company is Unicomp. Website is pckeyboard.com. They probably support the keyvboard.
    That said, the generic synaptics reference driver should work for the trackpad. Can't say the same for the trackpoint.
    Jonathan Becker
    CURRENT LENOVO PRODUCTS: Thinkpad Tablet 2
    sn #R9WHND7, Win 8 Pro, BIOS 1.51, with Dock and TPT2 keyboard
    Thinkpad USB Keyboard with Trackpoint
    IdeaCenter B500
    PAST: Thinkpad T22, X60 Tablet, X220 Tablet

  • Casting, generics and unchecked expressions

    Hi
    I'm trying to access a vector of Recommendations held by a Person object, but I don't want to allow direct access to the vector, just the information contained in it
    public Vector<Recommendation> getRecommendations() {
         return((Vector<Recommendation>)recList.clone());
    }The trouble I'm having is that I have to cast the recList.clone() as a Vector<Recommendation> to return a compatible type.
    When I do this, the source compiles with a warning: unchecked cast.
    Could someone explain an unchecked cast and give me a pointer to solving this please? I've not managed to find anything about combining generics and clones in my books. Is there another way of returning a copy of the vector? All I want to do is make the objects in the vector available for viewing, via processing in a servlet, to a jsp.
    Thanks in advance

    YoGee wrote:
    What you are exposing is a Vector with a reference to a clone of the internal data array, you are not cloning the elements in that data array. So basically if you modify an element in one Vector chances are it will be reflected in the other (assuming the element is mutable).Thanks for the reply.
    I should have said that what I want to achieve is:
    make the Vector<Recommendation>recList contents available for viewing, but not expose the objects so that they are able to be changed - so what I have done is not good!
    after some thought, what I really want is this:
    If what you actually want to achieve is a deep clone (i.e. clone the elements in the internal data array) you need to do it yourself by looping through the Vector and cloning each element in it (assuming the elements implement clone properly)so thanks for the help!

  • How do I put mp3 files on a generic mp3 player

    I have a generic mp3 player that I would like to let my 7 year-old daugther use.  I have transfered music to it before from a mac but converted the audio files to mp3 first.  Now on my new macbook pro I can only find a way to burn mp3 files on to a cd.  Can anyone help me? 

    meliafrompoland wrote:
    Thank you I was able to turn them into mp3s.  But I cannot get them on to the device.  I get error code -36
    The Finder can't complete the operation because some data in "the flie.mp3" can't be read or written. 
    One or more of the files your attempting to convert is either DRMed or corrupted in some fashion.
    It can occur with hard drives, the sector can fail and the data on it can't be read anymore.
    I have one song out of over 8,000 that did that to me, took a rare chance that I played that song to find out about it, I restored it from a DVD backup I made long ago when I first downloaded the song.
    If I used TimeMachine it wouldn't have keep that ancient backup, why I suggest people employ a multiple backup  of clones, TM and burned DVD's or other permanent storage methods.
    Most commonly used backup methods

  • Why clone() in Object Class is protected

    hi,
    Why clone() in Object Class is protected
    Why finalize() in Object Class is protected
    Waiting for your reply
    suresh

    Why clone() in Object Class is protectedObject's clone() is meant to provide a generic cloning facility as the assistance for the types implementing Cloneable but not as a public ready-made method. Object's clone() should be overridden for those types to provide a meaningful implementation (maybe relying on Object's clone). Object's clone() being public were an invitation to try to clone every object, regardless of its being cloneable or not. For a type to be cloneable, it is necesary for this type in implement Cloneable, a no-method interface. While at writing the class and declaring it as Cloneable, it is not much more work to provide a clone() implementation. It is the responsibility of the author of a class to decide whether it should be cloneable and if yes, how it should be cloned.
    Why finalize() in Object Class is protected"finalize" is meant for the VM to invoke is as defined by the specification.
    Encapsulation implies everything should have the smallest scope, the most restrictve access which is still appropriate.

  • Script:  Does sheet exist?  If not, duplicate generic client & rename

    In my continuing education of Applescript, I've run across the following gap in my knowledge.
    I'm in a "tell Numbers" block. I've opened up my Numbers file (Clients.numbers). There will be about 60 sheets there, almost all of which (exceptions are a Master sheet with summaries and a Generic client sheet) relate to specific clients. These sheets are named with the client's name: i.e. "JetsonGeorge", "FlintstoneFred", etc. Each sheet has several tables: personal data, visit dates, billing data, etc.
    The script has a list of client names (clients I've seen today, via iCal). I want the script to see if there is a sheet for each client. For those clients who don't have a sheet yet, duplicate the sheet called Generic and rename the duplicate to the client name.
    I know how to do this for files in Finder. But I've been unable to find anything in the Numbers dictionary (or here searching on "script duplicate sheet") to make this happen within a Numbers file.
    I appreciate any information you can offer.
    Vince

    Here is a variant of the posted script.
    This one use a modified version of the duplicateSheet handler.
    It assumes that it may create new sheets without modifying the default contents.
    Working this way fasten seriously the job because what is time consuming is not the duplicate task by itself but
    the selection of the sheet to replicate.
    This new version selects the master sheet when it duplicate it for the first time in a loop.
    For the other replicate tasks, it will not re-select the master but it will replicate the last replicate .
    As such a replicate is identical to the master one, the result will be the same but it will be very faster.
    --[SCRIPT duplicatesheet3]
    Enregistrer le script en tant que Script : duplicate_sheet.scpt
    déplacer le fichier ainsi créé dans le dossier
    <VolumeDeDémarrage>:Users:<votreCompte>:Library:Scripts:Applications:Numbers:
    Il vous faudra peut-être créer le dossier Numbers et peut-être même le dossier Applications.
    Ouvrir le document Perfect_Kradebook
    aller au menu Scripts , choisir Numbers puis choisir "duplicate_sheet"
    --=====
    L'aide du Finder explique:
    L'Utilitaire AppleScript permet d'activer le Menu des scripts :
    Ouvrez l'Utilitaire AppleScript situé dans le dossier Applications/AppleScript.
    Cochez la case "Afficher le menu des scripts dans la barre de menus".
    --=====
    Save the script as a Script: duplicate_sheet.scpt
    Move the newly created file into the folder:
    <startup Volume>:Users:<yourAccount>:Library:Scripts:Applications:Numbers:
    Maybe you would have to create the folder Numbers and even the folder Applications by yourself.
    Open the Perfect_Kradebook document
    go to the Scripts Menu, choose Numbers, then choose "duplicate_sheet"
    --=====
    The Finder's Help explains:
    To make the Script menu appear:
    Open the AppleScript utility located in Applications/AppleScript.
    Select the "Show Script Menu in menu bar" checkbox.
    --=====
    Yvan KOENIG (VALLAURIS, France)
    2010/05/08
    2010/06/28
    --=====
    Some global constants
    property the_students : {"George", "John", "Paul", "Ringo"}
    property master_Sheet : "master"
    property tMasterTable1 : "tableau 1"
    property tMasterTable2 : "tableau 2"
    property tMasterTable3 : "tableau 3"
    property sKradebook : "Kradebook"
    property tKradebook : "Kradebook"
    property tCaution : "CAUTION"
    property sReport : "Report"
    property tReport1 : "report 1"
    property tReport2 : "report 2"
    property tReport3 : "report 3"
    property columnOfIDs : 2 (* vas 6 to grab the students ID *)
    --=====
    property mesFeuilles : {}
    Three properties required by the handler duplicateSheet
    property listeObjets : {}
    property lesFeuilles : {}
    property targetSheetRow : missing value
    rule the behaviour of the handler duplicateSheet
    --=====
    on run
    my activateGUIscripting()
    my nettoie()
    tell application "Numbers"
    set dName to name of document 1
    tell document dName to set my mesFeuilles to name of sheets
    end tell -- Numbers
    set missing to {}
    if master_Sheet is not in my mesFeuilles then copy master_Sheet to end of missing
    if sKradebook is not in my mesFeuilles then copy sKradebook to end of missing
    if sReport is not in my mesFeuilles then copy sReport to end of missing
    if missing is not {} then
    if (count of missing) > 1 then
    if my parleAnglais() then
    error "The sheets “" & my recolle(missing, " and ") & "” are unavailable in the document “" & dName & "” !"
    else
    error "Les feuilles “" & my recolle(missing, " et ") & "” n’existent pas dans le document “" & dName & "” !"
    end if
    else
    if my parleAnglais() then
    error "The sheet “" & item 1 of missing & "” is unavailable in the document “" & dName & "” !"
    else
    error "La feuille “" & item 1 of missing & "” n’existe pas dans le document “" & dName & "” !"
    end if
    end if -- count…
    end if -- missing…
    tell application "Numbers" to tell document dName
    set tables1 to name of tables of sheet master_Sheet
    set tables2 to name of tables of sheet sKradebook
    --set tables3 to name of tables of sheet sReport
    end tell
    set missing to {}
    if tMasterTable1 is not in tables1 then copy tMasterTable1 to end of missing
    if tMasterTable2 is not in tables1 then copy tMasterTable2 to end of missing
    if tMasterTable3 is not in tables1 then copy tMasterTable3 to end of missing
    if tKradebook is not in tables2 then copy tKradebook to end of missing
    if tCaution is not in tables2 then copy tCaution to end of missing
    --if tReport1 is not in tables3 then copy tReport1 to end of missing
    --if tReport2 is not in tables3 then copy tReport2 to end of missing
    --if tReport3 is not in tables3 then copy tReport3 to end of missing
    if missing is not {} then
    if (count of missing) > 1 then
    if my parleAnglais() then
    error "The tables “" & my recolle(missing, " and ") & "” are unavailable in the document “" & dName & "” !"
    else
    error "Les tables “" & my recolle(missing, " et ") & "” n’existent pas dans le document “" & dName & "” !"
    end if
    else
    if my parleAnglais() then
    error "The table “" & item 1 of missing & "” is unavailable in the document “" & dName & "” !"
    else
    error "La table “" & item 1 of missing & "” n’existe pas dans le document “" & dName & "” !"
    end if
    end if -- count…
    end if -- missing…
    tell application "Numbers" to tell document dName
    Grabs the list of students IDs
    With the property setting, here we don't use the IDs but the Last Names
    tell sheet sKradebook
    tell table tKradebook to set IDs to items 6 thru -2 of (get value of cells of column columnOfIDs)
    end tell
    set report to ""
    set nbIDS to count of IDs
    set replicates to {}
    repeat with anID in IDs
    set anID to anID as text
    set match to 0
    repeat with j from 1 to nbIDS
    if (item j of IDs) as text is anID then set match to match + 1
    end repeat
    if match > 1 then copy anID to end of replicates
    end repeat
    if replicates is not {} then
    set report to report & my recolle(replicates, ", ")
    if my parleAnglais() then
    set report to report & " are replicates in " & tKradebook
    else
    set report to report & " doublonnent dans " & tKradebook
    end if -- parleAnglais
    end if -- replicates…
    if report is not "" then error report
    end tell -- Numbers
    * Here we are ready to enter the main loop
    set targetSheetRow to missing value
    repeat with studentID in IDs
    if studentID as text is not in my mesFeuilles then (*
    Duplicate the master sheet *)
    my duplicateSheet_v3(dName, master_Sheet, studentID as text)
    delay 0.1
    end if
    end repeat -- for next student
    my nettoie()
    end run
    --=====
    on nettoie()
    set my mesFeuilles to {}
    set my listeObjets to {}
    set my lesFeuilles to {}
    set targetSheetRow to missing value
    end nettoie
    --=====
    on decoupe(t, d)
    local oTIDs, l
    set oTIDs to AppleScript's text item delimiters
    set AppleScript's text item delimiters to d
    set l to text items of t
    set AppleScript's text item delimiters to oTIDs
    return l
    end decoupe
    --=====
    on recolle(l, d)
    local oTIDs, l
    set oTIDs to AppleScript's text item delimiters
    set AppleScript's text item delimiters to d
    set t to l as text
    set AppleScript's text item delimiters to oTIDs
    return t
    end recolle
    --=====
    on parleAnglais()
    local z
    try
    tell application "Numbers" to set z to localized string "Cancel"
    on error
    set z to "Cancel"
    end try
    return (z is not "Annuler")
    end parleAnglais
    --=====
    on activateGUIscripting()
    tell application "System Events"
    if not (UI elements enabled) then set (UI elements enabled) to true (* to be sure than GUI scripting will be active *)
    end tell
    end activateGUIscripting
    --=====
    ==== Uses GUIscripting ====
    This handler may be used to 'type' text, invisible characters if the third parameter is an empty string.
    It may be used to 'type' keyboard shortcuts if the third parameter describe the required modifier keys.
    on raccourci(a, t, d)
    local k
    tell application a to activate
    tell application "System Events" to tell application process a
    set frontmost to true
    try
    t * 1
    if d is "" then
    key code t
    else if d is "c" then
    key code t using {command down}
    else if d is "a" then
    key code t using {option down}
    else if d is "k" then
    key code t using {control down}
    else if d is "s" then
    key code t using {shift down}
    else if d is in {"ac", "ca"} then
    key code t using {command down, option down}
    else if d is in {"as", "sa"} then
    key code t using {shift down, option down}
    else if d is in {"sc", "cs"} then
    key code t using {command down, shift down}
    else if d is in {"kc", "ck"} then
    key code t using {command down, control down}
    else if d is in {"ks", "sk"} then
    key code t using {shift down, control down}
    else if (d contains "c") and (d contains "s") and d contains "k" then
    key code t using {command down, shift down, control down}
    else if (d contains "c") and (d contains "s") and d contains "a" then
    key code t using {command down, shift down, option down}
    end if
    on error
    repeat with k in t
    if d is "" then
    keystroke (k as text)
    else if d is "c" then
    keystroke (k as text) using {command down}
    else if d is "a" then
    keystroke k using {option down}
    else if d is "k" then
    keystroke (k as text) using {control down}
    else if d is "s" then
    keystroke k using {shift down}
    else if d is in {"ac", "ca"} then
    keystroke (k as text) using {command down, option down}
    else if d is in {"as", "sa"} then
    keystroke (k as text) using {shift down, option down}
    else if d is in {"sc", "cs"} then
    keystroke (k as text) using {command down, shift down}
    else if d is in {"kc", "ck"} then
    keystroke (k as text) using {command down, control down}
    else if d is in {"ks", "sk"} then
    keystroke (k as text) using {shift down, control down}
    else if (d contains "c") and (d contains "s") and d contains "k" then
    keystroke (k as text) using {command down, shift down, control down}
    else if (d contains "c") and (d contains "s") and d contains "a" then
    keystroke (k as text) using {command down, shift down, option down}
    end if
    end repeat
    end try
    end tell
    end raccourci
    --=====
    CAUTION, this handler requires three properties :
    property listeObjets : {}
    property lesFeuilles : {}
    property targetSheetRow : missing value
    on duplicateSheet_v3(theDoc, theSheet, newName)
    most of this handler is from Nigel Garvey
    local maybe
    try
    tell application "Numbers"
    activate
    set theDoc to name of document theDoc (* useful if the passed value is a number. Checks also that we passed the name of an open doc *)
    end tell -- Numbers
    on error
    if my parleAnglais() then
    error "The spreadsheet “" & theDoc & "” is not open !"
    else
    error "Le tableur « " & theDoc & " » n’est pas ouvert ! "
    end if -- my parleAnglais
    end try
    if targetSheetRow is missing value then
    This piece of code is time consuming so, when there is nothing to change in the new sheet,
    we may drop it when it was already called with the same settings.
    The code will no longer duplicate the master sheet one but the newly created one.
    As this one is a clone of the master, the result will be the same but it will be really faster.
    try
    tell application "Numbers" to tell document theDoc
    set theSheet to name of sheet theSheet (* useful if the passed value is a number. If we passed a string, checks that the sheet theSheet is available *)
    end tell -- Numbers
    on error
    if my parleAnglais() then
    error "The sheet “" & theSheet & "” is unavailable in the spreadsheet “" & theDoc & "” !"
    else
    error "La feuille « " & theSheet & " » n’existe pas dans le tableur « " & theDoc & " » ! "
    end if -- my parleAnglais
    end try
    set maybe to 5 > (system attribute "sys2")
    tell application "System Events" to tell application process "Numbers"
    tell outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window theDoc
    if maybe then (* macOS X 10.4.x
    '(value of attributes contains 0)': '(value of attribute "AXDisclosureLevel" is 0)' sometimes works in Tiger, sometimes not.
    The only possible instances of 0 amongst the attributes are the disclosure level of a sheet row and the index of the first row, which represents a sheet anyway.
    Another possibility is '(value of attribute -1 is 0)', which makes me uneasy. *)
    set targetSheetRow to first row where ((value of attributes contains 0) and (value of first static text is theSheet))
    else (* macOS X 10.5.x or higher *)
    set targetSheetRow to first row where ((value of attribute "AXDisclosureLevel" is 0) and ((groups is {}) and (value of first static text is theSheet)) or (value of first group's first static text is theSheet))
    end if -- maybe…
    tell targetSheetRow to set {value of attribute "AXSelected", value of attribute "AXDisclosing"} to {true, true}
    -- Focus the "Sheets" column ('outline 1 …') AFTER the target row is selected.
    set value of attribute "AXFocused" to true
    delay 0.1
    set maybe to (get value of attribute "AXPosition" of targetSheetRow)
    Sometimes, the sheet's thumbnail is selected (with the yellow border) and the duplicate instruction behave correctly
    but sometimes the yellow border doesn't surface and the duplicate code fails (issue a bell)
    end tell -- outline…
    end tell -- System Events
    end if -- targetSheetRow…
    tell application "Numbers" to tell document theDoc
    set my listeObjets to name of sheets
    end tell -- Numbers
    my raccourci("Numbers", "d", "c") (* duplicate , must be here for Snow Leopard !!!! *)
    tell application "Numbers" to tell document theDoc
    repeat
    set my lesFeuilles to name of sheets
    if my lesFeuilles is not my listeObjets then exit repeat
    delay 0.1
    end repeat
    repeat with i in my lesFeuilles
    if i is not in my listeObjets then (*
    Here i is the name of the newly created sheet *)
    set name of sheet i to newName
    exit repeat
    end if -- i is not…
    end repeat
    end tell -- document thedoc…
    end duplicateSheet_v3
    --=====
    --[/SCRIPT]
    Yvan KOENIG (VALLAURIS, France) mercredi 30 juin 2010 12:48:47

  • Generics/Abstract class question

    I'm not sure exactly what my problem is here. I am creating an abstract class for a number of other data types that I am creating. The purpose of this class is to track changes so that the GUI can prompt the user to save changes if they try to exit without saving. I want to do this by storing a reference of the original object and then making changes on a new object. I am running into problems though. Right now I am trying to define the clone method in that class and am getting an error.
    public abstract class ChangeableDataType<T extends ChangeableDataType>{
        protected T old;
        public Object clone(){
            T t = new T(); // Error occurs here
            //Stuff
        }The error I get is unexpected type on the line where I try to call a new T(). Is this not something that I can do? I have tried to put any code in that I thought might have the problem.

    No, that isn't something you can do. I'm sure it's discussed in more (and better) detail in [the Generics FAQ|http://www.angelikalanger.com/GenericsFAQ/JavaGenericsFAQ.html] though.

  • Error during deployment - NoSuchMethodError DatabaseLogin.clone()

    Hi All,
    I'm running Jdeveloper 11.1.1.6.0 and I have a SOA composite that contains a BPM process wired to a BPEL process which is connected to a DBAdapter. I suddenly started getting these errors when deploying my app today.
    <Mar 28, 2013 11:08:30 AM EDT> <Error> <ServletContext-/soa-infra> <BEA-000000> <Error during deployment
    oracle.fabric.common.FabricException: Deployment Failed: [JCABinding] [Ver2_NoEOorVO.getSTN/1.0]Unable to complete load due to: org.eclipse.persistence.sessions.DatabaseLogin.clone()Lorg/eclipse/persistence/sessions/DatasourceLogin;: org.eclipse.persistence.sessions.DatabaseLogin.clone()Lorg/eclipse/persistence/sessions/DatasourceLogin;
    at oracle.integration.platform.blocks.deploy.StandaloneCompositeDeploymentCoordinatorImpl.coordinateCompositeDeployment(StandaloneCompositeDeploymentCoordinatorImpl.java:64)
    at oracle.integration.platform.blocks.deploy.servlet.BaseDeployProcessor.deployNewComposite(BaseDeployProcessor.java:415)
    at oracle.integration.platform.blocks.deploy.servlet.BaseDeployProcessor.deploySARs(BaseDeployProcessor.java:250)
    at oracle.integration.platform.blocks.deploy.servlet.DeployProcessor.doDeployWork(DeployProcessor.java:167)
    at oracle.integration.platform.blocks.deploy.servlet.DeployProcessor.doDeployWork(DeployProcessor.java:112)
    Truncated. see log file for complete stacktrace
    Caused By: oracle.fabric.common.FabricDeploymentException: [JCABinding] [Ver2_NoEOorVO.getSTN/1.0]Unable to complete load due to: org.eclipse.persistence.sessions.DatabaseLogin.clone()Lorg/eclipse/persistence/sessions/DatasourceLogin;: org.eclipse.persistence.sessions.DatabaseLogin.clone()Lorg/eclipse/persistence/sessions/DatasourceLogin; {rootCauses=[]}
    at oracle.integration.platform.blocks.adapter.AdapterReference.load(AdapterReference.java:458)
    at oracle.integration.platform.blocks.adapter.AdapterReference.load(AdapterReference.java:82)
    at oracle.integration.platform.blocks.deploy.CompositeDeploymentConnection.deployReferences(CompositeDeploymentConnection.java:201)
    at oracle.integration.platform.blocks.deploy.CompositeDeploymentConnection.deploy(CompositeDeploymentConnection.java:93)
    at oracle.integration.platform.blocks.deploy.CompositeDeploymentManagerImpl.initDeployment(CompositeDeploymentManagerImpl.java:150)
    Truncated. see log file for complete stacktrace
    Caused By: java.lang.NoSuchMethodError: org.eclipse.persistence.sessions.DatabaseLogin.clone()Lorg/eclipse/persistence/sessions/DatasourceLogin;
    at oracle.tip.adapter.db.DBManagedConnectionFactory.buildServerSession(DBManagedConnectionFactory.java:1316)
    at oracle.tip.adapter.db.DBManagedConnectionFactory.createServerSession(DBManagedConnectionFactory.java:1172)
    at oracle.tip.adapter.db.DBManagedConnectionFactory.acquireSession(DBManagedConnectionFactory.java:635)
    at oracle.tip.adapter.db.transaction.DBTransaction.getSession(DBTransaction.java:379)
    at oracle.tip.adapter.db.DBConnection.getSession(DBConnection.java:264)
    Truncated. see log file for complete stacktrace
    Could this be due to the fact that the db adapter getSTN jca connection factory location is bound to a jndi name that has a multi-data source (load-balanced) ?
    thanks,
    Vikram

    Never mind. I found the problem. But you have to admit - The error does throw you off completely though.
    I had a database adapter referencing a jndi name like eis/DB/MySTN which did exist earlier but I removed it from the DbAdapter connection factory on the weblogic console before deploying. Also I referenced the DbAdapter connection factory xaDataSource to a generic data source instead of multi - that seemed to help as well.

  • Carbon Clone and Time Machine: developing a backup plan

    Howdy all!
    This is a second post that sort of flows on from another I have written today
    https://discussions.apple.com/thread/4649740
    I initally put them all together, but they were too rambling and disconnected, so it seemed better to seperate them. The question I have here is how best to organise my backup plan? I have a few ideas, but, basically, want to make sure I get the whole setup right the first time and would appreciate any advice from others that have been down the path before. As I am still waiting for some parts to arrive in the mail, I have a little time to think about how to go about setting up my Mac.
    Basically the setup is:
    Mac Mini 2012, boot drive is a Samsung 256GB 830 series SSD, seconday drive for data is a 1TB mechanical disk. I plan on having all my data on the seconday mechanical disk (photos, movies, music etc) and only the OS and Applications on the SSD. To this end, I understand I only have to move /Users to the mechanical disk to achieve this. I then also have 2x 2TB Western Digital MyBook Essential USB 3 disks for Time Machine backups. I plan on rotating them on a weekly basis (storing the disk not in use in a safe or offsite), and then, depending on costs a cloud backup service for some data (music, photos etc) which I might want to access when im not at home.
    So I have been thinking for a few days now on the benefit of having a Carbon Clone bootable recovery drive. The thinking goes along these lines. As my data is on a seperate drive, and is backed up to Time Machine, in the event of an OS disk failure, I can replace the disk and then point /Users to the new drive, and I can be up and running once I have reinstalled the apps i need. Now, I understand the idea of the Carbon Clone backup is such that it speeds up the time to rebuild the OS disk, but I have to question, how useful is this in reality?
    Consider, I can sit down now and write down all the apps I have needed in the past, install Mac OS, set it up (possibly with a generic admin password), install the apps I need from the App store and DVDs etc and then take a Carbon Clone at this point before any setup of Apps are done. If the apps configuration is backed up in the Time Machine backup (i.e.: the config files exist under /Users) then this is almost workable - in a recovery situation, the CC clone is used to rebuild the OS drive, the config files are pulled from the TM backups, and we're back up and running. Where this fails, is if I have installed (or removed) apps since the CC clone was made. At this point then, is it best to (a) make a new clone when a new app is added/removed or (b) make a note of apps added/removed, which will then have to be reinstalled if a recovery is required. I tend to think the (b) method is best here, as it preserves the integrity of the clone. If the machine has been compromised (malware etc) then remaking the clone, causes the clone to be compromised and hence the reinstalled machine as well. Though this method could be a pain if the machine state has changed somewhat over time. Also, it means that the reinstalled system will be missing updates etc which could be time consuming to apply anyway, so the usefulness of a clone is slightly reduced anyway.
    Does anyone have any thoughts on this? Some days I think having a clone will be useful esp. as most of my software was delivered on CD (Adobe Creative Suite, Office) or are large install bases (XCode), but other days I think, "its not a mission critical machine", i can survive a day without it while I rebuild the install, and so I dont achieve much by having a clone which is likely out-of-date by the time I go to use it.
    Also, in this backup plan, is it best to rely on TM for things like email backup or a dedicated mail backup utility? can a Carbon Clone exist on the same disk as Time Machine uses, or do I need to invest in a new disk or two for the CC clones?
    As I say, I want to make sure I have this machine setup right from the start, and would really appreciate any pointers, tips or advice.

    There is one big advantage of a clone.  You can immediately reboot
    to it and continue working and deal with the regular boot drive faiure,
    what ever it may be, later.  Especially since all your data and such
    is on another drive.  If you use your computer for work and time
    critical projects, this is a major plus!
    In the case of a hard drive failure/replacement, copying the clone
    to the drive is the fastest way to get the system and all your settings
    back.
    Time Machine and incremental backups have a place as well.  It is best
    suited for "incremental" problems.  Examples are installing an upgrade to
    software that doesn't work or just don't plain like.  With Time Machine it
    is easy to just restore back to the point before the install.
    Something else I do is backup current project files to USB memory sticks.
    If you are using your computer for business, you can never have too many
    backups.  Coralllary 456 of Murphy's Law is the "number of backups that
    you need will be one more than what you have!"

  • Clone Objects

    Hi everybody,
    I have the next trouble, I need to clone an Object, but the method "clone()" in the Object class is protected.
    I am working with a DBMSOO that provide me the following classes: Database, Transaction. I want to have a generic command that retrieve Objects from a database Object-Oriented, and then to make a cast to a specific class.
    This is the code:
    public class Lookup
    private Object object;
    public Lookup
    Database db = new Database();
    db.open( "dbUrl->server", Database.OPEN_READ_ONLY );
    Transaction txn = new Transaction( db );
    txn.begin();
    object = db.lookup( "idObject" );
    txn.commit();
    db.close();
    public Object getObject() {
    return object;
    My trouble is that when the Transaction is finished with commit() method, the object reference is null. I thought to clone the Object, but is not posible.
    Could anyone help me, please?
    Sincerely,
    Alvaro
    PS: Sorry, for my english. I know it isn't very good.

    Hi DrClap,
    I understand you, but if I don't write the sentence:
    txn.commit()
    that close the Transaction, the reference "object" isn't null.
    What's the matter?
    Thanks a lot for your interesting.
    Alvaro

Maybe you are looking for

  • How to use Aggregate Functions during Top N analysis?

    Say i want to find top 5 highest salaries and their totals and average. In that case how to use aggregate functions. Please give me an example on this. Regards, Renu Message was edited by: user642387

  • How To Fix a folder w/ exclamation icon

    I have a 3rd gen 15gb ipod, it is showing a folder with an exclamation point icon. i have tried all the reset options, but i don't want to pay the $270 that apple will fix it for, because i can just buy a new one for that. Any help would be appreciat

  • PE10 & Dazzle.

    A while ago I read a lot of suggestions for downloading/copying old VHS tapes into PE10 using Dazzle. From my point of view none of them worked electronicaly. So I reverted to a practical way and used dazzle to download into my copy of Pinnacle Studi

  • 0IC_MP04 and 0IC_MC01

    We are implementing Inventory and need to understand the difference between the multiproviders 0IC_MP04 and 0IC_MC01. I have browsed through the help.sap.com definitions but it doesn't tell me why these are two different multiproviders. I understand

  • How to start 2 RMI servers on same machine ??

    Hello friends, I am developing databackup project USING RMI i want to start servers on same machine and client may be on different machine. we tried it used as on different port . but it stil not working. so can u provide me solution for that , how t