hermor
asked on
Explain Java Code
Please, I need some help with this Java code. This is not for a homework. What happens is that I am learning some JAVA, I understand part of the code but I am not sure. Can anyone explain me these two codes. Which are the classes, methods, objects, and what does each of the lines do? This is call that will communicate with an API. Thanks!
CustInquiry
----------------------
public InquiryResultSet searchForCusts (SearchBean search,int pageWanted,Cursor cursor){
int PageSize = 90;
CustInquiry inquiry =(CustInquiry) service.createCustInquiry( );
CustFilter Cust = new CustFilter();
inquiry.setSortDirection(2 );
inquiry.setPageNumber(page Wanted);
inquiry.setPageSize(PageSi ze);
String searchWord = "";
Cust.setFirstName(search.g etFirstNam e());
Cust.setLastName(search.ge tLastName( ));
Cust.setSsn(search.getTaxI d());
inquiry.setCustFilter(Cust );
if(cursor != null){
inquiry.setCursor(cursor);
}
sendMessage(inquiry, "Cust Inquiry failed", "error.CustInquiry", searchWord);
InquiryResultSet results = inquiry.getInquiryResultSe t();
return results;
}
-------------------------- ---------- ---------- ---------- ------
AcctInquiry
----------------------
public Collection getAcctInfo(String uniqueId) {
ServiceAccInquiry acctInquiry = service.createServiceAcctI nquiry();
acctInquiry.setUniqueID(un iqueId);
acctInquiry.setIncludeExte ndedBalanc es(true);
sendMessage(acctInquiry, "Info for uniqueId: '" + uniqueId + "'",
"error.acctInfo", uniqueId);
return acctInquiry.getAccounts();
}
CustInquiry
----------------------
public InquiryResultSet searchForCusts (SearchBean search,int pageWanted,Cursor cursor){
int PageSize = 90;
CustInquiry inquiry =(CustInquiry) service.createCustInquiry(
CustFilter Cust = new CustFilter();
inquiry.setSortDirection(2
inquiry.setPageNumber(page
inquiry.setPageSize(PageSi
String searchWord = "";
Cust.setFirstName(search.g
Cust.setLastName(search.ge
Cust.setSsn(search.getTaxI
inquiry.setCustFilter(Cust
if(cursor != null){
inquiry.setCursor(cursor);
}
sendMessage(inquiry, "Cust Inquiry failed", "error.CustInquiry", searchWord);
InquiryResultSet results = inquiry.getInquiryResultSe
return results;
}
--------------------------
AcctInquiry
----------------------
public Collection getAcctInfo(String uniqueId) {
ServiceAccInquiry acctInquiry = service.createServiceAcctI
acctInquiry.setUniqueID(un
acctInquiry.setIncludeExte
sendMessage(acctInquiry, "Info for uniqueId: '" + uniqueId + "'",
"error.acctInfo", uniqueId);
return acctInquiry.getAccounts();
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Which is the third API?
Of course they are all developed in Java but since they are not standard Java API but 3rd party so we can't tell much about what they do unless we have their code or documentation.
Of course they are all developed in Java but since they are not standard Java API but 3rd party so we can't tell much about what they do unless we have their code or documentation.
ASKER
Oh Ok, I understand. I am sorry because I don't have that information right now. I can accept more opinions regarding this code as well. Thanks!
Is that something in my first comment that you did not understand? Pls feel free to ask Q's....
ASKER
Thanks for writing again Mayankeagle.
Please confirm the following:
I think that:
Although the 'Cust' object is part of the CustFilter class, I am missing where the class is declared.
inquiry.setSortDirection(2 );
inquiry.setPageNumber(page Wanted);
inquiry.setPageSize(PageSi ze);
inquiry.setCursor(cursor);
These are object methods right? inquiry is the object and set... are methods. For example 'inquiry.setSortDirection( 2);' means that it is invoking the method 'setSortDirection(2)' on the object inquiry. What does the numer '2' mean in this example?
What does this exactly mean?
if(cursor != null){
inquiry.setCursor(cursor);
}
Is 'sendMessage' a Java command or what exactly it is?
'ServiceAccInquiry acctInquiry = service.createServiceAcctI nquiry();' I understand the first part, It is creating the 'acctInquiry' as part of the 'ServiceAccInquiry' class. Can you explain this part a bit more?
What does service in 'service.create...' mean?
I know these are a lot of questions, but I am sure they will be easy for you to answer. Thank you.
Please confirm the following:
I think that:
Although the 'Cust' object is part of the CustFilter class, I am missing where the class is declared.
inquiry.setSortDirection(2
inquiry.setPageNumber(page
inquiry.setPageSize(PageSi
inquiry.setCursor(cursor);
These are object methods right? inquiry is the object and set... are methods. For example 'inquiry.setSortDirection(
What does this exactly mean?
if(cursor != null){
inquiry.setCursor(cursor);
}
Is 'sendMessage' a Java command or what exactly it is?
'ServiceAccInquiry acctInquiry = service.createServiceAcctI
What does service in 'service.create...' mean?
I know these are a lot of questions, but I am sure they will be easy for you to answer. Thank you.
>> am missing where the class is declared.
It will probably be in another CustFilter.java file.
>> These are object methods right? inquiry is the object and set... are methods.
Yes.
>> What does this exactly mean?
>> if(cursor != null){
>> inquiry.setCursor(cursor);
>> }
Means you are calling the setCursor () method if the inquiry object and passing the cursor object to it. What the method does internally can be known only by seeing its code.
>> Is 'sendMessage' a Java command or what exactly it is?
No, it is probably also a method defined in some class.
>> Can you explain this part a bit more?
Its creating an object of the class 'ServiceAccInquiry.
>> What does service in 'service.create...' mean?
Its an object of some other class - can't see where service is defined in that method, so it must be a class level data member.
It will probably be in another CustFilter.java file.
>> These are object methods right? inquiry is the object and set... are methods.
Yes.
>> What does this exactly mean?
>> if(cursor != null){
>> inquiry.setCursor(cursor);
>> }
Means you are calling the setCursor () method if the inquiry object and passing the cursor object to it. What the method does internally can be known only by seeing its code.
>> Is 'sendMessage' a Java command or what exactly it is?
No, it is probably also a method defined in some class.
>> Can you explain this part a bit more?
Its creating an object of the class 'ServiceAccInquiry.
>> What does service in 'service.create...' mean?
Its an object of some other class - can't see where service is defined in that method, so it must be a class level data member.
ASKER
I've been reading a few books about Java during these days and I can understand much better your answer. Thanks a lot!
Great.
ASKER