javaclass

Changeset

76:7fa32ea2ff28
2004-11-21 Paul Boddie raw files shortlog changelog graph Added method entries for Java access to the String class.
java/lang.py (file)
     1.1 --- a/java/lang.py	Sun Nov 21 23:48:35 2004 +0100
     1.2 +++ b/java/lang.py	Sun Nov 21 23:49:39 2004 +0100
     1.3 @@ -92,6 +92,13 @@
     1.4          raise NotImplementedError, "compareTo"
     1.5  
     1.6  class String(object):
     1.7 +
     1.8 +    def init__empty(self):
     1.9 +        self.value = u""
    1.10 +
    1.11 +    def init__String(self, obj):
    1.12 +        self.value = obj.value
    1.13 +
    1.14      def __init__(self, *args):
    1.15          # Python string initialisation:
    1.16          if len(args) == 1 and isinstance(args[0], str):
    1.17 @@ -102,11 +109,11 @@
    1.18              return
    1.19          # __init__(self)
    1.20          elif len(args) == 0:
    1.21 -            self.value = u""
    1.22 +            self.__init__empty()
    1.23              return
    1.24          # __init__(self, original)
    1.25          elif len(args) == 1 and isinstance(args[0], String):
    1.26 -            self.value = args[0].value
    1.27 +            self.__init__String(args[0])
    1.28              return
    1.29          # __init__(self, value)
    1.30          # __init__(self, value, offset, count)
    1.31 @@ -203,4 +210,7 @@
    1.32      def intern(self):
    1.33          raise NotImplementedError, "intern"
    1.34  
    1.35 +setattr(String, "__init__$", String.init__empty)
    1.36 +setattr(String, "__init__$java/lang/String", String.init__String)
    1.37 +
    1.38  # vim: tabstop=4 expandtab shiftwidth=4