Examples of toJava()


Examples of jp.ac.kobe_u.cs.prolog.lang.Term.toJava()

    } else { // a1 = nonvar /\ a2 = var
      // (a1 = java \/ a1 = str \/ a1 = clo) /\ a2 = var
      if (a1.isJavaObject() || a1.isStructure() || a1.isClosure()) {
        ((VariableTerm) a2).bind(a1, engine.trail);
      } else { // a1 != java /\ a1 != str /\ a1 != clo /\ a2 = var
        ((VariableTerm) a2).bind(new JavaObjectTerm(a1.toJava()),
            engine.trail);
      }
    }
    return cont;
  }
View Full Code Here

Examples of jp.ac.kobe_u.cs.prolog.lang.VariableTerm.toJava()

    }
    if (!executeGoal(prior_action_probability, args)) {
      throw new IllegalStateException("Failed to call "
          + prior_action_probability);
    }
    return (Double) p.toJava();
  }

  @Override
  public void setChosenNode(INode node) {
   
View Full Code Here

Examples of org.jruby.RubyFixnum.toJava()

        return RubyArray.newArray(document.getRuntime());
    }

    private boolean isErrorIncreased(RubyArray baseErrors, RubyArray createdErrors) {
        RubyFixnum length = ((RubyArray)createdErrors.op_diff(baseErrors)).length();
        int diff_in_length = (Integer)length.toJava(Integer.class);
        return diff_in_length > 0;
    }

    @JRubyMethod(name = {"content", "text", "inner_text"})
    public IRubyObject content(ThreadContext context) {
View Full Code Here

Examples of org.jruby.RubyString.toJava()

        if (value instanceof RubyBoolean) return (Object)((RubyBoolean)value).toJava(Boolean.class);
        if (value instanceof RubyFixnum) return (Object)((RubyFixnum)value).toJava(Long.class);
        if (value instanceof DiametricUUID) return ((DiametricUUID)value).getUUID();
        if (value instanceof RubyBignum) {
            RubyString svalue = (RubyString)((RubyBignum)value).to_s();
            java.math.BigInteger bivalue = new java.math.BigInteger((String)svalue.toJava(String.class));
            return (Object)bivalue;
        }
        if (value instanceof RubyFloat) return (Object)((RubyFloat)value).toJava(Double.class);
        if (value instanceof RubyTime) {
            RubyTime tmvalue = (RubyTime)value;
View Full Code Here

Examples of org.jruby.runtime.builtin.IRubyObject.toJava()

          }
          javaValue = bytes;
          break;
        case ValueMeta.TYPE_BIGNUMBER:
          if (rubyVal instanceof RubyFloat) {
            javaValue = new BigDecimal(((Double) rubyVal.toJava(Double.class)).doubleValue());
          } else {
            javaValue = new BigDecimal(rubyVal.toString());
          }

          break;
View Full Code Here

Examples of org.jruby.runtime.builtin.IRubyObject.toJava()

        }

        public Object next() {
            IRubyObject element = elt(index);
            last = index++;
            return element.toJava(Object.class);
        }

        public void remove() {
            if (last == -1) throw new IllegalStateException();
View Full Code Here

Examples of org.jruby.runtime.builtin.IRubyObject.toJava()

            "return volume, surface_area";
        instance.put("@r", 1.0);
        instance.put("@h", Math.sqrt(3.0));
        EmbedEvalUnit unit = result.parse(script);
        IRubyObject ret = unit.run();
        List<Double> rightCircularCone = (List<Double>) ret.toJava(List.class);
        assertEquals(1.813799, rightCircularCone.get(0), 0.000001);
        assertEquals(9.424778, rightCircularCone.get(1), 0.000001);

        instance.getVarMap().clear();
        instance = null;
View Full Code Here

Examples of org.jruby.runtime.builtin.IRubyObject.toJava()

        Ruby runtime = JavaEmbedUtils.initialize(new ArrayList());
        Node node = runtime.parseEval(script, "<script>", null, 0);
        IRubyObject expRet = runtime.runInterpreter(node);
        result = instance.parse(script);
        IRubyObject ret = result.run();
        assertEquals(expRet.toJava(String.class), ret.toJava(String.class));
        // Maybe bug. This returns RubyNil, but it should be ""
        //assertEquals("", ret.toJava(String.class));

        script = "def say_something()" +
                   "\"はろ〜、わぁ〜るど!\"\n" +
View Full Code Here

Examples of org.jruby.runtime.builtin.IRubyObject.toJava()

                   "\"はろ〜、わぁ〜るど!\"\n" +
                 "end\n" +
                 "say_something";
        expRet = runtime.runInterpreter(runtime.parseEval(script, "<script>", null, 0));
        ret = instance.parse(script).run();
        assertEquals(expRet.toJava(String.class), ret.toJava(String.class));

        //sharing variables
        instance.put("what", "Trick or Treat.");
        script = "\"Did you say, #{what}?\"";
        result = instance.parse(script);
View Full Code Here

Examples of org.jruby.runtime.builtin.IRubyObject.toJava()

        //sharing variables
        instance.put("what", "Trick or Treat.");
        script = "\"Did you say, #{what}?\"";
        result = instance.parse(script);
        ret = result.run();
        assertEquals("Did you say, Trick or Treat.?", ret.toJava(String.class));

        // line number test
        script = "puts \"Hello World!!!\"\nputs \"Have a nice day!";
        StringWriter sw = new StringWriter();
        instance.setErrorWriter(sw);
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.