1.1 --- a/java/lang.py Fri Dec 10 01:04:59 2004 +0100
1.2 +++ b/java/lang.py Fri Dec 10 01:27:29 2004 +0100
1.3 @@ -3,105 +3,183 @@
1.4 class Character(object):
1.5 def __init__(self, value):
1.6 raise NotImplementedError, "__init__"
1.7 +
1.8 def charValue(self):
1.9 raise NotImplementedError, "charValue"
1.10 + charValue___ = charValue
1.11 +
1.12 def hashCode(self):
1.13 raise NotImplementedError, "hashCode"
1.14 + hashCode___ = hashCode
1.15 +
1.16 def equals(self, anObject):
1.17 raise NotImplementedError, "equals"
1.18 + equals___java__lang__Object = equals
1.19 +
1.20 def toString(self):
1.21 raise NotImplementedError, "toString"
1.22 + toString___ = toString
1.23 +
1.24 def isLowerCase(self, ch):
1.25 raise NotImplementedError, "isLowerCase"
1.26 - isLowerCase = staticmethod(isLowerCase)
1.27 + isLowerCase____C_ = staticmethod(isLowerCase)
1.28 +
1.29 def isUpperCase(self, ch):
1.30 raise NotImplementedError, "isUpperCase"
1.31 - isUpperCase = staticmethod(isUpperCase)
1.32 + isUpperCase____C_ = staticmethod(isUpperCase)
1.33 +
1.34 def isTitleCase(self, ch):
1.35 raise NotImplementedError, "isTitleCase"
1.36 - isTitleCase = staticmethod(isTitleCase)
1.37 + isTitleCase____C_ = staticmethod(isTitleCase)
1.38 +
1.39 def isDigit(self, ch):
1.40 raise NotImplementedError, "isDigit"
1.41 - isDigit = staticmethod(isDigit)
1.42 + isDigit____C_ = staticmethod(isDigit)
1.43 +
1.44 def isDefined(self, ch):
1.45 raise NotImplementedError, "isDefined"
1.46 - isDefined = staticmethod(isDefined)
1.47 + isDefined____C_ = staticmethod(isDefined)
1.48 +
1.49 def isLetter(self, ch):
1.50 raise NotImplementedError, "isLetter"
1.51 - isLetter = staticmethod(isLetter)
1.52 + isLetter____C_ = staticmethod(isLetter)
1.53 +
1.54 def isLetterOrDigit(self, ch):
1.55 raise NotImplementedError, "isLetterOrDigit"
1.56 - isLetterOrDigit = staticmethod(isLetterOrDigit)
1.57 + isLetterOrDigit____C_ = staticmethod(isLetterOrDigit)
1.58 +
1.59 def isJavaLetter(self, ch):
1.60 raise NotImplementedError, "isJavaLetter"
1.61 - isJavaLetter = staticmethod(isJavaLetter)
1.62 + isJavaLetter____C_ = staticmethod(isJavaLetter)
1.63 +
1.64 def isJavaLetterOrDigit(self, ch):
1.65 raise NotImplementedError, "isJavaLetterOrDigit"
1.66 - isJavaLetterOrDigit = staticmethod(isJavaLetterOrDigit)
1.67 + isJavaLetterOrDigit____C_ = staticmethod(isJavaLetterOrDigit)
1.68 +
1.69 def isJavaIdentifierStart(self, ch):
1.70 raise NotImplementedError, "isJavaIdentifierStart"
1.71 - isJavaIdentifierStart = staticmethod(isJavaIdentifierStart)
1.72 + isJavaIdentifierStart____C_ = staticmethod(isJavaIdentifierStart)
1.73 +
1.74 def isJavaIdentifierPart(self, ch):
1.75 raise NotImplementedError, "isJavaIdentifierPart"
1.76 - isJavaIdentifierPart = staticmethod(isJavaIdentifierPart)
1.77 + isJavaIdentifierPart____C_ = staticmethod(isJavaIdentifierPart)
1.78 +
1.79 def isUnicodeIdentifierStart(self, ch):
1.80 raise NotImplementedError, "isUnicodeIdentifierStart"
1.81 - isUnicodeIdentifierStart = staticmethod(isUnicodeIdentifierStart)
1.82 + isUnicodeIdentifierStart____C_ = staticmethod(isUnicodeIdentifierStart)
1.83 +
1.84 def isUnicodeIdentifierPart(self, ch):
1.85 raise NotImplementedError, "isUnicodeIdentifierPart"
1.86 - isUnicodeIdentifierPart = staticmethod(isUnicodeIdentifierPart)
1.87 + isUnicodeIdentifierPart____C_ = staticmethod(isUnicodeIdentifierPart)
1.88 +
1.89 def isIdentifierIgnorable(self, ch):
1.90 raise NotImplementedError, "isIdentifierIgnorable"
1.91 - isIdentifierIgnorable = staticmethod(isIdentifierIgnorable)
1.92 + isIdentifierIgnorable____C_ = staticmethod(isIdentifierIgnorable)
1.93 +
1.94 def toLowerCase(self, ch):
1.95 raise NotImplementedError, "toLowerCase"
1.96 - toLowerCase = staticmethod(toLowerCase)
1.97 + toLowerCase____C_ = staticmethod(toLowerCase)
1.98 +
1.99 def toUpperCase(self, ch):
1.100 raise NotImplementedError, "toUpperCase"
1.101 - toUpperCase = staticmethod(toUpperCase)
1.102 + toUpperCase____C_ = staticmethod(toUpperCase)
1.103 +
1.104 def toTitleCase(self, ch):
1.105 raise NotImplementedError, "toTitleCase"
1.106 - toTitleCase = staticmethod(toTitleCase)
1.107 + toTitleCase____C_ = staticmethod(toTitleCase)
1.108 +
1.109 def digit(self, ch, radix):
1.110 raise NotImplementedError, "digit"
1.111 - digit = staticmethod(digit)
1.112 + digit____C_____I_ = staticmethod(digit)
1.113 +
1.114 def getNumericValue(self, ch):
1.115 raise NotImplementedError, "getNumericValue"
1.116 - getNumericValue = staticmethod(getNumericValue)
1.117 + getNumericValue____C_ = staticmethod(getNumericValue)
1.118 +
1.119 def isSpace(self, ch):
1.120 raise NotImplementedError, "isSpace"
1.121 - isSpace = staticmethod(isSpace)
1.122 + isSpace____C_ = staticmethod(isSpace)
1.123 +
1.124 def isSpaceChar(self, ch):
1.125 raise NotImplementedError, "isSpaceChar"
1.126 - isSpaceChar = staticmethod(isSpaceChar)
1.127 + isSpaceChar____C_ = staticmethod(isSpaceChar)
1.128 +
1.129 def isWhitespace(self, ch):
1.130 raise NotImplementedError, "isWhitespace"
1.131 - isWhitespace = staticmethod(isWhitespace)
1.132 + isWhitespace____C_ = staticmethod(isWhitespace)
1.133 +
1.134 def isISOControl(self, ch):
1.135 raise NotImplementedError, "isISOControl"
1.136 - isISOControl = staticmethod(isISOControl)
1.137 + isISOControl____C_ = staticmethod(isISOControl)
1.138 +
1.139 def getType(self, ch):
1.140 raise NotImplementedError, "getType"
1.141 - getType = staticmethod(getType)
1.142 + getType____C_ = staticmethod(getType)
1.143 +
1.144 def forDigit(self, ch, radix):
1.145 raise NotImplementedError, "forDigit"
1.146 - forDigit = staticmethod(forDigit)
1.147 + forDigit____C_____I_ = staticmethod(forDigit)
1.148 +
1.149 def compareTo(self, *args):
1.150 # compareTo(self, anotherCharacter)
1.151 # compareTo(self, o)
1.152 raise NotImplementedError, "compareTo"
1.153 + compareTo____C_ = compareTo
1.154 + compareTo___java__lang__Object = compareTo
1.155 +
1.156 +setattr(Character, "__init____C_", Character.__init__)
1.157 +
1.158 +class Class(object):
1.159 + def forName(className):
1.160 + parts = unicode(className).split(".")
1.161 + obj = __import__(className, globals(), {}, [])
1.162 + for part in parts[1:]:
1.163 + obj = obj[part]
1.164 + return obj
1.165 +
1.166 + forName___java__lang__String = staticmethod(forName)
1.167 + # NOTE: To be enhanced.
1.168 + forName___java__lang__String____Z____java__lang__ClassLoader = staticmethod(forName)
1.169
1.170 # NOTE: Establish a better exception hierarchy.
1.171
1.172 -class IllegalArgumentException(object):
1.173 +class Error(object):
1.174 + def __init__(self, *args):
1.175 + self.args = args
1.176 +
1.177 +setattr(Error, "__init_____", Error.__init__)
1.178 +setattr(Error, "__init_____java__lang__String", Error.__init__)
1.179 +
1.180 +class Exception(object):
1.181 + def __init__(self, *args):
1.182 + self.args = args
1.183 +
1.184 +setattr(Exception, "__init_____", Exception.__init__)
1.185 +setattr(Exception, "__init_____java__lang__String", Exception.__init__)
1.186 +
1.187 +class IllegalArgumentException(Exception):
1.188 def __init__(self, *args):
1.189 self.args = args
1.190
1.191 setattr(IllegalArgumentException, "__init_____", IllegalArgumentException.__init__)
1.192 setattr(IllegalArgumentException, "__init_____java__lang__String", IllegalArgumentException.__init__)
1.193
1.194 +class SecurityException(Exception):
1.195 + def __init__(self, *args):
1.196 + self.args = args
1.197 +
1.198 +setattr(SecurityException, "__init_____", SecurityException.__init__)
1.199 +setattr(SecurityException, "__init_____java__lang__String", SecurityException.__init__)
1.200 +
1.201 class String(object):
1.202
1.203 + # NOTE: This method should not be needed, really.
1.204 + def __str__(self):
1.205 + return self.value.encode("utf-8")
1.206 +
1.207 + def __unicode__(self):
1.208 + return self.value
1.209 +
1.210 def init__empty(self):
1.211 self.value = u""
1.212
1.213 @@ -109,7 +187,9 @@
1.214 self.value = obj.value
1.215
1.216 def __init__(self, *args):
1.217 - # Python string initialisation:
1.218 +
1.219 + "Python string initialisation only."
1.220 +
1.221 if len(args) == 1 and isinstance(args[0], str):
1.222 self.value = unicode(args[0])
1.223 return
1.224 @@ -122,7 +202,7 @@
1.225 return
1.226 # __init__(self, original)
1.227 elif len(args) == 1 and isinstance(args[0], String):
1.228 - self.__init__String(args[0])
1.229 + self.init__String(args[0])
1.230 return
1.231 # __init__(self, value)
1.232 # __init__(self, value, offset, count)