Beispiel #1
0
  /**
   * Prepare the binding dictionary with the correct datatypes.
   *
   * @param params a non-None list of params
   * @param bindings a dictionary of bindings
   */
  public void normalizeInput(PyObject params, PyObject bindings) throws SQLException {

    if (this.columns == Py.None) {
      return;
    }

    // do nothing with params at the moment
    for (int i = 0, len = this.columns.__len__(), binding = 0; i < len; i++) {
      PyObject column = this.columns.__getitem__(i);
      int colType = column.__getitem__(COLUMN_TYPE).asInt();

      switch (colType) {
        case DatabaseMetaData.procedureColumnIn:
        case DatabaseMetaData.procedureColumnInOut:

          // bindings are Python-indexed
          PyInteger key = Py.newInteger(binding++);

          if (bindings.__finditem__(key) == null) {
            int dataType = column.__getitem__(DATA_TYPE).asInt();
            bindings.__setitem__(key, Py.newInteger(dataType));
          }

          // inputs are JDBC-indexed
          this.inputSet.set(i + 1);
          break;
      }
    }
  }
Beispiel #2
0
 /**
  * Convenience method for constructing a type object of a Python exception, named as given, and
  * added to the namespace of the "_io" module.
  *
  * @param dict module dictionary
  * @param excname name of the exception
  * @param bases one or more bases (superclasses)
  * @return the constructed exception type
  */
 private static PyType makeException(PyObject dict, String excname, PyObject... bases) {
   PyStringMap classDict = new PyStringMap();
   classDict.__setitem__("__module__", Py.newString("_io"));
   PyType type = (PyType) Py.makeClass(excname, bases, classDict);
   dict.__setitem__(excname, type);
   return type;
 }
Beispiel #3
0
  /**
   * Initializes the object's namespace.
   *
   * @param dict
   */
  public static void classDictInit(PyObject dict) {

    dict.__setitem__(
        "__version__",
        Py.newString("$Revision: 5206 $").__getslice__(Py.newInteger(11), Py.newInteger(-2), null));
    dict.__setitem__("bcp", new BCPFunc("bcp", 0, 1, 2, zxJDBC.getString("bcp")));
    dict.__setitem__("batchsize", Py.newString(zxJDBC.getString("batchsize")));
    dict.__setitem__("queuesize", Py.newString(zxJDBC.getString("queuesize")));

    // hide from python
    dict.__setitem__("classDictInit", null);
    dict.__setitem__("toString", null);
    dict.__setitem__("PyClass", null);
    dict.__setitem__("getPyClass", null);
    dict.__setitem__("sourceDH", null);
    dict.__setitem__("destDH", null);
  }
Beispiel #4
0
  public static void classDictInit(PyObject dict) {
    dict.__setitem__("__name__", new PyString("_jythonlib"));
    dict.__setitem__("__doc__", __doc__);
    dict.__setitem__("__module__", new PyString("_jythonlib"));
    dict.__setitem__("dict_builder", dict_builder.TYPE);
    dict.__setitem__("set_builder", set_builder.TYPE);

    // Hide from Python
    dict.__setitem__("classDictInit", null);
  }
Beispiel #5
0
  /**
   * This method is called when the module is loaded, to populate the namespace (dictionary) of the
   * module. The dictionary has been initialised at this point reflectively from the methods of this
   * class and this method nulls those entries that ought not to be exposed.
   *
   * @param dict namespace of the module
   */
  public static void classDictInit(PyObject dict) {
    dict.__setitem__("__name__", new PyString("_io"));
    dict.__setitem__("__doc__", new PyString(__doc__));
    dict.__setitem__("DEFAULT_BUFFER_SIZE", DEFAULT_BUFFER_SIZE);

    dict.__setitem__("_IOBase", PyIOBase.TYPE);
    dict.__setitem__("_RawIOBase", PyRawIOBase.TYPE);
    dict.__setitem__("FileIO", PyFileIO.TYPE);

    // Define UnsupportedOperation exception by constructing the type

    PyObject exceptions = imp.load("exceptions");
    PyObject ValueError = exceptions.__getattr__("ValueError");
    PyObject IOError = exceptions.__getattr__("IOError");
    // Equivalent to class UnsupportedOperation(ValueError, IOError) : pass
    // UnsupportedOperation = makeException(dict, "UnsupportedOperation", ValueError, IOError);
    // XXX Work-around: slots not properly initialised unless IOError comes first
    UnsupportedOperation = makeException(dict, "UnsupportedOperation", IOError, ValueError);

    // Hide from Python
    dict.__setitem__("classDictInit", null);
    dict.__setitem__("makeException", null);
  }
Beispiel #6
0
 public static void classDictInit(PyObject dict) {
   dict.__setitem__("Struct", PyStruct.TYPE);
 }
Beispiel #7
0
 private static PyObject exceptionNamespace() {
   PyObject dict = new PyStringMap();
   dict.__setitem__("__module__", new PyString("struct"));
   return dict;
 }
 /**
  * Set a variable in the local namespace
  *
  * @param name the name of the variable
  * @param value the value to set the variable to
  */
 public void set(String name, PyObject value) {
   locals.__setitem__(name.intern(), value);
 }
 /**
  * Set a variable in the local namespace
  *
  * @param name the name of the variable
  * @param value the value to set the variable to. Will be automatically converted to an
  *     appropriate Python object.
  */
 public void set(String name, Object value) {
   locals.__setitem__(name.intern(), Py.java2py(value));
 }