How to copy a future object in java ???

here is a part of class Hand for a blackjack game.
I want to make a copy of a future Hand object using constructor copyHand(),
I dont know how ????????
I appreciate anyones help .....
// the array of cards in the hand
    Card [] cards;
     * Builds a Hand with 0 cards in it, but capable of holding
     * max cards.
    public Hand(int max)
        cards = new Card[max];
     * Builds a copy of this Hand.
     * @return a deep copy of this Hand.
    public Hand copyHand()
    }-med

Assuming that you DO want a deep copy, begin with a constructor that takes another hand.
public Hand( Hand h ) { ...Then for each instance variable, within that constructor:
this.instVar0 = h.instVar0;
this.instVar1 = h.instVar1;
. . .And last, for every reference, make sure there is a constructor (or copy method for arrays) that itself makes a deep copy:
this.ref0 = new Ref0Type( h.ref0 );

Similar Messages

  • How to manipulate a javascript object in java?

    Hi, I am fiddling with the java scripting interface. As I understand the rhino engine is packaged with the jdk but what I don't understand is how does one reconcile the objects one gets from their engine (e.g. sun.org.mozilla.javascript.internal.ScriptableObject) versus the ones in the rhino api (e.g. org.mozilla.javascript.ScriptableObject)?
    Is the one in the jdk heavily modified or wrappered up to suit their javax.scripting interface?
    More specifically, how do I manipulate javascript objects from java?
    e.g. suppose I have this java code:
    ScriptEngineManager mgr = new ScriptEngineManager();
    ScriptEngine js = mgr.getEngineByName("js");
    jsEngine.eval("var foo = { x : 1, y : 'hello', z : false };");
    Object o = jsEngine.get("foo");Now o is instanceof sun.org.mozilla.javascript.internal.NativeObject, which is a subclass of a bunch of other classes in the s.o.m.j.i namespace. Being internal I can't use these directly.
    Looking at the Rhino API obviously you normally get a org.mozilla.javascript.ScriptableObject and can call the .get() .getIds() methods. But I don't know how to translate the objects I am getting in my actual java code which uses the jdk engine into org.mozilla.javascript objects.
    Is this even possible? Am I misunderstanding something completely? Should I just be using the rhino js jar and not the javax.scripting interface? If so, for what reason is the javax.scripting interface implemented?

    Assuming that you DO want a deep copy, begin with a constructor that takes another hand.
    public Hand( Hand h ) { ...Then for each instance variable, within that constructor:
    this.instVar0 = h.instVar0;
    this.instVar1 = h.instVar1;
    . . .And last, for every reference, make sure there is a constructor (or copy method for arrays) that itself makes a deep copy:
    this.ref0 = new Ref0Type( h.ref0 );

  • How to Copy and Paste object in InDesignServer CS3.

    Hi All:
    Is there a method to copy and paste object in InDesignServer CS3?
    Thanks in advanced.

    search forum - workaround - export snippet
    robin
    www.adobescripts.com

  • How to bind a String object to java:comp/env name space?

    Hi, does anybody know how to declare a String as a JNDI object in OC4J V904. I want to register a String named 'Foo' with the value 'val' with JNDI. Eventually I want to get the value of this by referencing this JNDI name:
    java:comp/env/ejb/Foo
    I don't really care how this is done either by declaring it by way of ejb-jar.xml or a global setting at the application server level.
    Please assist!
    Thanks
    J

    There are many possible ways.
    - (BEST) Use the J2EE resource environment variable mechanism (ie resource-env-ref in ejb-jar.xml).
    - (MEDIUM) Use OC4J startup classes.
    - (IF ELSE FAILS) Use the InitialContext.rebind method.

  • How to copy a smart object transform in Photoshop

    Hello!
    Smart objects in photoshop is realy powerfull tool, i use it  in many different ways and create complicated web graphic. But many times i need to do one thing with them and always fail:
    If i have several different smart objects, and I do DIFFERENT  perspective transform to them (it means scaling distortion rotation etc)
    how can i apply the *same* transform that has one of my objects to another one smart objet that yet has no transformation (or it has some alrady dosn't matter)?
    In other words how can i copy the transformation in some way (as you might copy a layer style and apply the same one to a different layer)
    Is there any way? or i shoud look to scripting to do that?
    Is there real photoshop guru who knows how to do that?
    thanks in advance

    Thank you!
    Yes i know about this workaround but unfortunatly there will be immediatly other question raised :
    if i do this (replace content of my new smart object created by copying from original) then this new smart object will be disconnected from any other smart object, and there is no way how to restore this connection betwen smart objects after content replace operation. Or there is?
    This is important  for me cause in my work i have a lot of smart objects with different transformations but conneted to one source data object.
    So unfortunatly for me but this idea is not even workaround for my workflow? It's so pity

  • How To Use A .dll Object in Java Servlet/JSP

    I need the Solution, Is there any API's Available to do so.
    Ofcourse The .dll is a Microsoft Visual Basic Product.

    You need to use JNI to wrap C/C++ function provided by the .dll library. and then call it from JNI implementation class.
    [email protected]
    http://www.sinotar.com/

  • How do I copy text and objects from pages to and paste into Email, objects don't show in Email

    Anyone know how I copy text and objects from pages and paste into Email, objects don't show in Email, thanks

    You can't expect Mail to support all the objects of Pages which can include anything up to charts generated from spreadsheet tables.
    Even if Mail was a superset of Pages, what would the recipients who don't have either Mail or Pages, make of it?
    Peter

  • How to use bean objects in java script

    function insertRow()
              var row=1;
              var tbl = document.all("TAU");
         var tr = tbl.rows(row);
         var td = tr.cells(0);
         var td2 = tr.cells(1);
         var td3 = tr.cells(2);
         row++;
         tr = tbl.insertRow();
         tr.setAttribute(false);
         td = tr.insertCell();
         td2 = tr.insertCell();
         td3 = tr.insertCell();
         td.innerHTML = "<html:text property='unit' value ='02' />";
         td2.innerHTML = "<html:text property='unit Id' />" ;
         td3.innerHTML = "<html:text property='unit Type' />" ;
    this is my code, it is basicaly add row at run time thru java scripts. i want to set property of beans with this script , in this code i foun error ie. "can not found bean in nay scope" so plz anybody can tell me how can i pass bean object to java script !!!!!!

    mmmh i'm not understanding so much....
    well... as i told before i'm working in oracle database environment and i'm developing a java procedure.
    now, i have this object
    CREATE OR REPLACE
    TYPE REPORT.FATTURA_OBJ AS OBJECT (
    POD VARCHAR2(1000),
    ID_FATTURA NUMBER,
    ID_FILE NUMBER,
    COERENZA_EA_F VARCHAR2(1000),
    COERENZA_ER_F VARCHAR2(1000),
    COERENZA_EA_M VARCHAR2(1000),
    COERENZA_EF_M VARCHAR2(1000),
    ANOMALIA VARCHAR2(1000),
    MOTIVO_INVALIDAZIONE VARCHAR2(1000),
    MATRICOLA_CONTATORE VARCHAR2(1000),
    POTENZA_DISPONIBILE VARCHAR2(1000),
    MEMBER PROCEDURE pulisci
    /and i need to work with it inside this procedure:
    CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED REPORT."Manage_Excel_ASMBS" AS
    import java.io.*;
    import java.io.IOException;
    import java.io.StringWriter;
    public class Manage_Excel_ASMBS
    public static void read_Excel(String inputFile,int var_Id_Caricamento, int var_Id_Distributore, String var_Distributore) throws SQLException, IOException
              **here i need to put what i'm reading inside the excel file into oracle objects**
    /can you please give me a sample ?
    thanks

  • How to deal future objects and wait calls

    Hi all,
    How can I handle Future objects if the Callable object calls a wait() into the call() method? If the Callable object is waiting for something, the call Future.get() throws an IllegalMonitorStateException.
    For example:
    public class Test {
        private final ExecutorService POOL = Executors.newFixedThreadPool(1);
        private static Random r = new Random(System.nanoTime());  
        List<Callable> waiting = new ArrayList<Callable>(10);
        public Test() {
            Future[] res = new Future[10];
            for (int i = 0; i < 10; i++) {
                    res[i] = execute();  
            synchronized (res) {
                for (int i = 0; i < 10; i++) {
                    try {
                        System.err.println(res.get(10L, TimeUnit.MILLISECONDS));
    } catch (InterruptedException e) {
    e.printStackTrace();
    } catch (ExecutionException e) {
    e.printStackTrace();
    } catch (TimeoutException e) {
    POOL.shutdown();
    System.err.println("size: " + waiting.size());
    private Future<Integer> execute() {
    return POOL.submit(new Executor());
    * @param args
    public static void main(String[] args) {
    Test t = new Test();
    private class Executor implements Callable<Integer> {
    public Integer call() throws Exception {
    Integer value = -1;
    try {
    value = r.nextInt();
    waiting.add(this);
    wait(2000);
    } catch (InterruptedException e) {
    // Thread.currentThread().interrupt();
    waiting.remove(this);
    return value;
    The Object.notify() documentation says:
    "This method should only be called by a thread that is the owner of this object's monitor. A thread becomes the owner of the object's monitor in one of three ways:
    * By executing a synchronized instance method of that object.
    * By executing the body of a synchronized statement that synchronizes on the object.
    * For objects of type Class, by executing a synchronized static method of that class.",
    so how can the main thread became the owner?

    Hello,
    HR objects are not supposed to be in the SPAU list during the upgrade. It might show though because of the coding error in note 519678. The error wrote entries of HR objects in the tabel SMODILOG which is not supposed to be.
    You can try the solution in the note 519678 to remove the entries of HR objects in SMODILOG and after that they will no longer be shown in SPAU.
    Regards,
    Joe

  • How to return custJava Object from Java Stored Function/Procedure to Java Application

    I WILL PAY $100 FOR SOLUTION.
    Oracle JDBC documentation gives step by step on how to return Oracle Type Object to Java Application. No question here.
    But is it possible to create Java Stored Function [getMyClass() ] which returns CUSTOM Java based object [MyClass] to Java application like:
    //java stored function
    class Foo
    public static MyClass getMyClass()
    return new MyClass();
    //java class I want to return to Java
    class MyClass
    public String getGreetings(String name)
    return "Hello " + name;
    I tried to do it using intermittent Oracle
    Type Object and OracleConnection map to make binding between Java->Oracle->Java. I could
    not get throgh meaningless run time ORA Errors. Any kind of help would be greatly
    appreciated. If you know the answer please
    post it or e-mail [email protected]
    null

    You don't say which version of the database you are on. There's an interesting looking article on OTN on handling CLOBs in JDBC in 10g. It may well be useful for earlier versions too (but no guarantees).
    Cheers, APC

  • How register COM object from java?

    Hi!
    In my user home directory I have myCOM.dll. My sign applet use this myCOM.dll. But before use this dll I must register it (by use regsvr32).When myCOM.dll will be success register my applet can work. The problem is that I can not get answer from regsvr3 (is myCOM.dll are successed registered or not, or is user has a grants to register COM object and so on.)
    Again, my java applet can work ONLY when myCOM.dll is registered.
    How I can register myCOM.dll from java applet and if registered is not success exit from java applet?

    I must not have been clear. I am not asking how to access a COM object using Java, we already have tools to do that.
    The question is whether there is a way to define a COM interface using Java. I want to code my COM object in Java. Right now we are using PowerBuilder to code COM objects. I would rather use Java.

  • How to copy a file from Java code

    I have written a file through Java code in folder, say, "A". Now, I want a copy of that file exactly the same in some other folder "B". How, it can be done?

    http://java.sun.com/docs/books/tutorial/essential/io/streams.html

  • How to  get the profile object in simple java class  (Property accessor)

    Hi All,
    Please guide me how to get the profile object in simple java class (Property accessor) which is extending the RepositoryPropertyDescriptor.
    I have one requirement where i need the profile object i.e i have store id which is tied to profile .so i need the profile object in the property accessor of the SKU item descriptor property, which is extending RepositoryPropertyDescriptor.
    a.I dont have request object also to do request.resolvename.
    b.It is not a component to create setter and getter.It is simple java class which is extending the RepositoryPropertyDescriptor.
    Advance Thanks.

    Iam afraid you might run into synchronization issues with it. You are trying to get/set value of property of a sku repository item that is shared across various profiles.
    Say one profile A called setPropertyValue("propertyName", value).Now another profile B accesses
    getPropertyValue() {
    super.getPropertyValue() // Chance of getting value set by Profile A.
    // Perform logic
    There is a chance that profile B getting the value set by Profile A and hence inconsistency.
    How about doing this way??
    Create PropertyDescriptor in Profile (i.e user item descriptor), pass the attribute CustomCatalogTools in userProfile.xml to that property.
    <attribute name="catalogTools" value="atg.commerce.catalog.CustomCatalogTools"/>
    getPropertyValue()
    //You have Profile item descriptor and also storeId property value.
    // Use CustomCatalogTools.findSku();
    // Use storeId, profile repository item, sku repository item to perform the logic
    Here user itemdescriptor getPropertyValue/setPropertyValue is always called by same profile and there is consistency.
    -karthik

  • How to copy the java concurren program in oracle application

    Hi All
    I am working in oracle Apps R12.
    In AP (Account Analysis Report) is registered as java concurrent Program.
    Now i need to customize this concurrent program and add two new column and two parameter in that.
    Could any one pls provide me the steps that how to copy the Java concurrent,and make a new customized program.
    Whether copying a java concurrent program is same as cp registered as oracle report.
    Thanks & Regards
    Srikkanth

    Hi Sir,
    Thanks for your reply.
    I have find the xml file form data definition and in that they have written Sql query and they have called a Package.
    And the i have also taken the class file from the path as mentioned.
    Now i need to customize this report by adding two parameter and i need to add two new column to display in the rtf.
    Can you pls tell me the steps to copy or how to customize this report.
    Regards
    Srikkanth

  • How to send data to bam data object through java code

    how to send data to bam data object through java code

    I've made a suggestion in other thread: https://forums.oracle.com/thread/2560276
    You can invoke BAM Webservices (Using Oracle BAM Web Services) or use JMS integration using Enterprise Message Sources (http://docs.oracle.com/cd/E17904_01/integration.1111/e10224/bam_ent_msg_sources.htm)
    Regards
    Luis Fernando Heckler

Maybe you are looking for

  • How to print  xml tag in other group

    I want to print G_EXCISE_DUTY_REG_NO group in g_headers. below are tags - <XXJAPRPOL> - <LIST_G_INIT_INFO> - <G_INIT_INFO> <MANUAL_PO_NUM_TYPE>NUMERIC</MANUAL_PO_NUM_TYPE> <C_COMPANY>Raychem RPG</C_COMPANY> <C_ORGANIZATION_ID>84</C_ORGANIZATION_ID> <

  • Reg_GRC 10.0 Integration with backend systems

    Hi Everyone, Could you please help me to find out  which all of the below products can be integrated with GRC 10.0 Access control. Click  Schedule PI System BOBJ - CMS BOBJ-DS-CMS SAP Mobile Platform - Derby Afaria ADP ARIS Cloud SOLMON Adobe Live Cy

  • Can Standalone OC4j 11g TP4 be runned on RedHat Linux  ?

    Hi , i have a web application(ADF/ADF Faces) developed with JDev 11g TP4. Iwant to install and run it on Standalone OC4J 11g, under Linux RedHat OS. In the OC4j release note it's written "Requires SUN JDK 5.0.11". However i want to ensure that the on

  • Is it possible to link in files based on a pattern?

    Is it possible to automatically link in php files in the way css, js and included and required includes are linked? The image is from Dw cs5, swedish, but I think you know what I mean. This shows the desired behavior based on a bug i found in cs5. Ev

  • Calculating the memory and performance of a oracle query

    Hi, I am now developing application in java with oracle as a back-end. In my application i require lot of queries to be executed. Hence, the system is getting is slow due to queries. So, i planned to develop one Stand-alone application in java, that