1.1 --- a/java/io.py Thu Dec 09 02:17:22 2004 +0100
1.2 +++ b/java/io.py Thu Dec 09 02:18:05 2004 +0100
1.3 @@ -9,33 +9,47 @@
1.4 self.out.write(value[start:start+length])
1.5 else:
1.6 self.out.write(value)
1.7 + write___java__lang__String = write
1.8 + write___java__lang__String____I_____I_ = write
1.9 def flush(self):
1.10 self.out.flush()
1.11 + flush___ = flush
1.12 def close(self):
1.13 self.out.close()
1.14 + close___ = close
1.15
1.16 class InputStream:
1.17 def read(self, *args):
1.18 raise NotImplementedError, "read"
1.19 + read___ = read
1.20 def skip(self, n):
1.21 raise NotImplementedError, "skip"
1.22 + skip___int = skip
1.23 def available(self):
1.24 raise NotImplementedError, "available"
1.25 + available___ = available
1.26 def close(self):
1.27 raise NotImplementedError, "close"
1.28 + close___ = close
1.29 def mark(self, readlimit):
1.30 raise NotImplementedError, "mark"
1.31 + mark___ = mark
1.32 def reset(self):
1.33 raise NotImplementedError, "reset"
1.34 + reset___ = reset
1.35 def markSupported(self):
1.36 raise NotImplementedError, "markSupported"
1.37 + markSupported___ = markSupported
1.38
1.39 class OutputStream:
1.40 def write(self, b, *args):
1.41 raise NotImplementedError, "write"
1.42 + write___java__lang__String = write
1.43 def flush(self):
1.44 raise NotImplementedError, "flush"
1.45 + flush___ = flush
1.46 def close(self):
1.47 raise NotImplementedError, "close"
1.48 + close___ = close
1.49
1.50 # vim: tabstop=4 expandtab shiftwidth=4
2.1 --- a/java/lang.py Thu Dec 09 02:17:22 2004 +0100
2.2 +++ b/java/lang.py Thu Dec 09 02:18:05 2004 +0100
2.3 @@ -91,6 +91,15 @@
2.4 # compareTo(self, o)
2.5 raise NotImplementedError, "compareTo"
2.6
2.7 +# NOTE: Establish a better exception hierarchy.
2.8 +
2.9 +class IllegalArgumentException(object):
2.10 + def __init__(self, *args):
2.11 + self.args = args
2.12 +
2.13 +setattr(IllegalArgumentException, "__init_____", IllegalArgumentException.__init__)
2.14 +setattr(IllegalArgumentException, "__init_____java__lang__String", IllegalArgumentException.__init__)
2.15 +
2.16 class String(object):
2.17
2.18 def init__empty(self):
2.19 @@ -127,70 +136,126 @@
2.20 raise NotImplementedError, "__init__"
2.21 # __init__(self, buffer)
2.22 raise NotImplementedError, "__init__"
2.23 +
2.24 def length(self):
2.25 return len(self.value)
2.26 + length___ = length
2.27 +
2.28 def charAt(self, index):
2.29 - return self.value[index]
2.30 + return ord(self.value[index])
2.31 + charAt____I_ = charAt
2.32 +
2.33 def getChars(self, srcBegin, srcEnd, dst, dstBegin):
2.34 raise NotImplementedError, "getChars"
2.35 + getChars____I_____I_____C__array_____I_ = getChars
2.36 +
2.37 def getBytes(self, *args):
2.38 # void getBytes(self, srcBegin, srcEnd, dst, dstBegin)
2.39 # byte[] getBytes(self, enc)
2.40 # byte[] getBytes(self)
2.41 raise NotImplementedError, "getBytes"
2.42 + getBytes___ = getBytes
2.43 + getBytes____I_____I_____B__array_____I_ = getBytes
2.44 +
2.45 def equals(self, anObject):
2.46 - raise NotImplementedError, "equals"
2.47 + return isinstance(anObject, self.__class__) and self.value == anObject.value
2.48 + equals___java__lang__Object = equals
2.49 +
2.50 def compareTo(self, obj):
2.51 - raise NotImplementedError, "compareTo"
2.52 - # NOTE: Comparator defined using private classes.
2.53 + if self.value < obj.value:
2.54 + return -1
2.55 + elif self.value == obj.value:
2.56 + return 0
2.57 + else:
2.58 + return 1
2.59 + compareTo___java__lang__String = compareTo
2.60 +
2.61 + # NOTE: Comparator defined using private classes. This implementation just
2.62 + # NOTE: uses Python's lower method.
2.63 def compareToIgnoreCase(self, str):
2.64 - raise NotImplementedError, "compareToIgnoreCase"
2.65 + value = self.value.lower()
2.66 + value2 = str.value.lower()
2.67 + if value < value2:
2.68 + return -1
2.69 + elif value == value2:
2.70 + return 0
2.71 + else:
2.72 + return 1
2.73 + compareToIgnoreCase___java__lang__String = compareToIgnoreCase
2.74 +
2.75 + # NOTE: Comparator defined using private classes. This implementation just
2.76 + # NOTE: uses Python's lower method.
2.77 + def equalsIgnoreCase(self, anotherString):
2.78 + value = self.value.lower()
2.79 + value2 = anotherString.value.lower()
2.80 + return value == value2
2.81 + equalsIgnoreCase___java__lang__String = equalsIgnoreCase
2.82 +
2.83 def regionMatches(self, *args):
2.84 # regionMatches(self, toffset, other, ooffset, len)
2.85 # regionMatches(self, ignoreCase, toffset, other, ooffset, len)
2.86 raise NotImplementedError, "regionMatches"
2.87 +
2.88 def startsWith(self, *args):
2.89 # startsWith(self, prefix, toffset)
2.90 # startsWith(self, prefix)
2.91 raise NotImplementedError, "startsWith"
2.92 +
2.93 def endsWith(self, suffix):
2.94 raise NotImplementedError, "endsWith"
2.95 +
2.96 def hashCode(self):
2.97 raise NotImplementedError, "hashCode"
2.98 - def indexOf(self, *args):
2.99 - # indexOf(self, ch)
2.100 - # indexOf(self, ch, fromIndex)
2.101 - # indexOf(self, str)
2.102 - # indexOf(self, str, fromIndex)
2.103 - raise NotImplementedError, "indexOf"
2.104 +
2.105 + def indexOf____I_(self, ch):
2.106 + return self.value.find(chr(ch))
2.107 +
2.108 + def indexOf____I_____I_(self, ch, fromIndex):
2.109 + return self.value.find(chr(ch), fromIndex)
2.110 +
2.111 + def indexOf___java__lang__String___(self, str):
2.112 + return self.value.find(str.value)
2.113 +
2.114 + def indexOf___java__lang__String____I_(self, str, fromIndex):
2.115 + return self.value.find(str.value, fromIndex)
2.116 +
2.117 def lastIndexOf(self, *args):
2.118 # lastIndexOf(self, ch)
2.119 # lastIndexOf(self, ch, fromIndex)
2.120 # lastIndexOf(self, str)
2.121 # lastIndexOf(self, str, fromIndex)
2.122 raise NotImplementedError, "lastIndexOf"
2.123 +
2.124 def substring(self, *args):
2.125 # substring(self, beginIndex)
2.126 # substring(self, beginIndex, endIndex)
2.127 raise NotImplementedError, "substring"
2.128 +
2.129 def concat(self, str):
2.130 raise NotImplementedError, "concat"
2.131 +
2.132 def replace(self, oldChar, newChar):
2.133 raise NotImplementedError, "replace"
2.134 +
2.135 def toLowerCase(self, *args):
2.136 # toLowerCase(self, locale)
2.137 # toLowerCase(self)
2.138 raise NotImplementedError, "toLowerCase"
2.139 +
2.140 def toUpperCase(self, *args):
2.141 # toUpperCase(self, locale)
2.142 # toUpperCase(self)
2.143 raise NotImplementedError, "toUpperCase"
2.144 +
2.145 def trim(self):
2.146 raise NotImplementedError, "trim"
2.147 +
2.148 def toString(self):
2.149 return self
2.150 +
2.151 def toCharArray(self):
2.152 raise NotImplementedError, "toCharArray"
2.153 +
2.154 def valueOf(self, *args):
2.155 # valueOf(self, obj)
2.156 # valueOf(self, data)
2.157 @@ -202,15 +267,17 @@
2.158 # valueOf(self, d)
2.159 raise NotImplementedError, "valueOf"
2.160 valueOf = staticmethod(valueOf)
2.161 +
2.162 def copyValueOf(self, *args):
2.163 # copyValueOf(self, data, offset, count)
2.164 # copyValueOf(self, data)
2.165 raise NotImplementedError, "copyValueOf"
2.166 copyValueOf = staticmethod(copyValueOf)
2.167 +
2.168 def intern(self):
2.169 raise NotImplementedError, "intern"
2.170
2.171 -setattr(String, "__init__$", String.init__empty)
2.172 -setattr(String, "__init__$java/lang/String", String.init__String)
2.173 +setattr(String, "__init_____", String.init__empty)
2.174 +setattr(String, "__init_____java__lang__String", String.init__String)
2.175
2.176 # vim: tabstop=4 expandtab shiftwidth=4
3.1 --- a/java/text.py Thu Dec 09 02:17:22 2004 +0100
3.2 +++ b/java/text.py Thu Dec 09 02:18:05 2004 +0100
3.3 @@ -1,6 +1,6 @@
3.4 #!/usr/bin/env python
3.5
3.6 -class FilterOutputStream:
3.7 +class FilterOutputStream(object):
3.8 def __init__(self, out):
3.9 self.out = out
3.10 def write(self, value, *args):
3.11 @@ -14,7 +14,7 @@
3.12 def close(self):
3.13 self.out.close()
3.14
3.15 -class InputStream:
3.16 +class InputStream(object):
3.17 def read(self, *args):
3.18 raise NotImplementedError, "read"
3.19 def skip(self, n):
3.20 @@ -30,7 +30,40 @@
3.21 def markSupported(self):
3.22 raise NotImplementedError, "markSupported"
3.23
3.24 -class OutputStream:
3.25 +class MessageFormat(object):
3.26 + def __init__(self, pattern):
3.27 + self.pattern = pattern
3.28 +
3.29 + def applyPattern(self, pattern):
3.30 + self.pattern = pattern
3.31 + applyPattern___java__lang__String = applyPattern
3.32 +
3.33 + def equals(self, obj):
3.34 + return self == obj
3.35 + equals___java__lang__Object = equals
3.36 +
3.37 + def format(self, *args):
3.38 + raise NotImplementedError, "format"
3.39 + format___java__lang__Object_array____java__lang__StringBuffer___java__text__FieldPosition = format
3.40 + format___java__lang__Object___java__lang__StringBuffer___java__text__FieldPosition = format
3.41 +
3.42 + def format__static(pattern, arguments):
3.43 + mf = MessageFormat(pattern)
3.44 + # NOTE: To be implemented.
3.45 + return ""
3.46 + format___java__lang__String___java__lang__Object_array_ = staticmethod(format__static)
3.47 +
3.48 + def getFormats(self):
3.49 + raise NotImplementedError, "getFormats"
3.50 + getFormats___ = getFormats
3.51 +
3.52 + def getLocale(self):
3.53 + raise NotImplementedError, "getLocale"
3.54 + getLocale___ = getLocale
3.55 +
3.56 +setattr(MessageFormat, "__init_____java__lang__String", MessageFormat.__init__)
3.57 +
3.58 +class OutputStream(object):
3.59 def write(self, b, *args):
3.60 raise NotImplementedError, "write"
3.61 def flush(self):
4.1 --- a/java/util.py Thu Dec 09 02:17:22 2004 +0100
4.2 +++ b/java/util.py Thu Dec 09 02:18:05 2004 +0100
4.3 @@ -14,12 +14,13 @@
4.4 # NOTE: To be implemented.
4.5 pass
4.6
4.7 -setattr(Hashtable, "__init__$", Hashtable.__init__)
4.8 +setattr(Hashtable, "__init_____", Hashtable.__init__)
4.9
4.10 class ResourceBundle(object):
4.11 def __init__(self, *args):
4.12 # NOTE: To be implemented.
4.13 pass
4.14 +
4.15 def getBundle(self, *args):
4.16 # getBundle(self, baseName)
4.17 # getBundle(self, baseName, locale)
4.18 @@ -27,9 +28,28 @@
4.19 # NOTE: Obviously not the correct implementation.
4.20 return ResourceBundle(args)
4.21 getBundle = staticmethod(getBundle)
4.22 + getBundle___java__lang__String = getBundle
4.23 + getBundle___java__lang__String___java__util__Locale = getBundle
4.24 + getBundle___java__lang__String___java__util__Locale___java__lang__ClassLoader = getBundle
4.25
4.26 -setattr(ResourceBundle, "getBundle$java/lang/String", staticmethod(ResourceBundle.getBundle))
4.27 -setattr(ResourceBundle, "getBundle$java/lang/String$java/util/Locale", staticmethod(ResourceBundle.getBundle))
4.28 -setattr(ResourceBundle, "getBundle$java/lang/String$java/util/Locale$java/lang/ClassLoader", staticmethod(ResourceBundle.getBundle))
4.29 + def getObject(self, key):
4.30 + # NOTE: To be implemented.
4.31 + return None
4.32 + getObject___java__lang__String = getObject
4.33 +
4.34 + def getString(self, key):
4.35 + # NOTE: To be implemented.
4.36 + return None
4.37 + getString___java__lang__String = getString
4.38 +
4.39 + def getStringArray(self, key):
4.40 + # NOTE: To be implemented.
4.41 + return None
4.42 + getStringArray___java__lang__String = getStringArray
4.43 +
4.44 + def getLocale(self, key):
4.45 + # NOTE: To be implemented.
4.46 + return None
4.47 + getLocale___ = getLocale
4.48
4.49 # vim: tabstop=4 expandtab shiftwidth=4