ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » If exists equivalent in Java compute

Post new topic  Reply to topic
 If exists equivalent in Java compute « View previous topic :: View next topic » 
Author Message
Veera B
PostPosted: Sun Mar 17, 2013 11:49 pm    Post subject: If exists equivalent in Java compute Reply with quote

Voyager

Joined: 16 Jan 2013
Posts: 76

Hi All,

I need to do a if exists .. then logic in Java compute to find if a purticular tree element is present in environment.

not finding much from infocenter ...

please suggest how to achieve this ?
Back to top
View user's profile Send private message
Esa
PostPosted: Mon Mar 18, 2013 12:03 am    Post subject: Reply with quote

Grand Master

Joined: 22 May 2008
Posts: 1387
Location: Finland

To find out if an element exists in a message tree you can issue MbElement.getFirstElementByPath(), MbElement..evalueateXPath() or MbMessage.evalueateXPath() and examine the result.
Back to top
View user's profile Send private message
Tibor
PostPosted: Mon Mar 18, 2013 5:02 am    Post subject: Reply with quote

Grand Master

Joined: 20 May 2001
Posts: 1033
Location: Hungary

I've just played with getFirstElementByPath() ten minutes ago and you can get a null pointer as a result, if there is no such an element.

OFF: Hi Esa
Back to top
View user's profile Send private message
nukalas2010
PostPosted: Mon Mar 18, 2013 5:40 am    Post subject: Reply with quote

Master

Joined: 04 Oct 2010
Posts: 220
Location: Somewhere in the World....

Dear Veera,
You can try somethign like this..

Code:

MbElement oReqRoot = contact admin.getMessage().getRootElement();
MbElement oName = oReqRoot.getFirstElementByPath("/XMLNSC/Request/Name");
      String sName = null;
      if (oName == null)// if it is null the string has been assigned to
                        // null
      {
         sName = null;
      } else
         sName= oName.getValueAsString();
Back to top
View user's profile Send private message
Veera B
PostPosted: Mon Mar 18, 2013 6:42 pm    Post subject: Reply with quote

Voyager

Joined: 16 Jan 2013
Posts: 76

nukalas2010 wrote:
Dear Veera,
You can try somethign like this..

Code:

MbElement oReqRoot = contact admin.getMessage().getRootElement();
MbElement oName = oReqRoot.getFirstElementByPath("/XMLNSC/Request/Name");
      String sName = null;
      if (oName == null)// if it is null the string has been assigned to
                        // null
      {
         sName = null;
      } else
         sName= oName.getValueAsString();


Thank you nukalas2010. your logic worked . I don't know java, which made it a bit complicated, but your explanation was so clear.
Back to top
View user's profile Send private message
Esa
PostPosted: Tue Mar 19, 2013 12:17 am    Post subject: Reply with quote

Grand Master

Joined: 22 May 2008
Posts: 1387
Location: Finland

nukalas2010 wrote:

Code:

MbElement oReqRoot = contact admin.getMessage().getRootElement();


I wonder if this is going to compile

Do we really need this kind of parental control?
Back to top
View user's profile Send private message
Veera B
PostPosted: Tue Mar 19, 2013 12:59 am    Post subject: Reply with quote

Voyager

Joined: 16 Jan 2013
Posts: 76

Esa wrote:
nukalas2010 wrote:

Code:

MbElement oReqRoot = contact admin.getMessage().getRootElement();


I wonder if this is going to compile

Do we really need this kind of parental control?


Nope it will not compile, but the advantage of using IDE's for developing code, makes it simpler to eliminate such syntax or naive errors ...

I may not know java, but i sure know programming ..

i used nukalas2010's logic to develop below code ..

Code:
MbElement oReqRoot = oGlobalEnvironment.getRootElement();
            MbElement oName = oReqRoot.getFirstElementByPath("/variables/status");
                  String sName = null;
                  if (oName == null)// if it is null the string has been assigned to
                                    // null
                  {
                     sName = null;
                  } else
                  { 
                     sName = getValue(oGlobalEnvironment.getRootElement(), "variables/status").toString();

                  }
[/quote]
Back to top
View user's profile Send private message
Esa
PostPosted: Tue Mar 19, 2013 1:19 am    Post subject: Reply with quote

Grand Master

Joined: 22 May 2008
Posts: 1387
Location: Finland

Yes, Veera.

I was just referring to this forum's way to automatically replace any words or acronyms that it thinks may be "bad words" with "contact admin".

But in this case nukalas may actually have written a bad word for us to see. .getMessage() is a method of the class MbMessageAssembly. Maybe he named the instance of it with a shorthand name. Like the first three letters of the word "assembly"...

Which would result to ass. But as you can see, it does not get converted to "contact admin", so it is not a bad word in context of mqseries.net. Neither is it's british version arse.

Maybe he created a New ASsembly and named it using the letters that I have written in upper case: contact admin - yes, that's it!

contact admin!
Back to top
View user's profile Send private message
nukalas2010
PostPosted: Tue Mar 19, 2013 3:34 am    Post subject: Reply with quote

Master

Joined: 04 Oct 2010
Posts: 220
Location: Somewhere in the World....

Esa wrote:
nukalas2010 wrote:

Code:

MbElement oReqRoot = contact admin.getMessage().getRootElement();


I wonder if this is going to compile

Do we really need this kind of parental control?


lol.. It's pretty wonder. I didn't mentioned any bad words except the word called {inA s s e m b l y} there. Is it really a bad word ???
I just taken this name as below..
Code:
 public void evaluate(MbMessageAssembly inA s s e m b l y) throws MbException {


Now its time to the list of words which it may think it is a "bad word".. before its going to punch me again...
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » If exists equivalent in Java compute
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.