How to get currentPosition of a StringTokenizer object


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: How to get currentPosition of a StringTokenizer object

  1. #1
    Geir Arnesen Guest

    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.

  2. #2
    Tom Duffy Guest

    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.



  3. #3
    Geir Arnesen Guest

    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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center