-
How to get currentPosition of a StringTokenizer object
I have an object instansiated from the StringTokenizer class. This class/object
has a privat property currentPosition. For my application I need to get hold
of this offsett telling where in the input string I am at a current stage
the parsing. How to I get access to the currentPosition???
rgds.
Geir A.
-
Re: How to get currentPosition of a StringTokenizer object
Hello Geir:
Subclass StringTokenizer and add a public getter for currentPosition:
public class MyStringTokenizer extends java.util.StringTokenizer{
public MyStringTokenizer(s){
super(s);
}
public MyStringTokenizer(s, d){
super(s, d);
}
public MyStringTokenizer(s, d, b){
super(s, d, b);
}
public int getCurrentPosition(){
return this.currentPosition;
}
}
This class assumes that currentPosition is an int - which I don't know off
the top of my head. If it is not an int, then substitute the appropriate
data type in the method signature.
Hope this helps.
Tom Duffy
"Geir Arnesen" <geir.arnesen@aftenposten.no> wrote:
>
>I have an object instansiated from the StringTokenizer class. This class/object
>has a privat property currentPosition. For my application I need to get
hold
>of this offsett telling where in the input string I am at a current stage
>the parsing. How to I get access to the currentPosition???
>
>rgds.
>
>Geir A.
-
Re: How to get currentPosition of a StringTokenizer object
Sorry, - but this gives me upon compile time "Error: (21) variable currentPosition
has private access in class java.util.StringTokenizer.
Any better clues??
Rgds.
Geir A.
"Tom Duffy" <td4729@hotmail.com> wrote:
>
>Hello Geir:
>
>Subclass StringTokenizer and add a public getter for currentPosition:
>
>public class MyStringTokenizer extends java.util.StringTokenizer{
>
>public MyStringTokenizer(s){
>super(s);
>}
>
>public MyStringTokenizer(s, d){
>super(s, d);
>}
>
>public MyStringTokenizer(s, d, b){
>super(s, d, b);
>}
>
>public int getCurrentPosition(){
>return this.currentPosition;
>}
>}
>
>This class assumes that currentPosition is an int - which I don't know off
>the top of my head. If it is not an int, then substitute the appropriate
>data type in the method signature.
>
>Hope this helps.
>
>Tom Duffy
>
>"Geir Arnesen" <geir.arnesen@aftenposten.no> wrote:
>>
>>I have an object instansiated from the StringTokenizer class. This class/object
>>has a privat property currentPosition. For my application I need to get
>hold
>>of this offsett telling where in the input string I am at a current stage
>>the parsing. How to I get access to the currentPosition???
>>
>>rgds.
>>
>>Geir A.
>
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