Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to Set Array in Value 3  RSS feed

 
Sharon Wong
Ranch Hand
Posts: 37
IBM DB2 Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Team,

I have a ini file
this is the format.
%F[ACCTTYPECD|ACMAST|ACCTNO=AAF12236|COMPANYID=1]/.csv

remarks:
After value 3 will not fix, may be have add 2 value or above..


value 1 (ACCTTYPECD) = field
Value 2(ACMAST) = table
after value 3 is condition

the ini file value will detect in servlet...
at servlet there i have write


how to write coding after value 3 in array in java?
 
Swastik Dey
Rancher
Posts: 1812
15
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you please elaborate your question little more.
 
Stefan Evans
Bartender
Posts: 1836
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Couple of comments on the code:

This logic looks wrong:


Because value3 is "F", it will never have a '|' character in it.
Can you explain what "value3" is? Maybe give that variable a better name.


- You have set up a loop through all the elements in your parts array. Then within that loop, you refer to the elements within the parts array by index.
You should do one or the other. Either loop through the elements in the array doing the same to each one, OR refer to elements by their index.
As it is, it looks like you will be doing the same logic multiple times unnecessarily.

If I understand your point, the first two entries on the line have special meaning, the remaining ones (however many there are) can presumably all be dealt with in the same manner.
In that case I would use code something like:


>
 
Norm Radder
Ranch Foreman
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the purpose of the for loop on line 7? The statements inside the for loop explicitly access elements in the part array? The variable str is ignored until line 16.

You need to add some comments to that section of code describing what the for loop is for and what the statements inside of the for loop are trying to do.
 
Sharon Wong
Ranch Hand
Posts: 37
IBM DB2 Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Stefan Evans. Your commend already solve my issue.

Thanks all for commend. Sorry, my poor english already giving trouble for you.

Thanks and Best regards
Sharon
 
Campbell Ritchie
Marshal
Posts: 55799
164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stefan Evans wrote:. . .
. . .
Another thing is that you should not use | on its own in a regex. The pipe character | is a metacharacter so it must be escaped to "\\|" if you want it as a regex. You can read what it means in the Java™ Tutorials.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!