-
StringTokenizer help
I have a method that takes a class that has strings stored in the left hand
side and right hand side like this: A,B> C,D where '>' is the middle delimeter.
I have read in the string correctly, but I am having some trouble doing
manipulation on it. The objects are stored in a LinkedList object. What
I am trying to do is to parse the right side. I take an object that has
a left side of A,B and a right side of C,D. If the right side only has one
token, I insert it into a new list. if it has more than one, I take the
first token, place it with the left side, insert it into the new list. Take
the second token, put it with the left side, insert it into the new list....until
there are no more tokens.
A,B > C,D would become A,B > C and A,B > D.
I am having so trouble with the following code, and being rather new to programming,
I am sure I am just not seeing the flow of the program. Thanks to anyone
who can help.
public static void stepSeven()
{
System.out.println( "\nlist: " );
StringTokenizer w;
for ( int k = 0; k < list.size(); k++ )
{
// Get the current DbTemplate Object
DbTemplate dbTemplateObject = (DbTemplate)(list.get(k));
// Assign it to the temp DbTemplate object
DbTemplate tmp = new DbTemplate();
tmp = dbTemplateObject;
// Assign the right side of the FD to S
String s = tmp.getRightSide();
// Tokenize the string
w = new StringTokenizer(s, ",");
// More than one token in the right side
if(w.countTokens() > 1)
{
tmp.setRightSide(w.nextToken());
tmp.setfD();
//fdList.add(tmp);
while(w.hasMoreTokens())
{
tmp.setRightSide(w.nextToken());
tmp.setfD();
//fdList.add(tmp);
}
}
else
{
fdList.add(tmp);
}
}//end for
}// end stepSeven
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks