raphy Posted September 7, 2006 Share Posted September 7, 2006 Hello,I would like to tokenize my string separated by ";".Is it possible to use StringTokenizer with iReport?Thanks for your replyRaphy Link to comment Share on other sites More sharing options...
javydreamercsw Posted September 7, 2006 Share Posted September 7, 2006 Maybe if you explain a bit what your plans are we could answer. As a first guess it's possible using custom coding... Link to comment Share on other sites More sharing options...
raphy Posted September 8, 2006 Author Share Posted September 8, 2006 Hello,I am using a custom data source and using a field named "person". This field containing firstname, lastname, phone etc.. as string and each values separated by ";". My own datasource class containing getFildValue() returns a person's value as a string correctly. The question:How can I tokenize the person's string value to retrieve all separate data. (firstname, lastname, phone etc.. ) Thanks for your replyRaphy Link to comment Share on other sites More sharing options...
Giulio Toffoli Posted September 8, 2006 Share Posted September 8, 2006 An idea could be to write a java class (i.e. MyUtilities) with a static method (i.e. getToken()) working as follows: getToken( String str, int tokenNum) then you can use this class in your expressions: MyUtilities.getToken($P{PersonField}, 1) (this expression will take the first token from your person string). Giulio Link to comment Share on other sites More sharing options...
raphy Posted September 8, 2006 Author Share Posted September 8, 2006 Hello,Thanks for your prompt reply.I do as you mentioned in your reply. But when I compiling with iReport there is no error and when run my application there is an error message as follows: Errors were encountered when compiling report expressions class file:Tools cannot be resolved value = (java.lang.String)(Tools.getName()); The method implemented in my Tools.class is: public static final String getName () { return "raphy" ; } Thanks for your help.Raphy Link to comment Share on other sites More sharing options...
Giulio Toffoli Posted September 8, 2006 Share Posted September 8, 2006 be sure Tools is in the classpath: I suggest you to put it in the same directory as your report, or in the classes directory of iReport.In this second case you risk to have to restart iReport each time you modify the class in order to force the use of the new one. Giulio Link to comment Share on other sites More sharing options...
raphy Posted September 9, 2006 Author Share Posted September 9, 2006 Hello,I have my tools class as follows: public class Tools{ public static final String Name = "Raphy" ; public static final String getName () { return Name ; }} Code:public class Tools{ public static final String Name = "Raphy" ; public static final String getName () { return Name ; }} When I set the textfield expression for the textfield as "Tools.Name" and executing the report gave me the results "Raphy". This is correct. But when I set the textfield expression for the same textfield as "Tools.getName()" and when executing the report I got the error message as follows:java.lang.NoClassDefFoundError:Âtest/Tools The tools class and the report are in the same directory & and classpath set correctly. Please help meBest regardsRaphy Link to comment Share on other sites More sharing options...
raphy Posted September 9, 2006 Author Share Posted September 9, 2006 Hello,I have my tools class as follows: public class Tools{ public static final String Name = "Raphy" ; public static final String getName () { return Name ; }} Code:public class Tools{ public static final String Name = "Raphy" ; public static final String getName () { return Name ; }} When I set the textfield expression for the textfield as "Tools.Name" and executing the report gave me the results "Raphy". This is correct. But when I set the textfield expression for the same textfield as "Tools.getName()" and when executing the report I got the error message as follows:java.lang.NoClassDefFoundError:Âtest/Tools The tools class and the report are in the same directory & and classpath set correctly. Please help meBest regardsRaphy Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now