Source Code Cross Referenced for PyInstance.java in  » Scripting » jython » org » python » core » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Scripting » jython » org.python.core 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        // Copyright (c) Corporation for National Research Initiatives
0002:        package org.python.core;
0003:
0004:        import java.util.Hashtable;
0005:        import java.util.StringTokenizer;
0006:        import java.io.Serializable;
0007:
0008:        /**
0009:         * A python class instance.
0010:         */
0011:
0012:        public class PyInstance extends PyObject {
0013:            // xxx doc, final name
0014:            public transient PyClass instclass;
0015:
0016:            // xxx
0017:            public PyObject fastGetClass() {
0018:                return instclass;
0019:            }
0020:
0021:            //This field is only used by Python subclasses of Java classes
0022:            Object javaProxy;
0023:
0024:            /**
0025:               The namespace of this instance.  Contains all instance attributes.
0026:             **/
0027:            public PyObject __dict__;
0028:
0029:            /* Override serialization behavior */
0030:            private void readObject(java.io.ObjectInputStream in)
0031:                    throws java.io.IOException, ClassNotFoundException {
0032:                in.defaultReadObject();
0033:
0034:                String module = in.readUTF();
0035:                String name = in.readUTF();
0036:
0037:                /* Check for types and missing members here */
0038:                //System.out.println("module: "+module+", "+name);
0039:                PyObject mod = imp.importName(module.intern(), false);
0040:                PyClass pyc = (PyClass) mod.__getattr__(name.intern());
0041:
0042:                instclass = pyc;
0043:                if (javaProxy != null)
0044:                    ((PyProxy) javaProxy)
0045:                            ._setPySystemState(Py.getSystemState());
0046:            }
0047:
0048:            private void writeObject(java.io.ObjectOutputStream out)
0049:                    throws java.io.IOException {
0050:                //System.out.println("writing: "+getClass().getName());
0051:                out.defaultWriteObject();
0052:                PyObject name = instclass.__findattr__("__module__");
0053:                if (!(name instanceof  PyString) || name == Py.None
0054:                        || name == null) {
0055:                    throw Py.ValueError("Can't find module for class: "
0056:                            + instclass.__name__);
0057:                }
0058:                out.writeUTF(name.toString());
0059:                name = instclass.__findattr__("__name__");
0060:                if (!(name instanceof  PyString) || name == Py.None
0061:                        || name == null) {
0062:                    throw Py
0063:                            .ValueError("Can't find module for class with no name");
0064:                }
0065:
0066:                out.writeUTF(name.toString());
0067:            }
0068:
0069:            /**
0070:               Returns a new
0071:             **/
0072:
0073:            public PyInstance(PyClass iclass, PyObject dict) {
0074:                instclass = iclass;
0075:                __dict__ = dict;
0076:            }
0077:
0078:            public PyInstance(PyClass iclass) {
0079:                this (iclass, new PyStringMap());
0080:            }
0081:
0082:            public PyInstance() {
0083:            }
0084:
0085:            private static Hashtable primitiveMap;
0086:
0087:            protected void makeProxy() {
0088:                Class c = instclass.proxyClass;
0089:                PyProxy proxy;
0090:                ThreadState ts = Py.getThreadState();
0091:                try {
0092:                    ts.pushInitializingProxy(this );
0093:                    try {
0094:                        proxy = (PyProxy) c.newInstance();
0095:                    } catch (java.lang.InstantiationException e) {
0096:                        Class sup = c.getSuperclass();
0097:                        String msg = "Default constructor failed for Java superclass";
0098:                        if (sup != null)
0099:                            msg += " " + sup.getName();
0100:                        throw Py.TypeError(msg);
0101:                    } catch (NoSuchMethodError nsme) {
0102:                        throw Py.TypeError("constructor requires arguments");
0103:                    } catch (Exception exc) {
0104:                        throw Py.JavaError(exc);
0105:                    }
0106:                } finally {
0107:                    ts.popInitializingProxy();
0108:                }
0109:
0110:                if (javaProxy != null && javaProxy != proxy) {
0111:                    // The javaProxy can be initialized in Py.jfindattr()
0112:                    throw Py.TypeError("Proxy instance already initialized");
0113:                }
0114:                PyInstance proxyInstance = proxy._getPyInstance();
0115:                if (proxyInstance != null && proxyInstance != this ) {
0116:                    // The proxy was initialized to another instance!!
0117:                    throw Py.TypeError("Proxy initialization conflict");
0118:                }
0119:
0120:                javaProxy = proxy;
0121:            }
0122:
0123:            public Object __tojava__(Class c) {
0124:                if ((c == Object.class || c == Serializable.class)
0125:                        && javaProxy != null) {
0126:                    return javaProxy;
0127:                }
0128:                if (c.isInstance(this ))
0129:                    return this ;
0130:
0131:                if (c.isPrimitive()) {
0132:                    if (primitiveMap == null) {
0133:                        primitiveMap = new Hashtable();
0134:                        primitiveMap.put(Character.TYPE, Character.class);
0135:                        primitiveMap.put(Boolean.TYPE, Boolean.class);
0136:                        primitiveMap.put(Byte.TYPE, Byte.class);
0137:                        primitiveMap.put(Short.TYPE, Short.class);
0138:                        primitiveMap.put(Integer.TYPE, Integer.class);
0139:                        primitiveMap.put(Long.TYPE, Long.class);
0140:                        primitiveMap.put(Float.TYPE, Float.class);
0141:                        primitiveMap.put(Double.TYPE, Double.class);
0142:                    }
0143:                    Class tmp = (Class) primitiveMap.get(c);
0144:                    if (tmp != null)
0145:                        c = tmp;
0146:                }
0147:
0148:                if (javaProxy == null && instclass.proxyClass != null) {
0149:                    makeProxy();
0150:                }
0151:                if (c.isInstance(javaProxy))
0152:                    return javaProxy;
0153:
0154:                if (instclass.__tojava__ != null) {
0155:                    //try {
0156:                    PyObject ret = instclass.__tojava__.__call__(this ,
0157:                            PyJavaClass.lookup(c));
0158:
0159:                    if (ret == Py.None)
0160:                        return Py.NoConversion;
0161:                    if (ret != this )
0162:                        return ret.__tojava__(c);
0163:                    /*} catch (PyException exc) {
0164:                      System.err.println("Error in __tojava__ method");
0165:                      Py.printException(exc);
0166:                      }*/
0167:                }
0168:                return Py.NoConversion;
0169:            }
0170:
0171:            public void __init__(PyObject[] args, String[] keywords) {
0172:                // Invoke our own init function
0173:                PyObject init = instclass.lookup("__init__", true);
0174:                PyObject ret = null;
0175:                if (init != null) {
0176:                    ret = init.__call__(this , args, keywords);
0177:                }
0178:                if (ret == null) {
0179:                    if (args.length != 0) {
0180:                        init = instclass.lookup("__init__", false);
0181:                        if (init != null) {
0182:                            ret = init.__call__(this , args, keywords);
0183:                        } else {
0184:                            throw Py
0185:                                    .TypeError("this constructor takes no arguments");
0186:                        }
0187:                    }
0188:                } else if (ret != Py.None) {
0189:                    throw Py.TypeError("constructor has no return value");
0190:                }
0191:                // Now init all superclasses that haven't already been initialized
0192:                if (javaProxy == null && instclass.proxyClass != null) {
0193:                    makeProxy();
0194:                }
0195:            }
0196:
0197:            public PyObject __jfindattr__(String name) {
0198:                //System.err.println("jfinding: "+name);
0199:                return __findattr__(name, true);
0200:            }
0201:
0202:            public PyObject __findattr__(String name) {
0203:                return __findattr__(name, false);
0204:            }
0205:
0206:            public PyObject __findattr__(String name, boolean stopAtJava) {
0207:                PyObject result = ifindlocal(name);
0208:                if (result != null)
0209:                    return result;
0210:                // it wasn't found in the instance, try the class
0211:                PyObject[] result2 = instclass.lookupGivingClass(name,
0212:                        stopAtJava);
0213:                if (result2[0] != null)
0214:                    // xxx do we need to use result2[1] (wherefound) for java cases for backw comp?
0215:                    return result2[0].__get__(this , instclass);
0216:                // xxx do we need to use 
0217:                return ifindfunction(name);
0218:            }
0219:
0220:            protected PyObject ifindlocal(String name) {
0221:                if (name == "__dict__")
0222:                    return __dict__;
0223:                if (name == "__class__")
0224:                    return instclass;
0225:                if (__dict__ == null)
0226:                    return null;
0227:
0228:                return __dict__.__finditem__(name);
0229:            }
0230:
0231:            protected PyObject ifindclass(String name, boolean stopAtJava) {
0232:                return instclass.lookup(name, stopAtJava);
0233:            }
0234:
0235:            protected PyObject ifindfunction(String name) {
0236:                PyObject getter = instclass.__getattr__;
0237:                if (getter == null)
0238:                    return null;
0239:
0240:                try {
0241:                    return getter.__call__(this , new PyString(name));
0242:                } catch (PyException exc) {
0243:                    if (Py.matchException(exc, Py.AttributeError))
0244:                        return null;
0245:                    throw exc;
0246:                }
0247:            }
0248:
0249:            public PyObject invoke(String name) {
0250:                PyObject f = ifindlocal(name);
0251:                if (f == null) {
0252:                    f = ifindclass(name, false);
0253:                    if (f != null) {
0254:                        if (f instanceof  PyFunction) {
0255:                            return f.__call__(this );
0256:                        } else {
0257:                            f = f.__get__(this , instclass);
0258:                        }
0259:                    }
0260:                }
0261:                if (f == null)
0262:                    f = ifindfunction(name);
0263:                if (f == null)
0264:                    throw Py.AttributeError(name);
0265:                return f.__call__();
0266:            }
0267:
0268:            public PyObject invoke(String name, PyObject arg1) {
0269:                PyObject f = ifindlocal(name);
0270:                if (f == null) {
0271:                    f = ifindclass(name, false);
0272:                    if (f != null) {
0273:                        if (f instanceof  PyFunction) {
0274:                            return f.__call__(this , arg1);
0275:                        } else {
0276:                            f = f.__get__(this , instclass);
0277:                        }
0278:                    }
0279:                }
0280:                if (f == null)
0281:                    f = ifindfunction(name);
0282:                if (f == null)
0283:                    throw Py.AttributeError(name);
0284:                return f.__call__(arg1);
0285:            }
0286:
0287:            public PyObject invoke(String name, PyObject arg1, PyObject arg2) {
0288:                PyObject f = ifindlocal(name);
0289:                if (f == null) {
0290:                    f = ifindclass(name, false);
0291:                    if (f != null) {
0292:                        if (f instanceof  PyFunction) {
0293:                            return f.__call__(this , arg1, arg2);
0294:                        } else {
0295:                            f = f.__get__(this , instclass);
0296:                        }
0297:                    }
0298:                }
0299:                if (f == null)
0300:                    f = ifindfunction(name);
0301:                if (f == null)
0302:                    throw Py.AttributeError(name);
0303:                return f.__call__(arg1, arg2);
0304:            }
0305:
0306:            public void __setattr__(String name, PyObject value) {
0307:                if (name == "__class__") {
0308:                    if (value instanceof  PyClass) {
0309:                        instclass = (PyClass) value;
0310:                    } else {
0311:                        throw Py.TypeError("__class__ must be set to a class");
0312:                    }
0313:                    return;
0314:                } else if (name == "__dict__") {
0315:                    __dict__ = value;
0316:                    return;
0317:                }
0318:
0319:                PyObject setter = instclass.__setattr__;
0320:                if (setter != null) {
0321:                    setter.__call__(this , new PyString(name), value);
0322:                } else {
0323:                    if (instclass.getProxyClass() != null) {
0324:                        PyObject field = instclass.lookup(name, false);
0325:                        if (field == null) {
0326:                            noField(name, value);
0327:                        } else if (!field.jtryset(this , value)) {
0328:                            unassignableField(name, value);
0329:                        }
0330:                    } else {
0331:                        __dict__.__setitem__(name, value);
0332:                    }
0333:                }
0334:            }
0335:
0336:            protected void noField(String name, PyObject value) {
0337:                __dict__.__setitem__(name, value);
0338:            }
0339:
0340:            protected void unassignableField(String name, PyObject value) {
0341:                __dict__.__setitem__(name, value);
0342:            }
0343:
0344:            public void __delattr__(String name) {
0345:                PyObject deller = instclass.__delattr__;
0346:                if (deller != null) {
0347:                    deller.__call__(this , new PyString(name));
0348:                } else {
0349:                    try {
0350:                        __dict__.__delitem__(name);
0351:                    } catch (PyException exc) {
0352:                        if (Py.matchException(exc, Py.KeyError))
0353:                            throw Py.AttributeError("class "
0354:                                    + instclass.__name__
0355:                                    + " has no attribute '" + name + "'");
0356:                    }
0357:                    ;
0358:                }
0359:            }
0360:
0361:            public PyObject invoke_ex(String name, PyObject[] args,
0362:                    String[] keywords) {
0363:                PyObject meth = __findattr__(name);
0364:                if (meth == null)
0365:                    return null;
0366:                return meth.__call__(args, keywords);
0367:            }
0368:
0369:            public PyObject invoke_ex(String name) {
0370:                PyObject meth = __findattr__(name);
0371:                if (meth == null)
0372:                    return null;
0373:                return meth.__call__();
0374:            }
0375:
0376:            public PyObject invoke_ex(String name, PyObject arg1) {
0377:                PyObject meth = __findattr__(name);
0378:                if (meth == null)
0379:                    return null;
0380:                return meth.__call__(arg1);
0381:            }
0382:
0383:            public PyObject invoke_ex(String name, PyObject arg1, PyObject arg2) {
0384:                PyObject meth = __findattr__(name);
0385:                if (meth == null)
0386:                    return null;
0387:                return meth.__call__(arg1, arg2);
0388:            }
0389:
0390:            public PyObject __call__(PyObject args[], String keywords[]) {
0391:                ThreadState ts = Py.getThreadState();
0392:                if (ts.recursion_depth++ > ts.systemState.getrecursionlimit())
0393:                    throw Py
0394:                            .RuntimeError("maximum __call__ recursion depth exceeded");
0395:                try {
0396:                    return invoke("__call__", args, keywords);
0397:                } finally {
0398:                    --ts.recursion_depth;
0399:                }
0400:            }
0401:
0402:            public PyString __repr__() {
0403:                PyObject ret = invoke_ex("__repr__");
0404:                if (ret == null) {
0405:                    PyObject mod = instclass.__dict__
0406:                            .__finditem__("__module__");
0407:                    String smod;
0408:                    if (mod == Py.None)
0409:                        smod = "";
0410:                    else {
0411:                        if (mod == null || !(mod instanceof  PyString))
0412:                            smod = "<unknown>.";
0413:                        else
0414:                            smod = ((PyString) mod).toString() + '.';
0415:                    }
0416:                    return new PyString("<" + smod + instclass.__name__
0417:                            + " instance " + Py.idstr(this ) + ">");
0418:                }
0419:
0420:                if (!(ret instanceof  PyString))
0421:                    throw Py.TypeError("__repr__ method must return a string");
0422:                return (PyString) ret;
0423:            }
0424:
0425:            public PyString __str__() {
0426:                PyObject ret = invoke_ex("__str__");
0427:                if (ret == null)
0428:                    return __repr__();
0429:                if (!(ret instanceof  PyString))
0430:                    throw Py.TypeError("__str__ method must return a string");
0431:                return (PyString) ret;
0432:            }
0433:
0434:            public int hashCode() {
0435:                PyObject ret;
0436:                ret = invoke_ex("__hash__");
0437:
0438:                if (ret == null) {
0439:                    if (__findattr__("__eq__") != null
0440:                            || __findattr__("__cmp__") != null)
0441:                        throw Py.TypeError("unhashable instance");
0442:                    return super .hashCode();
0443:                }
0444:                if (ret instanceof  PyInteger) {
0445:                    return ((PyInteger) ret).getValue();
0446:                }
0447:                throw Py.TypeError("__hash__() must return int");
0448:            }
0449:
0450:            // special case: does all the work
0451:            public int __cmp__(PyObject other) {
0452:                PyObject[] coerced = this ._coerce(other);
0453:                PyObject v;
0454:                PyObject w;
0455:                PyObject ret = null;
0456:                if (coerced != null) {
0457:                    v = coerced[0];
0458:                    w = coerced[1];
0459:                    if (!(v instanceof  PyInstance)
0460:                            && !(w instanceof  PyInstance))
0461:                        return v._cmp(w);
0462:                } else {
0463:                    v = this ;
0464:                    w = other;
0465:                }
0466:                if (v instanceof  PyInstance) {
0467:                    ret = ((PyInstance) v).invoke_ex("__cmp__", w);
0468:                    if (ret != null) {
0469:                        if (ret instanceof  PyInteger) {
0470:                            int result = ((PyInteger) ret).getValue();
0471:                            return result < 0 ? -1 : result > 0 ? 1 : 0;
0472:                        }
0473:                        throw Py.TypeError("__cmp__() must return int");
0474:                    }
0475:                }
0476:                if (w instanceof  PyInstance) {
0477:                    ret = ((PyInstance) w).invoke_ex("__cmp__", v);
0478:                    if (ret != null) {
0479:                        if (ret instanceof  PyInteger) {
0480:                            int result = ((PyInteger) ret).getValue();
0481:                            return -(result < 0 ? -1 : result > 0 ? 1 : 0);
0482:                        }
0483:                        throw Py.TypeError("__cmp__() must return int");
0484:                    }
0485:
0486:                }
0487:                return -2;
0488:            }
0489:
0490:            private PyObject invoke_ex_richcmp(String name, PyObject o) {
0491:                PyObject ret = invoke_ex(name, o);
0492:                if (ret == Py.NotImplemented)
0493:                    return null;
0494:                return ret;
0495:            }
0496:
0497:            public PyObject __lt__(PyObject o) {
0498:                return invoke_ex_richcmp("__lt__", o);
0499:            }
0500:
0501:            public PyObject __le__(PyObject o) {
0502:                return invoke_ex_richcmp("__le__", o);
0503:            }
0504:
0505:            public PyObject __gt__(PyObject o) {
0506:                return invoke_ex_richcmp("__gt__", o);
0507:            }
0508:
0509:            public PyObject __ge__(PyObject o) {
0510:                return invoke_ex_richcmp("__ge__", o);
0511:            }
0512:
0513:            public PyObject __eq__(PyObject o) {
0514:                return invoke_ex_richcmp("__eq__", o);
0515:            }
0516:
0517:            public PyObject __ne__(PyObject o) {
0518:                return invoke_ex_richcmp("__ne__", o);
0519:            }
0520:
0521:            public boolean __nonzero__() {
0522:                PyObject meth = null;
0523:                try {
0524:                    meth = __findattr__("__nonzero__");
0525:                } catch (PyException exc) {
0526:                }
0527:
0528:                if (meth == null) {
0529:                    // Copied form __len__()
0530:                    CollectionProxy proxy = getCollection();
0531:                    if (proxy != CollectionProxy.NoProxy) {
0532:                        return proxy.__len__() != 0 ? true : false;
0533:                    }
0534:                    try {
0535:                        meth = __findattr__("__len__");
0536:                    } catch (PyException exc) {
0537:                    }
0538:                    if (meth == null)
0539:                        return true;
0540:                }
0541:
0542:                PyObject ret = meth.__call__();
0543:                return ret.__nonzero__();
0544:            }
0545:
0546:            private CollectionProxy collectionProxy = null;
0547:
0548:            private CollectionProxy getCollection() {
0549:                if (collectionProxy == null)
0550:                    collectionProxy = CollectionProxy.findCollection(javaProxy);
0551:                return collectionProxy;
0552:            }
0553:
0554:            public int __len__() {
0555:                CollectionProxy proxy = getCollection();
0556:                if (proxy != CollectionProxy.NoProxy) {
0557:                    return proxy.__len__();
0558:                }
0559:
0560:                PyObject ret = invoke("__len__");
0561:                if (ret instanceof  PyInteger)
0562:                    return ((PyInteger) ret).getValue();
0563:                throw Py.TypeError("__len__() should return an int");
0564:            }
0565:
0566:            public PyObject __finditem__(int key) {
0567:                CollectionProxy proxy = getCollection();
0568:                if (proxy != CollectionProxy.NoProxy) {
0569:                    return proxy.__finditem__(key);
0570:                }
0571:                return __finditem__(new PyInteger(key));
0572:            }
0573:
0574:            private PyObject trySlice(PyObject key, String name,
0575:                    PyObject extraArg) {
0576:                if (!(key instanceof  PySlice))
0577:                    return null;
0578:
0579:                PySlice slice = (PySlice) key;
0580:
0581:                if (slice.step != Py.None && slice.step != Py.One) {
0582:                    if (slice.step instanceof  PyInteger) {
0583:                        if (((PyInteger) slice.step).getValue() != 1) {
0584:                            return null;
0585:                        }
0586:                    } else {
0587:                        return null;
0588:                    }
0589:                }
0590:                PyObject func;
0591:                try {
0592:                    func = __findattr__(name);
0593:                } catch (PyException e) {
0594:                    return null;
0595:                }
0596:                if (func == null)
0597:                    return null;
0598:
0599:                PyObject start = slice.start;
0600:                PyObject stop = slice.stop;
0601:
0602:                if (start == Py.None)
0603:                    start = Py.Zero;
0604:                if (stop == Py.None)
0605:                    stop = new PyInteger(PySystemState.maxint);
0606:
0607:                if (extraArg == null) {
0608:                    return func.__call__(start, stop);
0609:                } else {
0610:                    return func.__call__(start, stop, extraArg);
0611:                }
0612:            }
0613:
0614:            public PyObject __finditem__(PyObject key) {
0615:                CollectionProxy proxy = getCollection();
0616:                if (proxy != CollectionProxy.NoProxy) {
0617:                    return proxy.__finditem__(key);
0618:                }
0619:
0620:                try {
0621:                    PyObject ret = trySlice(key, "__getslice__", null);
0622:                    if (ret != null)
0623:                        return ret;
0624:                    return invoke("__getitem__", key);
0625:
0626:                } catch (PyException e) {
0627:                    if (Py.matchException(e, Py.IndexError))
0628:                        return null;
0629:                    throw e;
0630:                }
0631:            }
0632:
0633:            public PyObject __getitem__(PyObject key) {
0634:                CollectionProxy proxy = getCollection();
0635:                if (proxy != CollectionProxy.NoProxy) {
0636:                    PyObject ret = proxy.__finditem__(key);
0637:                    if (ret == null) {
0638:                        throw Py.KeyError(key.toString());
0639:                    }
0640:                    return ret;
0641:                }
0642:                PyObject ret = trySlice(key, "__getslice__", null);
0643:                if (ret != null)
0644:                    return ret;
0645:                return invoke("__getitem__", key);
0646:            }
0647:
0648:            public void __setitem__(PyObject key, PyObject value) {
0649:                CollectionProxy proxy = getCollection();
0650:                if (proxy != CollectionProxy.NoProxy) {
0651:                    proxy.__setitem__(key, value);
0652:                    return;
0653:                }
0654:                if (trySlice(key, "__setslice__", value) != null)
0655:                    return;
0656:
0657:                invoke("__setitem__", key, value);
0658:            }
0659:
0660:            public void __delitem__(PyObject key) {
0661:                CollectionProxy proxy = getCollection();
0662:                if (proxy != CollectionProxy.NoProxy) {
0663:                    proxy.__delitem__(key);
0664:                    return;
0665:                }
0666:                if (trySlice(key, "__delslice__", null) != null)
0667:                    return;
0668:                invoke("__delitem__", key);
0669:            }
0670:
0671:            public PyObject __iter__() {
0672:                PyObject iter = getCollectionIter();
0673:                if (iter != null) {
0674:                    return iter;
0675:                }
0676:                PyObject func = __findattr__("__iter__");
0677:                if (func != null)
0678:                    return func.__call__();
0679:                func = __findattr__("__getitem__");
0680:                if (func == null)
0681:                    return super .__iter__();
0682:                return new PySequenceIter(this );
0683:            }
0684:
0685:            public PyObject __iternext__() {
0686:                PyObject func = __findattr__("next");
0687:                if (func != null) {
0688:                    try {
0689:                        return func.__call__();
0690:                    } catch (PyException exc) {
0691:                        if (Py.matchException(exc, Py.StopIteration))
0692:                            return null;
0693:                        throw exc;
0694:                    }
0695:                }
0696:                throw Py.TypeError("instance has no next() method");
0697:            }
0698:
0699:            private static CollectionIter[] iterFactories = null;
0700:
0701:            private PyObject getCollectionIter() {
0702:                if (iterFactories == null)
0703:                    initializeIterators();
0704:                for (int i = 0; iterFactories[i] != null; i++) {
0705:                    PyObject iter = iterFactories[i].findCollection(javaProxy);
0706:                    if (iter != null)
0707:                        return iter;
0708:                }
0709:                return null;
0710:            }
0711:
0712:            private static synchronized void initializeIterators() {
0713:                if (iterFactories != null)
0714:                    return;
0715:                String factories = "org.python.core.CollectionIter,"
0716:                        + "org.python.core.CollectionIter2,"
0717:                        + Py.getSystemState().registry.getProperty(
0718:                                "python.collections", "");
0719:                int i = 0;
0720:                StringTokenizer st = new StringTokenizer(factories, ",");
0721:                iterFactories = new CollectionIter[st.countTokens() + 1];
0722:                while (st.hasMoreTokens()) {
0723:                    String s = st.nextToken();
0724:                    try {
0725:                        Class factoryClass = Class.forName(s);
0726:                        CollectionIter factory = (CollectionIter) factoryClass
0727:                                .newInstance();
0728:                        iterFactories[i++] = factory;
0729:                    } catch (Throwable t) {
0730:                    }
0731:                }
0732:            }
0733:
0734:            public boolean __contains__(PyObject o) {
0735:                PyObject func = __findattr__("__contains__");
0736:                if (func == null)
0737:                    return super .__contains__(o);
0738:                PyObject ret = func.__call__(o);
0739:                return ret.__nonzero__();
0740:            }
0741:
0742:            //Begin the numeric methods here
0743:            public Object __coerce_ex__(PyObject o) {
0744:                PyObject ret = invoke_ex("__coerce__", o);
0745:                if (ret == null || ret == Py.None)
0746:                    return ret;
0747:                if (!(ret instanceof  PyTuple))
0748:                    throw Py
0749:                            .TypeError("coercion should return None or 2-tuple");
0750:                return ((PyTuple) ret).getArray();
0751:            }
0752:
0753:            // Generated by make_binops.py
0754:
0755:            // Unary ops
0756:
0757:            /**
0758:             * Implements the __hex__ method by looking it up
0759:             * in the instance's dictionary and calling it if it is found.
0760:             **/
0761:            public PyString __hex__() {
0762:                PyObject ret = invoke("__hex__");
0763:                if (ret instanceof  PyString)
0764:                    return (PyString) ret;
0765:                throw Py.TypeError("__hex__() should return a string");
0766:            }
0767:
0768:            /**
0769:             * Implements the __oct__ method by looking it up
0770:             * in the instance's dictionary and calling it if it is found.
0771:             **/
0772:            public PyString __oct__() {
0773:                PyObject ret = invoke("__oct__");
0774:                if (ret instanceof  PyString)
0775:                    return (PyString) ret;
0776:                throw Py.TypeError("__oct__() should return a string");
0777:            }
0778:
0779:            /**
0780:             * Implements the __int__ method by looking it up
0781:             * in the instance's dictionary and calling it if it is found.
0782:             **/
0783:            public PyObject __int__() {
0784:                PyObject ret = invoke("__int__");
0785:                if (ret instanceof  PyInteger)
0786:                    return (PyInteger) ret;
0787:                throw Py.TypeError("__int__() should return a int");
0788:            }
0789:
0790:            /**
0791:             * Implements the __float__ method by looking it up
0792:             * in the instance's dictionary and calling it if it is found.
0793:             **/
0794:            public PyFloat __float__() {
0795:                PyObject ret = invoke("__float__");
0796:                if (ret instanceof  PyFloat)
0797:                    return (PyFloat) ret;
0798:                throw Py.TypeError("__float__() should return a float");
0799:            }
0800:
0801:            /**
0802:             * Implements the __long__ method by looking it up
0803:             * in the instance's dictionary and calling it if it is found.
0804:             **/
0805:            public PyLong __long__() {
0806:                PyObject ret = invoke("__long__");
0807:                if (ret instanceof  PyLong)
0808:                    return (PyLong) ret;
0809:                throw Py.TypeError("__long__() should return a long");
0810:            }
0811:
0812:            /**
0813:             * Implements the __complex__ method by looking it up
0814:             * in the instance's dictionary and calling it if it is found.
0815:             **/
0816:            public PyComplex __complex__() {
0817:                PyObject ret = invoke("__complex__");
0818:                if (ret instanceof  PyComplex)
0819:                    return (PyComplex) ret;
0820:                throw Py.TypeError("__complex__() should return a complex");
0821:            }
0822:
0823:            /**
0824:             * Implements the __pos__ method by looking it up
0825:             * in the instance's dictionary and calling it if it is found.
0826:             **/
0827:            public PyObject __pos__() {
0828:                return invoke("__pos__");
0829:            }
0830:
0831:            /**
0832:             * Implements the __neg__ method by looking it up
0833:             * in the instance's dictionary and calling it if it is found.
0834:             **/
0835:            public PyObject __neg__() {
0836:                return invoke("__neg__");
0837:            }
0838:
0839:            /**
0840:             * Implements the __abs__ method by looking it up
0841:             * in the instance's dictionary and calling it if it is found.
0842:             **/
0843:            public PyObject __abs__() {
0844:                return invoke("__abs__");
0845:            }
0846:
0847:            /**
0848:             * Implements the __invert__ method by looking it up
0849:             * in the instance's dictionary and calling it if it is found.
0850:             **/
0851:            public PyObject __invert__() {
0852:                return invoke("__invert__");
0853:            }
0854:
0855:            // Binary ops
0856:
0857:            /**
0858:             * Implements the __add__ method by looking it up
0859:             * in the instance's dictionary and calling it if it is found.
0860:             **/
0861:            public PyObject __add__(PyObject o) {
0862:                Object ctmp = __coerce_ex__(o);
0863:                if (ctmp == null || ctmp == Py.None)
0864:                    return invoke_ex("__add__", o);
0865:                else {
0866:                    PyObject o1 = ((PyObject[]) ctmp)[0];
0867:                    PyObject o2 = ((PyObject[]) ctmp)[1];
0868:                    if (this  == o1) // Prevent recusion if __coerce__ return self
0869:                        return invoke_ex("__add__", o2);
0870:                    else
0871:                        return o1._add(o2);
0872:                }
0873:            }
0874:
0875:            /**
0876:             * Implements the __radd__ method by looking it up
0877:             * in the instance's dictionary and calling it if it is found.
0878:             **/
0879:            public PyObject __radd__(PyObject o) {
0880:                Object ctmp = __coerce_ex__(o);
0881:                if (ctmp == null || ctmp == Py.None)
0882:                    return invoke_ex("__radd__", o);
0883:                else {
0884:                    PyObject o1 = ((PyObject[]) ctmp)[0];
0885:                    PyObject o2 = ((PyObject[]) ctmp)[1];
0886:                    if (this  == o1) // Prevent recusion if __coerce__ return self
0887:                        return invoke_ex("__radd__", o2);
0888:                    else
0889:                        return o2._add(o1);
0890:                }
0891:            }
0892:
0893:            /**
0894:             * Implements the __iadd__ method by looking it up
0895:             * in the instance's dictionary and calling it if it is found.
0896:             **/
0897:            public PyObject __iadd__(PyObject o) {
0898:                PyObject ret = invoke_ex("__iadd__", o);
0899:                if (ret != null)
0900:                    return ret;
0901:                return super .__iadd__(o);
0902:            }
0903:
0904:            /**
0905:             * Implements the __sub__ method by looking it up
0906:             * in the instance's dictionary and calling it if it is found.
0907:             **/
0908:            public PyObject __sub__(PyObject o) {
0909:                Object ctmp = __coerce_ex__(o);
0910:                if (ctmp == null || ctmp == Py.None)
0911:                    return invoke_ex("__sub__", o);
0912:                else {
0913:                    PyObject o1 = ((PyObject[]) ctmp)[0];
0914:                    PyObject o2 = ((PyObject[]) ctmp)[1];
0915:                    if (this  == o1) // Prevent recusion if __coerce__ return self
0916:                        return invoke_ex("__sub__", o2);
0917:                    else
0918:                        return o1._sub(o2);
0919:                }
0920:            }
0921:
0922:            /**
0923:             * Implements the __rsub__ method by looking it up
0924:             * in the instance's dictionary and calling it if it is found.
0925:             **/
0926:            public PyObject __rsub__(PyObject o) {
0927:                Object ctmp = __coerce_ex__(o);
0928:                if (ctmp == null || ctmp == Py.None)
0929:                    return invoke_ex("__rsub__", o);
0930:                else {
0931:                    PyObject o1 = ((PyObject[]) ctmp)[0];
0932:                    PyObject o2 = ((PyObject[]) ctmp)[1];
0933:                    if (this  == o1) // Prevent recusion if __coerce__ return self
0934:                        return invoke_ex("__rsub__", o2);
0935:                    else
0936:                        return o2._sub(o1);
0937:                }
0938:            }
0939:
0940:            /**
0941:             * Implements the __isub__ method by looking it up
0942:             * in the instance's dictionary and calling it if it is found.
0943:             **/
0944:            public PyObject __isub__(PyObject o) {
0945:                PyObject ret = invoke_ex("__isub__", o);
0946:                if (ret != null)
0947:                    return ret;
0948:                return super .__isub__(o);
0949:            }
0950:
0951:            /**
0952:             * Implements the __mul__ method by looking it up
0953:             * in the instance's dictionary and calling it if it is found.
0954:             **/
0955:            public PyObject __mul__(PyObject o) {
0956:                Object ctmp = __coerce_ex__(o);
0957:                if (ctmp == null || ctmp == Py.None)
0958:                    return invoke_ex("__mul__", o);
0959:                else {
0960:                    PyObject o1 = ((PyObject[]) ctmp)[0];
0961:                    PyObject o2 = ((PyObject[]) ctmp)[1];
0962:                    if (this  == o1) // Prevent recusion if __coerce__ return self
0963:                        return invoke_ex("__mul__", o2);
0964:                    else
0965:                        return o1._mul(o2);
0966:                }
0967:            }
0968:
0969:            /**
0970:             * Implements the __rmul__ method by looking it up
0971:             * in the instance's dictionary and calling it if it is found.
0972:             **/
0973:            public PyObject __rmul__(PyObject o) {
0974:                Object ctmp = __coerce_ex__(o);
0975:                if (ctmp == null || ctmp == Py.None)
0976:                    return invoke_ex("__rmul__", o);
0977:                else {
0978:                    PyObject o1 = ((PyObject[]) ctmp)[0];
0979:                    PyObject o2 = ((PyObject[]) ctmp)[1];
0980:                    if (this  == o1) // Prevent recusion if __coerce__ return self
0981:                        return invoke_ex("__rmul__", o2);
0982:                    else
0983:                        return o2._mul(o1);
0984:                }
0985:            }
0986:
0987:            /**
0988:             * Implements the __imul__ method by looking it up
0989:             * in the instance's dictionary and calling it if it is found.
0990:             **/
0991:            public PyObject __imul__(PyObject o) {
0992:                PyObject ret = invoke_ex("__imul__", o);
0993:                if (ret != null)
0994:                    return ret;
0995:                return super .__imul__(o);
0996:            }
0997:
0998:            /**
0999:             * Implements the __div__ method by looking it up
1000:             * in the instance's dictionary and calling it if it is found.
1001:             **/
1002:            public PyObject __div__(PyObject o) {
1003:                Object ctmp = __coerce_ex__(o);
1004:                if (ctmp == null || ctmp == Py.None)
1005:                    return invoke_ex("__div__", o);
1006:                else {
1007:                    PyObject o1 = ((PyObject[]) ctmp)[0];
1008:                    PyObject o2 = ((PyObject[]) ctmp)[1];
1009:                    if (this  == o1) // Prevent recusion if __coerce__ return self
1010:                        return invoke_ex("__div__", o2);
1011:                    else
1012:                        return o1._div(o2);
1013:                }
1014:            }
1015:
1016:            /**
1017:             * Implements the __rdiv__ method by looking it up
1018:             * in the instance's dictionary and calling it if it is found.
1019:             **/
1020:            public PyObject __rdiv__(PyObject o) {
1021:                Object ctmp = __coerce_ex__(o);
1022:                if (ctmp == null || ctmp == Py.None)
1023:                    return invoke_ex("__rdiv__", o);
1024:                else {
1025:                    PyObject o1 = ((PyObject[]) ctmp)[0];
1026:                    PyObject o2 = ((PyObject[]) ctmp)[1];
1027:                    if (this  == o1) // Prevent recusion if __coerce__ return self
1028:                        return invoke_ex("__rdiv__", o2);
1029:                    else
1030:                        return o2._div(o1);
1031:                }
1032:            }
1033:
1034:            /**
1035:             * Implements the __idiv__ method by looking it up
1036:             * in the instance's dictionary and calling it if it is found.
1037:             **/
1038:            public PyObject __idiv__(PyObject o) {
1039:                PyObject ret = invoke_ex("__idiv__", o);
1040:                if (ret != null)
1041:                    return ret;
1042:                return super .__idiv__(o);
1043:            }
1044:
1045:            /**
1046:             * Implements the __floordiv__ method by looking it up
1047:             * in the instance's dictionary and calling it if it is found.
1048:             **/
1049:            public PyObject __floordiv__(PyObject o) {
1050:                Object ctmp = __coerce_ex__(o);
1051:                if (ctmp == null || ctmp == Py.None)
1052:                    return invoke_ex("__floordiv__", o);
1053:                else {
1054:                    PyObject o1 = ((PyObject[]) ctmp)[0];
1055:                    PyObject o2 = ((PyObject[]) ctmp)[1];
1056:                    if (this  == o1) // Prevent recusion if __coerce__ return self
1057:                        return invoke_ex("__floordiv__", o2);
1058:                    else
1059:                        return o1._floordiv(o2);
1060:                }
1061:            }
1062:
1063:            /**
1064:             * Implements the __rfloordiv__ method by looking it up
1065:             * in the instance's dictionary and calling it if it is found.
1066:             **/
1067:            public PyObject __rfloordiv__(PyObject o) {
1068:                Object ctmp = __coerce_ex__(o);
1069:                if (ctmp == null || ctmp == Py.None)
1070:                    return invoke_ex("__rfloordiv__", o);
1071:                else {
1072:                    PyObject o1 = ((PyObject[]) ctmp)[0];
1073:                    PyObject o2 = ((PyObject[]) ctmp)[1];
1074:                    if (this  == o1) // Prevent recusion if __coerce__ return self
1075:                        return invoke_ex("__rfloordiv__", o2);
1076:                    else
1077:                        return o2._floordiv(o1);
1078:                }
1079:            }
1080:
1081:            /**
1082:             * Implements the __ifloordiv__ method by looking it up
1083:             * in the instance's dictionary and calling it if it is found.
1084:             **/
1085:            public PyObject __ifloordiv__(PyObject o) {
1086:                PyObject ret = invoke_ex("__ifloordiv__", o);
1087:                if (ret != null)
1088:                    return ret;
1089:                return super .__ifloordiv__(o);
1090:            }
1091:
1092:            /**
1093:             * Implements the __truediv__ method by looking it up
1094:             * in the instance's dictionary and calling it if it is found.
1095:             **/
1096:            public PyObject __truediv__(PyObject o) {
1097:                Object ctmp = __coerce_ex__(o);
1098:                if (ctmp == null || ctmp == Py.None)
1099:                    return invoke_ex("__truediv__", o);
1100:                else {
1101:                    PyObject o1 = ((PyObject[]) ctmp)[0];
1102:                    PyObject o2 = ((PyObject[]) ctmp)[1];
1103:                    if (this  == o1) // Prevent recusion if __coerce__ return self
1104:                        return invoke_ex("__truediv__", o2);
1105:                    else
1106:                        return o1._truediv(o2);
1107:                }
1108:            }
1109:
1110:            /**
1111:             * Implements the __rtruediv__ method by looking it up
1112:             * in the instance's dictionary and calling it if it is found.
1113:             **/
1114:            public PyObject __rtruediv__(PyObject o) {
1115:                Object ctmp = __coerce_ex__(o);
1116:                if (ctmp == null || ctmp == Py.None)
1117:                    return invoke_ex("__rtruediv__", o);
1118:                else {
1119:                    PyObject o1 = ((PyObject[]) ctmp)[0];
1120:                    PyObject o2 = ((PyObject[]) ctmp)[1];
1121:                    if (this  == o1) // Prevent recusion if __coerce__ return self
1122:                        return invoke_ex("__rtruediv__", o2);
1123:                    else
1124:                        return o2._truediv(o1);
1125:                }
1126:            }
1127:
1128:            /**
1129:             * Implements the __itruediv__ method by looking it up
1130:             * in the instance's dictionary and calling it if it is found.
1131:             **/
1132:            public PyObject __itruediv__(PyObject o) {
1133:                PyObject ret = invoke_ex("__itruediv__", o);
1134:                if (ret != null)
1135:                    return ret;
1136:                return super .__itruediv__(o);
1137:            }
1138:
1139:            /**
1140:             * Implements the __mod__ method by looking it up
1141:             * in the instance's dictionary and calling it if it is found.
1142:             **/
1143:            public PyObject __mod__(PyObject o) {
1144:                Object ctmp = __coerce_ex__(o);
1145:                if (ctmp == null || ctmp == Py.None)
1146:                    return invoke_ex("__mod__", o);
1147:                else {
1148:                    PyObject o1 = ((PyObject[]) ctmp)[0];
1149:                    PyObject o2 = ((PyObject[]) ctmp)[1];
1150:                    if (this  == o1) // Prevent recusion if __coerce__ return self
1151:                        return invoke_ex("__mod__", o2);
1152:                    else
1153:                        return o1._mod(o2);
1154:                }
1155:            }
1156:
1157:            /**
1158:             * Implements the __rmod__ method by looking it up
1159:             * in the instance's dictionary and calling it if it is found.
1160:             **/
1161:            public PyObject __rmod__(PyObject o) {
1162:                Object ctmp = __coerce_ex__(o);
1163:                if (ctmp == null || ctmp == Py.None)
1164:                    return invoke_ex("__rmod__", o);
1165:                else {
1166:                    PyObject o1 = ((PyObject[]) ctmp)[0];
1167:                    PyObject o2 = ((PyObject[]) ctmp)[1];
1168:                    if (this  == o1) // Prevent recusion if __coerce__ return self
1169:                        return invoke_ex("__rmod__", o2);
1170:                    else
1171:                        return o2._mod(o1);
1172:                }
1173:            }
1174:
1175:            /**
1176:             * Implements the __imod__ method by looking it up
1177:             * in the instance's dictionary and calling it if it is found.
1178:             **/
1179:            public PyObject __imod__(PyObject o) {
1180:                PyObject ret = invoke_ex("__imod__", o);
1181:                if (ret != null)
1182:                    return ret;
1183:                return super .__imod__(o);
1184:            }
1185:
1186:            /**
1187:             * Implements the __divmod__ method by looking it up
1188:             * in the instance's dictionary and calling it if it is found.
1189:             **/
1190:            public PyObject __divmod__(PyObject o) {
1191:                Object ctmp = __coerce_ex__(o);
1192:                if (ctmp == null || ctmp == Py.None)
1193:                    return invoke_ex("__divmod__", o);
1194:                else {
1195:                    PyObject o1 = ((PyObject[]) ctmp)[0];
1196:                    PyObject o2 = ((PyObject[]) ctmp)[1];
1197:                    if (this  == o1) // Prevent recusion if __coerce__ return self
1198:                        return invoke_ex("__divmod__", o2);
1199:                    else
1200:                        return o1._divmod(o2);
1201:                }
1202:            }
1203:
1204:            /**
1205:             * Implements the __rdivmod__ method by looking it up
1206:             * in the instance's dictionary and calling it if it is found.
1207:             **/
1208:            public PyObject __rdivmod__(PyObject o) {
1209:                Object ctmp = __coerce_ex__(o);
1210:                if (ctmp == null || ctmp == Py.None)
1211:                    return invoke_ex("__rdivmod__", o);
1212:                else {
1213:                    PyObject o1 = ((PyObject[]) ctmp)[0];
1214:                    PyObject o2 = ((PyObject[]) ctmp)[1];
1215:                    if (this  == o1) // Prevent recusion if __coerce__ return self
1216:                        return invoke_ex("__rdivmod__", o2);
1217:                    else
1218:                        return o2._divmod(o1);
1219:                }
1220:            }
1221:
1222:            /**
1223:             * Implements the __pow__ method by looking it up
1224:             * in the instance's dictionary and calling it if it is found.
1225:             **/
1226:            public PyObject __pow__(PyObject o) {
1227:                Object ctmp = __coerce_ex__(o);
1228:                if (ctmp == null || ctmp == Py.None)
1229:                    return invoke_ex("__pow__", o);
1230:                else {
1231:                    PyObject o1 = ((PyObject[]) ctmp)[0];
1232:                    PyObject o2 = ((PyObject[]) ctmp)[1];
1233:                    if (this  == o1) // Prevent recusion if __coerce__ return self
1234:                        return invoke_ex("__pow__", o2);
1235:                    else
1236:                        return o1._pow(o2);
1237:                }
1238:            }
1239:
1240:            /**
1241:             * Implements the __rpow__ method by looking it up
1242:             * in the instance's dictionary and calling it if it is found.
1243:             **/
1244:            public PyObject __rpow__(PyObject o) {
1245:                Object ctmp = __coerce_ex__(o);
1246:                if (ctmp == null || ctmp == Py.None)
1247:                    return invoke_ex("__rpow__", o);
1248:                else {
1249:                    PyObject o1 = ((PyObject[]) ctmp)[0];
1250:                    PyObject o2 = ((PyObject[]) ctmp)[1];
1251:                    if (this  == o1) // Prevent recusion if __coerce__ return self
1252:                        return invoke_ex("__rpow__", o2);
1253:                    else
1254:                        return o2._pow(o1);
1255:                }
1256:            }
1257:
1258:            /**
1259:             * Implements the __ipow__ method by looking it up
1260:             * in the instance's dictionary and calling it if it is found.
1261:             **/
1262:            public PyObject __ipow__(PyObject o) {
1263:                PyObject ret = invoke_ex("__ipow__", o);
1264:                if (ret != null)
1265:                    return ret;
1266:                return super .__ipow__(o);
1267:            }
1268:
1269:            /**
1270:             * Implements the __lshift__ method by looking it up
1271:             * in the instance's dictionary and calling it if it is found.
1272:             **/
1273:            public PyObject __lshift__(PyObject o) {
1274:                Object ctmp = __coerce_ex__(o);
1275:                if (ctmp == null || ctmp == Py.None)
1276:                    return invoke_ex("__lshift__", o);
1277:                else {
1278:                    PyObject o1 = ((PyObject[]) ctmp)[0];
1279:                    PyObject o2 = ((PyObject[]) ctmp)[1];
1280:                    if (this  == o1) // Prevent recusion if __coerce__ return self
1281:                        return invoke_ex("__lshift__", o2);
1282:                    else
1283:                        return o1._lshift(o2);
1284:                }
1285:            }
1286:
1287:            /**
1288:             * Implements the __rlshift__ method by looking it up
1289:             * in the instance's dictionary and calling it if it is found.
1290:             **/
1291:            public PyObject __rlshift__(PyObject o) {
1292:                Object ctmp = __coerce_ex__(o);
1293:                if (ctmp == null || ctmp == Py.None)
1294:                    return invoke_ex("__rlshift__", o);
1295:                else {
1296:                    PyObject o1 = ((PyObject[]) ctmp)[0];
1297:                    PyObject o2 = ((PyObject[]) ctmp)[1];
1298:                    if (this  == o1) // Prevent recusion if __coerce__ return self
1299:                        return invoke_ex("__rlshift__", o2);
1300:                    else
1301:                        return o2._lshift(o1);
1302:                }
1303:            }
1304:
1305:            /**
1306:             * Implements the __ilshift__ method by looking it up
1307:             * in the instance's dictionary and calling it if it is found.
1308:             **/
1309:            public PyObject __ilshift__(PyObject o) {
1310:                PyObject ret = invoke_ex("__ilshift__", o);
1311:                if (ret != null)
1312:                    return ret;
1313:                return super .__ilshift__(o);
1314:            }
1315:
1316:            /**
1317:             * Implements the __rshift__ method by looking it up
1318:             * in the instance's dictionary and calling it if it is found.
1319:             **/
1320:            public PyObject __rshift__(PyObject o) {
1321:                Object ctmp = __coerce_ex__(o);
1322:                if (ctmp == null || ctmp == Py.None)
1323:                    return invoke_ex("__rshift__", o);
1324:                else {
1325:                    PyObject o1 = ((PyObject[]) ctmp)[0];
1326:                    PyObject o2 = ((PyObject[]) ctmp)[1];
1327:                    if (this  == o1) // Prevent recusion if __coerce__ return self
1328:                        return invoke_ex("__rshift__", o2);
1329:                    else
1330:                        return o1._rshift(o2);
1331:                }
1332:            }
1333:
1334:            /**
1335:             * Implements the __rrshift__ method by looking it up
1336:             * in the instance's dictionary and calling it if it is found.
1337:             **/
1338:            public PyObject __rrshift__(PyObject o) {
1339:                Object ctmp = __coerce_ex__(o);
1340:                if (ctmp == null || ctmp == Py.None)
1341:                    return invoke_ex("__rrshift__", o);
1342:                else {
1343:                    PyObject o1 = ((PyObject[]) ctmp)[0];
1344:                    PyObject o2 = ((PyObject[]) ctmp)[1];
1345:                    if (this  == o1) // Prevent recusion if __coerce__ return self
1346:                        return invoke_ex("__rrshift__", o2);
1347:                    else
1348:                        return o2._rshift(o1);
1349:                }
1350:            }
1351:
1352:            /**
1353:             * Implements the __irshift__ method by looking it up
1354:             * in the instance's dictionary and calling it if it is found.
1355:             **/
1356:            public PyObject __irshift__(PyObject o) {
1357:                PyObject ret = invoke_ex("__irshift__", o);
1358:                if (ret != null)
1359:                    return ret;
1360:                return super .__irshift__(o);
1361:            }
1362:
1363:            /**
1364:             * Implements the __and__ method by looking it up
1365:             * in the instance's dictionary and calling it if it is found.
1366:             **/
1367:            public PyObject __and__(PyObject o) {
1368:                Object ctmp = __coerce_ex__(o);
1369:                if (ctmp == null || ctmp == Py.None)
1370:                    return invoke_ex("__and__", o);
1371:                else {
1372:                    PyObject o1 = ((PyObject[]) ctmp)[0];
1373:                    PyObject o2 = ((PyObject[]) ctmp)[1];
1374:                    if (this  == o1) // Prevent recusion if __coerce__ return self
1375:                        return invoke_ex("__and__", o2);
1376:                    else
1377:                        return o1._and(o2);
1378:                }
1379:            }
1380:
1381:            /**
1382:             * Implements the __rand__ method by looking it up
1383:             * in the instance's dictionary and calling it if it is found.
1384:             **/
1385:            public PyObject __rand__(PyObject o) {
1386:                Object ctmp = __coerce_ex__(o);
1387:                if (ctmp == null || ctmp == Py.None)
1388:                    return invoke_ex("__rand__", o);
1389:                else {
1390:                    PyObject o1 = ((PyObject[]) ctmp)[0];
1391:                    PyObject o2 = ((PyObject[]) ctmp)[1];
1392:                    if (this  == o1) // Prevent recusion if __coerce__ return self
1393:                        return invoke_ex("__rand__", o2);
1394:                    else
1395:                        return o2._and(o1);
1396:                }
1397:            }
1398:
1399:            /**
1400:             * Implements the __iand__ method by looking it up
1401:             * in the instance's dictionary and calling it if it is found.
1402:             **/
1403:            public PyObject __iand__(PyObject o) {
1404:                PyObject ret = invoke_ex("__iand__", o);
1405:                if (ret != null)
1406:                    return ret;
1407:                return super .__iand__(o);
1408:            }
1409:
1410:            /**
1411:             * Implements the __or__ method by looking it up
1412:             * in the instance's dictionary and calling it if it is found.
1413:             **/
1414:            public PyObject __or__(PyObject o) {
1415:                Object ctmp = __coerce_ex__(o);
1416:                if (ctmp == null || ctmp == Py.None)
1417:                    return invoke_ex("__or__", o);
1418:                else {
1419:                    PyObject o1 = ((PyObject[]) ctmp)[0];
1420:                    PyObject o2 = ((PyObject[]) ctmp)[1];
1421:                    if (this  == o1) // Prevent recusion if __coerce__ return self
1422:                        return invoke_ex("__or__", o2);
1423:                    else
1424:                        return o1._or(o2);
1425:                }
1426:            }
1427:
1428:            /**
1429:             * Implements the __ror__ method by looking it up
1430:             * in the instance's dictionary and calling it if it is found.
1431:             **/
1432:            public PyObject __ror__(PyObject o) {
1433:                Object ctmp = __coerce_ex__(o);
1434:                if (ctmp == null || ctmp == Py.None)
1435:                    return invoke_ex("__ror__", o);
1436:                else {
1437:                    PyObject o1 = ((PyObject[]) ctmp)[0];
1438:                    PyObject o2 = ((PyObject[]) ctmp)[1];
1439:                    if (this  == o1) // Prevent recusion if __coerce__ return self
1440:                        return invoke_ex("__ror__", o2);
1441:                    else
1442:                        return o2._or(o1);
1443:                }
1444:            }
1445:
1446:            /**
1447:             * Implements the __ior__ method by looking it up
1448:             * in the instance's dictionary and calling it if it is found.
1449:             **/
1450:            public PyObject __ior__(PyObject o) {
1451:                PyObject ret = invoke_ex("__ior__", o);
1452:                if (ret != null)
1453:                    return ret;
1454:                return super .__ior__(o);
1455:            }
1456:
1457:            /**
1458:             * Implements the __xor__ method by looking it up
1459:             * in the instance's dictionary and calling it if it is found.
1460:             **/
1461:            public PyObject __xor__(PyObject o) {
1462:                Object ctmp = __coerce_ex__(o);
1463:                if (ctmp == null || ctmp == Py.None)
1464:                    return invoke_ex("__xor__", o);
1465:                else {
1466:                    PyObject o1 = ((PyObject[]) ctmp)[0];
1467:                    PyObject o2 = ((PyObject[]) ctmp)[1];
1468:                    if (this  == o1) // Prevent recusion if __coerce__ return self
1469:                        return invoke_ex("__xor__", o2);
1470:                    else
1471:                        return o1._xor(o2);
1472:                }
1473:            }
1474:
1475:            /**
1476:             * Implements the __rxor__ method by looking it up
1477:             * in the instance's dictionary and calling it if it is found.
1478:             **/
1479:            public PyObject __rxor__(PyObject o) {
1480:                Object ctmp = __coerce_ex__(o);
1481:                if (ctmp == null || ctmp == Py.None)
1482:                    return invoke_ex("__rxor__", o);
1483:                else {
1484:                    PyObject o1 = ((PyObject[]) ctmp)[0];
1485:                    PyObject o2 = ((PyObject[]) ctmp)[1];
1486:                    if (this  == o1) // Prevent recusion if __coerce__ return self
1487:                        return invoke_ex("__rxor__", o2);
1488:                    else
1489:                        return o2._xor(o1);
1490:                }
1491:            }
1492:
1493:            /**
1494:             * Implements the __ixor__ method by looking it up
1495:             * in the instance's dictionary and calling it if it is found.
1496:             **/
1497:            public PyObject __ixor__(PyObject o) {
1498:                PyObject ret = invoke_ex("__ixor__", o);
1499:                if (ret != null)
1500:                    return ret;
1501:                return super.__ixor__(o);
1502:            }
1503:
1504:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.