1 #!/usr/bin/env python 2 3 class Character(object): 4 def __init__(self, value): 5 raise NotImplementedError, "__init__" 6 def charValue(self): 7 raise NotImplementedError, "charValue" 8 def hashCode(self): 9 raise NotImplementedError, "hashCode" 10 def equals(self, anObject): 11 raise NotImplementedError, "equals" 12 def toString(self): 13 raise NotImplementedError, "toString" 14 def isLowerCase(self, ch): 15 raise NotImplementedError, "isLowerCase" 16 isLowerCase = staticmethod(isLowerCase) 17 def isUpperCase(self, ch): 18 raise NotImplementedError, "isUpperCase" 19 isUpperCase = staticmethod(isUpperCase) 20 def isTitleCase(self, ch): 21 raise NotImplementedError, "isTitleCase" 22 isTitleCase = staticmethod(isTitleCase) 23 def isDigit(self, ch): 24 raise NotImplementedError, "isDigit" 25 isDigit = staticmethod(isDigit) 26 def isDefined(self, ch): 27 raise NotImplementedError, "isDefined" 28 isDefined = staticmethod(isDefined) 29 def isLetter(self, ch): 30 raise NotImplementedError, "isLetter" 31 isLetter = staticmethod(isLetter) 32 def isLetterOrDigit(self, ch): 33 raise NotImplementedError, "isLetterOrDigit" 34 isLetterOrDigit = staticmethod(isLetterOrDigit) 35 def isJavaLetter(self, ch): 36 raise NotImplementedError, "isJavaLetter" 37 isJavaLetter = staticmethod(isJavaLetter) 38 def isJavaLetterOrDigit(self, ch): 39 raise NotImplementedError, "isJavaLetterOrDigit" 40 isJavaLetterOrDigit = staticmethod(isJavaLetterOrDigit) 41 def isJavaIdentifierStart(self, ch): 42 raise NotImplementedError, "isJavaIdentifierStart" 43 isJavaIdentifierStart = staticmethod(isJavaIdentifierStart) 44 def isJavaIdentifierPart(self, ch): 45 raise NotImplementedError, "isJavaIdentifierPart" 46 isJavaIdentifierPart = staticmethod(isJavaIdentifierPart) 47 def isUnicodeIdentifierStart(self, ch): 48 raise NotImplementedError, "isUnicodeIdentifierStart" 49 isUnicodeIdentifierStart = staticmethod(isUnicodeIdentifierStart) 50 def isUnicodeIdentifierPart(self, ch): 51 raise NotImplementedError, "isUnicodeIdentifierPart" 52 isUnicodeIdentifierPart = staticmethod(isUnicodeIdentifierPart) 53 def isIdentifierIgnorable(self, ch): 54 raise NotImplementedError, "isIdentifierIgnorable" 55 isIdentifierIgnorable = staticmethod(isIdentifierIgnorable) 56 def toLowerCase(self, ch): 57 raise NotImplementedError, "toLowerCase" 58 toLowerCase = staticmethod(toLowerCase) 59 def toUpperCase(self, ch): 60 raise NotImplementedError, "toUpperCase" 61 toUpperCase = staticmethod(toUpperCase) 62 def toTitleCase(self, ch): 63 raise NotImplementedError, "toTitleCase" 64 toTitleCase = staticmethod(toTitleCase) 65 def digit(self, ch, radix): 66 raise NotImplementedError, "digit" 67 digit = staticmethod(digit) 68 def getNumericValue(self, ch): 69 raise NotImplementedError, "getNumericValue" 70 getNumericValue = staticmethod(getNumericValue) 71 def isSpace(self, ch): 72 raise NotImplementedError, "isSpace" 73 isSpace = staticmethod(isSpace) 74 def isSpaceChar(self, ch): 75 raise NotImplementedError, "isSpaceChar" 76 isSpaceChar = staticmethod(isSpaceChar) 77 def isWhitespace(self, ch): 78 raise NotImplementedError, "isWhitespace" 79 isWhitespace = staticmethod(isWhitespace) 80 def isISOControl(self, ch): 81 raise NotImplementedError, "isISOControl" 82 isISOControl = staticmethod(isISOControl) 83 def getType(self, ch): 84 raise NotImplementedError, "getType" 85 getType = staticmethod(getType) 86 def forDigit(self, ch, radix): 87 raise NotImplementedError, "forDigit" 88 forDigit = staticmethod(forDigit) 89 def compareTo(self, *args): 90 # compareTo(self, anotherCharacter) 91 # compareTo(self, o) 92 raise NotImplementedError, "compareTo" 93 94 class String(object): 95 96 def init__empty(self): 97 self.value = u"" 98 99 def init__String(self, obj): 100 self.value = obj.value 101 102 def __init__(self, *args): 103 # Python string initialisation: 104 if len(args) == 1 and isinstance(args[0], str): 105 self.value = unicode(args[0]) 106 return 107 elif len(args) == 1 and isinstance(args[0], unicode): 108 self.value = args[0] 109 return 110 # __init__(self) 111 elif len(args) == 0: 112 self.__init__empty() 113 return 114 # __init__(self, original) 115 elif len(args) == 1 and isinstance(args[0], String): 116 self.__init__String(args[0]) 117 return 118 # __init__(self, value) 119 # __init__(self, value, offset, count) 120 # __init__(self, ascii, hibyte, offset, count) 121 # __init__(self, ascii, hibyte) 122 # __init__(self, bytes, offset, length, enc) 123 # __init__(self, bytes, enc) 124 # __init__(self, bytes, offset, length) 125 # __init__(self, bytes) 126 elif len(args) >= 1 and isinstance(args[0], list): 127 raise NotImplementedError, "__init__" 128 # __init__(self, buffer) 129 raise NotImplementedError, "__init__" 130 def length(self): 131 return len(self.value) 132 def charAt(self, index): 133 return self.value[index] 134 def getChars(self, srcBegin, srcEnd, dst, dstBegin): 135 raise NotImplementedError, "getChars" 136 def getBytes(self, *args): 137 # void getBytes(self, srcBegin, srcEnd, dst, dstBegin) 138 # byte[] getBytes(self, enc) 139 # byte[] getBytes(self) 140 raise NotImplementedError, "getBytes" 141 def equals(self, anObject): 142 raise NotImplementedError, "equals" 143 def compareTo(self, obj): 144 raise NotImplementedError, "compareTo" 145 # NOTE: Comparator defined using private classes. 146 def compareToIgnoreCase(self, str): 147 raise NotImplementedError, "compareToIgnoreCase" 148 def regionMatches(self, *args): 149 # regionMatches(self, toffset, other, ooffset, len) 150 # regionMatches(self, ignoreCase, toffset, other, ooffset, len) 151 raise NotImplementedError, "regionMatches" 152 def startsWith(self, *args): 153 # startsWith(self, prefix, toffset) 154 # startsWith(self, prefix) 155 raise NotImplementedError, "startsWith" 156 def endsWith(self, suffix): 157 raise NotImplementedError, "endsWith" 158 def hashCode(self): 159 raise NotImplementedError, "hashCode" 160 def indexOf(self, *args): 161 # indexOf(self, ch) 162 # indexOf(self, ch, fromIndex) 163 # indexOf(self, str) 164 # indexOf(self, str, fromIndex) 165 raise NotImplementedError, "indexOf" 166 def lastIndexOf(self, *args): 167 # lastIndexOf(self, ch) 168 # lastIndexOf(self, ch, fromIndex) 169 # lastIndexOf(self, str) 170 # lastIndexOf(self, str, fromIndex) 171 raise NotImplementedError, "lastIndexOf" 172 def substring(self, *args): 173 # substring(self, beginIndex) 174 # substring(self, beginIndex, endIndex) 175 raise NotImplementedError, "substring" 176 def concat(self, str): 177 raise NotImplementedError, "concat" 178 def replace(self, oldChar, newChar): 179 raise NotImplementedError, "replace" 180 def toLowerCase(self, *args): 181 # toLowerCase(self, locale) 182 # toLowerCase(self) 183 raise NotImplementedError, "toLowerCase" 184 def toUpperCase(self, *args): 185 # toUpperCase(self, locale) 186 # toUpperCase(self) 187 raise NotImplementedError, "toUpperCase" 188 def trim(self): 189 raise NotImplementedError, "trim" 190 def toString(self): 191 return self 192 def toCharArray(self): 193 raise NotImplementedError, "toCharArray" 194 def valueOf(self, *args): 195 # valueOf(self, obj) 196 # valueOf(self, data) 197 # valueOf(self, data, offset, count) 198 # valueOf(self, b) 199 # valueOf(self, c) 200 # valueOf(self, l) 201 # valueOf(self, f) 202 # valueOf(self, d) 203 raise NotImplementedError, "valueOf" 204 valueOf = staticmethod(valueOf) 205 def copyValueOf(self, *args): 206 # copyValueOf(self, data, offset, count) 207 # copyValueOf(self, data) 208 raise NotImplementedError, "copyValueOf" 209 copyValueOf = staticmethod(copyValueOf) 210 def intern(self): 211 raise NotImplementedError, "intern" 212 213 setattr(String, "__init__$", String.init__empty) 214 setattr(String, "__init__$java/lang/String", String.init__String) 215 216 # vim: tabstop=4 expandtab shiftwidth=4