Implementing recursive taskflows

Hi
We have a requirement that a taskflow is allowed to call itself. As per documentation this seems to be allowed.
These taskflows should be opened as a dialog.
While i am able to invoke the taskflow recursively the issues i am facing:
1. If i a open the task flow recursively, the previously opened taskflow dialog window is not visible.
The currently open one is hiding it visually. Tried resizing the window but didn't help.
When i close one taskflow the previous task flow becomes visible.
Is it possible to keep the previous task flow visible?
2. I am unable to handle the return event from the recursive task flows.
I invoke these task flows from a button which has a returnListener but the method is never executed except for the base page from where i invoke the first time.
Please let me know.
Cheers,
Raj

Hi Raj,
1. Yes - this should work. The previously launched dialog should be covered with an opaque glass pane that you can see though, but you should still be able to see it. Can you move the newer window? What display style are you using, external window or inline-popup?
2. The dialog returnListener behavior is part of the ADF Faces layer of ADF. You may want to post that part of your question in the ADF Faces forum.
Dave

Similar Messages

  • Is it possible to implement Recursive CTE query in MDX to Cube dataset?

    I have data with hierarchical relationship like this:
    Release -> Features -> PBI/Bugs -> Tasks/Test Case. I have two datasets Work Item and Work Item Linked to get this hierarchical information.
    The data looks like this:
    Something like if I pass a Release ID, I need to get all the children and sub-children also. Basically a report like this:
    I did this by implementing a recursive CTE query with warehouse tables. But it takes more time to load. SO trying to find the possibility using MDX and querying the cube datasets

    Hello,
    There is nothing stopping you from querying the cache to see what is in it. However, this will only take into account items that are already in the cache. If you need a query to return items that are potentially not in the cache, you need to query the database, have the query return keys, and then request those keys through Coherence - which will in turn pull the items from the database as needed.
    Regards,
    -Dave

  • Possible bug while implementing recursion

    Hey,
         Either I am going complete nuts and not seing the most obvious mistake or there is really a bug, hope someone can help.  I have a herirachical xml document that I would like to flatten out.  I wrote a cfm code and it works perfectly, but when I put them logic in cfscript it does not work.   From what I can tell, when recursion returns back, and continues on, the old value in the loop is overwritten (counter value is not what it should be when the state was saved and recursion took place). I don't know how else to explain this.   Here is code in cfm and in cfscript, can you see something I am not? 
    function flattenXML works just fine, but flattenXML2 does not.
    [code]
    <cfset xmlfile = "/xDocs/TAXONOMY_XMLDOC_131.xml" />
    <cfset myDoc = xmlParse(xmlfile) />
    <cfset theRootElement = myDoc.XmlRoot>
    <cfdump var="#theRootElement.XMLChildren[1]#"/>
    <cfset st = flatternXML2(theRootElement, "", structNew())/>
    <cfdump var="#st#"/>
    <cffunction name="flatternXML" access="private" returntype="struct">
    <cfargument name="node" type="xml" required="true">
    <cfargument name="str" type="string" required="true">
    <cfargument name="lineage" type="struct" required="true" >
              <cfset t_name="NONE"/>
              <cfif structKeyExists(arguments.node.XmlAttributes, "NAME")>
                        <cfset t_name = arguments.node.XmlAttributes['NAME']/>
    </cfif>
              <cfif len(arguments.str)>
                        <cfset arguments.str &= "; " & left(arguments.node.XmlName, 1) & "_" & t_name/> 
    <cfelse>
                        <cfset arguments.str = left(arguments.node.XmlName, 1) & "_" & t_name/>
    </cfif>
              <cfif ArrayLen(arguments.node.XmlChildren) eq 0>
                        <!---<cfoutput>#arguments.str#</cfoutput></br>--->
                        <cfset hash_key = hash(arguments.str, "MD5")/>
                        <cfif not structKeyExists(arguments.lineage, hash_key)>
                                  <cfset structInsert(arguments.lineage, hash_key, arguments.str)/>
      <cfelse>
                                  <cfoutput>duplicate lineage #arguments.str#<br/></cfoutput>
      </cfif>
                        <cfreturn arguments.lineage/>
    </cfif>
    <cfloop from="1" to="#arraylen(arguments.node.XmlChildren)#" index="i">
                        <cfset arguments.lineage = flatternXML(arguments.node.XmlChildren[i], arguments.str, arguments.lineage)/>
    </cfloop>
              <cfreturn arguments.lineage/>
    </cffunction>
    <cffunction name="flatternXML2" access="private" returntype="struct">
    <cfargument name="node" type="xml" required="true">
    <cfargument name="str" type="string" required="true">
    <cfargument name="lineage" type="struct" required="true" >
    <cfscript>
                        //set name and prefix, of the current node
                        t_name = "NONE";
                        if (structKeyExists(arguments.node.XmlAttributes, "NAME"))
                                  t_name = arguments.node.XmlAttributes['NAME'];
                        if (len(arguments.str))
                                  arguments.str &= "; " & left(arguments.node.XmlName, 1) & "_" & t_name;
      else
                                  arguments.str = left(arguments.node.XmlName, 1) & "_" & t_name;
                        //recursion end condition
                        if (arraylen(arguments.node.XmlChildren) eq 0) {
                                  writeoutput(arguments.str & "</br>");
                                  hash_key = hash(arguments.str, "MD5");
                                  if (not structKeyExists(arguments.lineage, hash_key))
                                            structInsert(arguments.lineage, hash_key, arguments.str);
      else
                                            writeoutput("duplicate lineage: " & arguments.str & "<br/>");
                                  return(arguments.lineage);
                        for(j=1; j lte arraylen(arguments.node.XmlChildren); j=j+1){
                                  writeoutput("before " & j & "_" & arraylen(arguments.node.XmlChildren) & "<br/>");
                                  arguments.lineage = flatternXML2(arguments.node.XmlChildren[j], arguments.str, arguments.lineage);
                                  writeoutput("after " & j & "_" & arraylen(arguments.node.XmlChildren) & "<br/>");
                        return(arguments.lineage);
    </cfscript>
    </cffunction>
    [/code]

    To help you with another pair of eyes, I will just translate the tag version into a script. You can then compare. Here it is:
    <cfscript>
    var t_name="NONE";
    var output="";
    var hash_key="";
    var updatedStr="";
    var updatedLineage=structNew();
    var returnStruct=structNew();
    updatedStr = arguments.str;
    updatedLineage = arguments.lineage;
    if (structKeyExists(arguments.node.XmlAttributes, "NAME")) {
        t_name = arguments.node.XmlAttributes['NAME'];
    if (len(updatedStr)) {
        updatedStr &= "; " & left(arguments.node.XmlName, 1) & "_" & t_name;
    else
        updatedStr = left(arguments.node.XmlName, 1) & "_" & t_name;
    if (ArrayLen(arguments.node.XmlChildren) eq 0) {
         //output=output & updatedStr & "<br/>";
        hash_key = hash(updatedStr, "MD5");
        if (not structKeyExists(updatedLineage, hash_key)) {
            structInsert(updatedLineage, hash_key, updatedStr);
        else
        //output=output & "duplicate lineage: " & updatedStr & "<br/>";
    //returnStruct.output=output;
    //returnStruct.updatedLineage=updatedLineage;
    for (i=1; i LTE arraylen(arguments.node.XmlChildren); i=i+1) {
        updatedLineage = flatternXML(arguments.node.XmlChildren[i], updatedStr, updatedLineage);
        //updatedLineage = flatternXML(arguments.node.XmlChildren[i], updatedStr, updatedLineage).updatedLineage;
    return updatedLineage;
    // return returnStruct;
    </cfscript>
    It is good practice to leave variables in the arguments scope unmodified during the processing of a function. Modifying them increases complexity. This comes into play when you maintain the code later, as we are now doing here. The solution is obvious. Just define a new updatable variable. In this case, updatedStr and updatedLineage.
    You will also notice I have commented out all display statements. It is bad practice to make a function do more than one thing at once. The function returns a variable. It should therefore not have the added burden of writing output. If you wish to return output plus some other result(s), then store them in a struct and return that.

  • N-ary Trees non-recursive traversal algorithms

    Hi,
    Non-recursive traversals are needed when you are unsure how big the tree's will be. So far all the algorithms I have seen either use their own internal stack
    or threading to climb back up the tree.
    Here's my attempt that seems to work but I would value so critical evaluation
    * An extension of the CommonAST that records the line and column
    * number.  The idea was taken from <a target="_top"
    * href="http://www.jguru.com/jguru/faq/view.jsp?EID=62654">Java Guru
    * FAQ: How can I include line numbers in automatically generated
    * ASTs?</a>.
    * @author Oliver Burn
    * @author lkuehne
    * @version 1.0
    * @see <a target="_top" href="http://www.antlr.org/">ANTLR Website</a>
    public class DetailAST
        public AST getFirstChild()
        public AST getNextSibling()
        public int getChildCount()
        public DetailAST getParent()
        public int getChildCount(int aType)
        public String getText()
    }This was cut back just to give you enough info
         public static AST getLeftMostChild(DetailAST ast) {
              DetailAST tempAst = ast.getFirstChild();
              while (tempAst.getFirstChild() != null) {
                   tempAst = tempAst.getFirstChild();
              return tempAst;
         public static void traverseASTInOrder(DetailAST root) {
              DetailAST current = getLeftMostChild(ast);
              processNode(current);
              while (current != root) {
                   if (current == current.getParent().getFirstChild()) {
                        processNode(current.getParent());
                   if (current.getNextSibling() != null) {
                        DetailAST sibling = current.getNextSibling();
                        if (sibling.getChildCount() != 0) {
                             current = (DetailAST) getLeftMostChild(sibling);
                             processNode(current);
                        } else {
                             current = sibling;
                             processNode(current);
                   } else {
                        current = current.getParent();
            // do stuff at inorder traversal
         public static void processNode(AST current) {
              System.out.println(current.getText());
         }for pre-order and post-order John Cowan put forward this algorithm
    http://lists.xml.org/archives/xml-dev/199811/msg00050.html
    traverse(Node node) {
        Node currentNode = node;
        while (currentNode != null) {
          visit(currentNode); //pre order
          // Move down to first child
          Node nextNode = currentNode.getFirstChild();
          if (nextNode != null) {
            currentNode = nextNode;
            continue;
          // No child nodes, so walk tree
          while (currentNode != null) {
            revisit(currentNode)     // post order
            // Move to sibling if possible.
            nextNode = currentNode.getNextSibling();
            if (nextNode != null) {
              currentNode = nextNode;
              break;
           // Move up
           if (currentNode = node)
          currentNode = null;
           else
          currentNode = currentNode.getParentNode();
      }Any comments, criticisms or suggestions ?
    regards
    David Scurrah

    Stack is recursion? As far as I know recursion is when
    function (method) calls itself. Just using some
    Collection, which java.util.Stack implements is not
    recursion.
    Regards
    PawelStacks are used to implement recursive algorithms. What happens in most languages when you make a function call? Each function has an "activation record" where it stores its local variables and parameters. This activation record is usually allocated on a stack. Thus for any recursive algorithm, there is a non-recursive algorithm that uses a stack.
    In the OP's case you don't need a stack because of the peculiarities of tree traversal when you have a pointer to the parent node. (Namely, no cycles and you can get back to where you've been) So the algorithms he gave should work fine.
    My only "criticism" would be that it may be more useful to implement these algorithms with the iterator pattern. So you would have a tree with some functions like:
    public class Tree{
        public TreeIterator inOrderIteraror();
        public TreeIterator preOrderIterator();
    }Where the TreeIterator would look like a java.util.Iterator, except maybe you want some additional utility methods in there or something.
    Other than that, non-recursive algorithms are defnitely the way to go.

  • Do I correctly use recursion to write the below file?

    import javax.swing.JOptionPane;
    public class PowerTwoRecursion {
    public static void main(String[] args){
    long x,result;
    String input;
    input = JOptionPane.showInputDialog( "Enter the integer ");
    x = Integer.parseInt( input );
    result = powerTwo( x );
    JOptionPane.showMessageDialog(null,"The answer is " + result);
    System.exit (0);
    //Recursive definition of method powerTwo
    static public long powerTwo(long number){
    if(number == 0)     {
    return 1;//2 to the power of 0 is 1
    }else
    return(long)Math.pow(2,number) ;//return the answer}
    Please teach me to correct! Thank much!

    To correctly implement recursion, you need to define two things:
    1. Simplify the problem. Reduce each problem into the same problem, but simpler.
    2. Find the stopping case. The situation where you have the answer, so as to stop the recursion.
    In this case, powerTwo can be defined in the following way: (^ represents "to the power of")
    2 ^ 3 = 2 ^ 2 * 2
    and
    2 ^ 2 = 2 ^ 1 * 2
    In general, 2 ^ n = 2 ^ (n-1) * 2
    Next, the stopping case is what you have sort of coded:
    2 ^ 0 = 1
    So instead of using the Math.pow function, call your own function again to calculate the power of the smaller n, and multiply the result by 2.

  • Is it possible to reuse 1 taskflow on top of 3 different models?

    Hi,
    using JDEV 11.1.2.3. and want to implement 1 taskflow that will be used in 3 different applications using 3 different models.
    Is this possible?

    Isn't this the same question you asked in this thread https://forums.oracle.com/thread/2613427 ?
    Your question in not clear to me. A task flow encapsulates a unit of work. If you use e.g. a table in the task flow, there have to be some model to provide data for this table. This model is encapsulated in the task flow too.
    Per this definition you can reuse the task flow.
    If you mean to use different models (each of hte applications uses different models to provide data to the table from different sources) this isn't impossible but hard to do. Duncan Mills blogged about a solution here https://blogs.oracle.com/groundside/entry/adaptive_connections
    Timo

  • Reporting Against Level Reference Build Method

    All,
    I created a hierarchy in Essbase using the Level Reference build method since the data is in a bottom-up. The data is laid out like so:
    Statement
    --Assets
    ----Calc 1
    ------Calc 2
    --------Major Category 1
    --------Major Category 2
    --------Major Category 3
    ------Major Category 4
    ----Major Category 5
    --Liabilities
    ----Major Category 6
    Originally I had this in a generation reference, but that didn't work since we don't have a consistent number of layers for each item. Next I was thinking a parent-child relationship, but this doesnt work because major categories fall at different levels. Finally, I'm thinking level reference is the way to go since we can have different layers of parents for each lowest level member and the data can be laid out the way we need. (Let me know if you disagree with this approach).
    This works fine in the cube...however, when I import this into the BI Administration tool it only sees generations, not levels. How can I get it to pull in the levels so that I can add individual levels to a report?
    I'm planning on following this method to create the report: http://oraclebizint.wordpress.com/2008/01/10/oracle-bi-ee-101332-achieving-financial-template-layouts-using-pivot-tables/. However, when I do that with generations it has blanks because not all of the major categories are at the same generation. I'm hoping levels will clear this up, but if anyone has a suggestion of a different way to achieve this layout let me know.
    Thanks!

    Hi Corel,
    I am stucking on how and where to call the recursive function for performing Tree-level hierarchy for my above code.!
    in my hierarchy level, one parent has multiple children which in turn so many children and so on... if i am in the least level node , then i need to get the details of its related nodes which has been linked by that node.
    For ex: i have the structure somthing like below:
    Parent
    / | \
    child1 child2 child3
    |
    c5
    |
    c6
    In the above structure, Parent and its children sharing the same address id(56122). Suppose, If i am in c6, then i could get the references for C6->C5->child2->Parent as the hierarchy from ResultSet. child1 and child3 has been ignored ,since there is no implementation for saving their references.
    I am stucking here that i dont know how to save these ref. and get them too in the company hierarchy structure. Remember , i need to refer only the company which is sharing the same address id. there could be other address id assosiated with other children (not included here)
    any suggestion how to save the references by implementing recursive procedure from the resultset.
    thanks in advance

  • Removing Address Bar from external window popup

    Hi
    I have a modal popup which opens up another popup as an external window. Now this child popup window is consistent with the original browser window and shows toolbar and address bar.Is there an attribute of commandButton in ADF which can help me remove the address bar in the child popup ?
    I have removed the toolbar by setting windowEmbedStyle="window" in the commandbutton that launches the external window popup.
    PS - Both the parent and child popup dialogs have been implemented as taskflows.The parent popup is a modal dialog and not a browser window.
    Thanks

    from the parent popup.. open the child popup using javascript. .add a c
    <af:commandButton text="Click Me">
    <af:clientListener type="action" method="popUp"/>
    </af:commandButton>
    function popUp(e) {
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=600,height=600');");
    }

  • No matter which page i run... i should get the home page first

    Hi,
    i have some jspx pages in my application
    No matter which page i run... i should get the home page first
    Because there is a chance that the user might remember the url of a certain page and copy paste that one in the browser... in such type of scenarios also home page should come first
    After i implemented Adf security in the redirect upon successful login i took the home.jspx page... but it is not going to home.jspx when i run some 'x' page and give the credentials for authentication.
    This for our project they dont want to implement at taskflow level for each and every taskflow... is there any higher level where we can implement such feature because home page is common for all.
    Thanx,

    No matter which page i run... i should get the home page first
    Because there is a chance that the user might remember the url of a certain page and copy paste that one in the browser... in such type of scenarios also home page should come first
    After i implemented Adf security in the redirect upon successful login i took the home.jspx page... but it is not going to home.jspx when i run some 'x' page and give the credentials for authentication.Just create a filter and put some logic like the one below:
      if(!request.getRequestURI().contains("homePage"))
                 ((HttpServletResponse)servletResponse).sendRedirect("http://server/yourApp/faces/homePage");
      else
          filterChain.doFilter(request, servletResponse);You can easily search for how to create a web application filter and register it in web.xml ..

  • Stackoverflow

    HI,
    I have an applet that displays images thrown a diaporama. Sometimes images are reloaded because its content has changed. All works fine, excepts I got an error 12 or 14 hours after like : Stackoverflow error, then diaporama stop.
    I don't know what happen, for me all is ok, but I think perhaps I have to look about Threads that run the diaporama, but how ? Any Idea ?

    Stack overflow generally has one cause: you are either intentionally or unintentionally implementing recursion which is causing an infinite regression, which exhausts the stack, which is what is used to keep track of nested method calls.
    What does that mean? It means you have something like this:public void blowTheStack(int n)
        int m = n;
        if (m > 0)
            blowTheStack(m);
    }when the VM enters method blowTheStack(), it checks the passed variable n and effectively passes that value to itself. On entry, it checks the passed variable n and effectively passes that value to itself. On entry, it checks the passed variable n and effectively passes that value to itself... even though there is a check for 0 (which would bottom out the recursion), it never changes that value, with the result that if the initial value is anything but 0, it keeps calling iteself and calling itself in deeper and deeper nested levels until the call stack overflows. It's kinda like an infinite loop, except for the fact that instead of looping, it is regressing within itself. That's why it's called an "Infinite Regression". Kinda like the Morton salt container that has a picture of a girl holding a Morton salt container, that has a picture of a girl holding a Mortin salt container...
    Infinite regression can also be more devious.public void blowTheStackWithHelp(int n)
        int m = n;
        if (m > 0)
            helpBlowTheStack(m);
    public void helpBlowTheStack(int n)
        int m = n;
        if (m > 0)
            blowTheStackWithHelp(m);
    }here, neither method is calling itself, but each method calls the other. Once again, because nothing changes from method entry to the method call, it just repeats (or more exactly, propagates) the method calls until the stack is exhausted.
    Recursion can be a very useful strategy. It frequently makes very complicated problems simple. But you have to be careful to ensure that the recursion "bottoms out" eventually so it can climb back up the stack by successively returning from all thise nested method calls.

  • Split string based on number of characters

    Hi,
    I have a simple map where I receive a Streetname out of the source and have to write that streetname to the Address1 element in the destination. The issue is that the destination Address1 element can only contain 100 characters.
    If it has more then 100 characters then I have to split the string into the Address2 element.
    The next question is how I can do it the good way so that the string would be split between spaces and not in the middle of a word. For example:
    Streetname1 Streetname2 Streetname3 Streetname4 Streetname5 Streetname6 Streetname7 Streetname8 Streetname9
    The hundredth character is between t and r in Streetname9. So the cleanest solution would be to place everything in address1 and Streetname9 in address 2.
    How can I achieve this?

    I had faced a similar situation in which output element could only contain 100 characters after that i had to split rest of characters in batch of 100 characters and repeated the element.
    This was achieved by implementing recursion through XSLT. For this I created a template which will return a substring a generate an element with that element. This template will take two parameters-1) Complete string 2) Length (100 in your case).
    check the below article for a sample
    http://www.codeproject.com/Articles/16866/Recursive-XSL-Templates
    Thanks,
    Prashant
    Please mark this post accordingly if it answers your query or is helpful.

  • Pixel "selection" algorithm

    I am trying to write an algorithm that operates on a 2-bit (Black and white) image. Given a black pixel, it needs to be able to find all other black pixels that are directly connected to it, or indirectly connected to it (connected to it by being connected to another pixel that is directly connected to it, however many levels deep). (If you have ever used photoshop before, I am basically refering to the idea of a very simplified magic wand selection tool) I currently have this method implemented recursively, it traverses through the pixels as though they were a tree structure, which works for smaller images, but for larger images (longer paths to traverse) it gets a stack overflow. Does anyone know of any algorithms that would preform this kind of a task?

    It is fairly easy to convert a recursive "connected-components" algorithm to an iterative one. You just have to maintain your own stack (Use one of the List implementations in java.util)
    Remember that the pathological case for a recursive connected components algorithm results in the depth of recursion equaling the number of pixels in the image.
    matfud

  • How to Get days of Month in SSRS

    How can I get days of Month in SSRS report...?

    Hi RedZinc,
    You can do it by writing a SQL query to generate days of month. For doing recursive to generate days,
    Use CTE with recursive logic:
    Declare @StartDate as DATE, @EndDate as DATE;
    SET @StartDate = CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(GETDATE())-1),GETDATE()),101)
    SET @EndDate = CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(DATEADD(mm,1,Getdate()))),DATEADD(mm,1,Getdate())),101)
     ;WITH cte AS (
                   SELECT @StartDate AS myDate
                   UNION ALL
                   SELECT DATEADD(Day,1,myDate)
                   FROM cte
                   WHERE DATEADD(Day,1,myDate) <=  @EndDate
      Select * from CTEtested the above sql code and it is working. CTE will be easy to implement recursive stuff.
    Maruthi... http://www.msbimaru.blogspot.com/

  • Difficult program design

    i have a question here. It is a quite difficult program design for me. Any body can help me?
    As legend has it, some priests in the Far East endeavored to move a stack of disks from one peg to another. There were 64 disks in all. Each had a unique diameter. They were stacked in order of diameter from the largest on the bottom to the smallest on the top. Three pegs were available, with the stack beginning on peg 1. The stack needed to be moved to peg 3. The restrictions were that only one disk could be moved at a time, and that a disk could not be placed upon another that was smaller. The legend claims that if and when completed, the world would end.
    To speed the onset of Armageddon, complete a Java program that solves the Towers of Hanoi. Two methods need to be implemented to complete the class TowersOfHanoi. The method main must prompt the user for the number of disks with which to run the simulation. Store the input into the variable numDisks, which is already declared in the method main. Assume the input will be a positive integer.
    The method move is the workhorse, and must be implemented recursively. Its prototype follows.
    protected static void move(int n, int from, int to, int temp);
    The first parameter is the number of disks to move. The second is the peg upon which the disks to be moved currently reside. The third is the peg onto which those disks will be moved. The fourth is the extra peg, used as a temporary holding spot to facilitate the move. The method move must implement the following formula.
    Formula to Move n Disks
    move n - 1 disks to the temporary peg
    move 1 disk to the destination peg
    move n - 1 disks to the destination peg
    Picture moving the stack by hand, disregarding, for now, the restriction that only one disk can be moved at a time. To move a stack of n disks, grab all but the last disk and place that sub-stack onto the temporary peg. Move that last (largest) disk to the destination peg. Grab the sub-stack from the temporary peg and move it on top of the (largest) disk now residing on the destination peg. The restriction that a larger disk couldn't be placed upon a smaller one has not been violated. The recursion comes into play in the part where the sub-stack is moved. To move a stack of n disks requires, based on the formula, moving a stack of n - 1 disks. This smaller task can be solved with the same formula. The new (smaller) task becomes moving n - 1 disks from one peg to another. The base case occurs when the method move is called to move just one disk (when the parameter n is 1). During, and only during, the invocation of the method move in which the parameter n is 1, the method move must print a line of instruction describing the move, as in the following example.
    Move top disk from peg <from> to peg <to>
    <from> is simply the second parameter of the method move, and <to> is the third. The fourth parameter, the temporary peg, is not used in the output.

    Looks a bit like homework, tell us how far you've got and which particular points you're stuck on and people might be willing and able to help.
    Actually I suspect if you search Google for 'Tower of Hanoi' you'll probably find lots of help.

  • Hashtables and Vectors

    Hi there !!!
    Today I made some stuff but still a lot more needs to be done.
    So first of all let me explain what is all about.
    I have to make a hashtable that contains a String as a key and a vector as a value associated with that String.The following classes extend Relation (this is an interface)
    Analogy,Cause and so on.
    The instances have as fields DestinationID and SourceID .
    The table sorts the instances as follows : the objects with the same SourceID are put in a vector that is mapped to that SourceID.There is a second table that does the same but for the DestinationID-s
    The tables I have implemented recursively
    Here is the code for one of them:
    public class AnnotationThread1 {
        private Vector v = new Vector();
        private Hashtable h_sourceID = new Hashtable();
        private Hashtable h_destinationID = new Hashtable();
        private Vector leaves = new Vector();
    /** Creates a new instance of AnnotationThread1 */
        public AnnotationThread1() {}
    /** Creates the hashtable (recursively) the key is the SourceID and the
    *value is a vector that contains all the nodes that have the same SourceID
        public Hashtable add(Relation r){
            String sourceID = r.getSourceID();
            Vector v = (Vector) h_sourceID.get(sourceID);
            //if the Vector is null we create a new one
             if (v == null) v = new Vector();
            //if we add the same node twice the second will be neglected
              if (!v.contains(r)){
               v.add(r);
               h_sourceID.put(sourceID,v);
          return h_sourceID;
        }Now i should also retrieve the so called leaves : here the ID -s that are not SourceID -s . (they are not parents so to say).I have done that for every single object (i chech whether the given Relation possesses a leaf or not) but still I can not come up with an idea how to retrieve all leaves and for example to have them in a vector .
    Here is the code how I check if one ID is a leaf or not:
    /** Asks if a given ID is a leaf or not(uses the add() method)
    *@param Relation r
    *@return false if the node does not have a leaf and true otherwise
        public boolean ifLeaf(Relation r){
          boolean ifleaf = false;
          String leaf = r.getDestinationID();
          if (!h_sourceID.containsKey(leaf)){ ifleaf = true; }
          return ifleaf;
        }If anyone has ideas I will be very glad.
    The same problems I have with finding the root.
    Thanks in advance...

    OPS I forgot to mention how is the table actually created.Well in the main class i have something like:
    public static void main(String args[]){
          AnnotationThread1 example = new AnnotationThread1();
          BackgroundInformation a = new BackgroundInformation(0.1f,0.3f,"a","b");
          example.add(a);
          Analogy b = new Analogy(0.2f,0.1f,"a","c");
          example.add(b);
          SupportArgument c = new SupportArgument(0.2f,0.1f,"b","d");
          example.add(c);The Strings are as mentioned the SourceID and the DestinationID.
    for example after writing
    System.out.printlnexample.add(c);I will get as an output(in NetBeans):
    a=[collate.AnnotationThread.BackgroundInformation@1f12c4e,    collate.AnnotationThread.Analogy@93dee9]}

Maybe you are looking for