Examples of PyType


Examples of org.python.core.PyType

  private static String hasSelectedRowsStatement = null;
  private static String importStatement = null;
  public static String getPyObjectValueAsString(PyObject obj) {
    if (obj == null)
      return "";
    PyType type = obj.getType();
    if (type.getName().equals("long"))
      return Long.toString(obj.asLong());
    else if (type.getName().equals("int"))
      return Integer.toString(obj.asInt());
    else if (type.getName().equals("bool"))
      return obj.asInt() != 0 ? "true" : "false";
    return obj.asString();
  }
View Full Code Here

Examples of org.python.core.PyType

  }

  public static boolean getPyObjectValueAsBoolean(PyObject obj) {
    if (obj == null)
      return false;
    PyType type = obj.getType();
    if (type.getName().equals("long"))
      return (obj.asLong() != 0);
    else if (type.getName().equals("int"))
      return (obj.asInt() != 0);
    else if (type.getName().equals("bool"))
      return (obj.asInt() != 0);
    else if (type.getName().equals("NoneType"))
      return false;

    return obj.asString().length() != 0;
  }
View Full Code Here

Examples of org.python.core.PyType

      PyClass userPyClass = (PyClass) valueFromUser;
      return processJythonType(userPyClass.__name__, interpreter);

      // user gave a PyType, process as Jython class
    } else if (valueFromUser instanceof PyType) {
      PyType userPyType = (PyType) valueFromUser;
      return processJythonType(userPyType.getName(), interpreter);

      // Otherwise, don't know how to handle this, so error
    } else {
      throw new IllegalArgumentException("Don't know how to handle " +
          valueFromUser + " of class " + valueFromUser.getClass() +
View Full Code Here

Examples of org.python.core.PyType

        slots = new PyObject[subtype.getNumSlots()];
        dict = subtype.instDict();
    }

    public PyString __str__() {
        PyType self_type = getType();
        PyObject impl = self_type.lookup("__str__");
        if (impl != null) {
            PyObject res = impl.__get__(this, self_type).__call__();
            if (res instanceof PyString)
                return (PyString) res;
            throw Py.TypeError("__str__" + " should return a " + "string");
View Full Code Here

Examples of org.python.core.PyType

        }
        return super.__str__();
    }

    public PyString __repr__() {
        PyType self_type = getType();
        PyObject impl = self_type.lookup("__repr__");
        if (impl != null) {
            PyObject res = impl.__get__(this, self_type).__call__();
            if (res instanceof PyString)
                return (PyString) res;
            throw Py.TypeError("__repr__" + " should return a " + "string");
View Full Code Here

Examples of org.python.core.PyType

        }
        return super.__repr__();
    }

    public PyString __hex__() {
        PyType self_type = getType();
        PyObject impl = self_type.lookup("__hex__");
        if (impl != null) {
            PyObject res = impl.__get__(this, self_type).__call__();
            if (res instanceof PyString)
                return (PyString) res;
            throw Py.TypeError("__hex__" + " should return a " + "string");
View Full Code Here

Examples of org.python.core.PyType

        }
        return super.__hex__();
    }

    public PyString __oct__() {
        PyType self_type = getType();
        PyObject impl = self_type.lookup("__oct__");
        if (impl != null) {
            PyObject res = impl.__get__(this, self_type).__call__();
            if (res instanceof PyString)
                return (PyString) res;
            throw Py.TypeError("__oct__" + " should return a " + "string");
View Full Code Here

Examples of org.python.core.PyType

        }
        return super.__oct__();
    }

    public PyFloat __float__() {
        PyType self_type = getType();
        PyObject impl = self_type.lookup("__float__");
        if (impl != null) {
            PyObject res = impl.__get__(this, self_type).__call__();
            if (res instanceof PyFloat)
                return (PyFloat) res;
            throw Py.TypeError("__float__" + " should return a " + "float");
View Full Code Here

Examples of org.python.core.PyType

        }
        return super.__float__();
    }

    public PyLong __long__() {
        PyType self_type = getType();
        PyObject impl = self_type.lookup("__long__");
        if (impl != null) {
            PyObject res = impl.__get__(this, self_type).__call__();
            if (res instanceof PyLong)
                return (PyLong) res;
            throw Py.TypeError("__long__" + " should return a " + "long");
View Full Code Here

Examples of org.python.core.PyType

        }
        return super.__long__();
    }

    public PyComplex __complex__() {
        PyType self_type = getType();
        PyObject impl = self_type.lookup("__complex__");
        if (impl != null) {
            PyObject res = impl.__get__(this, self_type).__call__();
            if (res instanceof PyComplex)
                return (PyComplex) res;
            throw Py.TypeError("__complex__" + " should return a " + "complex");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.