Jump to content

String Tokenizer


raphy

Recommended Posts

  • Replies 7
  • Created
  • Last Reply

Top Posters In This Topic

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 reply

Raphy

Link to comment
Share on other sites

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

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

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 me

Best regards

Raphy

Link to comment
Share on other sites

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 me

Best regards

Raphy

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...