Jaxp xpath evaluate method node list parameter?

The javadoc for XPath.evaluate(String, Object, QName) says that the second parameter is the context "node or node list for example". I'm familiar with the concept of an XPath context node. What does it mean to pass a node list as the second argument?
With Xalan 2.7 and this xml:
<doc><a/></a></doc>
NodeList nl = (NodeList) xp.evaluate("//*", doc, XPathConstants.NODESET);
Number n = (Number) xp.evaluate("count(self::node())", nl, XPathConstants.NUMBER);
Results in zero.
NodeList nl2 = (NodeList) xp.evaluate("self::node()", nl, XPathConstants.NODESET);
Results in an empty node list.
Message was edited by:
queshaw

Specify the XML document as the context node.
InputSource inputSource =
    new InputSource(new FileInputStream(xmlDocument)));xmlDocument is the java.io.File object of the XML document.
NodeSet nodes =
    (NodeSet) xPath.evaluate(xpathExpression,
        inputSource, XPathConstants.NODESET);

Similar Messages

  • Using xpath.evaluate(): xpath exp with multiple namespaces

    Hi,
    I have to evaluate a xpath expression with parent node and child node having different namespaces. Like : env:parent/mig:child.
    I have set the namespacecontext for the child node[i.e., for the prefix 'mig'.]
    But am getting this error :
    javax.xml.transform.TransformerException: Prefix must resolve to a namespace: env
    How can I set the namespace context for both the parent and child nodes? Or is there are any other way of doing it?
    I cant use //mig:child as the requirement needs the whole xpath expression [env:parent/mig:child] to be given as input for the xpath.evaluate() method.
    Here's the code :
    File file = new File("D:\\Backup\\XMLs\\test.xml");
    Document xmlDocument = builder.parse(file);
    XPath xpathEvaluator = XPathFactory.newInstance().newXPath();
    xpathEvaluator.setNamespaceContext(new NamespaceContextProvider("env", "http://xmlns.oracle.com/apps/account/1.0"));
    NodeList nodeList =
    (NodeList)xpathEvaluator.evaluate("/env:parent/mig:child", xmlDocument,
    XPathConstants.NODESET);
    xpathEvaluator.setNamespaceContext(new NamespaceContextProvider("mig", "http://xmlns.oracle.com/apps/account/1.0"));
    Thanks in advance.

    If you want, I can help you tomorrow. Call me at my nieuwegein office or mail me at marco[dot]gralike[at]amis[dot]nl
    I have some time tomorrow, so I can help you with this. My next presentation for UKOUG will be on XML indexes strategies anyway...
    In the meantime and/or also have a look at:
    XML Howto's (http://www.liberidu.com/blog/?page_id=441) specifically:
    XML Indexing
    * Unstructured XMLIndex (part 1) – The Concepts (http://www.liberidu.com/blog/?p=228)
    * Unstructured XMLIndex (Part 2) – XMLIndex Path Subsetting (http://www.liberidu.com/blog/?p=242)
    * Unstructured XMLIndex (Part 3) – XMLIndex Syntax Dissected (http://www.liberidu.com/blog/?p=259)
    * Unstructured XMLIndex Performance and Fuzzy XPath Searches (http://www.liberidu.com/blog/?p=310)
    * Structured XMLIndex (Part 1) – Rules of Numb (http://www.liberidu.com/blog/?p=1791)
    * Structured XMLIndex (Part 2) – Howto build a structured XMLIndex (http://www.liberidu.com/blog/?p=1798)
    * Structured XMLIndex (Part 3) – Building Multiple XMLIndex Structures (http://www.liberidu.com/blog/?p=1805)
    The posts were based on Index for XML with Repeated Elements maybe that is a bit better to read than on my notepad on the internet (aka blog)
    Edited by: Marco Gralike on Oct 28, 2010 7:51 PM

  • How to correctly use the evaluate() method in Xpath?

    I have this sample code. I would expect the output to be something like
    Channel #0
    Channel Name : Ch1
    Channel #1
    Channel Name : Ch2
    Channel #2
    Channel Name : Ch3
    but all I get is
    Channel #0
    Channel Name : Ch1
    Channel #1
    Channel Name : Ch1
    Channel #2
    Channel Name : Ch1
    Do I misuse the evaluate() method? It seems the evaluate method disregards the"doc" start node I pass in and always start from the beginning of the XML...
    Very appreciate your suggestion. Thank you very much.
    import javax.xml.xpath.*;
    import org.xml.sax.InputSource;
    import java.io.StringReader;
    import org.w3c.dom.Document;
    import org.w3c.dom.NodeList;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    public class EvaluateTest {
         * @param args
         public static void main(String[] args) {
              String myxml = "<?xml version='1.0' encoding='utf-8' ?><mytest><ChannelList>" +
              "<Channel><ChannelId>0001</ChannelId><ChannelName>Ch1</ChannelName></Channel>" +
              "<Channel><ChannelId>0002</ChannelId><ChannelName>Ch2</ChannelName></Channel>" +
              "<Channel><ChannelId>0003</ChannelId><ChannelName>Ch3</ChannelName></Channel>" +
              "</ChannelList></mytest>";
              //Get the Document object
              Document doc = null;
              try {
                   InputSource inputSource = new InputSource();
                   inputSource.setCharacterStream( new StringReader(myxml));
                   DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                   DocumentBuilder db = factory.newDocumentBuilder();
                   doc = db.parse(inputSource);
                   //Iterate thru the Channel list
                   NodeList channellist = getSubElements(doc, "/mytest/ChannelList/Channel");
                   if (channellist==null)
                        System.out.println("the channel list is null");
                   for (int i=0, len=channellist.getLength(); i<len; i++) {
                        System.out.println("Channel #" + i);
                        /*{XPathFactory factory = XPathFactory.newInstance();
                        XPath anxpath = factory.newXPath();
                        String result = (String)anxpath.evaluate(".", channellist.item(i), XPathConstants.STRING);
                        out.println(result);}*/
                        String name = getTagValue(channellist.item(i), "//ChannelName/text()", -1);
                        System.out.println("Channel Name : " + name);
              catch ( Exception e ) {
                   e.printStackTrace();
                   return;
         //Get the text value of a tag from a document object using XPath method
         static public String getTagValue(Object doc, String xpathstr, int index) throws Exception {
              String result = "";
              if ((doc==null)     || (xpathstr==null) || "".equals(xpathstr))
                   return result;
              XPathFactory factory = XPathFactory.newInstance();
              XPath xpath = factory.newXPath();
              result = (String)xpath.evaluate(xpathstr, doc, XPathConstants.STRING);
              if (result==null)
                   result = "";
              return result;
         static public NodeList getSubElements(Object doc, String xpathstr) throws Exception {
              if ((doc==null)     || (xpathstr==null) || "".equals(xpathstr))
                   return null;
              XPathFactory factory = XPathFactory.newInstance();
              XPath xpath = factory.newXPath();
              Object result = xpath.evaluate(xpathstr, doc, XPathConstants.NODESET);
              return (NodeList)result;
    }

    Sorry here is a repost of the code. Didn't realize there is a code tag feature.
    import javax.xml.xpath.*;
    import org.xml.sax.InputSource;
    import java.io.StringReader;
    import org.w3c.dom.Document;
    import org.w3c.dom.NodeList;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    public class EvaluateTest {
        * @param args
       public static void main(String[] args) {
          String myxml = "<?xml version='1.0' encoding='utf-8' ?><mytest><ChannelList>" +
                      "<Channel><ChannelId>0001</ChannelId><ChannelName>Ch1</ChannelName></Channel>" +
                                 "<Channel><ChannelId>0002</ChannelId><ChannelName>Ch2</ChannelName></Channel>" +
                      "<Channel><ChannelId>0003</ChannelId><ChannelName>Ch3</ChannelName></Channel>" +
                      "</ChannelList></mytest>";
          //Get the Document object
          Document doc = null;
          try {
                InputSource inputSource = new InputSource();
                inputSource.setCharacterStream( new StringReader(myxml));
                DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                DocumentBuilder db = factory.newDocumentBuilder();
                doc = db.parse(inputSource);
                //Iterate thru the Channel list
                NodeList channellist = getSubElements(doc, "/mytest/ChannelList/Channel");
                if (channellist==null)
                      System.out.println("the channel list is null");
                for (int i=0, len=channellist.getLength(); i<len; i++) {
                      System.out.println("Channel #" + i);
                      String name = getTagValue(channellist.item(i), "//ChannelName/text()", -1);
                      System.out.println("Channel Name : " + name);
          } catch ( Exception e ) {
                e.printStackTrace();
                return;
       //Get the text value of a tag from a document object using XPath method
       static public String getTagValue(Object doc, String xpathstr, int index) throws Exception {
          String result = "";
          if ((doc==null)     || (xpathstr==null) || "".equals(xpathstr))
                return result;
          XPathFactory factory = XPathFactory.newInstance();
          XPath xpath = factory.newXPath();
          result = (String)xpath.evaluate(xpathstr, doc, XPathConstants.STRING);
          if (result==null)
                result = "";
          return result;
       static public NodeList getSubElements(Object doc, String xpathstr) throws Exception {
          if ((doc==null)     || (xpathstr==null) || "".equals(xpathstr))
                return null;
          XPathFactory factory = XPathFactory.newInstance();
          XPath xpath = factory.newXPath();
          Object result = xpath.evaluate(xpathstr, doc, XPathConstants.NODESET);
          return (NodeList)result;
    }

  • Using XPath to create nodes

    Hi,
    Obviously the main use of XPath is to query the state of an XML document... the equivalent to a "select" statement in SQL.
    DOM4J has methods that allow you to use XPath as the equivalent to "insert" statements in SQL. You can specify an XPath like "/Hello/World/Value = 3" and apply this XPath to an XML document so that it creates something like this for you:
    <Hello>
    <World>
    <Value>3</Value>
    </World>
    </Hello>
    This is actually very useful for an investment banking application that I'm working on.
    The problem with DOM4J is that it doesn't handle attributes or conditionals well. If you specify
    /Hello[@name=2]/World = 3
    I would expect
    <Hello name=2>
    <World>3</World>
    </Hello>
    to be produced. Instead, it produces
    <Hello[@name=2]>
    <World>3</World>
    </Hello>
    These are all simple examples. What I'm doing in real life is using XPath to insert nodes into a complicated XML document that already has a lot of structure. I'm only adding one or two elements to big documents.
    Is there anything at all like this available in the JDK 1.5 release. I've had a good look, and XPath looks like it's only for queries. Is this correct?

    I think this might do what you need...
    // Create a dummy XML document
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    DocumentBuilder db = dbf.newDocumentBuilder();
    InputStream bais = new ByteArrayInputStream("<test><e1/></test>".getBytes());       
    Document doc = db.parse(bais);
    // Define the XPath expression to "select" the parent element in the document       
    XPath xpath = XPathFactory.newInstance().newXPath();
    XPathExpression xpathExpression = xpath.compile("/test/e1");    
    // Select the parent node (should probably chuck an ex if not present)       
    Node node = (Node) xpathExpression.evaluate(doc, XPathConstants.NODE);
    // Create and append the child element
    node.appendChild(doc.createElement("newElement"));
    // Convert the Document into a string
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DOMSource source = new DOMSource(doc);
    StreamResult result = new StreamResult(baos);
    TransformerFactory transformerFactory = TransformerFactory.newInstance();
    Transformer transformer = transformerFactory.newTransformer();
    transformer.transform(source, result);
    // <?xml version="1.0" encoding="UTF-8"?><test><e1><newElement/></e1></test>
    System.out.println(baos.toString());

  • How to binding incoming xml node list to the tree control as dataProvider

    Recently, I faced into one issue: I want to binding incoming xml node (it's not avaliable at start) list to the tree control as a dataProvider.
    Since the incoming xml node list is not avaliable at beginning but I needs to bind it to the tree, so I create one virtual one in the xml, and prepare to remove it before the tree is shown. (ready for the actual node adding). But It did not work.
    Please see the presudo-code here:
    1.  Model layer(CsModel.as)
    public class CsModel
            [Bindable]
            public var treeXML:XML=<nodes><car label="virtualOne" id="1">
                                   </car></nodes>;
            (Here, I want to build binding relationship on the <car/> node,
             one 'virtual/stub' node is set here with lable="virtualOne".
             But this node will be deleted after IdTree
             control is created completely.)      
            [Bindable]
            public var treeData:XMLList =new XMLListCollection(treeXML.car);
    2. view layer(treePage.mxml)
            private var _model:CsModel = new CsModel();
            private function addNode():void
                    var newNode:XML=<car/>;
                    newNode.@label="newOne";
                    newNode.@id=1;
                    _model.treeXML.appendChild(newNode);
                             private function cleanData():void
                                     delete _model.treeXML.car;
            <mx:VBox height="100%" width="100%">
            <mx:Button label="AddNode" click="addNode()" />
            <mx:Tree id="IdTree"  labelField="@label"
              creationComplete="cleanData()"
              dataProvider="{_model}"/>
        </mx:VBox>
    3. Top view layer (App.Mxml)
    <mx:application>
        <treePage />
    </mx:application>
    For method: cleanData(),It's expected that when the treePage is shown, we first delete the virutalOne to provide one 'clear' tree since we don't want show virtualOne to the user. The virutalOne node just for building the relationship between treeData and treeXML at beginning. But the side effect of this method, I found, is that the relationship between treeXML and treeData was cut off. And this leads to that when I added new node (by click the 'addNode' button) to the xmlXML, the xmlData was not affected at all !
    So Is there any other way to solve this issue or bind the incoming xml node list to the xmlListCollection which will be used as Tree control's dataProvider ?

    If u want to display the name : value then u can do like this
    <xsl:eval>this.selectSingleNode("name").nodeName</xsl:eval> : <xsl:value-of select="name" />

  • Getting the XPath from a Node

    Hey Folks, have a scenario where i need to link my data, i.e one node points to another node, e.g
    <data>
    <liability id="1">
    <value> 10000 </value>
    </liability>
    <asset id = "2">
    <value> 20000 </value>
    </asset>
    </data>
    so take the case above, i have a house which is an asset and i have a mortgage(liability) on that house, now i want to show that in my asset that there is a liability on this asset, so i need to come up with a way to link my asset to a liability, now easiest way in my thinking is just point to the XPath of the liability!! Now problem is this, at the data level that im working at, i know what data node im working on but i dont know its absolute path, in my case the above XML is just a snippet of what im dealing with, there is more hierarchical levels in my document!! Maybe im blind but i couldnt see from the API how to get the XPath of a node?? is there existing API which does this or will i have to go ahead and write something to come up with the XPath!! or does anyone have any other suggestions as to how i would do my link??
    The way i see my XML when finished is something like this
    <data>
    <liability id="1">
    <value> 10000 </value>
    </liability>
    <asset id = "2">
    <value> 20000 </value>
    <liability> /data/liability[@id='1'] </liability>
    </asset>
    </data>
    any thoughts are welcome,
    cheers,
    LL

    A better design would be to make your "id" attribute the key... looking back at your post, it seems that you have done that already. So your XML should just look something like this:<data>
    <liability id="1">
    <value> 10000 </value>
    </liability>
    <asset id = "2" liabilityid="1">
    <value> 20000 </value>
    </asset>
    </data>Then when your code needs to match the liability to the asset, you can easily build the XPath to find it. (Of course if there can be more than one liability per asset, you shouldn't use a liabilityid attribute as I did in the example.)
    PC&#178;

  • Using Java Reflection to call a method with int parameter

    Hi,
    Could someone please tell me how can i use the invoke() of the Method class to call an method wiht int parameter? The invoke() takes an array of Object, but I need to pass in an array of int.
    For example I have a setI(int i) in my class.
    Class[] INT_PARAMETER_TYPES = new Class[] {Integer.TYPE };
    Method method = targetClass.getMethod(methodName, INT_PARAMETER_TYPES);
    Object[] args = new Object[] {4}; // won't work, type mismatch
    int[] args = new int[] {4}; // won't work, type mismatch
    method.invoke(target, args);
    thanks for any help.

    Object[] args = new Object[] {4}; // won't work, type
    mismatchShould be:
        Object[] args = new Object[] { new Integer(4) };The relevant part of the JavaDoc for Method.invoke(): "If the corresponding formal parameter has a primitive type, an unwrapping conversion is attempted to convert the object value to a value of a primitive type. If this attempt fails, the invocation throws an IllegalArgumentException. "
    I suppose you could pass in any Number (eg, Double instead of Integer), but that's just speculation.

  • How to pass table to in a method as a parameter

    Hi
    I need to pass one table in one method to another method as a parameter.
    ex: it_tab type zvalue(DDIC).
         send_mail( it_tab)like this i need to pass. How to do this.
    Please help me.
    Thanks & Regards
    SUN

    Hello,
    You'll need a table category that has the same structure of your internal table. Suppose you need to pass an internal table of type SCARR: you'll actually pass a parameter of type SCARR_TAB (look for it into tcode SE11).
    Remember that in a OOP scope, you cannot have header line in your internal tables.
    Regards,
    Andre

  • Why the non-cluster SQL Server appeared in the cluster nodes list

    1, I install the node rs6 standalone, Why it appeared in the cluster node list by inquiry the dmv?
    2, how to removed the rs6 from the cluster node list ?
    by "set -clusterownernode -resource "XXXASQL" -owners NODE1,NODE2"?
    But how to find the resource  name? I tried to use window cluster name, SQL cluster name, and SQL role name , All of them say failed to get the cluster object.
     3,how to set the owers to {}, I try below, but failed.

    IMHO, sys.dm_os_cluster_nodes  DMV is associated with the SQL Server
    Operating System (SQLOS), sys.dm_os_cluster_nodes returns one row for each node in the failover cluster configuration.
    As you are running standalone instance on cluster I am assuming this information is being picked from
    OS and not from RS6 SQL instance.
    As you have confirmed Is_cluster is false and if you don’t see RS6 instance in failover cluster manager I don’t think anything damaged here. Everything looking as expected, dont change owner node as its standalone instance.

  • HOWTO remove an entry from the node list...

    Hi all,
    does anybody know, howto remove an entry from the node list TAB ?
    I recentyl updated my system to 11.5.10.2 including enabling autoconfig.
    Now, concurrent processes won't start, because of two entries in the node list tab (yes, it's a single node installation!). There are two entries, one with the IP-address and one with the hostname.
    Can somebody tell me howto remove this obsolete entry?
    Thanks.

    1) Login as APPS user to SQL*Plus
    2) Issue the following:
    SQL> EXEC FND_CONC_CLONE.SETUP_CLEAN;
    SQL> COMMIT;3) Run AutoConfig
    For more details, please refer to:
    Note: 260887.1 - Steps to Clean Nonexistent Nodes or IP Addresses from FND_NODES
    https://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=260887.1

  • Do we have any method to list out the servers that are critical and the component/monitor causing the server to turn into critical state in SCOM 2012

    Hello Team,
    We are monitoring 1000 servers in our environment and out of 1000 servers, we have approximately 100 servers showing as critical state on the server state view.
    We can get the critical servers list from SCOM console, but we are not able to get the information about the component responsible for the server to be critical. Using Health explorer to find the root cause for 100 servers is really impossible and time consuming.
    Do we have any method to list out the servers that are critical and the component/monitor causing the server to turn into critical state?
    Advance thanks for your help.
    Regards,
    Dinesh
    Thanks &amp; Regards, Dinesh

    Hi,
    As far as I know alerts with severity as criticla may cause windows computer in a critical state, we can try below code to find all critical alerts:
    get-alert -criteria 'ResolutionState=0 AND Severity=2' | select Name,ResolutionState,TimeRaised | export-csv c:\Alerts.txt
    Criteria Syntax http://msdn.microsoft.com/en-us/library/bb437603.aspx
    Values to use.
    Resolution State 
    Severity Values for Alerts
    0       =   New
    0 = INFORMATIONAL
    255   =   Closed
    1 = WARNING
    2 = CRITICAL
    Hope this helps.
    Regards,
    Yan Li
    Regards, Yan Li

  • Retrieve XPath of a node : Urgent

    Hey guys,
    I have a small problem.
    I have an application in which a XML is displayed in browser and when user selects a node i want the XPath of that node.
    I got a handy javascript utility to do the same but it is not very efficient.
    Can anybody tellme how to do it.
    Thanks

    Crosspost: http://forum.java.sun.com/thread.jspa?threadID=5173128

  • Reading DMA FIFO using Invoke method node

    Hi
    I am trying to read a DMA FIFO using invoke method node to read the data in the FIFO on RT.
    It works fine but the problem is that it consumes a lot of CPU if the timeout is increased. Can
    anyone tell why this is happening and if this is the desired behaviour then what other methods i can
    use to avert this.
    Please help at the earliest
    Regards
    Amit

    Hi
    Can anybody help me as it is urgent ,
    What i further found out is that is that it is eating up a lot of meory when continuosly polled up in a looop....
    Regards
    Amit Ahuja

  • LV 2012 Calling FPGA method node with reference 0x000000 does not return error

    Why is it the case that when an FPGA reference is initialised with a constant (resulting in it having the value 0x000000), it doesn't return an error when passed to a method node?
    I'm having some weird behaviour in my code where 99% of the time when run, it doesn't function correctly (the reference is deemed valid despite being 0x000000) and then when initialised to an actual running FPGA, the FPGA doesn't seem to respond to commands.
    Edit: Further to the message, linking the reference to a NaN/Reference comparison returns true. So it's detected as being not a reference, but yet the method node doesn't see this as an error.

    Hi Alex,
    Can you please post a screenshot of the portion of your Host vi where you are creating the FPGA reference?
    Thanks,
    Allie

  • Swap method for list of Nodes not working correctly

    Ok so I'm basically messing with a list of nodes, swapping, reversing, and cycling. My only problem is the swap method that I am implementing.
    It starts out with a boolean to see if the position is valid, and if so, it will go through the instructions.
    The first condition is that if the the position to be swapped( which is named secondPosition) equals 2, it goes through a certain method, which I have no problem with...BUT in the second condition, if secondPosition is greater than 2, I have to use a different way of swapping them...Of course, I have to change their references and not positions, since that's the way nodes work. Also, at the end of the list of nodes, the reference will be null, so I have to deal with that as well, which is to set it to the first node in the list. I am very sure I am writing the code for swapping correctly, but yet it seems that the lists that I swap in the second condition don't even change at all! I don't really see how its happening...could anyone help???
    Here is the run:
    TESTING SWAP
    Trying an invalid swap (position 0)
    Passed test
    Passed test
    Trying an invalid swap (position 4/list size 3)
    Passed test
    Passed test
    Trying a valid swap (position 3/list size 3)
    Passed test
    *** Failed test (bad list on swap)
    *// the result is supposed to be: John Jack Jill, but the list stays in its initial state*
    Jack
    Jill
    John
    Trying a valid swap (position 3/list size 4)
    Passed test
    *** Failed test (bad list on swap)
    *// result is supposed to be Jill Jack John Jerry, yet the list stays in its initial state*
    Jill
    John
    Jack
    Jerry
    Trying a valid swap (position 4/list size 4)
    Passed test
    *** Failed test (bad list on swap)
    *//result is supposed to be Jill Jack John Jerry, yet it still stays in its initial state*
    Jill
    John
    Jack
    Jerry
    Trying a valid swap (position 2/list size 3)
    Passed test
    Passed test
    Here is the method:
         public boolean swap(int secondPosition)
              boolean valid = false;
              if( secondPosition == 2)
                   valid = true;
                   Node<T> nodeOne = this.firstNode;
                   Node<T> nodeTwo = nodeOne.getNextNode();
                   Node<T> nodeThree = nodeTwo.getNextNode();
                   firstNode = nodeThree;
                   nodeThree = nodeOne;
                   nodeOne = nodeTwo;
              else if( secondPosition > 2 && secondPosition <= length)  //this loop is where I'm having problems
                   valid = true;
                   Node<T> nodeBefore = getNodeAt(secondPosition -2);
                   Node<T> nodeOne = nodeBefore.getNextNode();
                   Node<T> nodeTwo = nodeOne.getNextNode();
                   Node<T> nodeAfter = nodeTwo.getNextNode();
                   if( nodeAfter == null)
                        nodeAfter = firstNode;
                   nodeBefore = nodeTwo;
                   nodeTwo = nodeOne;
                   nodeOne = nodeAfter;
              return valid;
         }

    I'm sure there is a bug in swap method.
    if( secondPosition == 2)
                   valid = true;
                   Node<T> nodeOne = this.firstNode;
                   Node<T> nodeTwo = nodeOne.getNextNode();
                   Node<T> nodeThree = nodeTwo.getNextNode();
                   firstNode = nodeThree;
                   nodeThree = nodeOne;
                   nodeOne = nodeTwo;
              }All this code does not actually reorder your nodes. All it does is move a bunch of pointers about. For example firstNode will end up pointing to the last node in the list but this does not automagically make it the first node. If you were to make a call to firstNode .getNextNode I'm sure it will return null and not the next node in the list like you think.

Maybe you are looking for

  • SQL Query C# Using Execution Plan Cache Without SP

    I have a situation where i am executing an SQL query thru c# code. I cannot use a stored procedure because the database is hosted by another company and i'm not allowed to create any new procedures. If i run my query on the sql mgmt studio the first

  • EXCEL - when I click in a cell or in the formula bar, the page jumps down.

    When I click in a cell or in the formula bar, the page jumps down.  I am not clicking on the border, so it's not that.  It doesn't happen in all documents... just some.  I copied the info to a new doc and it didn't do it right away, then started happ

  • Satellite A660 - message Wireless Radio is disabled

    I recently had some issues with my Belkin Router and after a reset was performed I attempted to update my wireless security settings. This failed and I was met with the message "Wireless radio is disabled. To configure wireless security, please enabl

  • Print space

    Hi, would any mind helping me in solving this problem? Because I stuck now. The problem is to print a space in a binary tree (not binary search tree) import java.util.*; class BinaryTree     public static void main(String args[])         Scanner inpu

  • My MacBook Pro WILL NOT START. Powers on, grey apple screen loads then shuts off

    Fairly new MacBook Pro with OXLion. When I try to turn on the computer, the startup noise and screen appear (grey loading screenwith apple icon). A loading bar at the bottom of the screen fills about a third up, then the computer shuts down again. AN