[1650] in java-interest

home help back first fref pref prev next nref lref last post

extending string functionality.

daemon@ATHENA.MIT.EDU (Graham Matthews)
Wed Sep 13 02:14:33 1995

Date: Wed, 13 Sep 1995 12:59:33 +1000
From: Graham Matthews <graham@pell.anu.edu.au>
To: java-interest@java.sun.com

I have a Java Language question. It probably has a simple answer, but I
have not found it.

I have a collection of string parsing routines written in a language called
Python (these routines don't change the strings in any way, rather they 
return information from within the string (eg. maximal length substrings 
satisfying patterns, etc). Now I have translated them into Java, and would 
like to allow them to be user on Java Strings (i.e. objects of class String).
There does not seem to be a convenient way of doing this however. 

I first tried to put all these routines in a file, and just compile up
that file. That didn't work as it seems that all routines have to be
inside class definitions (ie. have to be methods).

So I thought I would extend class String - can't do that since there are
no extension mechanisms (other than subclassing in Java).

So I thought I would subclass String, making a class MyString, which
contained my routines, and which inherited the String methods. Can't do 
that since String is final.

There seems to be no way to add my routines to the existing functionality
of class String.

graham
                  A cat named Easter
              He say "will you ever learn"
              Its just an empty cage girl
                 If you kill the bird

-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post