Thanks Jeff
On Tue, May 13, 2008 at 8:18 PM, Jeff Emanuel <jemanuel@...> wrote:
>
> // You can check the subtype of the PyObject as
> // you do with your other language.
> if (ob instanceof PyString) {
> } if (ob instanceof PyList) {
>
> } else if (ob instanceof PyAndSoOn) {
>
> } else if (ob instanceof PyJavaInstance) {
> // Interpreter returned wrapped java instance
> Object jobject = (Object)ob.__tojava__(Object.class);
> // Now do instanceof checks on jobject.
>
> if (jobject instance Date) {
> } // etc...
>
> }
>
> Heshan Suriyaarachchi wrote:
>
> > Hi,
> > Assume that I am executing following code sample (jython). Is there a
> > way
> > to know which type does the object PyObject belong to? To further
> > clarify
> > what I am asking of , I am inserting some jruby code. So is there a way
> > that
> > I can to something like
> > (ob instanceof _ _ _ _)
> >
> >
> > // Jython code
> > String fileName = "/home/heshan/workspace/Axis2Service
> > ver2/src/mymessagereceiver/filepy.py";
> > interp.execfile(fileName);
> > String s4 = "celciusToFarenheit("+args+")";
> > PyObject ob = interp.eval(s4);
> >
> >
> > // Jruby code
> > IRubyObject obj =
> >
> > runtime.evalScript((scriptreader.readWithMetaData(reader)+FunctionName));
> > String string_result = "";
> > Boolean bool_result = null;
> > Integer int_result = null;
> > Double double_result = null;
> >
> > /* jruby is giving a feature like this , so we can do a instance of
> > operation on our object. Is there a simillar way to do this using
> > jython?
> > Then what is it?*/
> > if (obj instanceof RubyString) {
> > string_result = obj.toString();
> >
> > envelope.getBody().addChild(fac.createOMElement(string_result, null));
> > }
> >
> > if(obj instanceof RubyBoolean){
> > // Logic
> > }
> >
> > if((obj instanceof RubyBigDecimal) | (obj instanceof
> > RubyFloat)){
> > // Logic
> > }
> >
> > if(obj instanceof RubyInteger) {
> > // Logic
> > }
> >
> > if (obj == null) {
> > throw new AxisFault("RubyScriptNoanswer");
> > }
> >
> >
> > ------------------------------------------------------------------------
> >
> >
> > -------------------------------------------------------------------------
> > This SF.net email is sponsored by: Microsoft Defy all challenges.
> > Microsoft(R) Visual Studio 2008.
> > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > Jython-users mailing list
> > Jython-users@...
> > https://lists.sourceforge.net/lists/listinfo/jython-users
> >
> >
>
--
Regards,
Heshan Suriyaarachchi
|