Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-15-2008, 11:07 AM
Member
 
Join Date: Apr 2008
Posts: 3
a_iyer20 is on a distinguished road
Accessing boolean Values of another values in one class.
Hi All,
I have 2 classes. say Class A and Class B. My logic is coded in a method in class B. I am accessing this method of class B by creating an instance of class B in class A.

To explain better:
Class A{

ClassB b = new ClassB();
b.parse();
}

Class B{

parse(){
// some logic code.
}

At the end of processing the logic in parse() of Class B, I wish to set a boolean flag in Class B. such that after parse() returns what it has to, I will check the flag value and process some stuff in Class A. How can I design my solution? I tried using a static flg value in Class B. But this will not hold good in my case, because there are concurrent users to sign in to my application. Please guide and help.

Thanks,
Ashok.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 04-15-2008, 11:25 AM
sanjeevtarar's Avatar
Senior Member
 
Join Date: Apr 2008
Location: Delhi(India)
Posts: 249
sanjeevtarar is on a distinguished road
Hi Ashok,

Why do not you return boolean value from parse method directly..?

boolean parse(){

boolean flag;
// some logic code.
// set flag

return flag;
}

after calling parse method from class A get this boolean variable and do more....

If i misunderstand then correct me.

sanjeev

Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 04-15-2008, 12:27 PM
Member
 
Join Date: Apr 2008
Posts: 3
a_iyer20 is on a distinguished road
Accessing boolean Values of another values in one class.
Hi Sanjeev,

Actually the parse() returns a arrayList to me. I cannot use it to return boolean flag. I tried using a setter/getter to get the boolean flag value. Seems Ok. I am testing a few conditions.

Is there a better way I could handle this.

Ashok.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 04-15-2008, 01:40 PM
sanjeevtarar's Avatar
Senior Member
 
Join Date: Apr 2008
Location: Delhi(India)
Posts: 249
sanjeevtarar is on a distinguished road
Ok Ashok,

do one thing..

public ArrayList parse(){
boolean flag;
ArrayList templist = new ArrayList();
ArrayList dataList = new ArrayList();


///// do processing

templist.add(flag);
templist.add(datalist);

return templist;

}

When you get this arraylist Fist get(0)--> boolean flag and then get(1) your data list.

OK

If still some problem let me know..


sanjeev
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 04-15-2008, 02:04 PM
Member
 
Join Date: Apr 2008
Posts: 3
a_iyer20 is on a distinguished road
Hey Sanjeev,

I think your solution is good! Thanks. I have not yet tried but I was meanwhile using this:

In ClassB, I created a private boolean variable to hold a flag value.

then using getter/setter modifying the flag and accessing it from ClassA. But I think you solution suits my design.

Thanks,
Ashok.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Byte Values javaplus New To Java 1 06-23-2008 01:08 AM
A utility class that parses a Comma Separated Values (CSV) file Java Tip java.io 0 04-16-2008 11:58 PM
I want to get values from login jsp trill JavaServer Pages (JSP) and JSTL 1 08-07-2007 08:33 AM
Accept 2 values .... danny000 New To Java 1 07-31-2007 03:12 PM
Passing the Values Lagarto Database 1 07-16-2007 04:03 AM


All times are GMT +3. The time now is 03:09 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org