KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > python > core > PyString


1 /// Copyright (c) Corporation for National Research Initiatives
2
package org.python.core;
3
4 /**
5  * A builtin python string.
6  */

7 public class PyString extends PyBaseString implements ClassDictInit
8 {
9     //~ BEGIN GENERATED
10

11     /* type info */
12
13     public static final String JavaDoc exposed_name="str";
14
15     public static void typeSetup(PyObject dict,PyType.Newstyle marker) {
16         class exposed___ne__ extends PyBuiltinFunctionNarrow {
17
18             private PyString self;
19
20             public PyObject getSelf() {
21                 return self;
22             }
23
24             exposed___ne__(PyString self,PyBuiltinFunction.Info info) {
25                 super(info);
26                 this.self=self;
27             }
28
29             public PyBuiltinFunction makeBound(PyObject self) {
30                 return new exposed___ne__((PyString)self,info);
31             }
32
33             public PyObject __call__(PyObject arg0) {
34                 PyObject ret=self.str___ne__(arg0);
35                 if (ret==null)
36                     return Py.NotImplemented;
37                 return ret;
38             }
39
40             public PyObject inst_call(PyObject gself,PyObject arg0) {
41                 PyString self=(PyString)gself;
42                 PyObject ret=self.str___ne__(arg0);
43                 if (ret==null)
44                     return Py.NotImplemented;
45                 return ret;
46             }
47
48         }
49         dict.__setitem__("__ne__",new PyMethodDescr("__ne__",PyString.class,1,1,new exposed___ne__(null,null)));
50         class exposed___eq__ extends PyBuiltinFunctionNarrow {
51
52             private PyString self;
53
54             public PyObject getSelf() {
55                 return self;
56             }
57
58             exposed___eq__(PyString self,PyBuiltinFunction.Info info) {
59                 super(info);
60                 this.self=self;
61             }
62
63             public PyBuiltinFunction makeBound(PyObject self) {
64                 return new exposed___eq__((PyString)self,info);
65             }
66
67             public PyObject __call__(PyObject arg0) {
68                 PyObject ret=self.str___eq__(arg0);
69                 if (ret==null)
70                     return Py.NotImplemented;
71                 return ret;
72             }
73
74             public PyObject inst_call(PyObject gself,PyObject arg0) {
75                 PyString self=(PyString)gself;
76                 PyObject ret=self.str___eq__(arg0);
77                 if (ret==null)
78                     return Py.NotImplemented;
79                 return ret;
80             }
81
82         }
83         dict.__setitem__("__eq__",new PyMethodDescr("__eq__",PyString.class,1,1,new exposed___eq__(null,null)));
84         class exposed___contains__ extends PyBuiltinFunctionNarrow {
85
86             private PyString self;
87
88             public PyObject getSelf() {
89                 return self;
90             }
91
92             exposed___contains__(PyString self,PyBuiltinFunction.Info info) {
93                 super(info);
94                 this.self=self;
95             }
96
97             public PyBuiltinFunction makeBound(PyObject self) {
98                 return new exposed___contains__((PyString)self,info);
99             }
100
101             public PyObject __call__(PyObject arg0) {
102                 return Py.newBoolean(self.str___contains__(arg0));
103             }
104
105             public PyObject inst_call(PyObject gself,PyObject arg0) {
106                 PyString self=(PyString)gself;
107                 return Py.newBoolean(self.str___contains__(arg0));
108             }
109
110         }
111         dict.__setitem__("__contains__",new PyMethodDescr("__contains__",PyString.class,1,1,new exposed___contains__(null,null)));
112         class exposed___len__ extends PyBuiltinFunctionNarrow {
113
114             private PyString self;
115
116             public PyObject getSelf() {
117                 return self;
118             }
119
120             exposed___len__(PyString self,PyBuiltinFunction.Info info) {
121                 super(info);
122                 this.self=self;
123             }
124
125             public PyBuiltinFunction makeBound(PyObject self) {
126                 return new exposed___len__((PyString)self,info);
127             }
128
129             public PyObject __call__() {
130                 return Py.newInteger(self.str___len__());
131             }
132
133             public PyObject inst_call(PyObject gself) {
134                 PyString self=(PyString)gself;
135                 return Py.newInteger(self.str___len__());
136             }
137
138         }
139         dict.__setitem__("__len__",new PyMethodDescr("__len__",PyString.class,0,0,new exposed___len__(null,null)));
140         class exposed___add__ extends PyBuiltinFunctionNarrow {
141
142             private PyString self;
143
144             public PyObject getSelf() {
145                 return self;
146             }
147
148             exposed___add__(PyString self,PyBuiltinFunction.Info info) {
149                 super(info);
150                 this.self=self;
151             }
152
153             public PyBuiltinFunction makeBound(PyObject self) {
154                 return new exposed___add__((PyString)self,info);
155             }
156
157             public PyObject __call__(PyObject arg0) {
158                 return self.str___add__(arg0);
159             }
160
161             public PyObject inst_call(PyObject gself,PyObject arg0) {
162                 PyString self=(PyString)gself;
163                 return self.str___add__(arg0);
164             }
165
166         }
167         dict.__setitem__("__add__",new PyMethodDescr("__add__",PyString.class,1,1,new exposed___add__(null,null)));
168         class exposed___mul__ extends PyBuiltinFunctionNarrow {
169
170             private PyString self;
171
172             public PyObject getSelf() {
173                 return self;
174             }
175
176             exposed___mul__(PyString self,PyBuiltinFunction.Info info) {
177                 super(info);
178                 this.self=self;
179             }
180
181             public PyBuiltinFunction makeBound(PyObject self) {
182                 return new exposed___mul__((PyString)self,info);
183             }
184
185             public PyObject __call__(PyObject arg0) {
186                 return self.str___mul__(arg0);
187             }
188
189             public PyObject inst_call(PyObject gself,PyObject arg0) {
190                 PyString self=(PyString)gself;
191                 return self.str___mul__(arg0);
192             }
193
194         }
195         dict.__setitem__("__mul__",new PyMethodDescr("__mul__",PyString.class,1,1,new exposed___mul__(null,null)));
196         class exposed___rmul__ extends PyBuiltinFunctionNarrow {
197
198             private PyString self;
199
200             public PyObject getSelf() {
201                 return self;
202             }
203
204             exposed___rmul__(PyString self,PyBuiltinFunction.Info info) {
205                 super(info);
206                 this.self=self;
207             }
208
209             public PyBuiltinFunction makeBound(PyObject self) {
210                 return new exposed___rmul__((PyString)self,info);
211             }
212
213             public PyObject __call__(PyObject arg0) {
214                 return self.str___rmul__(arg0);
215             }
216
217             public PyObject inst_call(PyObject gself,PyObject arg0) {
218                 PyString self=(PyString)gself;
219                 return self.str___rmul__(arg0);
220             }
221
222         }
223         dict.__setitem__("__rmul__",new PyMethodDescr("__rmul__",PyString.class,1,1,new exposed___rmul__(null,null)));
224         class exposed___hash__ extends PyBuiltinFunctionNarrow {
225
226             private PyString self;
227
228             public PyObject getSelf() {
229                 return self;
230             }
231
232             exposed___hash__(PyString self,PyBuiltinFunction.Info info) {
233                 super(info);
234                 this.self=self;
235             }
236
237             public PyBuiltinFunction makeBound(PyObject self) {
238                 return new exposed___hash__((PyString)self,info);
239             }
240
241             public PyObject __call__() {
242                 return Py.newInteger(self.str_hashCode());
243             }
244
245             public PyObject inst_call(PyObject gself) {
246                 PyString self=(PyString)gself;
247                 return Py.newInteger(self.str_hashCode());
248             }
249
250         }
251         dict.__setitem__("__hash__",new PyMethodDescr("__hash__",PyString.class,0,0,new exposed___hash__(null,null)));
252         class exposed___repr__ extends PyBuiltinFunctionNarrow {
253
254             private PyString self;
255
256             public PyObject getSelf() {
257                 return self;
258             }
259
260             exposed___repr__(PyString self,PyBuiltinFunction.Info info) {
261                 super(info);
262                 this.self=self;
263             }
264
265             public PyBuiltinFunction makeBound(PyObject self) {
266                 return new exposed___repr__((PyString)self,info);
267             }
268
269             public PyObject __call__() {
270                 return new PyString(self.str_toString());
271             }
272
273             public PyObject inst_call(PyObject gself) {
274                 PyString self=(PyString)gself;
275                 return new PyString(self.str_toString());
276             }
277
278         }
279         dict.__setitem__("__repr__",new PyMethodDescr("__repr__",PyString.class,0,0,new exposed___repr__(null,null)));
280         class exposed_capitalize extends PyBuiltinFunctionNarrow {
281
282             private PyString self;
283
284             public PyObject getSelf() {
285                 return self;
286             }
287
288             exposed_capitalize(PyString self,PyBuiltinFunction.Info info) {
289                 super(info);
290                 this.self=self;
291             }
292
293             public PyBuiltinFunction makeBound(PyObject self) {
294                 return new exposed_capitalize((PyString)self,info);
295             }
296
297             public PyObject __call__() {
298                 return new PyString(self.str_capitalize());
299             }
300
301             public PyObject inst_call(PyObject gself) {
302                 PyString self=(PyString)gself;
303                 return new PyString(self.str_capitalize());
304             }
305
306         }
307         dict.__setitem__("capitalize",new PyMethodDescr("capitalize",PyString.class,0,0,new exposed_capitalize(null,null)));
308         class exposed_center extends PyBuiltinFunctionNarrow {
309
310             private PyString self;
311
312             public PyObject getSelf() {
313                 return self;
314             }
315
316             exposed_center(PyString self,PyBuiltinFunction.Info info) {
317                 super(info);
318                 this.self=self;
319             }
320
321             public PyBuiltinFunction makeBound(PyObject self) {
322                 return new exposed_center((PyString)self,info);
323             }
324
325             public PyObject __call__(PyObject arg0) {
326                 try {
327                     return new PyString(self.str_center(arg0.asInt(0)));
328                 } catch (PyObject.ConversionException e) {
329                     String JavaDoc msg;
330                     switch (e.index) {
331                     case 0:
332                         msg="expected an integer";
333                         break;
334                     default:
335                         msg="xxx";
336                     }
337                     throw Py.TypeError(msg);
338                 }
339             }
340
341             public PyObject inst_call(PyObject gself,PyObject arg0) {
342                 PyString self=(PyString)gself;
343                 try {
344                     return new PyString(self.str_center(arg0.asInt(0)));
345                 } catch (PyObject.ConversionException e) {
346                     String JavaDoc msg;
347                     switch (e.index) {
348                     case 0:
349                         msg="expected an integer";
350                         break;
351                     default:
352                         msg="xxx";
353                     }
354                     throw Py.TypeError(msg);
355                 }
356             }
357
358         }
359         dict.__setitem__("center",new PyMethodDescr("center",PyString.class,1,1,new exposed_center(null,null)));
360         class exposed_count extends PyBuiltinFunctionNarrow {
361
362             private PyString self;
363
364             public PyObject getSelf() {
365                 return self;
366             }
367
368             exposed_count(PyString self,PyBuiltinFunction.Info info) {
369                 super(info);
370                 this.self=self;
371             }
372
373             public PyBuiltinFunction makeBound(PyObject self) {
374                 return new exposed_count((PyString)self,info);
375             }
376
377             public PyObject __call__(PyObject arg0,PyObject arg1,PyObject arg2) {
378                 try {
379                     return Py.newInteger(self.str_count(arg0.asString(0),arg1.asInt(1),arg2.asInt(2)));
380                 } catch (PyObject.ConversionException e) {
381                     String JavaDoc msg;
382                     switch (e.index) {
383                     case 1:
384                     case 2:
385                         msg="expected an integer";
386                         break;
387                     case 0:
388                         msg="expected a string";
389                         break;
390                     default:
391                         msg="xxx";
392                     }
393                     throw Py.TypeError(msg);
394                 }
395             }
396
397             public PyObject inst_call(PyObject gself,PyObject arg0,PyObject arg1,PyObject arg2) {
398                 PyString self=(PyString)gself;
399                 try {
400                     return Py.newInteger(self.str_count(arg0.asString(0),arg1.asInt(1),arg2.asInt(2)));
401                 } catch (PyObject.ConversionException e) {
402                     String JavaDoc msg;
403                     switch (e.index) {
404                     case 1:
405                     case 2:
406                         msg="expected an integer";
407                         break;
408                     case 0:
409                         msg="expected a string";
410                         break;
411                     default:
412                         msg="xxx";
413                     }
414                     throw Py.TypeError(msg);
415                 }
416             }
417
418             public PyObject __call__(PyObject arg0,PyObject arg1) {
419                 try {
420                     return Py.newInteger(self.str_count(arg0.asString(0),arg1.asInt(1)));
421                 } catch (PyObject.ConversionException e) {
422                     String JavaDoc msg;
423                     switch (e.index) {
424                     case 1:
425                         msg="expected an integer";
426                         break;
427                     case 0:
428                         msg="expected a string";
429                         break;
430                     default:
431                         msg="xxx";
432                     }
433                     throw Py.TypeError(msg);
434                 }
435             }
436
437             public PyObject inst_call(PyObject gself,PyObject arg0,PyObject arg1) {
438                 PyString self=(PyString)gself;
439                 try {
440                     return Py.newInteger(self.str_count(arg0.asString(0),arg1.asInt(1)));
441                 } catch (PyObject.ConversionException e) {
442                     String JavaDoc msg;
443                     switch (e.index) {
444                     case 1:
445                         msg="expected an integer";
446                         break;
447                     case 0:
448                         msg="expected a string";
449                         break;
450                     default:
451                         msg="xxx";
452                     }
453                     throw Py.TypeError(msg);
454                 }
455             }
456
457             public PyObject __call__(PyObject arg0) {
458                 try {
459                     return Py.newInteger(self.str_count(arg0.asString(0)));
460                 } catch (PyObject.ConversionException e) {
461                     String JavaDoc msg;
462                     switch (e.index) {
463                     case 0:
464                         msg="expected a string";
465                         break;
466                     default:
467                         msg="xxx";
468                     }
469                     throw Py.TypeError(msg);
470                 }
471             }
472
473             public PyObject inst_call(PyObject gself,PyObject arg0) {
474                 PyString self=(PyString)gself;
475                 try {
476                     return Py.newInteger(self.str_count(arg0.asString(0)));
477                 } catch (PyObject.ConversionException e) {
478                     String JavaDoc msg;
479                     switch (e.index) {
480                     case 0:
481                         msg="expected a string";
482                         break;
483                     default:
484                         msg="xxx";
485                     }
486                     throw Py.TypeError(msg);
487                 }
488             }
489
490         }
491         dict.__setitem__("count",new PyMethodDescr("count",PyString.class,1,3,new exposed_count(null,null)));
492         class exposed_decode extends PyBuiltinFunctionNarrow {
493
494             private PyString self;
495
496             public PyObject getSelf() {
497                 return self;
498             }
499
500             exposed_decode(PyString self,PyBuiltinFunction.Info info) {
501                 super(info);
502                 this.self=self;
503             }
504
505             public PyBuiltinFunction makeBound(PyObject self) {
506                 return new exposed_decode((PyString)self,info);
507             }
508
509             public PyObject __call__(PyObject arg0,PyObject arg1) {
510                 try {
511                     return new PyString(self.str_decode(arg0.asString(0),arg1.asString(1)));
512                 } catch (PyObject.ConversionException e) {
513                     String JavaDoc msg;
514                     switch (e.index) {
515                     case 0:
516                     case 1:
517                         msg="expected a string";
518                         break;
519                     default:
520                         msg="xxx";
521                     }
522                     throw Py.TypeError(msg);
523                 }
524             }
525
526             public PyObject inst_call(PyObject gself,PyObject arg0,PyObject arg1) {
527                 PyString self=(PyString)gself;
528                 try {
529                     return new PyString(self.str_decode(arg0.asString(0),arg1.asString(1)));
530                 } catch (PyObject.ConversionException e) {
531                     String JavaDoc msg;
532                     switch (e.index) {
533                     case 0:
534                     case 1:
535                         msg="expected a string";
536                         break;
537                     default:
538                         msg="xxx";
539                     }
540                     throw Py.TypeError(msg);
541                 }
542             }
543
544             public PyObject __call__(PyObject arg0) {
545                 try {
546                     return new PyString(self.str_decode(arg0.asString(0)));
547                 } catch (PyObject.ConversionException e) {
548                     String JavaDoc msg;
549                     switch (e.index) {
550                     case 0:
551                         msg="expected a string";
552                         break;
553                     default:
554                         msg="xxx";
555                     }
556                     throw Py.TypeError(msg);
557                 }
558             }
559
560             public PyObject inst_call(PyObject gself,PyObject arg0) {
561                 PyString self=(PyString)gself;
562                 try {
563                     return new PyString(self.str_decode(arg0.asString(0)));
564                 } catch (PyObject.ConversionException e) {
565                     String JavaDoc msg;
566                     switch (e.index) {
567                     case 0:
568                         msg="expected a string";
569                         break;
570                     default:
571                         msg="xxx";
572                     }
573                     throw Py.TypeError(msg);
574                 }
575             }
576
577             public PyObject __call__() {
578                 return new PyString(self.str_decode());
579             }
580
581             public PyObject inst_call(PyObject gself) {
582                 PyString self=(PyString)gself;
583                 return new PyString(self.str_decode());
584             }
585
586         }
587         dict.__setitem__("decode",new PyMethodDescr("decode",PyString.class,0,2,new exposed_decode(null,null)));
588         class exposed_encode extends PyBuiltinFunctionNarrow {
589
590             private PyString self;
591
592             public PyObject getSelf() {
593                 return self;
594             }
595
596             exposed_encode(PyString self,PyBuiltinFunction.Info info) {
597                 super(info);
598                 this.self=self;
599             }
600
601             public PyBuiltinFunction makeBound(PyObject self) {
602                 return new exposed_encode((PyString)self,info);
603             }
604
605             public PyObject __call__(PyObject arg0,PyObject arg1) {
606                 try {
607                     return new PyString(self.str_encode(arg0.asString(0),arg1.asString(1)));
608                 } catch (PyObject.ConversionException e) {
609                     String JavaDoc msg;
610                     switch (e.index) {
611                     case 0:
612                     case 1:
613                         msg="expected a string";
614                         break;
615                     default:
616                         msg="xxx";
617                     }
618                     throw Py.TypeError(msg);
619                 }
620             }
621
622             public PyObject inst_call(PyObject gself,PyObject arg0,PyObject arg1) {
623                 PyString self=(PyString)gself;
624                 try {
625                     return new PyString(self.str_encode(arg0.asString(0),arg1.asString(1)));
626                 } catch (PyObject.ConversionException e) {
627                     String JavaDoc msg;
628                     switch (e.index) {
629                     case 0:
630                     case 1:
631                         msg="expected a string";
632                         break;
633                     default:
634                         msg="xxx";
635                     }
636                     throw Py.TypeError(msg);
637                 }
638             }
639
640             public PyObject __call__(PyObject arg0) {
641                 try {
642                     return new PyString(self.str_encode(arg0.asString(0)));
643                 } catch (PyObject.ConversionException e) {
644                     String JavaDoc msg;
645                     switch (e.index) {
646                     case 0:
647                         msg="expected a string";
648                         break;
649                     default:
650                         msg="xxx";
651                     }
652                     throw Py.TypeError(msg);
653                 }
654             }
655
656             public PyObject inst_call(PyObject gself,PyObject arg0) {
657                 PyString self=(PyString)gself;
658                 try {
659                     return new PyString(self.str_encode(arg0.asString(0)));
660                 } catch (PyObject.ConversionException e) {
661                     String JavaDoc msg;
662                     switch (e.index) {
663                     case 0:
664                         msg="expected a string";
665                         break;
666                     default:
667                         msg="xxx";
668                     }
669                     throw Py.TypeError(msg);
670                 }
671             }
672
673             public PyObject __call__() {
674                 return new PyString(self.str_encode());
675             }
676
677             public PyObject inst_call(PyObject gself) {
678                 PyString self=(PyString)gself;
679                 return new PyString(self.str_encode());
680             }
681
682         }
683         dict.__setitem__("encode",new PyMethodDescr("encode",PyString.class,0,2,new exposed_encode(null,null)));
684         class exposed_endswith extends PyBuiltinFunctionNarrow {
685
686             private PyString self;
687
688             public PyObject getSelf() {
689                 return self;
690             }
691
692             exposed_endswith(PyString self,PyBuiltinFunction.Info info) {
693                 super(info);
694                 this.self=self;
695             }
696
697             public PyBuiltinFunction makeBound(PyObject self) {
698                 return new exposed_endswith((PyString)self,info);
699             }
700
701             public PyObject __call__(PyObject arg0,PyObject arg1,PyObject arg2) {
702                 try {
703                     return Py.newBoolean(self.str_endswith(arg0.asString(0),arg1.asInt(1),arg2.asInt(2)));
704                 } catch (PyObject.ConversionException e) {
705                     String JavaDoc msg;
706                     switch (e.index) {
707                     case 1:
708                     case 2:
709                         msg="expected an integer";
710                         break;
711                     case 0:
712                         msg="expected a string";
713                         break;
714                     default:
715                         msg="xxx";
716                     }
717                     throw Py.TypeError(msg);
718                 }
719             }
720
721             public PyObject inst_call(PyObject gself,PyObject arg0,PyObject arg1,PyObject arg2) {
722                 PyString self=(PyString)gself;
723                 try {
724                     return Py.newBoolean(self.str_endswith(arg0.asString(0),arg1.asInt(1),arg2.asInt(2)));
725                 } catch (PyObject.ConversionException e) {
726                     String JavaDoc msg;
727                     switch (e.index) {
728                     case 1:
729                     case 2:
730                         msg="expected an integer";
731                         break;
732                     case 0:
733                         msg="expected a string";
734                         break;
735                     default:
736                         msg="xxx";
737                     }
738                     throw Py.TypeError(msg);
739                 }
740             }
741
742             public PyObject __call__(PyObject arg0,PyObject arg1) {
743                 try {
744                     return Py.newBoolean(self.str_endswith(arg0.asString(0),arg1.asInt(1)));
745                 } catch (PyObject.ConversionException e) {
746                     String JavaDoc msg;
747                     switch (e.index) {
748                     case 1:
749                         msg="expected an integer";
750                         break;
751                     case 0:
752                         msg="expected a string";
753                         break;
754                     default:
755                         msg="xxx";
756                     }
757                     throw Py.TypeError(msg);
758                 }
759             }
760
761             public PyObject inst_call(PyObject gself,PyObject arg0,PyObject arg1) {
762                 PyString self=(PyString)gself;
763                 try {
764                     return Py.newBoolean(self.str_endswith(arg0.asString(0),arg1.asInt(1)));
765                 } catch (PyObject.ConversionException e) {
766                     String JavaDoc msg;
767                     switch (e.index) {
768                     case 1:
769                         msg="expected an integer";
770                         break;
771                     case 0:
772                         msg="expected a string";
773                         break;
774                     default:
775                         msg="xxx";
776                     }
777                     throw Py.TypeError(msg);
778                 }
779             }
780
781             public PyObject __call__(PyObject arg0) {
782                 try {
783                     return Py.newBoolean(self.str_endswith(arg0.asString(0)));
784                 } catch (PyObject.ConversionException e) {
785                     String JavaDoc msg;
786                     switch (e.index) {
787                     case 0:
788                         msg="expected a string";
789                         break;
790                     default:
791                         msg="xxx";
792                     }
793                     throw Py.TypeError(msg);
794                 }
795             }
796
797             public PyObject inst_call(PyObject gself,PyObject arg0) {
798                 PyString self=(PyString)gself;
799                 try {
800                     return Py.newBoolean(self.str_endswith(arg0.asString(0)));
801                 } catch (PyObject.ConversionException e) {
802                     String JavaDoc msg;
803                     switch (e.index) {
804                     case 0:
805                         msg="expected a string";
806                         break;
807                     default:
808                         msg="xxx";
809                     }
810                     throw Py.TypeError(msg);
811                 }
812             }
813
814         }
815         dict.__setitem__("endswith",new PyMethodDescr("endswith",PyString.class,1,3,new exposed_endswith(null,null)));
816         class exposed_expandtabs extends PyBuiltinFunctionNarrow {
817
818             private PyString self;
819
820             public PyObject getSelf() {
821                 return self;
822             }
823
824             exposed_expandtabs(PyString self,PyBuiltinFunction.Info info) {
825                 super(info);
826                 this.self=self;
827             }
828
829             public PyBuiltinFunction makeBound(PyObject self) {
830                 return new exposed_expandtabs((PyString)self,info);
831             }
832
833             public PyObject __call__(PyObject arg0) {
834                 try {
835                     return new PyString(self.str_expandtabs(arg0.asInt(0)));
836                 } catch (PyObject.ConversionException e) {
837                     String JavaDoc msg;
838                     switch (e.index) {
839                     case 0:
840                         msg="expected an integer";
841                         break;
842                     default:
843                         msg="xxx";
844                     }
845                     throw Py.TypeError(msg);
846                 }
847             }
848
849             public PyObject inst_call(PyObject gself,PyObject arg0) {
850                 PyString self=(PyString)gself;
851                 try {
852                     return new PyString(self.str_expandtabs(arg0.asInt(0)));
853                 } catch (PyObject.ConversionException e) {
854                     String JavaDoc msg;
855                     switch (e.index) {
856                     case 0:
857                         msg="expected an integer";
858                         break;
859                     default:
860                         msg="xxx";
861                     }
862                     throw Py.TypeError(msg);
863                 }
864             }
865
866             public PyObject __call__() {
867                 return new PyString(self.str_expandtabs());
868             }
869
870             public PyObject inst_call(PyObject gself) {
871                 PyString self=(PyString)gself;
872                 return new PyString(self.str_expandtabs());
873             }
874
875         }
876         dict.__setitem__("expandtabs",new PyMethodDescr("expandtabs",PyString.class,0,1,new exposed_expandtabs(null,null)));
877         class exposed_find extends PyBuiltinFunctionNarrow {
878
879             private PyString self;
880
881             public PyObject getSelf() {
882                 return self;
883             }
884
885             exposed_find(PyString self,PyBuiltinFunction.Info info) {
886                 super(info);
887                 this.self=self;
888             }
889
890             public PyBuiltinFunction makeBound(PyObject self) {
891                 return new exposed_find((PyString)self,info);
892             }
893
894             public PyObject __call__(PyObject arg0,PyObject arg1,PyObject arg2) {
895                 try {
896                     return Py.newInteger(self.str_find(arg0.asString(0),arg1.asInt(1),arg2.asInt(2)));
897                 } catch (PyObject.ConversionException e) {
898                     String JavaDoc msg;
899                     switch (e.index) {
900                     case 1:
901                     case 2:
902                         msg="expected an integer";
903                         break;
904                     case 0:
905                         msg="expected a string";
906                         break;
907                     default:
908                         msg="xxx";
909                     }
910                     throw Py.TypeError(msg);
911                 }
912             }
913
914             public PyObject inst_call(PyObject gself,PyObject arg0,PyObject arg1,PyObject arg2) {
915                 PyString self=(PyString)gself;
916                 try {
917                     return Py.newInteger(self.str_find(arg0.asString(0),arg1.asInt(1),arg2.asInt(2)));
918                 } catch (PyObject.ConversionException e) {
919                     String JavaDoc msg;
920                     switch (e.index) {
921                     case 1:
922                     case 2:
923                         msg="expected an integer";
924                         break;
925                     case 0:
926                         msg="expected a string";
927                         break;
928                     default:
929                         msg="xxx";
930                     }
931                     throw Py.TypeError(msg);
932                 }
933             }
934
935             public PyObject __call__(PyObject arg0,PyObject arg1) {
936                 try {
937                     return Py.newInteger(self.str_find(arg0.asString(0),arg1.asInt(1)));
938                 } catch (PyObject.ConversionException e) {
939                     String JavaDoc msg;
940                     switch (e.index) {
941                     case 1:
942                         msg="expected an integer";
943                         break;
944                     case 0:
945                         msg="expected a string";
946                         break;
947                     default:
948                         msg="xxx";
949                     }
950                     throw Py.TypeError(msg);
951                 }
952             }
953
954             public PyObject inst_call(PyObject gself,PyObject arg0,PyObject arg1) {
955                 PyString self=(PyString)gself;
956                 try {
957                     return Py.newInteger(self.str_find(arg0.asString(0),arg1.asInt(1)));
958                 } catch (PyObject.ConversionException e) {
959                     String JavaDoc msg;
960                     switch (e.index) {
961                     case 1:
962                         msg="expected an integer";
963                         break;
964                     case 0:
965                         msg="expected a string";
966                         break;
967                     default:
968                         msg="xxx";
969                     }
970                     throw Py.TypeError(msg);
971                 }
972             }
973
974             public PyObject __call__(PyObject arg0) {
975                 try {
976                     return Py.newInteger(self.str_find(arg0.asString(0)));
977                 } catch (PyObject.ConversionException e) {
978                     String JavaDoc msg;
979                     switch (e.index) {
980                     case 0:
981                         msg="expected a string";
982                         break;
983                     default:
984                         msg="xxx";
985                     }
986                     throw Py.TypeError(msg);
987                 }
988             }
989
990             public PyObject inst_call(PyObject gself,PyObject arg0) {
991                 PyString self=(PyString)gself;
992                 try {
993                     return Py.newInteger(self.str_find(arg0.asString(0)));
994                 } catch (PyObject.ConversionException e) {
995                     String JavaDoc msg;
996                     switch (e.index) {
997                     case 0:
998                         msg="expected a string";
999                         break;
1000                    default:
1001                        msg="xxx";
1002                    }
1003                    throw Py.TypeError(msg);
1004                }
1005            }
1006
1007        }
1008        dict.__setitem__("find",new PyMethodDescr("find",PyString.class,1,3,new exposed_find(null,null)));
1009        class exposed_index extends PyBuiltinFunctionNarrow {
1010
1011            private PyString self;
1012
1013            public PyObject getSelf() {
1014                return self;
1015            }
1016
1017            exposed_index(PyString self,PyBuiltinFunction.Info info) {
1018                super(info);
1019                this.self=self;
1020            }
1021
1022            public PyBuiltinFunction makeBound(PyObject self) {
1023                return new exposed_index((PyString)self,info);
1024            }
1025
1026            public PyObject __call__(PyObject arg0,PyObject arg1,PyObject arg2) {
1027                try {
1028                    return Py.newInteger(self.str_index(arg0.asString(0),arg1.asInt(1),arg2.asInt(2)));
1029                } catch (PyObject.ConversionException e) {
1030                    String JavaDoc msg;
1031                    switch (e.index) {
1032                    case 1:
1033                    case 2:
1034                        msg="expected an integer";
1035                        break;
1036                    case 0:
1037                        msg="expected a string";
1038                        break;
1039                    default:
1040                        msg="xxx";
1041                    }
1042                    throw Py.TypeError(msg);
1043                }
1044            }
1045
1046            public PyObject inst_call(PyObject gself,PyObject arg0,PyObject arg1,PyObject arg2) {
1047                PyString self=(PyString)gself;
1048                try {
1049                    return Py.newInteger(self.str_index(arg0.asString(0),arg1.asInt(1),arg2.asInt(2)));
1050                } catch (PyObject.ConversionException e) {
1051                    String JavaDoc msg;
1052                    switch (e.index) {
1053                    case 1:
1054                    case 2:
1055                        msg="expected an integer";
1056                        break;
1057                    case 0:
1058                        msg="expected a string";
1059                        break;
1060                    default:
1061                        msg="xxx";
1062                    }
1063                    throw Py.TypeError(msg);
1064                }
1065            }
1066
1067            public PyObject __call__(PyObject arg0,PyObject arg1) {
1068                try {
1069                    return Py.newInteger(self.str_index(arg0.asString(0),arg1.asInt(1)));
1070                } catch (PyObject.ConversionException e) {
1071                    String JavaDoc msg;
1072                    switch (e.index) {
1073                    case 1:
1074                        msg="expected an integer";
1075                        break;
1076                    case 0:
1077                        msg="expected a string";
1078                        break;
1079                    default:
1080                        msg="xxx";
1081                    }
1082                    throw Py.TypeError(msg);
1083                }
1084            }
1085
1086            public PyObject inst_call(PyObject gself,PyObject arg0,PyObject arg1) {
1087                PyString self=(PyString)gself;
1088                try {
1089                    return Py.newInteger(self.str_index(arg0.asString(0),arg1.asInt(1)));
1090                } catch (PyObject.ConversionException e) {
1091                    String JavaDoc msg;
1092                    switch (e.index) {
1093                    case 1:
1094                        msg="expected an integer";
1095                        break;
1096                    case 0:
1097                        msg="expected a string";
1098                        break;
1099                    default:
1100                        msg="xxx";
1101                    }
1102                    throw Py.TypeError(msg);
1103                }
1104            }
1105
1106            public PyObject __call__(PyObject arg0) {
1107                try {
1108                    return Py.newInteger(self.str_index(arg0.asString(0)));
1109                } catch (PyObject.ConversionException e) {
1110                    String JavaDoc msg;
1111                    switch (e.index) {
1112                    case 0:
1113                        msg="expected a string";
1114                        break;
1115                    default:
1116                        msg="xxx";
1117                    }
1118                    throw Py.TypeError(msg);
1119                }
1120            }
1121
1122            public PyObject inst_call(PyObject gself,PyObject arg0) {
1123                PyString self=(PyString)gself;
1124                try {
1125                    return Py.newInteger(self.str_index(arg0.asString(0)));
1126                } catch (PyObject.ConversionException e) {
1127                    String JavaDoc msg;
1128                    switch (e.index) {
1129                    case 0:
1130                        msg="expected a string";
1131                        break;
1132                    default:
1133                        msg="xxx";
1134                    }
1135                    throw Py.TypeError(msg);
1136                }
1137            }
1138
1139        }
1140        dict.__setitem__("index",new PyMethodDescr("index",PyString.class,1,3,new exposed_index(null,null)));
1141        class exposed_isalnum extends PyBuiltinFunctionNarrow {
1142
1143            private PyString self;
1144
1145            public PyObject getSelf() {
1146                return self;
1147            }
1148
1149            exposed_isalnum(PyString self,PyBuiltinFunction.Info info) {
1150                super(info);
1151                this.self=self;
1152            }
1153
1154            public PyBuiltinFunction makeBound(PyObject self) {
1155                return new exposed_isalnum((PyString)self,info);
1156            }
1157
1158            public PyObject __call__() {
1159                return Py.newBoolean(self.str_isalnum());
1160            }
1161
1162            public PyObject inst_call(PyObject gself) {
1163                PyString self=(PyString)gself;
1164                return Py.newBoolean(self.str_isalnum());
1165            }
1166
1167        }
1168        dict.__setitem__("isalnum",new PyMethodDescr("isalnum",PyString.class,0,0,new exposed_isalnum(null,null)));
1169        class exposed_isalpha extends PyBuiltinFunctionNarrow {
1170
1171            private PyString self;
1172
1173            public PyObject getSelf() {
1174                return self;
1175            }
1176
1177            exposed_isalpha(PyString self,PyBuiltinFunction.Info info) {
1178                super(info);
1179                this.self=self;
1180            }
1181
1182            public PyBuiltinFunction makeBound(PyObject self) {
1183                return new exposed_isalpha((PyString)self,info);
1184            }
1185
1186            public PyObject __call__() {
1187                return Py.newBoolean(self.str_isalpha());
1188            }
1189
1190            public PyObject inst_call(PyObject gself) {
1191                PyString self=(PyString)gself;
1192                return Py.newBoolean(self.str_isalpha());
1193            }
1194
1195        }
1196        dict.__setitem__("isalpha",new PyMethodDescr("isalpha",PyString.class,0,0,new exposed_isalpha(null,null)));
1197        class exposed_isdecimal extends PyBuiltinFunctionNarrow {
1198
1199            private PyString self;
1200
1201            public PyObject getSelf() {
1202                return self;
1203            }
1204
1205            exposed_isdecimal(PyString self,PyBuiltinFunction.Info info) {
1206                super(info);
1207                this.self=self;
1208            }
1209
1210            public PyBuiltinFunction makeBound(PyObject self) {
1211                return new exposed_isdecimal((PyString)self,info);
1212            }
1213
1214            public PyObject __call__() {
1215                return Py.newBoolean(self.str_isdecimal());
1216            }
1217
1218            public PyObject inst_call(PyObject gself) {
1219                PyString self=(PyString)gself;
1220                return Py.newBoolean(self.str_isdecimal());
1221            }
1222
1223        }
1224        dict.__setitem__("isdecimal",new PyMethodDescr("isdecimal",PyString.class,0,0,new exposed_isdecimal(null,null)));
1225        class exposed_isdigit extends PyBuiltinFunctionNarrow {
1226
1227            private PyString self;
1228
1229            public PyObject getSelf() {
1230                return self;
1231            }
1232
1233            exposed_isdigit(PyString self,PyBuiltinFunction.Info info) {
1234                super(info);
1235                this.self=self;
1236            }
1237
1238            public PyBuiltinFunction makeBound(PyObject self) {
1239                return new exposed_isdigit((PyString)self,info);
1240            }
1241
1242            public PyObject __call__() {
1243                return Py.newBoolean(self.str_isdigit());
1244            }
1245
1246            public PyObject inst_call(PyObject gself) {
1247                PyString self=(PyString)gself;
1248                return Py.newBoolean(self.str_isdigit());
1249            }
1250
1251        }
1252        dict.__setitem__("isdigit",new PyMethodDescr("isdigit",PyString.class,0,0,new exposed_isdigit(null,null)));
1253        class exposed_islower extends PyBuiltinFunctionNarrow {
1254
1255            private PyString self;
1256
1257            public PyObject getSelf() {
1258                return self;
1259            }
1260
1261            exposed_islower(PyString self,PyBuiltinFunction.Info info) {
1262                super(info);
1263                this.self=self;
1264            }
1265
1266            public PyBuiltinFunction makeBound(PyObject self) {
1267                return new exposed_islower((PyString)self,info);
1268            }
1269
1270            public PyObject __call__() {
1271                return Py.newBoolean(self.str_islower());
1272            }
1273
1274            public PyObject inst_call(PyObject gself) {
1275                PyString self=(PyString)gself;
1276                return Py.newBoolean(self.str_islower());
1277            }
1278
1279        }
1280        dict.__setitem__("islower",new PyMethodDescr("islower",PyString.class,0,0,new exposed_islower(null,null)));
1281        class exposed_isnumeric extends PyBuiltinFunctionNarrow {
1282
1283            private PyString self;
1284
1285            public PyObject getSelf() {
1286                return self;
1287            }
1288
1289            exposed_isnumeric(PyString self,PyBuiltinFunction.Info info) {
1290                super(info);
1291                this.self=self;
1292            }
1293
1294            public PyBuiltinFunction makeBound(PyObject self) {
1295                return new exposed_isnumeric((PyString)self,info);
1296            }
1297
1298            public PyObject __call__() {
1299                return Py.newBoolean(self.str_isnumeric());
1300            }
1301
1302            public PyObject inst_call(PyObject gself) {
1303                PyString self=(PyString)gself;
1304                return Py.newBoolean(self.str_isnumeric());
1305            }
1306
1307        }
1308        dict.__setitem__("isnumeric",new PyMethodDescr("isnumeric",PyString.class,0,0,new exposed_isnumeric(null,null)));
1309        class exposed_isspace extends PyBuiltinFunctionNarrow {
1310
1311            private PyString self;
1312
1313            public PyObject getSelf() {
1314                return self;
1315            }
1316
1317            exposed_isspace(PyString self,PyBuiltinFunction.Info info) {
1318                super(info);
1319                this.self=self;
1320            }
1321
1322            public PyBuiltinFunction makeBound(PyObject self) {
1323                return new exposed_isspace((PyString)self,info);
1324            }
1325
1326            public PyObject __call__() {
1327                return Py.newBoolean(self.str_isspace());
1328            }
1329
1330            public PyObject inst_call(PyObject gself) {
1331                PyString self=(PyString)gself;
1332                return Py.newBoolean(self.str_isspace());
1333            }
1334
1335        }
1336        dict.__setitem__("isspace",new PyMethodDescr("isspace",PyString.class,0,0,new exposed_isspace(null,null)));
1337        class exposed_istitle extends PyBuiltinFunctionNarrow {
1338
1339            private PyString self;
1340
1341            public PyObject getSelf() {
1342                return self;
1343            }
1344
1345            exposed_istitle(PyString self,PyBuiltinFunction.Info info) {
1346                super(info);
1347                this.self=self;
1348            }
1349
1350            public PyBuiltinFunction makeBound(PyObject self) {
1351                return new exposed_istitle((PyString)self,info);
1352            }
1353
1354            public PyObject __call__() {
1355                return Py.newBoolean(self.str_istitle());
1356            }
1357
1358            public PyObject inst_call(PyObject gself) {
1359                PyString self=(PyString)gself;
1360                return Py.newBoolean(self.str_istitle());
1361            }
1362
1363        }
1364        dict.__setitem__("istitle",new PyMethodDescr("istitle",PyString.class,0,0,new exposed_istitle(null,null)));
1365        class exposed_isunicode extends PyBuiltinFunctionNarrow {
1366
1367            private PyString self;
1368
1369            public PyObject getSelf() {
1370                return self;
1371            }
1372
1373            exposed_isunicode(PyString self,PyBuiltinFunction.Info info) {
1374                super(info);
1375                this.self=self;
1376            }
1377
1378            public PyBuiltinFunction makeBound(PyObject self) {
1379                return new exposed_isunicode((PyString)self,info);
1380            }
1381
1382            public PyObject __call__() {
1383                return Py.newBoolean(self.str_isunicode());
1384            }
1385
1386            public PyObject inst_call(PyObject gself) {
1387                PyString self=(PyString)gself;
1388                return Py.newBoolean(self.str_isunicode());
1389            }
1390
1391        }
1392        dict.__setitem__("isunicode",new PyMethodDescr("isunicode",PyString.class,0,0,new exposed_isunicode(null,null)));
1393        class exposed_isupper extends PyBuiltinFunctionNarrow {
1394
1395            private PyString self;
1396
1397            public PyObject getSelf() {
1398                return self;
1399            }
1400
1401            exposed_isupper(PyString self,PyBuiltinFunction.Info info) {
1402                super(info);
1403                this.self=self;
1404            }
1405
1406            public PyBuiltinFunction makeBound(PyObject self) {
1407                return new exposed_isupper((PyString)self,info);
1408            }
1409
1410            public PyObject __call__() {
1411                return Py.newBoolean(self.str_isupper());
1412            }
1413
1414            public PyObject inst_call(PyObject gself) {
1415                PyString self=(PyString)gself;
1416                return Py.newBoolean(self.str_isupper());
1417            }
1418
1419        }
1420        dict.__setitem__("isupper",new PyMethodDescr("isupper",PyString.class,0,0,new exposed_isupper(null,null)));
1421        class exposed_join extends PyBuiltinFunctionNarrow {
1422
1423            private PyString self;
1424
1425            public PyObject getSelf() {
1426                return self;
1427            }
1428
1429            exposed_join(PyString self,PyBuiltinFunction.Info info) {
1430                super(info);
1431                this.self=self;
1432            }
1433
1434            public PyBuiltinFunction makeBound(PyObject self) {
1435                return new exposed_join((PyString)self,info);
1436            }
1437
1438            public PyObject __call__(PyObject arg0) {
1439                return new PyString(self.str_join(arg0));
1440            }
1441
1442            public PyObject inst_call(PyObject gself,PyObject arg0) {
1443                PyString self=(PyString)gself;
1444                return new PyString(self.str_join(arg0));
1445            }
1446
1447        }
1448        dict.__setitem__("join",new PyMethodDescr("join",PyString.class,1,1,new exposed_join(null,null)));
1449        class exposed_ljust extends PyBuiltinFunctionNarrow {
1450
1451            private PyString self;
1452
1453            public PyObject getSelf() {
1454                return self;
1455            }
1456
1457            exposed_ljust(PyString self,PyBuiltinFunction.Info info) {
1458                super(info);
1459                this.self=self;
1460            }
1461
1462            public PyBuiltinFunction makeBound(PyObject self) {
1463                return new exposed_ljust((PyString)self,info);
1464            }
1465
1466            public PyObject __call__(PyObject arg0) {
1467                try {
1468                    return new PyString(self.str_ljust(arg0.asInt(0)));
1469                } catch (PyObject.ConversionException e) {
1470                    String JavaDoc msg;
1471                    switch (e.index) {
1472                    case 0:
1473                        msg="expected an integer";
1474                        break;
1475                    default:
1476                        msg="xxx";
1477                    }
1478                    throw Py.TypeError(msg);
1479                }
1480            }
1481
1482            public PyObject inst_call(PyObject gself,PyObject arg0) {
1483                PyString self=(PyString)gself;
1484                try {
1485                    return new PyString(self.str_ljust(arg0.asInt(0)));
1486                } catch (PyObject.ConversionException e) {
1487                    String JavaDoc msg;
1488                    switch (e.index) {
1489                    case 0:
1490                        msg="expected an integer";
1491                        break;
1492                    default:
1493                        msg="xxx";
1494                    }
1495                    throw Py.TypeError(msg);
1496                }
1497            }
1498
1499        }
1500        dict.__setitem__("ljust",new PyMethodDescr("ljust",PyString.class,1,1,new exposed_ljust(null,null)));
1501        class exposed_lower extends PyBuiltinFunctionNarrow {
1502
1503            private PyString self;
1504
1505            public PyObject getSelf() {
1506                return self;
1507            }
1508
1509            exposed_lower(PyString self,PyBuiltinFunction.Info info) {
1510                super(info);
1511                this.self=self;
1512            }
1513
1514            public PyBuiltinFunction makeBound(PyObject self) {
1515                return new exposed_lower((PyString)self,info);
1516            }
1517
1518            public PyObject __call__() {
1519                return new PyString(self.str_lower());
1520            }
1521
1522            public PyObject inst_call(PyObject gself) {
1523                PyString self=(PyString)gself;
1524                return new PyString(self.str_lower());
1525            }
1526
1527        }
1528        dict.__setitem__("lower",new PyMethodDescr("lower",PyString.class,0,0,new exposed_lower(null,null)));
1529        class exposed_lstrip extends PyBuiltinFunctionNarrow {
1530
1531            private PyString self;
1532
1533            public PyObject getSelf() {
1534                return self;
1535            }
1536
1537            exposed_lstrip(PyString self,PyBuiltinFunction.Info info) {
1538                super(info);
1539                this.self=self;
1540            }
1541
1542            public PyBuiltinFunction makeBound(PyObject self) {
1543                return new exposed_lstrip((PyString)self,info);
1544            }
1545
1546            public PyObject __call__(PyObject arg0) {
1547                try {
1548                    return new PyString(self.str_lstrip(arg0.asStringOrNull(0)));
1549                } catch (PyObject.ConversionException e) {
1550                    String JavaDoc msg;
1551                    switch (e.index) {
1552                    case 0:
1553                        msg="expected a string or None";
1554                        break;
1555                    default:
1556                        msg="xxx";
1557                    }
1558                    throw Py.TypeError(msg);
1559                }
1560            }
1561
1562            public PyObject inst_call(PyObject gself,PyObject arg0) {
1563                PyString self=(PyString)gself;
1564                try {
1565                    return new PyString(self.str_lstrip(arg0.asStringOrNull(0)));
1566                } catch (PyObject.ConversionException e) {
1567                    String JavaDoc msg;
1568                    switch (e.index) {
1569                    case 0:
1570                        msg="expected a string or None";
1571                        break;
1572                    default:
1573                        msg="xxx";
1574                    }
1575                    throw Py.TypeError(msg);
1576                }
1577            }
1578
1579            public PyObject __call__() {
1580                return new PyString(self.str_lstrip());
1581            }
1582
1583            public PyObject inst_call(PyObject gself) {
1584                PyString self=(PyString)gself;
1585                return new PyString(self.str_lstrip());
1586            }
1587
1588        }
1589        dict.__setitem__("lstrip",new PyMethodDescr("lstrip",PyString.class,0,1,new exposed_lstrip(null,null)));
1590        class exposed_replace extends PyBuiltinFunctionNarrow {
1591
1592            private PyString self;
1593
1594            public PyObject getSelf() {
1595                return self;
1596            }
1597
1598            exposed_replace(PyString self,PyBuiltinFunction.Info info) {
1599                super(info);
1600                this.self=self;
1601            }
1602
1603            public PyBuiltinFunction makeBound(PyObject self) {
1604                return new exposed_replace((PyString)self,info);
1605            }
1606
1607            public PyObject __call__(PyObject arg0,PyObject arg1,PyObject arg2) {
1608                try {
1609                    return new PyString(self.str_replace(arg0.asString(0),arg1.asString(1),arg2.asInt(2)));
1610                } catch (PyObject.ConversionException e) {
1611                    String JavaDoc msg;
1612                    switch (e.index) {
1613                    case 2:
1614                        msg="expected an integer";
1615                        break;
1616                    case 0:
1617                    case 1:
1618                        msg="expected a string";
1619                        break;
1620                    default:
1621                        msg="xxx";
1622                    }
1623                    throw Py.TypeError(msg);
1624                }
1625            }
1626
1627            public PyObject inst_call(PyObject gself,PyObject arg0,PyObject arg1,PyObject arg2) {
1628                PyString self=(PyString)gself;
1629                try {
1630                    return new PyString(self.str_replace(arg0.asString(0),arg1.asString(1),arg2.asInt(2)));
1631                } catch (PyObject.ConversionException e) {
1632                    String JavaDoc msg;
1633                    switch (e.index) {
1634                    case 2:
1635                        msg="expected an integer";
1636                        break;
1637                    case 0:
1638                    case 1:
1639                        msg="expected a string";
1640                        break;
1641                    default:
1642                        msg="xxx";
1643                    }
1644                    throw Py.TypeError(msg);
1645                }
1646            }
1647
1648            public PyObject __call__(PyObject arg0,PyObject arg1) {
1649                try {
1650                    return new PyString(self.str_replace(arg0.asString(0),arg1.asString(1)));
1651                } catch (PyObject.ConversionException e) {
1652                    String JavaDoc msg;
1653                    switch (e.index) {
1654                    case 0:
1655                    case 1:
1656                        msg="expected a string";
1657                        break;
1658                    default:
1659                        msg="xxx";
1660                    }
1661                    throw Py.TypeError(msg);
1662                }
1663            }
1664
1665            public PyObject inst_call(PyObject gself,PyObject arg0,PyObject arg1) {
1666                PyString self=(PyString)gself;
1667                try {
1668                    return new PyString(self.str_replace(arg0.asString(0),arg1.asString(1)));
1669                } catch (PyObject.ConversionException e) {
1670                    String JavaDoc msg;
1671                    switch (e.index) {
1672                    case 0:
1673                    case 1:
1674                        msg="expected a string";
1675                        break;
1676                    default:
1677                        msg="xxx";
1678                    }
1679                    throw Py.TypeError(msg);
1680                }
1681            }
1682
1683        }
1684        dict.__setitem__("replace",new PyMethodDescr("replace",PyString.class,2,3,new exposed_replace(null,null)));
1685        class exposed_rfind extends PyBuiltinFunctionNarrow {
1686
1687            private PyString self;
1688
1689            public PyObject getSelf() {
1690                return self;
1691            }
1692
1693            exposed_rfind(PyString self,PyBuiltinFunction.Info info) {
1694                super(info);
1695                this.self=self;
1696            }
1697
1698            public PyBuiltinFunction makeBound(PyObject self) {
1699                return new exposed_rfind((PyString)self,info);
1700            }
1701
1702            public PyObject __call__(PyObject arg0,PyObject arg1,PyObject arg2) {
1703                try {
1704                    return Py.newInteger(self.str_rfind(arg0.asString(0),arg1.asInt(1),arg2.asInt(2)));
1705                } catch (PyObject.ConversionException e) {
1706                    String JavaDoc msg;
1707                    switch (e.index) {
1708                    case 1:
1709                    case 2:
1710                        msg="expected an integer";
1711                        break;
1712                    case 0:
1713                        msg="expected a string";
1714                        break;
1715                    default:
1716                        msg="xxx";
1717                    }
1718                    throw Py.TypeError(msg);
1719                }
1720            }
1721
1722            public PyObject inst_call(PyObject gself,PyObject arg0,PyObject arg1,PyObject arg2) {
1723                PyString self=(PyString)gself;
1724                try {
1725                    return Py.newInteger(self.str_rfind(arg0.asString(0),arg1.asInt(1),arg2.asInt(2)));
1726                } catch (PyObject.ConversionException e) {
1727                    String JavaDoc msg;
1728                    switch (e.index) {
1729                    case 1:
1730                    case 2:
1731                        msg="expected an integer";
1732                        break;
1733                    case 0:
1734                        msg="expected a string";
1735                        break;
1736                    default:
1737                        msg="xxx";
1738                    }
1739                    throw Py.TypeError(msg);
1740                }
1741            }
1742
1743            public PyObject __call__(PyObject arg0,PyObject arg1) {
1744                try {
1745                    return Py.newInteger(self.str_rfind(arg0.asString(0),arg1.asInt(1)));
1746                } catch (PyObject.ConversionException e) {
1747                    String JavaDoc msg;
1748                    switch (e.index) {
1749                    case 1:
1750                        msg="expected an integer";
1751                        break;
1752                    case 0:
1753                        msg="expected a string";
1754                        break;
1755                    default:
1756                        msg="xxx";
1757                    }
1758                    throw Py.TypeError(msg);
1759                }
1760            }
1761
1762            public PyObject inst_call(PyObject gself,PyObject arg0,PyObject arg1) {
1763                PyString self=(PyString)gself;
1764                try {
1765                    return Py.newInteger(self.str_rfind(arg0.asString(0),arg1.asInt(1)));
1766                } catch (PyObject.ConversionException e) {
1767                    String JavaDoc msg;
1768                    switch (e.index) {
1769                    case 1:
1770                        msg="expected an integer";
1771                        break;
1772                    case 0:
1773                        msg="expected a string";
1774                        break;
1775                    default:
1776                        msg="xxx";
1777                    }
1778                    throw Py.TypeError(msg);
1779                }
1780            }
1781
1782            public PyObject __call__(PyObject arg0) {
1783                try {
1784                    return Py.newInteger(self.str_rfind(arg0.asString(0)));
1785                } catch (PyObject.ConversionException e) {
1786                    String JavaDoc msg;
1787                    switch (e.index) {
1788                    case 0:
1789                        msg="expected a string";
1790                        break;
1791                    default:
1792                        msg="xxx";
1793                    }
1794                    throw Py.TypeError(msg);
1795                }
1796            }
1797
1798            public PyObject inst_call(PyObject gself,PyObject arg0) {
1799                PyString self=(PyString)gself;
1800                try {
1801                    return Py.newInteger(self.str_rfind(arg0.asString(0)));
1802                } catch (PyObject.ConversionException e) {
1803                    String JavaDoc msg;
1804                    switch (e.index) {
1805                    case 0:
1806                        msg="expected a string";
1807                        break;
1808                    default:
1809                        msg="xxx";
1810                    }
1811                    throw Py.TypeError(msg);
1812                }
1813            }
1814
1815        }
1816        dict.__setitem__("rfind",new PyMethodDescr("rfind",PyString.class,1,3,new exposed_rfind(null,null)));
1817        class exposed_rindex extends PyBuiltinFunctionNarrow {
1818
1819            private PyString self;
1820
1821            public PyObject getSelf() {
1822                return self;
1823            }
1824
1825            exposed_rindex(PyString self,PyBuiltinFunction.Info info) {
1826                super(info);
1827                this.self=self;
1828            }
1829
1830            public PyBuiltinFunction makeBound(PyObject self) {
1831                return new exposed_rindex((PyString)self,info);
1832            }
1833
1834            public PyObject __call__(PyObject arg0,PyObject arg1,PyObject arg2) {
1835                try {
1836                    return Py.newInteger(self.str_rindex(arg0.asString(0),arg1.asInt(1),arg2.asInt(2)));
1837                } catch (PyObject.ConversionException e) {
1838                    String JavaDoc msg;
1839                    switch (e.index) {
1840                    case 1:
1841                    case 2:
1842                        msg="expected an integer";
1843                        break;
1844                    case 0:
1845                        msg="expected a string";
1846                        break;
1847                    default:
1848                        msg="xxx";
1849                    }
1850                    throw Py.TypeError(msg);
1851                }
1852            }
1853
1854            public PyObject inst_call(PyObject gself,PyObject arg0,PyObject arg1,PyObject arg2) {
1855                PyString self=(PyString)gself;
1856                try {
1857                    return Py.newInteger(self.str_rindex(arg0.asString(0),arg1.asInt(1),arg2.asInt(2)));
1858                } catch (PyObject.ConversionException e) {
1859                    String JavaDoc msg;
1860                    switch (e.index) {
1861                    case 1:
1862                    case 2:
1863                        msg="expected an integer";
1864                        break;
1865                    case 0:
1866                        msg="expected a string";
1867                        break;
1868                    default:
1869                        msg="xxx";
1870                    }
1871                    throw Py.TypeError(msg);
1872                }
1873            }
1874
1875            public PyObject __call__(PyObject arg0,PyObject arg1) {
1876                try {
1877                    return Py.newInteger(self.str_rindex(arg0.asString(0),arg1.asInt(1)));
1878                } catch (PyObject.ConversionException e) {
1879                    String JavaDoc msg;
1880                    switch (e.index) {
1881                    case 1:
1882                        msg="expected an integer";
1883                        break;
1884                    case 0:
1885                        msg="expected a string";
1886                        break;
1887                    default:
1888                        msg="xxx";
1889                    }
1890                    throw Py.TypeError(msg);
1891                }
1892            }
1893
1894            public PyObject inst_call(PyObject gself,PyObject arg0,PyObject arg1) {
1895                PyString self=(PyString)gself;
1896                try {
1897                    return Py.newInteger(self.str_rindex(arg0.asString(0),arg1.asInt(1)));
1898                } catch (PyObject.ConversionException e) {
1899                    String JavaDoc msg;
1900                    switch (e.index) {
1901                    case 1:
1902                        msg="expected an integer";
1903                        break;
1904                    case 0:
1905                        msg="expected a string";
1906                        break;
1907                    default:
1908                        msg="xxx";
1909                    }
1910                    throw Py.TypeError(msg);
1911                }
1912            }
1913
1914            public PyObject __call__(PyObject arg0) {
1915                try {
1916                    return Py.newInteger(self.str_rindex(arg0.asString(0)));
1917                } catch (PyObject.ConversionException e) {
1918                    String JavaDoc msg;
1919                    switch (e.index) {
1920                    case 0:
1921                        msg="expected a string";
1922                        break;
1923                    default:
1924                        msg="xxx";
1925                    }
1926                    throw Py.TypeError(msg);
1927                }
1928            }
1929
1930            public PyObject inst_call(PyObject gself,PyObject arg0) {
1931                PyString self=(PyString)gself;
1932                try {
1933                    return Py.newInteger(self.str_rindex(arg0.asString(0)));
1934                } catch (PyObject.ConversionException e) {
1935                    String JavaDoc msg;
1936                    switch (e.index) {
1937                    case 0:
1938                        msg="expected a string";
1939                        break;
1940                    default:
1941                        msg="xxx";
1942                    }
1943                    throw Py.TypeError(msg);
1944                }
1945            }
1946
1947        }
1948        dict.__setitem__("rindex",new PyMethodDescr("rindex",PyString.class,1,3,new exposed_rindex(null,null)));
1949        class exposed_rjust extends PyBuiltinFunctionNarrow {
1950
1951            private PyString self;
1952
1953            public PyObject getSelf() {
1954                return self;
1955            }
1956
1957            exposed_rjust(PyString self,PyBuiltinFunction.Info info) {
1958                super(info);
1959                this.self=self;
1960            }
1961
1962            public PyBuiltinFunction makeBound(PyObject self) {
1963                return new exposed_rjust((PyString)self,info);
1964            }
1965
1966            public PyObject __call__(PyObject arg0) {
1967                try {
1968                    return new PyString(self.str_rjust(arg0.asInt(0)));
1969                } catch (PyObject.ConversionException e) {
1970                    String JavaDoc msg;
1971                    switch (e.index) {
1972                    case 0:
1973                        msg="expected an integer";
1974                        break;
1975                    default:
1976                        msg="xxx";
1977                    }
1978                    throw Py.TypeError(msg);
1979                }
1980            }
1981
1982            public PyObject inst_call(PyObject gself,PyObject arg0) {
1983                PyString self=(PyString)gself;
1984                try {
1985                    return new PyString(self.str_rjust(arg0.asInt(0)));
1986                } catch (PyObject.ConversionException e) {
1987                    String JavaDoc msg;
1988                    switch (e.index) {
1989                    case 0:
1990                        msg="expected an integer";
1991                        break;
1992                    default:
1993                        msg="xxx";
1994                    }
1995                    throw Py.TypeError(msg);
1996                }
1997            }
1998
1999        }
2000        dict.__setitem__("rjust",new PyMethodDescr("rjust",PyString.class,1,1,new exposed_rjust(null,null)));
2001        class exposed_rstrip extends PyBuiltinFunctionNarrow {
2002
2003            private PyString self;
2004
2005            public PyObject getSelf() {
2006                return self;
2007            }
2008
2009            exposed_rstrip(PyString self,PyBuiltinFunction.Info info) {
2010                super(info);
2011                this.self=self;
2012            }
2013
2014            public PyBuiltinFunction makeBound(PyObject self) {
2015                return new exposed_rstrip((PyString)self,info);
2016            }
2017
2018            public PyObject __call__(PyObject arg0) {
2019                try {
2020                    return new PyString(self.str_rstrip(arg0.asStringOrNull(0)));
2021                } catch (PyObject.ConversionException e) {
2022                    String JavaDoc msg;
2023                    switch (e.index) {
2024                    case 0:
2025                        msg="expected a string or None";
2026                        break;
2027                    default:
2028                        msg="xxx";
2029                    }
2030                    throw Py.TypeError(msg);
2031                }
2032            }
2033
2034            public PyObject inst_call(PyObject gself,PyObject arg0) {
2035                PyString self=(PyString)gself;
2036                try {
2037                    return new PyString(self.str_rstrip(arg0.asStringOrNull(0)));
2038                } catch (PyObject.ConversionException e) {
2039                    String JavaDoc msg;
2040                    switch (e.index) {
2041                    case 0:
2042                        msg="expected a string or None";
2043                        break;
2044                    default:
2045                        msg="xxx";
2046                    }
2047                    throw Py.TypeError(msg);
2048                }
2049            }
2050
2051            public PyObject __call__() {
2052                return new PyString(self.str_rstrip());
2053            }
2054
2055            public PyObject inst_call(PyObject gself) {
2056                PyString self=(PyString)gself;
2057                return new PyString(self.str_rstrip());
2058            }
2059
2060        }
2061        dict.__setitem__("rstrip",new PyMethodDescr("rstrip",PyString.class,0,1,new exposed_rstrip(null,null)));
2062        class exposed_split extends PyBuiltinFunctionNarrow {
2063
2064            private PyString self;
2065
2066            public PyObject getSelf() {
2067                return self;
2068            }
2069
2070            exposed_split(PyString self,PyBuiltinFunction.Info info) {
2071                super(info);
2072                this.self=self;
2073            }
2074
2075            public PyBuiltinFunction makeBound(PyObject self) {
2076                return new exposed_split((PyString)self,info);
2077            }
2078
2079            public PyObject __call__(PyObject arg0,PyObject arg1) {
2080                try {
2081                    return self.str_split(arg0.asStringOrNull(0),arg1.asInt(1));
2082                } catch (PyObject.ConversionException e) {
2083                    String JavaDoc msg;
2084                    switch (e.index) {
2085                    case 1:
2086                        msg="expected an integer";
2087                        break;
2088                    case 0:
2089                        msg="expected a string or None";
2090                        break;
2091                    default:
2092                        msg="xxx";
2093                    }
2094                    throw Py.TypeError(msg);
2095                }
2096            }
2097
2098            public PyObject inst_call(PyObject gself,PyObject arg0,PyObject arg1) {
2099                PyString self=(PyString)gself;
2100                try {
2101                    return self.str_split(arg0.asStringOrNull(0),arg1.asInt(1));
2102                } catch (PyObject.ConversionException e) {
2103                    String JavaDoc msg;
2104                    switch (e.index) {
2105                    case 1:
2106                        msg="expected an integer";
2107                        break;
2108                    case 0:
2109                        msg="expected a string or None";
2110                        break;
2111                    default:
2112                        msg="xxx";
2113                    }
2114                    throw Py.TypeError(msg);
2115                }
2116            }
2117
2118            public PyObject __call__(PyObject arg0) {
2119                try {
2120                    return self.str_split(arg0.asStringOrNull(0));
2121                } catch (PyObject.ConversionException e) {
2122                    String JavaDoc msg;
2123                    switch (e.index) {
2124                    case 0:
2125                        msg="expected a string or None";
2126                        break;
2127                    default:
2128                        msg="xxx";
2129                    }
2130                    throw Py.TypeError(msg);
2131                }
2132            }
2133
2134            public PyObject inst_call(PyObject gself,PyObject arg0) {
2135                PyString self=(PyString)gself;
2136                try {
2137                    return self.str_split(arg0.asStringOrNull(0));
2138                } catch (PyObject.ConversionException e) {
2139                    String JavaDoc msg;
2140                    switch (e.index) {
2141                    case 0:
2142                        msg="expected a string or None";
2143                        break;
2144                    default:
2145                        msg="xxx";
2146                    }
2147                    throw Py.TypeError(msg);
2148                }
2149            }
2150
2151            public PyObject __call__() {
2152                return self.str_split();
2153            }
2154
2155            public PyObject inst_call(PyObject gself) {
2156                PyString self=(PyString)gself;
2157                return self.str_split();
2158            }
2159
2160        }
2161        dict.__setitem__("split",new PyMethodDescr("split",PyString.class,0,2,new exposed_split(null,null)));
2162        class exposed_splitlines extends PyBuiltinFunctionNarrow {
2163
2164            private PyString self;
2165
2166            public PyObject getSelf() {
2167                return self;
2168            }
2169
2170            exposed_splitlines(PyString self,PyBuiltinFunction.Info info) {
2171                super(info);
2172                this.self=self;
2173            }
2174
2175            public PyBuiltinFunction makeBound(PyObject self) {
2176                return new exposed_splitlines((PyString)self,info);
2177            }
2178
2179            public PyObject __call__(PyObject arg0) {
2180                return self.str_splitlines(arg0.__nonzero__());
2181            }
2182
2183            public PyObject inst_call(PyObject gself,PyObject arg0) {
2184                PyString self=(PyString)gself;
2185                return self.str_splitlines(arg0.__nonzero__());
2186            }
2187
2188            public PyObject __call__() {
2189                return self.str_splitlines();
2190            }
2191
2192            public PyObject inst_call(PyObject gself) {
2193                PyString self=(PyString)gself;
2194                return self.str_splitlines();
2195            }
2196
2197        }
2198        dict.__setitem__("splitlines",new PyMethodDescr("splitlines",PyString.class,0,1,new exposed_splitlines(null,null)));
2199        class exposed_startswith extends PyBuiltinFunctionNarrow {
2200
2201            private PyString self;
2202
2203            public PyObject getSelf() {
2204                return self;
2205            }
2206
2207            exposed_startswith(PyString self,PyBuiltinFunction.Info info) {
2208                super(info);
2209                this.self=self;
2210            }
2211
2212            public PyBuiltinFunction makeBound(PyObject self) {
2213                return new exposed_startswith((PyString)self,info);
2214            }
2215
2216            public PyObject __call__(PyObject arg0,PyObject arg1,PyObject arg2) {
2217                try {
2218                    return Py.newBoolean(self.str_startswith(arg0.asString(0),arg1.asInt(1),arg2.asInt(2)));
2219                } catch (PyObject.ConversionException e) {
2220                    String JavaDoc msg;
2221                    switch (e.index) {
2222                    case 1:
2223                    case 2:
2224                        msg="expected an integer";
2225                        break;
2226                    case 0:
2227                        msg="expected a string";
2228                        break;
2229                    default:
2230                        msg="xxx";
2231                    }
2232                    throw Py.TypeError(msg);
2233                }
2234            }
2235
2236            public PyObject inst_call(PyObject gself,PyObject arg0,PyObject arg1,PyObject arg2) {
2237                PyString self=(PyString)gself;
2238                try {
2239                    return Py.newBoolean(self.str_startswith(arg0.asString(0),arg1.asInt(1),arg2.asInt(2)));
2240                } catch (PyObject.ConversionException e) {
2241                    String JavaDoc msg;
2242                    switch (e.index) {
2243                    case 1:
2244                    case 2:
2245                        msg="expected an integer";
2246                        break;
2247                    case 0:
2248                        msg="expected a string";
2249                        break;
2250                    default:
2251                        msg="xxx";
2252                    }
2253                    throw Py.TypeError(msg);
2254                }
2255            }
2256
2257            public PyObject __call__(PyObject arg0,PyObject arg1) {
2258                try {
2259                    return Py.newBoolean(self.str_startswith(arg0.asString(0),arg1.asInt(1)));
2260                } catch (PyObject.ConversionException e) {
2261                    String JavaDoc msg;
2262                    switch (e.index) {
2263                    case 1:
2264                        msg="expected an integer";
2265                        break;
2266                    case 0:
2267                        msg="expected a string";
2268                        break;
2269                    default:
2270                        msg="xxx";
2271                    }
2272                    throw Py.TypeError(msg);
2273                }
2274            }
2275
2276            public PyObject inst_call(PyObject gself,PyObject arg0,PyObject arg1) {
2277                PyString self=(PyString)gself;
2278                try {
2279                    return Py.newBoolean(self.str_startswith(arg0.asString(0),arg1.asInt(1)));
2280                } catch (PyObject.ConversionException e) {
2281                    String JavaDoc msg;
2282                    switch (e.index) {
2283                    case 1:
2284                        msg="expected an integer";
2285                        break;
2286                    case 0:
2287                        msg="expected a string";
2288                        break;
2289                    default:
2290                        msg="xxx";
2291                    }
2292                    throw Py.TypeError(msg);
2293                }
2294            }
2295
2296            public PyObject __call__(PyObject arg0) {
2297                try {
2298                    return Py.newBoolean(self.str_startswith(arg0.asString(0)));
2299                } catch (PyObject.ConversionException e) {
2300                    String JavaDoc msg;
2301                    switch (e.index) {
2302                    case 0:
2303                        msg="expected a string";
2304                        break;
2305                    default:
2306                        msg="xxx";
2307                    }
2308                    throw Py.TypeError(msg);
2309                }
2310            }
2311
2312            public PyObject inst_call(PyObject gself,PyObject arg0) {
2313                PyString self=(PyString)gself;
2314                try {
2315                    return Py.newBoolean(self.str_startswith(arg0.asString(0)));
2316                } catch (PyObject.ConversionException e) {
2317                    String JavaDoc msg;
2318                    switch (e.index) {
2319                    case 0:
2320                        msg="expected a string";
2321                        break;
2322                    default:
2323                        msg="xxx";
2324                    }
2325                    throw Py.TypeError(msg);
2326                }
2327            }
2328
2329        }
2330        dict.__setitem__("startswith",new PyMethodDescr("startswith",PyString.class,1,3,new exposed_startswith(null,null)));
2331        class exposed_strip extends PyBuiltinFunctionNarrow {
2332
2333            private PyString self;
2334
2335            public PyObject getSelf() {
2336                return self;
2337            }
2338
2339            exposed_strip(PyString self,PyBuiltinFunction.Info info) {
2340                super(info);
2341                this.self=self;
2342            }
2343
2344            public PyBuiltinFunction makeBound(PyObject self) {
2345                return new exposed_strip((PyString)self,info);
2346            }
2347
2348            public PyObject __call__(PyObject arg0) {
2349                try {
2350                    return new PyString(self.str_strip(arg0.asStringOrNull(0)));
2351                } catch (PyObject.ConversionException e) {
2352                    String JavaDoc msg;
2353                    switch (e.index) {
2354                    case 0:
2355                        msg="expected a string or None";
2356                        break;
2357                    default:
2358                        msg="xxx";
2359                    }
2360                    throw Py.TypeError(msg);
2361                }
2362            }
2363
2364            public PyObject inst_call(PyObject gself,PyObject arg0) {
2365                PyString self=(PyString)gself;
2366                try {
2367                    return new PyString(self.str_strip(arg0.asStringOrNull(0)));
2368                } catch (PyObject.ConversionException e) {
2369                    String JavaDoc msg;
2370                    switch (e.index) {
2371                    case 0:
2372                        msg="expected a string or None";
2373                        break;
2374                    default:
2375                        msg="xxx";
2376                    }
2377                    throw Py.TypeError(msg);
2378                }
2379            }
2380
2381            public PyObject __call__() {
2382                return new PyString(self.str_strip());
2383            }
2384
2385            public PyObject inst_call(PyObject gself) {
2386                PyString self=(PyString)gself;
2387                return new PyString(self.str_strip());
2388            }
2389
2390        }
2391        dict.__setitem__("strip",new PyMethodDescr("strip",PyString.class,0,1,new exposed_strip(null,null)));
2392        class exposed_swapcase extends PyBuiltinFunctionNarrow {
2393
2394            private PyString self;
2395
2396            public PyObject getSelf() {
2397                return self;
2398            }
2399
2400            exposed_swapcase(PyString self,PyBuiltinFunction.Info info) {
2401                super(info);
2402                this.self=self;
2403            }
2404
2405            public PyBuiltinFunction makeBound(PyObject self) {
2406                return new exposed_swapcase((PyString)self,info);
2407            }
2408
2409            public PyObject __call__() {
2410                return new PyString(self.str_swapcase());
2411            }
2412
2413            public PyObject inst_call(PyObject gself) {
2414                PyString self=(PyString)gself;
2415                return new PyString(self.str_swapcase());
2416            }
2417
2418        }
2419        dict.__setitem__("swapcase",new PyMethodDescr("swapcase",PyString.class,0,0,new exposed_swapcase(null,null)));
2420        class exposed_title extends PyBuiltinFunctionNarrow {
2421
2422            private PyString self;
2423
2424            public PyObject getSelf() {
2425                return self;
2426            }
2427
2428            exposed_title(PyString self,PyBuiltinFunction.Info info) {
2429                super(info);
2430                this.self=self;
2431            }
2432
2433            public PyBuiltinFunction makeBound(PyObject self) {
2434                return new exposed_title((PyString)self,info);
2435            }
2436
2437            public PyObject __call__() {
2438                return new PyString(self.str_title());
2439            }
2440
2441            public PyObject inst_call(PyObject gself) {
2442                PyString self=(PyString)gself;
2443                return new PyString(self.str_title());
2444            }
2445
2446        }
2447        dict.__setitem__("title",new PyMethodDescr("title",PyString.class,0,0,new exposed_title(null,null)));
2448        class exposed_translate extends PyBuiltinFunctionNarrow {
2449
2450            private PyString self;
2451
2452            public PyObject getSelf() {
2453                return self;
2454            }
2455
2456            exposed_translate(PyString self,PyBuiltinFunction.Info info) {
2457                super(info);
2458                this.self=self;
2459            }
2460
2461            public PyBuiltinFunction makeBound(PyObject self) {
2462                return new exposed_translate((PyString)self,info);
2463            }
2464
2465            public PyObject __call__(PyObject arg0,PyObject arg1) {
2466                try {
2467                    return new PyString(self.str_translate(arg0.asString(0),arg1.asString(1)));
2468                } catch (PyObject.ConversionException e) {
2469                    String JavaDoc msg;
2470                    switch (e.index) {
2471                    case 0:
2472                    case 1:
2473                        msg="expected a string";
2474                        break;
2475                    default:
2476                        msg="xxx";
2477                    }
2478                    throw Py.TypeError(msg);
2479                }
2480            }
2481
2482            public PyObject inst_call(PyObject gself,PyObject arg0,PyObject arg1) {
2483                PyString self=(PyString)gself;
2484                try {
2485                    return new PyString(self.str_translate(arg0.asString(0),arg1.asString(1)));
2486                } catch (PyObject.ConversionException e) {
2487                    String JavaDoc msg;
2488                    switch (e.index) {
2489                    case 0:
2490                    case 1:
2491                        msg="expected a string";
2492                        break;
2493                    default:
2494                        msg="xxx";
2495                    }
2496                    throw Py.TypeError(msg);
2497                }
2498            }
2499
2500            public PyObject __call__(PyObject arg0) {
2501                try {
2502                    return new PyString(self.str_translate(arg0.asString(0)));
2503                } catch (PyObject.ConversionException e) {
2504                    String JavaDoc msg;
2505                    switch (e.index) {
2506                    case 0:
2507                        msg="expected a string";
2508                        break;
2509                    default:
2510                        msg="xxx";
2511                    }
2512                    throw Py.TypeError(msg);
2513                }
2514            }
2515
2516            public PyObject inst_call(PyObject gself,PyObject arg0) {
2517                PyString self=(PyString)gself;
2518                try {
2519                    return new PyString(self.str_translate(arg0.asString(0)));
2520                } catch (PyObject.ConversionException e) {
2521                    String JavaDoc msg;
2522                    switch (e.index) {
2523                    case 0:
2524                        msg="expected a string";
2525                        break;
2526                    default:
2527                        msg="xxx";
2528                    }
2529                    throw Py.TypeError(msg);
2530                }
2531            }
2532
2533        }
2534        dict.__setitem__("translate",new PyMethodDescr("translate",PyString.class,1,2,new exposed_translate(null,null)));
2535        class exposed_upper extends PyBuiltinFunctionNarrow {
2536
2537            private PyString self;
2538
2539            public PyObject getSelf() {
2540                return self;
2541            }
2542
2543            exposed_upper(PyString self,PyBuiltinFunction.Info info) {
2544                super(info);
2545                this.self=self;
2546            }
2547
2548            public PyBuiltinFunction makeBound(PyObject self) {
2549                return new exposed_upper((PyString)self,info);
2550            }
2551
2552            public PyObject __call__() {
2553                return new PyString(self.str_upper());
2554            }
2555
2556            public PyObject inst_call(PyObject gself) {
2557                PyString self=(PyString)gself;
2558                return new PyString(self.str_upper());
2559            }
2560
2561        }
2562        dict.__setitem__("upper",new PyMethodDescr("upper",PyString.class,0,0,new exposed_upper(null,null)));
2563        class exposed_zfill extends PyBuiltinFunctionNarrow {
2564
2565            private PyString self;
2566
2567            public PyObject getSelf() {
2568                return self;
2569            }
2570
2571            exposed_zfill(PyString self,PyBuiltinFunction.Info info) {
2572                super(info);
2573                this.self=self;
2574            }
2575
2576            public PyBuiltinFunction makeBound(PyObject self) {
2577                return new exposed_zfill((PyString)self,info);
2578            }
2579
2580            public PyObject __call__(PyObject arg0) {
2581                try {
2582                    return new PyString(self.str_zfill(arg0.asInt(0)));
2583                } catch (PyObject.ConversionException e) {
2584                    String JavaDoc msg;
2585                    switch (e.index) {
2586                    case 0:
2587                        msg="expected an integer";
2588                        break;
2589                    default:
2590                        msg="xxx";
2591                    }
2592                    throw Py.TypeError(msg);
2593                }
2594            }
2595
2596            public PyObject inst_call(PyObject gself,PyObject arg0) {
2597                PyString self=(PyString)gself;
2598                try {
2599                    return new PyString(self.str_zfill(arg0.asInt(0)));
2600                } catch (PyObject.ConversionException e) {
2601                    String JavaDoc msg;
2602                    switch (e.index) {
2603                    case 0:
2604                        msg="expected an integer";
2605                        break;
2606                    default:
2607                        msg="xxx";
2608                    }
2609                    throw Py.TypeError(msg);
2610                }
2611            }
2612
2613        }
2614        dict.__setitem__("zfill",new PyMethodDescr("zfill",PyString.class,1,1,new exposed_zfill(null,null)));
2615        dict.__setitem__("__new__",new PyNewWrapper(PyString.class,"__new__",-1,-1) {
2616            public PyObject new_impl(boolean init, PyType subtype, PyObject[] args, String JavaDoc[] keywords) {
2617                return str_new(this, init, subtype, args, keywords);
2618            }
2619        });
2620    }
2621    //~ END GENERATED
2622

2623    private String JavaDoc string;
2624    private transient int cached_hashcode=0;
2625    private transient boolean interned=false;
2626
2627    // for PyJavaClass.init()
2628
public PyString() {
2629        string = "";
2630    }
2631
2632    public PyString(PyType subType) {
2633        super(subType);
2634    }
2635
2636    public PyString(String JavaDoc string) {
2637        if (string == null) {
2638            throw new IllegalArgumentException JavaDoc(
2639                            "Cannot create PyString from null!");
2640        }
2641        this.string = string;
2642    }
2643
2644    public PyString(char c) {
2645        this(String.valueOf(c));
2646    }
2647
2648    final static PyObject str_new(PyObject new_, boolean init, PyType subtype,
2649            PyObject[] args, String JavaDoc[] keywords) {
2650        ArgParser ap = new ArgParser("str", args, keywords, new String JavaDoc[] { "S" }, 0);
2651        PyObject S = ap.getPyObject(0, null);
2652        if (S instanceof PyString)
2653            return S;
2654        return S.__str__();
2655    }
2656
2657    /** <i>Internal use only. Do not call this method explicit.</i> */
2658    public static void classDictInit(PyObject dict) throws PyIgnoreMethodTag {}
2659
2660    public String JavaDoc safeRepr() throws PyIgnoreMethodTag {
2661        return "'string' object";
2662    }
2663
2664    public PyString __str__() {
2665        return this;
2666    }
2667
2668    public int __len__() {
2669        return str___len__();
2670    }
2671
2672    final int str___len__() {
2673        return string.length();
2674    }
2675
2676    public String JavaDoc toString() {
2677        return str_toString();
2678    }
2679
2680    final String JavaDoc str_toString() {
2681        return string;
2682    }
2683
2684    public String JavaDoc internedString() {
2685        if (interned)
2686            return string;
2687        else {
2688            string = string.intern();
2689            interned = true;
2690            return string;
2691        }
2692    }
2693
2694    public PyString __repr__() {
2695        return new PyString(encode_UnicodeEscape(string, true));
2696    }
2697
2698    private static char[] hexdigit = "0123456789ABCDEF".toCharArray();
2699
2700    public static String JavaDoc encode_UnicodeEscape(String JavaDoc str,
2701                                              boolean use_quotes)
2702    {
2703        int size = str.length();
2704        StringBuffer JavaDoc v = new StringBuffer JavaDoc(str.length());
2705
2706        char quote = 0;
2707        boolean unicode = false;
2708
2709        if (use_quotes) {
2710            quote = str.indexOf('\'') >= 0 &&
2711                             str.indexOf('"') == -1 ? '"' : '\'';
2712            v.append(quote);
2713        }
2714
2715        for (int i = 0; size-- > 0; ) {
2716            int ch = str.charAt(i++);
2717            /* Escape quotes */
2718            if (use_quotes && (ch == quote || ch == '\\')) {
2719                v.append('\\');
2720                v.append((char) ch);
2721            }
2722            /* Map 16-bit characters to '\\uxxxx' */
2723            else if (ch >= 256) {
2724                if (use_quotes && !unicode) {
2725                   v.insert(0, 'u');
2726                   unicode = true;
2727                }
2728                v.append('\\');
2729                v.append('u');
2730                v.append(hexdigit[(ch >> 12) & 0xf]);
2731                v.append(hexdigit[(ch >> 8) & 0xf]);
2732                v.append(hexdigit[(ch >> 4) & 0xf]);
2733                v.append(hexdigit[ch & 15]);
2734            }
2735            /* Map non-printable US ASCII to '\ooo' */
2736            else if (use_quotes && ch == '\n') v.append("\\n");
2737            else if (use_quotes && ch == '\t') v.append("\\t");
2738            else if (use_quotes && ch == '\b') v.append("\\b");
2739            else if (use_quotes && ch == '\f') v.append("\\f");
2740            else if (use_quotes && ch == '\r') v.append("\\r");
2741            else if (ch < ' ' || ch >= 127) {
2742                v.append("\\x");
2743                v.append(hexdigit[(ch >> 4) & 0xF]);
2744                v.append(hexdigit[ch & 0xF]);
2745            }
2746            /* Copy everything else as-is */
2747            else
2748                v.append((char) ch);
2749        }
2750        if (use_quotes)
2751            v.append(quote);
2752        return v.toString();
2753    }
2754
2755    private static ucnhashAPI pucnHash = null;
2756
2757    public static String JavaDoc decode_UnicodeEscape(String JavaDoc str, int start, int end,
2758                                              String JavaDoc errors, boolean unicode)
2759    {
2760        StringBuffer JavaDoc v = new StringBuffer JavaDoc(end-start);
2761        for (int s = start; s < end; ) {
2762            char ch = str.charAt(s);
2763
2764            /* Non-escape characters are interpreted as Unicode ordinals */
2765            if (ch != '\\') {
2766                v.append(ch);
2767                s++;
2768                continue;
2769            }
2770
2771            /* \ - Escapes */
2772            s++;
2773            ch = str.charAt(s++);
2774            switch (ch) {
2775
2776            /* \x escapes */
2777            case '\n': break;
2778            case '\\': v.append('\\'); break;
2779            case '\'': v.append('\''); break;
2780            case '\"': v.append('\"'); break;
2781            case 'b': v.append('\b'); break;
2782            case 'f': v.append('\014'); break; /* FF */
2783            case 't': v.append('\t'); break;
2784            case 'n': v.append('\n'); break;
2785            case 'r': v.append('\r'); break;
2786            case 'v': v.append('\013'); break; /* VT */
2787            case 'a': v.append('\007'); break; /* BEL, not classic C */
2788
2789            /* \OOO (octal) escapes */
2790            case '0': case '1': case '2': case '3':
2791            case '4': case '5': case '6': case '7':
2792
2793                int x = Character.digit(ch, 8);
2794                for (int j = 0; j < 2 && s < end; j++, s++) {
2795                    ch = str.charAt(s);
2796                    if (ch < '0' || ch > '7')
2797                        break;
2798                    x = (x<<3) + Character.digit(ch, 8);
2799                }
2800                v.append((char) x);
2801                break;
2802
2803            case 'x':
2804                int i;
2805                for (x = 0, i = 0; i < 2 && s < end; i++) {
2806                    ch = str.charAt(s + i);
2807                    int d = Character.digit(ch, 16);
2808                    if (d == -1) {
2809                        codecs.decoding_error("unicode escape", v, errors,
2810                                                     "truncated \\xXX");
2811                        i++;
2812                        break;
2813                    }
2814
2815                    x = ((x<<4) & ~0xF) + d;
2816                }
2817                s += i;
2818                v.append((char) x);
2819                break;
2820
2821            /* \ uXXXX with 4 hex digits */
2822            case 'u':
2823                if (!unicode) {
2824                    v.append('\\');
2825                    v.append('u');
2826                    break;
2827                }
2828                if (s+4 > end) {
2829                    codecs.decoding_error("unicode escape", v, errors,
2830                                              "truncated \\uXXXX");
2831                    break;
2832                }
2833                for (x = 0, i = 0; i < 4; i++) {
2834                    ch = str.charAt(s + i);
2835                    int d = Character.digit(ch, 16);
2836                    if (d == -1) {
2837                        codecs.decoding_error("unicode escape", v, errors,
2838                                              "truncated \\uXXXX");
2839                        break;
2840                    }
2841                    x = ((x<<4) & ~0xF) + d;
2842                }
2843                s += i;
2844                v.append((char) x);
2845                break;
2846
2847            case 'N':
2848                if (!unicode) {
2849                    v.append('\\');
2850                    v.append('N');
2851                    break;
2852                }
2853                /* Ok, we need to deal with Unicode Character Names now,
2854                 * make sure we've imported the hash table data...
2855                 */

2856                if (pucnHash == null) {
2857                     PyObject mod = imp.importName("ucnhash", true);
2858                     mod = mod.__call__();
2859                     pucnHash = (ucnhashAPI) mod.__tojava__(Object JavaDoc.class);
2860                     if (pucnHash.getCchMax() < 0)
2861                         codecs.decoding_error("unicode escape", v, errors,
2862                                 "Unicode names not loaded");
2863                }
2864
2865                if (str.charAt(s) == '{') {
2866                    int startName = s + 1;
2867                    int endBrace = startName;
2868
2869                    /* look for either the closing brace, or we
2870                     * exceed the maximum length of the unicode
2871                     * character names
2872                     */

2873                    int maxLen = pucnHash.getCchMax();
2874                    while (endBrace < end && str.charAt(endBrace) != '}'
2875                           && (endBrace - startName) <= maxLen) {
2876                        endBrace++;
2877                    }
2878                    if (endBrace != end && str.charAt(endBrace) == '}') {
2879                         int value = pucnHash.getValue(str, startName,
2880                                                       endBrace);
2881                         if (value < 0) {
2882                             codecs.decoding_error("unicode escape", v,
2883                                  errors, "Invalid Unicode Character Name");
2884                             v.append('\\');
2885                             v.append(str.charAt(s-1));
2886                             break;
2887                         }
2888
2889                         if (value < 1<<16) {
2890                             /* In UCS-2 range, easy solution.. */
2891                             v.append((char) value);
2892                         } else {
2893                             /* Oops, its in UCS-4 space, */
2894                             /* compute and append the two surrogates: */
2895                             /* translate from 10000..10FFFF to 0..FFFFF */
2896                             value -= 0x10000;
2897
2898                             /* high surrogate = top 10 bits added to D800 */
2899                             v.append((char) (0xD800 + (value >> 10)));
2900
2901                             /* low surrogate = bottom 10 bits added to DC00*/
2902                             v.append((char) (0xDC00 + (value & ~0xFC00)));
2903                        }
2904                        s = endBrace + 1;
2905                    } else {
2906                         codecs.decoding_error("unicode escape", v, errors,
2907                              "Unicode name missing closing brace");
2908                         v.append('\\');
2909                         v.append(str.charAt(s-1));
2910                         break;
2911                    }
2912                    break;
2913                }
2914                codecs.decoding_error("unicode escape", v, errors,
2915                                      "Missing opening brace for Unicode " +
2916                                      "Character Name escape");
2917
2918                /* fall through on purpose */
2919           default:
2920               v.append('\\');
2921               v.append(str.charAt(s-1));
2922               break;
2923           }
2924       }
2925       return v.toString();
2926    }
2927
2928    public boolean equals(Object JavaDoc other) {
2929        if (!(other instanceof PyString))
2930            return false;
2931
2932        PyString o = (PyString)other;
2933        if (interned && o.interned)
2934            return string == o.string;
2935
2936        return string.equals(o.string);
2937    }
2938
2939    public int __cmp__(PyObject other) {
2940        return str___cmp__(other);
2941    }
2942
2943    final int str___cmp__(PyObject other) {
2944        if (!(other instanceof PyString))
2945            return -2;
2946
2947        int c = string.compareTo(((PyString)other).string);
2948        return c < 0 ? -1 : c > 0 ? 1 : 0;
2949    }
2950
2951    public PyObject __eq__(PyObject other) {
2952        return str___eq__(other);
2953    }
2954
2955    final PyObject str___eq__(PyObject other) {
2956        String JavaDoc s = coerce(other);
2957        if (s == null)
2958            return null;
2959        return string.equals(s) ? Py.One : Py.Zero;
2960    }
2961
2962    public PyObject __ne__(PyObject other) {
2963        return str___ne__(other);
2964    }
2965
2966    final PyObject str___ne__(PyObject other) {
2967        String JavaDoc s = coerce(other);
2968        if (s == null)
2969            return null;
2970        return string.equals(s) ? Py.Zero : Py.One;
2971    }
2972
2973    public PyObject __lt__(PyObject other) {
2974        String JavaDoc s = coerce(other);
2975        if (s == null)
2976            return null;
2977        return string.compareTo(s) < 0 ? Py.One : Py.Zero;
2978    }
2979
2980    public PyObject __le__(PyObject other) {
2981        String JavaDoc s = coerce(other);
2982        if (s == null)
2983            return null;
2984        return string.compareTo(s) <= 0 ? Py.One : Py.Zero;
2985    }
2986
2987    public PyObject __gt__(PyObject other) {
2988        String JavaDoc s = coerce(other);
2989        if (s == null)
2990            return null;
2991        return string.compareTo(s) > 0 ? Py.One : Py.Zero;
2992    }
2993
2994    public PyObject __ge__(PyObject other) {
2995        String JavaDoc s = coerce(other);
2996        if (s == null)
2997            return null;
2998        return string.compareTo(s) >= 0 ? Py.One : Py.Zero;
2999    }
3000
3001    private static String JavaDoc coerce(PyObject o) {
3002        if (o instanceof PyString)
3003            return o.toString();
3004        return null;
3005    }
3006
3007    public int hashCode() {
3008        return str_hashCode();
3009    }
3010
3011    final int str_hashCode() {
3012        if (cached_hashcode == 0)
3013            cached_hashcode = string.hashCode();
3014        return cached_hashcode;
3015    }
3016
3017    private byte[] getBytes() {
3018        byte[] buf = new byte[string.length()];
3019        string.getBytes(0, string.length(), buf, 0);
3020        return buf;
3021    }
3022
3023    public Object JavaDoc __tojava__(Class JavaDoc c) {
3024        if (c.isAssignableFrom(String JavaDoc.class)) {
3025            return string;
3026        }
3027
3028        if (c == Character.TYPE || c == Character JavaDoc.class)
3029            if (string.length() == 1)
3030                return new Character JavaDoc(string.charAt(0));
3031
3032        if (c.isArray()) {
3033            if (c.getComponentType() == Byte.TYPE)
3034                return getBytes();
3035            if (c.getComponentType() == Character.TYPE)
3036                return string.toCharArray();
3037        }
3038
3039        if (c.isInstance(this))
3040            return this;
3041
3042        return Py.NoConversion;
3043    }
3044
3045    protected PyObject pyget(int i) {
3046        return Py.newString(string.charAt(i));
3047    }
3048
3049    protected PyObject getslice(int start, int stop, int step) {
3050        if (step > 0 && stop < start)
3051            stop = start;
3052        if (step == 1)
3053            return new PyString(string.substring(start, stop));
3054        else {
3055            int n = sliceLength(start, stop, step);
3056            char new_chars[] = new char[n];
3057            int j = 0;
3058            for (int i=start; j<n; i+=step)
3059                new_chars[j++] = string.charAt(i);
3060
3061            return new PyString(new String JavaDoc(new_chars));
3062        }
3063    }
3064
3065    public boolean __contains__(PyObject o) {
3066        return str___contains__(o);
3067    }
3068
3069    final boolean str___contains__(PyObject o) {
3070        if (!(o instanceof PyString))
3071            throw Py.TypeError("'in <string>' requires string as left operand");
3072        PyString other = (PyString) o;
3073        return string.indexOf(other.string) >= 0;
3074    }
3075
3076    protected PyObject repeat(int count) {
3077        if (count < 0)
3078            count = 0;
3079        int s = string.length();
3080        char new_chars[] = new char[s*count];
3081        for (int i=0; i<count; i++) {
3082            string.getChars(0, s, new_chars, i*s);
3083        }
3084        return new PyString(new String JavaDoc(new_chars));
3085    }
3086
3087    final PyObject str___mul__(PyObject o) {
3088        if (!(o instanceof PyInteger || o instanceof PyLong))
3089            throw Py.TypeError("can't multiply sequence to non-int");
3090        int count = ((PyInteger)o.__int__()).getValue();
3091        return repeat(count);
3092    }
3093
3094    final PyObject str___rmul__(PyObject o) {
3095        if (!(o instanceof PyInteger || o instanceof PyLong))
3096            throw Py.TypeError("can't multiply sequence to non-int");
3097        int count = ((PyInteger)o.__int__()).getValue();
3098        return repeat(count);
3099    }
3100
3101    public PyObject __add__(PyObject generic_other) {
3102        return str___add__(generic_other);
3103    }
3104
3105    final PyObject str___add__(PyObject generic_other) {
3106        if (generic_other instanceof PyString) {
3107            PyString other = (PyString)generic_other;
3108            return new PyString(string.concat(other.string));
3109        }
3110        else return null;
3111    }
3112
3113
3114    public PyObject __mod__(PyObject other) {
3115        StringFormatter fmt = new StringFormatter(string);
3116        return new PyString(fmt.format(other));
3117    }
3118
3119    public PyObject __int__() {
3120        return Py.newInteger(atoi(10));
3121    }
3122
3123    public PyLong __long__() {
3124        return atol(10);
3125    }
3126
3127    public PyFloat __float__() {
3128        return new PyFloat(atof());
3129    }
3130
3131    public PyObject __pos__() {
3132      throw Py.TypeError("bad operand type for unary +");
3133    }
3134
3135    public PyObject __neg__() {
3136      throw Py.TypeError("bad operand type for unary -");
3137    }
3138
3139    public PyObject __invert__() {
3140      throw Py.TypeError("bad operand type for unary ~");
3141    }
3142
3143    public PyComplex __complex__() {
3144        boolean got_re = false;
3145        boolean got_im = false;
3146        boolean done = false;
3147        boolean sw_error = false;
3148
3149        int s = 0;
3150        int n = string.length();
3151        while (s < n && Character.isSpaceChar(string.charAt(s)))
3152            s++;
3153
3154        if (s == n) {
3155            throw Py.ValueError("empty string for complex()");
3156        }
3157
3158        double z = -1.0;
3159        double x = 0.0;
3160        double y = 0.0;
3161
3162        int sign = 1;
3163        do {
3164            char c = string.charAt(s);
3165            switch (c) {
3166            case '-':
3167                sign = -1;
3168                /* Fallthrough */
3169            case '+':
3170                if (done || s+1 == n) {
3171                    sw_error = true;
3172                    break;
3173                }
3174                // a character is guaranteed, but it better be a digit
3175
// or J or j
3176
c = string.charAt(++s); // eat the sign character
3177
// and check the next
3178
if (!Character.isDigit(c) && c!='J' && c!='j')
3179                    sw_error = true;
3180                break;
3181
3182            case 'J':
3183            case 'j':
3184                if (got_im || done) {
3185                    sw_error = true;
3186                    break;
3187                }
3188                if (z < 0.0) {
3189                    y = sign;
3190                } else {
3191                    y = sign * z;
3192                }
3193                got_im = true;
3194                done = got_re;
3195                sign = 1;
3196                s++; // eat the J or j
3197
break;
3198
3199            case ' ':
3200                while (s < n && Character.isSpaceChar(string.charAt(s)))
3201                    s++;
3202                if (s != n)
3203                    sw_error = true;
3204                break;
3205
3206            default:
3207                boolean digit_or_dot = (c == '.' || Character.isDigit(c));
3208                if (!digit_or_dot) {
3209                    sw_error = true;
3210                    break;
3211                }
3212                int end = endDouble(string, s);
3213                z = Double.valueOf(string.substring(s, end)).doubleValue();
3214                s=end;
3215                if (s < n) {
3216                    c = string.charAt(s);
3217                    if (c == 'J' || c == 'j') {
3218                        break;
3219                    }
3220                }
3221                if (got_re) {
3222                   sw_error = true;
3223                   break;
3224                }
3225
3226                /* accept a real part */
3227                x = sign * z;
3228                got_re = true;
3229                done = got_im;
3230                z = -1.0;
3231                sign = 1;
3232                break;
3233
3234             } /* end of switch */
3235
3236        } while (s < n && !sw_error);
3237
3238        if (sw_error) {
3239            throw Py.ValueError("malformed string for complex() " +
3240                                string.substring(s));
3241        }
3242
3243        return new PyComplex(x,y);
3244    }
3245
3246    private int endDouble(String JavaDoc string, int s) {
3247        int n = string.length();
3248        while (s < n) {
3249            char c = string.charAt(s++);
3250            if (Character.isDigit(c))
3251                continue;
3252            if (c == '.')
3253                continue;
3254            if (c == 'e' || c == 'E') {
3255                if (s < n) {
3256                    c = string.charAt(s);
3257                    if (c == '+' || c == '-')
3258                        s++;
3259                    continue;
3260                }
3261            }
3262            return s-1;
3263        }
3264        return s;
3265    }
3266
3267    // Add in methods from string module
3268
public String JavaDoc lower() {
3269        return str_lower();
3270    }
3271
3272    final String JavaDoc str_lower() {
3273        return string.toLowerCase();
3274    }
3275
3276    public String JavaDoc upper() {
3277        return str_upper();
3278    }
3279
3280    final String JavaDoc str_upper() {
3281        return string.toUpperCase();
3282    }
3283
3284    public String JavaDoc title() {
3285        return str_title();
3286    }
3287
3288    final String JavaDoc str_title() {
3289        char[] chars = string.toCharArray();
3290        int n = chars.length;
3291
3292        boolean previous_is_cased = false;
3293        for (int i = 0; i < n; i++) {
3294            char ch = chars[i];
3295            if (previous_is_cased)
3296                chars[i] = Character.toLowerCase(ch);
3297            else
3298                chars[i] = Character.toTitleCase(ch);
3299
3300            if (Character.isLowerCase(ch) ||
3301                   Character.isUpperCase(ch) ||
3302                   Character.isTitleCase(ch))
3303                previous_is_cased = true;
3304            else
3305                previous_is_cased = false;
3306        }
3307        return new String JavaDoc(chars);
3308    }
3309
3310    public String JavaDoc swapcase() {
3311        return str_swapcase();
3312    }
3313
3314    final String JavaDoc str_swapcase() {
3315        char[] chars = string.toCharArray();
3316        int n=chars.length;
3317        for (int i=0; i<n; i++) {
3318            char c = chars[i];
3319            if (Character.isUpperCase(c)) {
3320                chars[i] = Character.toLowerCase(c);
3321            }
3322            else if (Character.isLowerCase(c)) {
3323                chars[i] = Character.toUpperCase(c);
3324            }
3325        }
3326        return new String JavaDoc(chars);
3327    }
3328
3329    public String JavaDoc strip() {
3330        return str_strip();
3331    }
3332
3333    final String JavaDoc str_strip() {
3334        return str_strip(null);
3335    }
3336
3337    public String JavaDoc strip(String JavaDoc sep) {
3338        return str_strip(sep);
3339    }
3340
3341    final String JavaDoc str_strip(String JavaDoc sep) {
3342        char[] chars = string.toCharArray();
3343        int n=chars.length;
3344        int start=0;
3345        if (sep == null)
3346            while (start < n && Character.isWhitespace(chars[start]))
3347                start++;
3348        else
3349            while (start < n && sep.indexOf(chars[start]) >= 0)
3350                start++;
3351
3352        int end=n-1;
3353        if (sep == null)
3354            while (end >= 0 && Character.isWhitespace(chars[end]))
3355                end--;
3356        else
3357            while (end >= 0 && sep.indexOf(chars[end]) >= 0)
3358                end--;
3359
3360        if (end >= start) {
3361            return (end < n-1 || start > 0)
3362                ? string.substring(start, end+1) : string;
3363        } else {
3364            return "";
3365        }
3366    }
3367
3368    public String JavaDoc lstrip() {
3369        return str_lstrip();
3370    }
3371
3372    final String JavaDoc str_lstrip() {
3373        return str_lstrip(null);
3374    }
3375
3376    public String JavaDoc lstrip(String JavaDoc sep) {
3377        return str_lstrip(sep);
3378    }
3379
3380    final String JavaDoc str_lstrip(String JavaDoc sep) {
3381        char[] chars = string.toCharArray();
3382        int n=chars.length;
3383        int start=0;
3384        if (sep == null)
3385            while (start < n && Character.isWhitespace(chars[start]))
3386                start++;
3387        else
3388            while (start < n && sep.indexOf(chars[start]) >= 0)
3389                start++;
3390
3391        return (start > 0) ? string.substring(start, n) : string;
3392    }
3393
3394    public String JavaDoc rstrip() {
3395        return str_rstrip();
3396    }
3397
3398    final String JavaDoc str_rstrip() {
3399        return str_rstrip(null);
3400    }
3401
3402    public String JavaDoc rstrip(String JavaDoc sep) {
3403        return str_rstrip(sep);
3404    }
3405
3406    final String JavaDoc str_rstrip(String JavaDoc sep) {
3407        char[] chars = string.toCharArray();
3408        int n=chars.length;
3409        int end=n-1;
3410        if (sep == null)
3411            while (end >= 0 && Character.isWhitespace(chars[end]))
3412                end--;
3413        else
3414            while (end >= 0 && sep.indexOf(chars[end]) >= 0)
3415                end--;
3416
3417        return (end < n-1) ? string.substring(0, end+1) : string;
3418    }
3419
3420
3421    public PyList split() {
3422        return str_split();
3423    }
3424
3425    final PyList str_split() {
3426        return str_split(null, -1);
3427    }
3428
3429    public PyList split(String JavaDoc sep) {
3430        return str_split(sep);
3431    }
3432
3433    final PyList str_split(String JavaDoc sep) {
3434        return str_split(sep, -1);
3435    }
3436
3437    public PyList split(String JavaDoc sep, int maxsplit) {
3438        return str_split(sep, maxsplit);
3439    }
3440
3441    final PyList str_split(String JavaDoc sep, int maxsplit) {
3442        if (sep != null)
3443            return splitfields(sep, maxsplit);
3444
3445        PyList list = new PyList();
3446
3447        char[] chars = string.toCharArray();
3448        int n=chars.length;
3449
3450        if (maxsplit < 0)
3451            maxsplit = n;
3452
3453        int splits=0;
3454        int index=0;
3455        while (index < n && splits < maxsplit) {
3456            while (index < n && Character.isWhitespace(chars[index]))
3457                index++;
3458            if (index == n)
3459                break;
3460            int start = index;
3461
3462            while (index < n && !Character.isWhitespace(chars[index]))
3463                index++;
3464            list.append(new PyString(string.substring(start, index)));
3465            splits++;
3466        }
3467        while (index < n && Character.isWhitespace(chars[index]))
3468            index++;
3469        if (index < n) {
3470            list.append(new PyString(string.substring(index, n)));
3471        }
3472        return list;
3473    }
3474
3475    private PyList splitfields(String JavaDoc sep, int maxsplit) {
3476        if (sep.length() == 0) {
3477            throw Py.ValueError("empty separator");
3478        }
3479
3480        PyList list = new PyList();
3481
3482        int length = string.length();
3483        if (maxsplit < 0)
3484            maxsplit = length;
3485
3486        int lastbreak = 0;
3487        int splits = 0;
3488        int sepLength = sep.length();
3489        while (splits < maxsplit) {
3490            int index = string.indexOf(sep, lastbreak);
3491            if (index == -1)
3492                break;
3493            splits += 1;
3494            list.append(new PyString(string.substring(lastbreak, index)));
3495            lastbreak = index + sepLength;
3496        }
3497        if (lastbreak <= length) {
3498            list.append(new PyString(string.substring(lastbreak, length)));
3499        }
3500        return list;
3501    }
3502
3503    public PyList splitlines() {
3504        return str_splitlines();
3505    }
3506
3507    final PyList str_splitlines() {
3508        return str_splitlines(false);
3509    }
3510
3511    public PyList splitlines(boolean keepends) {
3512        return str_splitlines(keepends);
3513    }
3514
3515    final PyList str_splitlines(boolean keepends) {
3516        PyList list = new PyList();
3517
3518        char[] chars = string.toCharArray();
3519        int n=chars.length;
3520
3521        int j = 0;
3522        for (int i = 0; i < n; ) {
3523            /* Find a line and append it */
3524            while (i < n && chars[i] != '\n' && chars[i] != '\r' &&
3525                    Character.getType(chars[i]) != Character.LINE_SEPARATOR)
3526                i++;
3527
3528            /* Skip the line break reading CRLF as one line break */
3529            int eol = i;
3530            if (i < n) {
3531                if (chars[i] == '\r' && i + 1 < n && chars[i+1] == '\n')
3532                    i += 2;
3533                else
3534                    i++;
3535                if (keepends)
3536                    eol = i;
3537            }
3538            list.append(new PyString(string.substring(j, eol)));
3539            j = i;
3540        }
3541        if (j < n) {
3542            list.append(new PyString(string.substring(j, n)));
3543        }
3544        return list;
3545    }
3546
3547
3548
3549    public int index(String JavaDoc sub) {
3550        return str_index(sub);
3551    }
3552
3553    final int str_index(String JavaDoc sub) {
3554        return str_index(sub, 0, string.length());
3555    }
3556
3557    public int index(String JavaDoc sub, int start) {
3558        return str_index(sub, start);
3559    }
3560
3561    final int str_index(String JavaDoc sub, int start) {
3562        return str_index(sub, start, string.length());
3563    }
3564
3565    public int index(String JavaDoc sub, int start, int end) {
3566        return str_index(sub, start, end);
3567    }
3568
3569    final int str_index(String JavaDoc sub, int start, int end) {
3570        int n = string.length();
3571
3572        if (start < 0)
3573            start = n+start;
3574        if (end < 0)
3575            end = n+end;
3576
3577        int index;
3578        if (end < n) {
3579            index = string.substring(start, end).indexOf(sub);
3580        } else {
3581            index = string.indexOf(sub, start);
3582        }
3583        if (index == -1)
3584            throw Py.ValueError("substring not found in string.index");
3585        return index;
3586    }
3587
3588    public int rindex(String JavaDoc sub) {
3589        return str_rindex(sub);
3590    }
3591
3592    final int str_rindex(String JavaDoc sub) {
3593        return str_rindex(sub, 0, string.length());
3594    }
3595
3596    public int rindex(String JavaDoc sub, int start) {
3597        return str_rindex(sub, start);
3598    }
3599
3600    final int str_rindex(String JavaDoc sub, int start) {
3601        return str_rindex(sub, start, string.length());
3602    }
3603
3604    public int rindex(String JavaDoc sub, int start, int end) {
3605        return str_rindex(sub, start, end);
3606    }
3607
3608    final int str_rindex(String JavaDoc sub, int start, int end) {
3609        int n = string.length();
3610
3611        if (start < 0)
3612            start = n+start;
3613        if (end < 0)
3614            end = n+end;
3615
3616        int index;
3617        if (start > 0) {
3618            index = string.substring(start, end).lastIndexOf(sub);
3619        } else {
3620            index = string.lastIndexOf(sub, end);
3621        }
3622        if (index == -1)
3623            throw Py.ValueError("substring not found in string.rindex");
3624        return index;
3625    }
3626
3627    public int count(String JavaDoc sub) {
3628        return str_count(sub);
3629    }
3630
3631    final int str_count(String JavaDoc sub) {
3632        return count(sub, 0, string.length());
3633    }
3634
3635    public int count(String JavaDoc sub, int start) {
3636        return str_count(sub, start);
3637    }
3638
3639    final int str_count(String JavaDoc sub, int start) {
3640        return count(sub, start, string.length());
3641    }
3642
3643    public int count(String JavaDoc sub, int start, int end) {
3644        return str_count(sub, start, end);
3645    }
3646
3647    final int str_count(String JavaDoc sub, int start, int end) {
3648        int len = string.length();
3649        if (end > len)
3650            end = len;
3651        if (end < 0)
3652            end += len;
3653        if (end < 0)
3654            end = 0;
3655        if (start < 0)
3656            start += len;
3657        if (start < 0)
3658            start = 0;
3659
3660        int n = sub.length();
3661        end = end + 1 - n;
3662        if (n == 0)
3663            return end-start;
3664
3665        int count=0;
3666        while (start < end) {
3667            int index = string.indexOf(sub, start);
3668            if (index >= end || index == -1)
3669                break;
3670            count++;
3671            start = index + n;
3672        }
3673        return count;
3674    }
3675
3676    public int find(String JavaDoc sub) {
3677        return str_find(sub);
3678    }
3679
3680    final int str_find(String JavaDoc sub) {
3681        return str_find(sub, 0, string.length());
3682    }
3683
3684    public int find(String JavaDoc sub, int start) {
3685        return str_find(sub, start);
3686    }
3687
3688    final int str_find(String JavaDoc sub, int start) {
3689        return str_find(sub, start, string.length());
3690    }
3691
3692    public int find(String JavaDoc sub, int start, int end) {
3693        return str_find(sub, start, end);
3694    }
3695
3696    final int str_find(String JavaDoc sub, int start, int end) {
3697        int n = string.length();
3698        if (start < 0)
3699            start = n+start;
3700        if (end < 0)
3701            end = n+end;
3702        if (end > n)
3703            end = n;
3704        if (start > end)
3705            start = end;
3706        int slen = sub.length();
3707        end = end-slen;
3708
3709        int index = string.indexOf(sub, start);
3710        if (index > end)
3711            return -1;
3712        return index;
3713    }
3714
3715    public int rfind(String JavaDoc sub) {
3716        return str_rfind(sub);
3717    }
3718
3719    final int str_rfind(String JavaDoc sub) {
3720        return str_rfind(sub, 0, string.length());
3721    }
3722
3723    public int rfind(String JavaDoc sub, int start) {
3724        return str_rfind(sub, start);
3725    }
3726
3727    final int str_rfind(String JavaDoc sub, int start) {
3728        return str_rfind(sub, start, string.length());
3729    }
3730
3731    public int rfind(String JavaDoc sub, int start, int end) {
3732        return str_rfind(sub, start, end);
3733    }
3734
3735    final int str_rfind(String JavaDoc sub, int start, int end) {
3736        int n = string.length();
3737        if (start < 0)
3738            start = n+start;
3739        if (end < 0)
3740            end = n+end;
3741        if (end > n)
3742            end = n;
3743        if (start > end)
3744            start = end;
3745        int slen = sub.length();
3746        end = end-slen;
3747
3748        int index = string.lastIndexOf(sub, end);
3749        if (index < start)
3750            return -1;
3751        return index;
3752    }
3753
3754    public double atof() {
3755        StringBuffer JavaDoc s = null;
3756        int n = string.length();
3757        for (int i = 0; i < n; i++) {
3758            char ch = string.charAt(i);
3759            if (ch == '\u0000') {
3760                throw Py.ValueError("null byte in argument for float()");
3761            }
3762            if (Character.isDigit(ch)) {
3763                if (s == null)
3764                    s = new StringBuffer JavaDoc(string);
3765                int val = Character.digit(ch, 10);
3766                s.setCharAt(i, Character.forDigit(val, 10));
3767            }
3768        }
3769        String JavaDoc sval = string;
3770        if (s != null)
3771            sval = s.toString();
3772        try {
3773            return Double.valueOf(sval).doubleValue();
3774        }
3775        catch (NumberFormatException JavaDoc exc) {
3776            throw Py.ValueError("invalid literal for __float__: "+string);
3777        }
3778    }
3779
3780    public int atoi() {
3781        return atoi(10);
3782    }
3783
3784    public int atoi(int base) {
3785        if ((base != 0 && base < 2) || (base > 36)) {
3786            throw Py.ValueError("invalid base for atoi()");
3787        }
3788
3789        int b = 0;
3790        int e = string.length();
3791
3792        while (b < e && Character.isWhitespace(string.charAt(b)))
3793            b++;
3794
3795        while (e > b && Character.isWhitespace(string.charAt(e-1)))
3796            e--;
3797
3798        char sign = 0;
3799        if (b < e) {
3800            sign = string.charAt(b);
3801            if (sign == '-' || sign == '+') {
3802                b++;
3803                while (b < e && Character.isWhitespace(string.charAt(b))) b++;
3804            }
3805
3806            if (base == 0 || base == 16) {
3807                if (string.charAt(b) == '0') {
3808                    if (b < e-1 &&
3809                           Character.toUpperCase(string.charAt(b+1)) == 'X') {
3810                        base = 16;
3811                        b += 2;
3812                    } else {
3813                        if (base == 0)
3814                            base = 8;
3815                    }
3816                }
3817            }
3818        }
3819
3820        if (base == 0)
3821            base = 10;
3822
3823        String JavaDoc s = string;
3824        if (b > 0 || e < string.length())
3825            s = string.substring(b, e);
3826
3827        try {
3828            long result = Long.parseLong(s, base);
3829            if (result < 0 && !(sign == '-' && result == -result))
3830                throw Py.ValueError("invalid literal for __int__: "+string);
3831            if (sign == '-')
3832                result = - result;
3833            if (result < Integer.MIN_VALUE || result > Integer.MAX_VALUE)
3834                throw Py.ValueError("invalid literal for __int__: "+string);
3835            return (int) result;
3836        } catch (NumberFormatException JavaDoc exc) {
3837            throw Py.ValueError("invalid literal for __int__: "+string);
3838        } catch (StringIndexOutOfBoundsException JavaDoc exc) {
3839            throw Py.ValueError("invalid literal for __int__: "+string);
3840        }
3841    }
3842
3843    public PyLong atol() {
3844        return atol(10);
3845    }
3846
3847    public PyLong atol(int base) {
3848        String JavaDoc str = string;
3849        int b = 0;
3850        int e = str.length();
3851
3852        while (b < e && Character.isWhitespace(str.charAt(b)))
3853            b++;
3854
3855        while (e > b && Character.isWhitespace(str.charAt(e-1)))
3856            e--;
3857        if (e > b && (str.charAt(e-1) == 'L' || str.charAt(e-1) == 'l'))
3858            e--;
3859
3860        char sign = 0;
3861        if (b < e) {
3862            sign = string.charAt(b);
3863            if (sign == '-' || sign == '+') {
3864                b++;
3865                while (b < e && Character.isWhitespace(str.charAt(b))) b++;
3866            }
3867
3868
3869            if (base == 0 || base == 16) {
3870                if (string.charAt(b) == '0') {
3871                    if (b < e-1 &&
3872                           Character.toUpperCase(string.charAt(b+1)) == 'X') {
3873                        base = 16;
3874                        b += 2;
3875                    } else {
3876                        if (base == 0)
3877                            base = 8;
3878                    }
3879                }
3880            }
3881        }
3882        if (base == 0)
3883            base = 10;
3884
3885        if (base < 2 || base > 36)
3886            throw Py.ValueError("invalid base for long literal:" + base);
3887
3888        if (b > 0 || e < str.length())
3889            str = str.substring(b, e);
3890
3891        try {
3892            java.math.BigInteger JavaDoc bi = null;
3893            if (sign == '-')
3894                bi = new java.math.BigInteger JavaDoc("-" + str, base);
3895            else
3896                bi = new java.math.BigInteger JavaDoc(str, base);
3897            return new PyLong(bi);
3898        } catch (NumberFormatException JavaDoc exc) {
3899            throw Py.ValueError("invalid literal for __long__: "+str);
3900        } catch (StringIndexOutOfBoundsException JavaDoc exc) {
3901            throw Py.ValueError("invalid literal for __long__: "+str);
3902        }
3903    }
3904
3905
3906    private static String JavaDoc spaces(int n) {
3907        char[] chars = new char[n];
3908        for (int i=0; i<n; i++)
3909            chars[i] = ' ';
3910        return new String JavaDoc(chars);
3911    }
3912
3913    public String JavaDoc ljust(int width) {
3914        return str_ljust(width);
3915    }
3916
3917    final String JavaDoc str_ljust(int width) {
3918        int n = width-string.length();
3919        if (n <= 0)
3920            return string;
3921        return string+spaces(n);
3922    }
3923
3924    public String JavaDoc rjust(int width) {
3925        return str_rjust(width);
3926    }
3927
3928    final String JavaDoc str_rjust(int width) {
3929        int n = width-string.length();
3930        if (n <= 0)
3931            return string;
3932        return spaces(n)+string;
3933    }
3934
3935    public String JavaDoc center(int width) {
3936        return str_center(width);
3937    }
3938
3939    final String JavaDoc str_center(int width) {
3940        int n = width-string.length();
3941        if (n <= 0)
3942            return string;
3943        int half = n/2;
3944        if (n%2 > 0 && width%2 > 0)
3945            half += 1;
3946        return spaces(half)+string+spaces(n-half);
3947    }
3948
3949    public String JavaDoc zfill(int width) {
3950        return str_zfill(width);
3951    }
3952
3953    final String JavaDoc str_zfill(int width) {
3954        String JavaDoc s = string;
3955        int n = s.length();
3956        if (n >= width)
3957            return s;
3958        char[] chars = new char[width];
3959        int nzeros = width-n;
3960        int i=0;
3961        int sStart=0;
3962        if (n > 0) {
3963            char start = s.charAt(0);
3964            if (start == '+' || start == '-') {
3965                chars[0] = start;
3966                i += 1;
3967                nzeros++;
3968                sStart=1;
3969            }
3970        }
3971        for(;i<nzeros; i++) {
3972            chars[i] = '0';
3973        }
3974        s.getChars(sStart, s.length(), chars, i);
3975        return new String JavaDoc(chars);
3976    }
3977
3978    public String JavaDoc expandtabs() {
3979        return str_expandtabs();
3980    }
3981
3982    final String JavaDoc str_expandtabs() {
3983        return str_expandtabs(8);
3984    }
3985
3986    public String JavaDoc expandtabs(int tabsize) {
3987        return str_expandtabs(tabsize);
3988    }
3989
3990    final String JavaDoc str_expandtabs(int tabsize) {
3991        String JavaDoc s = string;
3992        StringBuffer JavaDoc buf = new StringBuffer JavaDoc((int)(s.length()*1.5));
3993        char[] chars = s.toCharArray();
3994        int n = chars.length;
3995        int position = 0;
3996
3997        for(int i=0; i<n; i++) {
3998            char c = chars[i];
3999            if (c == '\t') {
4000                int spaces = tabsize-position%tabsize;
4001                position += spaces;
4002                while (spaces-- > 0) {
4003                    buf.append(' ');
4004                }
4005                continue;
4006            }
4007            if (c == '\n' || c == '\r') {
4008                position = -1;
4009            }
4010            buf.append(c);
4011            position++;
4012        }
4013        return buf.toString();
4014    }
4015
4016    public String JavaDoc capitalize() {
4017        return str_capitalize();
4018    }
4019
4020    final String JavaDoc str_capitalize() {
4021        if (string.length() == 0)
4022            return string;
4023        String JavaDoc first = string.substring(0,1).toUpperCase();
4024        return first.concat(string.substring(1).toLowerCase());
4025    }
4026
4027    public String JavaDoc replace(String JavaDoc oldPiece, String JavaDoc newPiece) {
4028        return str_replace(oldPiece, newPiece);
4029    }
4030
4031    final String JavaDoc str_replace(String JavaDoc oldPiece, String JavaDoc newPiece) {
4032        return str_replace(oldPiece, newPiece, string.length());
4033    }
4034
4035    public String JavaDoc replace(String JavaDoc oldPiece, String JavaDoc newPiece, int maxsplit) {
4036        return str_replace(oldPiece, newPiece, maxsplit);
4037    }
4038
4039    final String JavaDoc str_replace(String JavaDoc oldPiece, String JavaDoc newPiece, int maxsplit) {
4040        PyString newstr = new PyString(newPiece);
4041        return newstr.join(split(oldPiece, maxsplit));
4042    }
4043
4044    public String JavaDoc join(PyObject seq) {
4045        return str_join(seq);
4046    }
4047
4048    final String JavaDoc str_join(PyObject seq) {
4049        StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
4050
4051        PyObject iter = seq.__iter__();
4052        PyObject obj = null;
4053        for (int i = 0; (obj = iter.__iternext__()) != null; i++) {
4054            if (!(obj instanceof PyString))
4055                 throw Py.TypeError(
4056                        "sequence item " + i + ": expected string, " +
4057                        obj.safeRepr() + " found");
4058            if (i > 0)
4059                buf.append(string);
4060            buf.append(obj.__str__());
4061        }
4062        return buf.toString();
4063    }
4064
4065
4066    public boolean startswith(String JavaDoc prefix) {
4067        return str_startswith(prefix);
4068    }
4069
4070    final boolean str_startswith(String JavaDoc prefix) {
4071        return string.startsWith(prefix);
4072    }
4073
4074    public boolean startswith(String JavaDoc prefix, int offset) {
4075        return str_startswith(prefix, offset);
4076    }
4077
4078    final boolean str_startswith(String JavaDoc prefix, int offset) {
4079        return string.startsWith(prefix, offset);
4080    }
4081
4082    public boolean startswith(String JavaDoc prefix, int start, int end) {
4083        return str_startswith(prefix, start, end);
4084    }
4085
4086    final boolean str_startswith(String JavaDoc prefix, int start, int end) {
4087        if (start < 0 || start + prefix.length() > string.length())
4088            return false;
4089        if (end > string.length())
4090            end = string.length();
4091        String JavaDoc substr = string.substring(start, end);
4092        return substr.startsWith(prefix);
4093    }
4094
4095    public boolean endswith(String JavaDoc suffix) {
4096        return str_endswith(suffix);
4097    }
4098
4099    final boolean str_endswith(String JavaDoc suffix) {
4100        return string.endsWith(suffix);
4101    }
4102
4103    public boolean endswith(String JavaDoc suffix, int start) {
4104        return str_endswith(suffix, start);
4105    }
4106
4107    final boolean str_endswith(String JavaDoc suffix, int start) {
4108        return str_endswith(suffix, start, string.length());
4109    }
4110
4111    public boolean endswith(String JavaDoc suffix, int start, int end) {
4112        return str_endswith(suffix, start, end);
4113    }
4114
4115    final boolean str_endswith(String JavaDoc suffix, int start, int end) {
4116        int len = string.length();
4117
4118        if (start < 0 || start > len || suffix.length() > len)
4119            return false;
4120
4121        end = (end <= len ? end : len);
4122        if (end < start)
4123            return false;
4124
4125        String JavaDoc substr = string.substring(start, end);
4126        return substr.endsWith(suffix);
4127    }
4128
4129    public String JavaDoc translate(String JavaDoc table) {
4130        return str_translate(table);
4131    }
4132
4133    final String JavaDoc str_translate(String JavaDoc table) {
4134        return str_translate(table, null);
4135    }
4136
4137    public String JavaDoc translate(String JavaDoc table, String JavaDoc deletechars) {
4138        return str_translate(table, deletechars);
4139    }
4140
4141    final String JavaDoc str_translate(String JavaDoc table, String JavaDoc deletechars) {
4142        if (table.length() != 256)
4143            throw Py.ValueError(
4144                "translation table must be 256 characters long");
4145
4146        StringBuffer JavaDoc buf = new StringBuffer JavaDoc(string.length());
4147        for (int i=0; i < string.length(); i++) {
4148            char c = string.charAt(i);
4149            if (deletechars != null && deletechars.indexOf(c) >= 0)
4150                continue;
4151            try {
4152                buf.append(table.charAt(c));
4153            }
4154            catch (IndexOutOfBoundsException JavaDoc e) {
4155                throw Py.TypeError(
4156                    "translate() only works for 8-bit character strings");
4157            }
4158        }
4159        return buf.toString();
4160    }
4161
4162    //XXX: is this needed?
4163
public String JavaDoc translate(PyObject table) {
4164        StringBuffer JavaDoc v = new StringBuffer JavaDoc(string.length());
4165        for (int i=0; i < string.length(); i++) {
4166            char ch = string.charAt(i);
4167
4168            PyObject w = Py.newInteger(ch);
4169            PyObject x = table.__finditem__(w);
4170            if (x == null) {
4171                /* No mapping found: default to 1-1 mapping */
4172                v.append(ch);
4173                continue;
4174            }
4175
4176            /* Apply mapping */
4177            if (x instanceof PyInteger) {
4178                int value = ((PyInteger) x).getValue();
4179                v.append((char) value);
4180            } else if (x == Py.None) {
4181                ;
4182            } else if (x instanceof PyString) {
4183                if (x.__len__() != 1) {
4184                    /* 1-n mapping */
4185                    throw new PyException(Py.NotImplementedError,
4186                          "1-n mappings are currently not implemented");
4187                }
4188                v.append(x.toString());
4189            }
4190            else {
4191                /* wrong return value */
4192                throw Py.TypeError(
4193                     "character mapping must return integer, " +
4194                     "None or unicode");
4195            }
4196        }
4197        return v.toString();
4198    }
4199
4200    public boolean islower() {
4201        return str_islower();
4202    }
4203
4204    final boolean str_islower() {
4205        int n = string.length();
4206
4207        /* Shortcut for single character strings */
4208        if (n == 1)
4209            return Character.isLowerCase(string.charAt(0));
4210
4211        boolean cased = false;
4212        for (int i = 0; i < n; i++) {
4213            char ch = string.charAt(i);
4214
4215            if (Character.isUpperCase(ch) || Character.isTitleCase(ch))
4216                return false;
4217            else if (!cased && Character.isLowerCase(ch))
4218                cased = true;
4219        }
4220        return cased;
4221    }
4222
4223    public boolean isupper() {
4224        return str_isupper();
4225    }
4226
4227    final boolean str_isupper() {
4228        int n = string.length();
4229
4230        /* Shortcut for single character strings */
4231        if (n == 1)
4232            return Character.isUpperCase(string.charAt(0));
4233
4234        boolean cased = false;
4235        for (int i = 0; i < n; i++) {
4236            char ch = string.charAt(i);
4237
4238            if (Character.isLowerCase(ch) || Character.isTitleCase(ch))
4239                return false;
4240            else if (!cased && Character.isUpperCase(ch))
4241                cased = true;
4242        }
4243        return cased;
4244    }
4245
4246    public boolean isalpha() {
4247        return str_isalpha();
4248    }
4249
4250    final boolean str_isalpha() {
4251        int n = string.length();
4252
4253        /* Shortcut for single character strings */
4254        if (n == 1)
4255            return Character.isLetter(string.charAt(0));
4256
4257        if (n == 0)
4258            return false;
4259
4260        for (int i = 0; i < n; i++) {
4261            char ch = string.charAt(i);
4262
4263            if (!Character.isLetter(ch))
4264                return false;
4265        }
4266        return true;
4267    }
4268
4269    public boolean isalnum() {
4270        return str_isalnum();
4271    }
4272
4273    final boolean str_isalnum() {
4274        int n = string.length();
4275
4276        /* Shortcut for single character strings */
4277        if (n == 1)
4278            return _isalnum(string.charAt(0));
4279
4280        if (n == 0)
4281            return false;
4282
4283        for (int i = 0; i < n; i++) {
4284            char ch = string.charAt(i);
4285
4286            if (!_isalnum(ch))
4287                return false;
4288        }
4289        return true;
4290    }
4291
4292    private boolean _isalnum(char ch) {
4293        // This can ever be entirely compatible with CPython. In CPython
4294
// The type is not used, the numeric property is determined from
4295
// the presense of digit, decimal or numeric fields. These fields
4296
// are not available in exactly the same way in java.
4297
return Character.isLetterOrDigit(ch) ||
4298               Character.getType(ch) == Character.LETTER_NUMBER;
4299    }
4300
4301    public boolean isdecimal() {
4302        return str_isdecimal();
4303    }
4304
4305    final boolean str_isdecimal() {
4306        int n = string.length();
4307
4308        /* Shortcut for single character strings */
4309        if (n == 1) {
4310            char ch = string.charAt(0);
4311            return _isdecimal(ch);
4312        }
4313
4314        if (n == 0)
4315            return false;
4316
4317        for (int i = 0; i < n; i++) {
4318            char ch = string.charAt(i);
4319
4320            if (!_isdecimal(ch))
4321                return false;
4322        }
4323        return true;
4324    }
4325
4326    private boolean _isdecimal(char ch) {
4327        // See the comment in _isalnum. Here it is even worse.
4328
return Character.getType(ch) == Character.DECIMAL_DIGIT_NUMBER;
4329    }
4330
4331    public boolean isdigit() {
4332        return str_isdigit();
4333    }
4334
4335    final boolean str_isdigit() {
4336        int n = string.length();
4337
4338        /* Shortcut for single character strings */
4339        if (n == 1)
4340            return Character.isDigit(string.charAt(0));
4341
4342        if (n == 0)
4343            return false;
4344
4345        for (int i = 0; i < n; i++) {
4346            char ch = string.charAt(i);
4347
4348            if (!Character.isDigit(ch))
4349                return false;
4350        }
4351        return true;
4352    }
4353
4354    public boolean isnumeric() {
4355        return str_isnumeric();
4356    }
4357
4358    final boolean str_isnumeric() {
4359        int n = string.length();
4360
4361        /* Shortcut for single character strings */
4362        if (n == 1)
4363            return _isnumeric(string.charAt(0));
4364
4365        if (n == 0)
4366            return false;
4367
4368        for (int i = 0; i < n; i++) {
4369            char ch = string.charAt(i);
4370            if (!_isnumeric(ch))
4371                return false;
4372        }
4373        return true;
4374    }
4375
4376    private boolean _isnumeric(char ch) {
4377        int type = Character.getType(ch);
4378        return type == Character.DECIMAL_DIGIT_NUMBER ||
4379               type == Character.LETTER_NUMBER ||
4380               type == Character.OTHER_NUMBER;
4381    }
4382
4383    public boolean istitle() {
4384        return str_istitle();
4385    }
4386
4387    final boolean str_istitle() {
4388        int n = string.length();
4389
4390        /* Shortcut for single character strings */
4391        if (n == 1)
4392            return Character.isTitleCase(string.charAt(0)) ||
4393                   Character.isUpperCase(string.charAt(0));
4394
4395        boolean cased = false;
4396        boolean previous_is_cased = false;
4397        for (int i = 0; i < n; i++) {
4398            char ch = string.charAt(i);
4399
4400            if (Character.isUpperCase(ch) || Character.isTitleCase(ch)) {
4401                if (previous_is_cased)
4402                    return false;
4403                previous_is_cased = true;
4404                cased = true;
4405            }
4406            else if (Character.isLowerCase(ch)) {
4407                if (!previous_is_cased)
4408                    return false;
4409                previous_is_cased = true;
4410                cased = true;
4411            }
4412            else
4413                previous_is_cased = false;
4414        }
4415        return cased;
4416    }
4417
4418    public boolean isspace() {
4419        return str_isspace();
4420    }
4421
4422    final boolean str_isspace() {
4423        int n = string.length();
4424
4425        /* Shortcut for single character strings */
4426        if (n == 1)
4427            return Character.isWhitespace(string.charAt(0));
4428
4429        if (n == 0)
4430            return false;
4431
4432        for (int i = 0; i < n; i++) {
4433            char ch = string.charAt(i);
4434
4435            if (!Character.isWhitespace(ch))
4436                return false;
4437        }
4438        return true;
4439    }
4440
4441    public boolean isunicode() {
4442        return str_isunicode();
4443    }
4444
4445    final boolean str_isunicode() {
4446        int n = string.length();
4447        for (int i = 0; i < n; i++) {
4448            char ch = string.charAt(i);
4449            if (ch > 255)
4450                return true;
4451        }
4452        return false;
4453    }
4454
4455    public String JavaDoc encode() {
4456        return str_encode();
4457    }
4458
4459    final String JavaDoc str_encode() {
4460        return str_encode(null, null);
4461    }
4462
4463    public String JavaDoc encode(String JavaDoc encoding) {
4464        return str_encode(encoding);
4465    }
4466
4467    final String JavaDoc str_encode(String JavaDoc encoding) {
4468        return str_encode(encoding, null);
4469    }
4470
4471    public String JavaDoc encode(String JavaDoc encoding, String JavaDoc errors) {
4472        return str_encode(encoding, errors);
4473    }
4474
4475    final String JavaDoc str_encode(String JavaDoc encoding, String JavaDoc errors) {
4476        return codecs.encode(this, encoding, errors);
4477    }
4478
4479    public String JavaDoc decode() {
4480        return str_decode();
4481    }
4482
4483    final String JavaDoc str_decode() {
4484        return str_decode(null, null); // xxx
4485
}
4486
4487    public String JavaDoc decode(String JavaDoc encoding) {
4488        return str_decode(encoding);
4489    }
4490
4491    final String JavaDoc str_decode(String JavaDoc encoding) {
4492        return str_decode(encoding, null);
4493    }
4494
4495    public String JavaDoc decode(String JavaDoc encoding, String JavaDoc errors) {
4496        return str_decode(encoding, errors);
4497    }
4498
4499    final String JavaDoc str_decode(String JavaDoc encoding, String JavaDoc errors) {
4500        return codecs.decode(this, encoding, errors);
4501    }
4502
4503    /* arguments' conversion helper */
4504
4505    public String JavaDoc asString(int index) throws PyObject.ConversionException {
4506        return string;
4507    }
4508
4509    public String JavaDoc asName(int index) throws PyObject.ConversionException {
4510        return internedString();
4511    }
4512
4513}
4514
4515final class StringFormatter
4516{
4517    int index;
4518    String JavaDoc format;
4519    StringBuffer JavaDoc buffer;
4520    boolean negative;
4521    int precision;
4522    int argIndex;
4523    PyObject args;
4524
4525    final char pop() {
4526        try {
4527            return format.charAt(index++);
4528        } catch (StringIndexOutOfBoundsException JavaDoc e) {
4529            throw Py.ValueError("incomplete format");
4530        }
4531    }
4532
4533    final char peek() {
4534        return format.charAt(index);
4535    }
4536
4537    final void push() {
4538        index--;
4539    }
4540
4541    public StringFormatter(String JavaDoc format) {
4542        index = 0;
4543        this.format = format;
4544        buffer = new StringBuffer JavaDoc(format.length()+100);
4545    }
4546
4547    PyObject getarg() {
4548        PyObject ret = null;
4549        switch(argIndex) {
4550            // special index indicating a mapping
4551
case -3:
4552            return args;
4553            // special index indicating a single item that has already been
4554
// used
4555
case -2:
4556            break;
4557            // special index indicating a single item that has not yet been
4558
// used
4559
case -1:
4560            argIndex=-2;
4561            return args;
4562        default:
4563            ret = args.__finditem__(argIndex++);
4564            break;
4565        }
4566        if (ret == null)
4567            throw Py.TypeError("not enough arguments for format string");
4568        return ret;
4569    }
4570
4571    int getNumber() {
4572        char c = pop();
4573        if (c == '*') {
4574            PyObject o = getarg();
4575            if (o instanceof PyInteger)
4576                return ((PyInteger)o).getValue();
4577            throw Py.TypeError("* wants int");
4578        } else {
4579            if (Character.isDigit(c)) {
4580                int numStart = index-1;
4581                while (Character.isDigit(c = pop()))
4582                    ;
4583                index -= 1;
4584                Integer JavaDoc i = Integer.valueOf(
4585                                    format.substring(numStart, index));
4586                return i.intValue();
4587            }
4588            index -= 1;
4589            return 0;
4590        }
4591    }
4592
4593    public String JavaDoc formatLong(PyString arg, char type, boolean altFlag) {
4594        String JavaDoc s = arg.toString();
4595        int end = s.length();
4596        int ptr = 0;
4597
4598        int numnondigits = 0;
4599        if (type == 'x' || type == 'X')
4600            numnondigits = 2;
4601
4602        if (s.endsWith("L"))
4603            end--;
4604
4605        negative = s.charAt(0) == '-';
4606        if (negative) {
4607            ptr++;
4608        }
4609
4610        int numdigits = end - numnondigits - ptr;
4611        if (!altFlag) {
4612            switch (type) {
4613            case 'o' :
4614                if (numdigits > 1) {
4615                     ++ptr;
4616                     --numdigits;
4617                }
4618                break;
4619            case 'x' :
4620            case 'X' :
4621                ptr += 2;
4622                numnondigits -= 2;
4623                break;
4624            }
4625        }
4626        if (precision > numdigits) {
4627            StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
4628            for (int i = 0; i < numnondigits; ++i)
4629                buf.append(s.charAt(ptr++));
4630            for (int i = 0; i < precision - numdigits; i++)
4631                buf.append('0');
4632            for (int i = 0; i < numdigits; i++)
4633                buf.append(s.charAt(ptr++));
4634            s = buf.toString();
4635        } else if (end < s.length() || ptr > 0)
4636            s = s.substring(ptr, end);
4637
4638        switch (type) {
4639        case 'x' :
4640            s = s.toLowerCase();
4641            break;
4642        }
4643        return s;
4644    }
4645
4646    public String JavaDoc formatInteger(PyObject arg, int radix, boolean unsigned) {
4647        return formatInteger(((PyInteger)arg.__int__()).getValue(), radix, unsigned);
4648    }
4649
4650    public String JavaDoc formatInteger(long v, int radix, boolean unsigned) {
4651        if (unsigned) {
4652            if (v < 0)
4653                v = 0x100000000l + v;
4654        } else {
4655            if (v < 0) {
4656                negative = true;
4657                v = -v;
4658            }
4659        }
4660        String JavaDoc s = Long.toString(v, radix);
4661        while (s.length() < precision) {
4662            s = "0"+s;
4663        }
4664        return s;
4665    }
4666
4667    public String JavaDoc formatFloatDecimal(PyObject arg, boolean truncate) {
4668        return formatFloatDecimal(arg.__float__().getValue(), truncate);
4669    }
4670
4671    public String JavaDoc formatFloatDecimal(double v, boolean truncate) {
4672        java.text.NumberFormat JavaDoc format = java.text.NumberFormat.getInstance(
4673                                           java.util.Locale.US);
4674        int prec = precision;
4675        if (prec == -1)
4676            prec = 6;
4677        if (v < 0) {
4678            v = -v;
4679            negative = true;
4680        }
4681        format.setMaximumFractionDigits(prec);
4682        format.setMinimumFractionDigits(truncate ? 0 : prec);
4683        format.setGroupingUsed(false);
4684
4685        String JavaDoc ret = format.format(v);
4686// System.err.println("formatFloat: "+v+", prec="+prec+", ret="+ret);
4687
// if (ret.indexOf('.') == -1) {
4688
// return ret+'.';
4689
// }
4690
return ret;
4691    }
4692
4693    public String JavaDoc formatFloatExponential(PyObject arg, char e,
4694                                         boolean truncate)
4695    {
4696        StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
4697        double v = arg.__float__().getValue();
4698        boolean isNegative = false;
4699        if (v < 0) {
4700            v = -v;
4701            isNegative = true;
4702        }
4703        double power = 0.0;
4704        if (v > 0)
4705            power = ExtraMath.closeFloor(ExtraMath.log10(v));
4706        //System.err.println("formatExp: "+v+", "+power);
4707
int savePrecision = precision;
4708
4709        if (truncate)
4710            precision = -1;
4711        else
4712            precision = 3;
4713
4714        String JavaDoc exp = formatInteger((long)power, 10, false);
4715        if (negative) {
4716            negative = false;
4717            exp = '-'+exp;
4718        }
4719        else {
4720            if (!truncate)
4721                exp = '+'+exp;
4722        }
4723
4724        precision = savePrecision;
4725
4726        double base = v/Math.pow(10, power);
4727        buf.append(formatFloatDecimal(base, truncate));
4728        buf.append(e);
4729
4730        buf.append(exp);
4731        negative = isNegative;
4732
4733        return buf.toString();
4734    }
4735
4736    public String JavaDoc format(PyObject args) {
4737        PyObject dict = null;
4738        this.args = args;
4739        if (args instanceof PyTuple) {
4740            argIndex = 0;
4741        } else {
4742            // special index indicating a single item rather than a tuple
4743
argIndex = -1;
4744            if (args instanceof PyDictionary ||
4745                args instanceof PyStringMap ||
4746                (!(args instanceof PySequence) &&
4747                 args.__findattr__("__getitem__") != null))
4748            {
4749                dict = args;
4750                argIndex = -3;
4751            }
4752        }
4753
4754        while (index < format.length()) {
4755            boolean ljustFlag=false;
4756            boolean signFlag=false;
4757            boolean blankFlag=false;
4758            boolean altFlag=false;
4759            boolean zeroFlag=false;
4760
4761            int width = -1;
4762            precision = -1;
4763
4764            char c = pop();
4765            if (c != '%') {
4766                buffer.append(c);
4767                continue;
4768            }
4769            c = pop();
4770            if (c == '(') {
4771                //System.out.println("( found");
4772
if (dict == null)
4773                    throw Py.TypeError("format requires a mapping");
4774                int parens = 1;
4775                int keyStart = index;
4776                while (parens > 0) {
4777                    c = pop();
4778                    if (c == ')')
4779                        parens--;
4780                    else if (c == '(')
4781                        parens++;
4782                }
4783                String JavaDoc tmp = format.substring(keyStart, index-1);
4784                this.args = dict.__getitem__(new PyString(tmp));
4785                //System.out.println("args: "+args+", "+argIndex);
4786
} else {
4787                push();
4788            }
4789            while (true) {
4790                switch (c = pop()) {
4791                case '-': ljustFlag=true; continue;
4792                case '+': signFlag=true; continue;
4793                case ' ': blankFlag=true; continue;
4794                case '#': altFlag=true; continue;
4795                case '0': zeroFlag=true; continue;
4796                }
4797                break;
4798            }
4799            push();
4800            width = getNumber();
4801            if (width < 0) {
4802                width = -width;
4803                ljustFlag = true;
4804            }
4805            c = pop();
4806            if (c == '.') {
4807                precision = getNumber();
4808                if (precision < -1)
4809                    precision = 0;
4810                if (precision > 250) {
4811                    // A magic number. Larger than in CPython.
4812
throw Py.OverflowError(
4813                         "formatted float is too long (precision too long?)");
4814                }
4815
4816                c = pop();
4817            }
4818            if (c == 'h' || c == 'l' || c == 'L') {
4819                c = pop();
4820            }
4821            if (c == '%') {
4822                buffer.append(c);
4823                continue;
4824            }
4825            PyObject arg = getarg();
4826            //System.out.println("args: "+args+", "+argIndex+", "+arg);
4827
char fill = ' ';
4828            String JavaDoc string=null;
4829            negative = false;
4830            if (zeroFlag)
4831                fill = '0';
4832            else
4833                fill = ' ';
4834
4835            switch(c) {
4836            case 's':
4837            case 'r':
4838                fill = ' ';
4839                if (c == 's')
4840                    string = arg.__str__().toString();
4841                else
4842                    string = arg.__repr__().toString();
4843                if (precision >= 0 && string.length() > precision) {
4844                    string = string.substring(0, precision);
4845                }
4846                break;
4847            case 'i':
4848            case 'd':
4849                if (arg instanceof PyLong)
4850                    string = formatLong(arg.__str__(), c, altFlag);
4851                else
4852                    string = formatInteger(arg, 10, false);
4853                break;
4854            case 'u':
4855                if (arg instanceof PyLong)
4856                    string = formatLong(arg.__str__(), c, altFlag);
4857                else
4858                    string = formatInteger(arg, 10, true);
4859                break;
4860            case 'o':
4861                if (arg instanceof PyLong)
4862                    string = formatLong(arg.__oct__(), c, altFlag);
4863                else {
4864                    string = formatInteger(arg, 8, true);
4865                    if (altFlag && string.charAt(0) != '0') {
4866                        string = "0" + string;
4867                    }
4868                }
4869                break;
4870            case 'x':
4871                if (arg instanceof PyLong)
4872                    string = formatLong(arg.__hex__(), c, altFlag);
4873                else {
4874                    string = formatInteger(arg, 16, true);
4875                    string = string.toLowerCase();
4876                    if (altFlag) {
4877                        string = "0x" + string;
4878                    }
4879                }
4880                break;
4881            case 'X':
4882                if (arg instanceof PyLong)
4883                    string = formatLong(arg.__hex__(), c, altFlag);
4884                else {
4885                    string = formatInteger(arg, 16, true);
4886                    string = string.toUpperCase();
4887                    if (altFlag) {
4888                        string = "0X" + string;
4889                   }
4890                }
4891
4892                break;
4893            case 'e':
4894            case 'E':
4895                string = formatFloatExponential(arg, c, false);
4896                break;
4897            case 'f':
4898                string = formatFloatDecimal(arg, false);
4899// if (altFlag && string.indexOf('.') == -1)
4900
// string += '.';
4901
break;
4902            case 'g':
4903            case 'G':
4904                int prec = precision;
4905                if (prec == -1)
4906                    prec = 6;
4907                double v = arg.__float__().getValue();
4908                int digits = (int)Math.ceil(ExtraMath.log10(v));
4909                if (digits > 0) {
4910                    if (digits <= prec) {
4911                        precision = prec-digits;
4912                        string = formatFloatDecimal(arg, true);
4913                    } else {
4914                        string = formatFloatExponential(arg, (char)(c-2),
4915                                                        true);
4916                    }
4917                } else {
4918                    string = formatFloatDecimal(arg, true);
4919                }
4920                if (altFlag && string.indexOf('.') == -1) {
4921                    int zpad = prec - string.length();
4922                    string += '.';
4923                    if (zpad > 0) {
4924                        char zeros[] = new char[zpad];
4925                        for (int ci=0; ci<zpad; zeros[ci++] = '0')
4926                            ;
4927                        string += new String JavaDoc(zeros);
4928                    }
4929                }
4930                break;
4931            case 'c':
4932                fill = ' ';
4933                if (arg instanceof PyString) {
4934                    string = ((PyString)arg).toString();
4935                    if (string.length() != 1)
4936                        throw Py.TypeError("%c requires int or char");
4937                    break;
4938                }
4939                char tmp = (char)((PyInteger)arg.__int__()).getValue();
4940                string = new Character JavaDoc(tmp).toString();
4941                break;
4942
4943            default:
4944                throw Py.ValueError("unsupported format character '" +
4945                         codecs.encode(Py.newString(c), null, "replace") +
4946                         "' (0x" + Integer.toHexString(c) + ") at index " +
4947                         (index-1));
4948            }
4949            int length = string.length();
4950            int skip = 0;
4951            String JavaDoc signString = null;
4952            if (negative) {
4953                signString = "-";
4954            } else {
4955                if (signFlag) {
4956                    signString = "+";
4957                } else if (blankFlag) {
4958                    signString = " ";
4959                }
4960            }
4961
4962            if (width < length)
4963                width = length;
4964            if (signString != null) {
4965                if (fill != ' ')
4966                    buffer.append(signString);
4967                if (width > length)
4968                    width--;
4969            }
4970            if (altFlag && (c == 'x' || c == 'X')) {
4971                if (fill != ' ') {
4972                    buffer.append('0');
4973                    buffer.append(c);
4974                    skip += 2;
4975                }
4976                width -= 2;
4977                if (width < 0)
4978                    width = 0;
4979                length -= 2;
4980            }
4981            if (width > length && !ljustFlag) {
4982                do {
4983                    buffer.append(fill);
4984                } while (--width > length);
4985            }
4986            if (fill == ' ') {
4987                if (signString != null)
4988                    buffer.append(signString);
4989                if (altFlag && (c == 'x' || c == 'X')) {
4990                    buffer.append('0');
4991                    buffer.append(c);
4992                    skip += 2;
4993                }
4994            }
4995            if (skip > 0)
4996                buffer.append(string.substring(skip));
4997            else
4998                buffer.append(string);
4999
5000            while (--width >= length) {
5001                buffer.append(' ');
5002            }
5003        }
5004        if (argIndex == -1 ||
5005            (argIndex >= 0 && args.__finditem__(argIndex) != null))
5006        {
5007            throw Py.TypeError("not all arguments converted");
5008        }
5009        return buffer.toString();
5010    }
5011
5012}
5013
Popular Tags