[jdom-interest] passing string from jdom tree to if statement

vonderLuft, Andrew vonderluft.andrew at con-way.com
Wed May 15 09:08:10 PDT 2002


Try using java method .equals

/**
 * <mailto:vonderluft.andrew at con-way.com>
 * Desk: 503.450.6055   Fax: 503.450.5790           
 * CON-WAY I.T. <www.con-way.com>
 * @author: Andrew vonderLuft 
 */



-----Original Message-----
From: Trond Fuglestad [mailto:tfuglest at c2i.net]
Sent: Wednesday, May 15, 2002 8:54 AM
To: jdom-interest at jdom.org
Subject: [jdom-interest] passing string from jdom tree to if statement


I am trying to get the contents of a an element in a jdom tree, and then use
this value (a String) in an if-statement.
My problem is, that when i try to use this String in the if-statement, it
does not match, and the else-statement is printed.
What I find strange is that when I use System.out.println it prints the
right value.
Very grateful if anyone can help me with this!

Here is the code:

private void docType (Document doc)
  { Element chk = doc.getRootElement();
    String type =
chk.getChild("header").getChild("command").getTextNormalize(); //Or
getText() or getTextTrim()

    System.out.println(type);  //Used for testing purposes, prints Send
    System.out.println(type.length()); //Used for testing purposes, prints 4
    if (ok == "Send")
    {
      System.out.println("Send loop");
    }
    else
    {System.out.println("feil");}


Trond Fuglestad

_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com



More information about the jdom-interest mailing list