1.1 --- a/java/lang/__init__.py Fri Jan 14 00:46:50 2005 +0100
1.2 +++ b/java/lang/__init__.py Fri Jan 14 00:48:01 2005 +0100
1.3 @@ -146,6 +146,26 @@
1.4 # NOTE: To be enhanced.
1.5 forName___java__lang__String____Z____java__lang__ClassLoader = staticmethod(forName)
1.6
1.7 +class Integer(Object):
1.8 + def init_int(self, i):
1.9 + self.i = i
1.10 +
1.11 + def init_String(self, s):
1.12 + self.i = int(s.value)
1.13 +
1.14 + def __init__(self, *args):
1.15 + if len(args) == 1 and isinstance(args[0], int):
1.16 + self.init_int(args[0])
1.17 + elif len(args) == 1 and isinstance(args[0], String):
1.18 + self.init_String(args[0])
1.19 +
1.20 + def toString(self):
1.21 + return String(str(self.i))
1.22 + toString___ = toString
1.23 +
1.24 +setattr(Integer, "__init______I_", Integer.init_int)
1.25 +setattr(Integer, "__init_____java__lang__String", Integer.init_String)
1.26 +
1.27 class String(Object):
1.28
1.29 # NOTE: This method should not be needed, really.
1.30 @@ -155,30 +175,14 @@
1.31 def __unicode__(self):
1.32 return self.value
1.33
1.34 - def init__empty(self):
1.35 + def init_empty(self):
1.36 + "__init__(self)"
1.37 self.value = u""
1.38
1.39 - def init__String(self, obj):
1.40 + def init_String(self, obj):
1.41 + "__init__(self, original)"
1.42 self.value = obj.value
1.43
1.44 - def __init__(self, *args):
1.45 -
1.46 - "Python string initialisation only."
1.47 -
1.48 - if len(args) == 1 and isinstance(args[0], str):
1.49 - self.value = unicode(args[0])
1.50 - return
1.51 - elif len(args) == 1 and isinstance(args[0], unicode):
1.52 - self.value = args[0]
1.53 - return
1.54 - # __init__(self)
1.55 - elif len(args) == 0:
1.56 - self.__init__empty()
1.57 - return
1.58 - # __init__(self, original)
1.59 - elif len(args) == 1 and isinstance(args[0], String):
1.60 - self.init__String(args[0])
1.61 - return
1.62 # __init__(self, value)
1.63 # __init__(self, value, offset, count)
1.64 # __init__(self, ascii, hibyte, offset, count)
1.65 @@ -187,10 +191,20 @@
1.66 # __init__(self, bytes, enc)
1.67 # __init__(self, bytes, offset, length)
1.68 # __init__(self, bytes)
1.69 - elif len(args) >= 1 and isinstance(args[0], list):
1.70 - raise NotImplementedError, "__init__"
1.71 # __init__(self, buffer)
1.72 - raise NotImplementedError, "__init__"
1.73 +
1.74 + def __init__(self, *args):
1.75 +
1.76 + "Python string initialisation only."
1.77 +
1.78 + if len(args) == 0:
1.79 + self.init_empty()
1.80 + elif len(args) == 1 and isinstance(args[0], str):
1.81 + self.value = unicode(args[0])
1.82 + elif len(args) == 1 and isinstance(args[0], unicode):
1.83 + self.value = args[0]
1.84 + elif len(args) == 1 and isinstance(args[0], String):
1.85 + self.init_String(args[0])
1.86
1.87 def length(self):
1.88 return len(self.value)
1.89 @@ -332,8 +346,57 @@
1.90 def intern(self):
1.91 raise NotImplementedError, "intern"
1.92
1.93 -setattr(String, "__init_____", String.init__empty)
1.94 -setattr(String, "__init_____java__lang__String", String.init__String)
1.95 +setattr(String, "__init_____", String.init_empty)
1.96 +setattr(String, "__init_____java__lang__String", String.init_String)
1.97 +
1.98 +class StringBuffer(Object):
1.99 +
1.100 + "Used when adding String objects."
1.101 +
1.102 + def __unicode__(self):
1.103 + return u"".join(self.buffer)
1.104 +
1.105 + def __str__(self):
1.106 + unicode(self).encode("utf-8")
1.107 +
1.108 + def init_empty(self):
1.109 + self.buffer = []
1.110 +
1.111 + def init_int(self, length):
1.112 + self.buffer = []
1.113 +
1.114 + def init_String(self, s):
1.115 + self.buffer = [unicode(s)]
1.116 +
1.117 + def __init__(self, *args):
1.118 + if len(args) == 0:
1.119 + self.init_empty()
1.120 + elif len(args) == 1 and isinstance(args[0], int):
1.121 + self.init_int(args[0])
1.122 + elif len(args) == 1 and isinstance(args[0], String):
1.123 + self.init_String(args[0])
1.124 +
1.125 + def append(self, s):
1.126 + sb = StringBuffer(String(unicode(self) + unicode(s)))
1.127 + return sb
1.128 + append____Z_ = append
1.129 + append____C_ = append
1.130 + append____C__array_ = append
1.131 + append____C__array_____I_____I_ = append
1.132 + append____D_ = append
1.133 + append____F_ = append
1.134 + append____I_ = append
1.135 + append____J_ = append
1.136 + append___java__lang__Object = append
1.137 + append___java__lang__String = append
1.138 +
1.139 + def toString(self):
1.140 + return String("".join(self.buffer))
1.141 + toString___ = toString
1.142 +
1.143 +setattr(StringBuffer, "__init_____", StringBuffer.init_empty)
1.144 +setattr(StringBuffer, "__init______I_", StringBuffer.init_int)
1.145 +setattr(StringBuffer, "__init_____java__lang__String", StringBuffer.init_String)
1.146
1.147 class System(Object):
1.148 # NOTE: Fix this - circular import nonsense!