Package org.jruby.runtime.builtin

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


                sr = runtime.getNil();
                si = m.callMethod(context, "[]", RubyFixnum.one(runtime));
                if (si.isNil()) si = runtime.newString();
                IRubyObject t = m.callMethod(context, "[]", RubyFixnum.two(runtime));
                if (t.isNil()) t = runtime.newString(new ByteList(new byte[]{'1'}));
                si.convertToString().cat(t.convertToString().getByteList());
                re = m.callMethod(context, "post_match");
                po = false;
            }
        }
View Full Code Here


                si = runtime.getNil();
            } else {
                si = m.callMethod(context, "[]", RubyFixnum.three(runtime));
                IRubyObject t = m.callMethod(context, "[]", RubyFixnum.four(runtime));
                if (t.isNil()) t = runtime.newString(new ByteList(new byte[]{'1'}));
                si.convertToString().cat(t.convertToString().getByteList());
            }
            re = m.callMethod(context, "post_match");
            po = false;
        }
View Full Code Here

   
    private static IRubyObject str_to_c_strict(ThreadContext context, IRubyObject recv) {
        RubyArray a = str_to_c_internal(context, recv);
        if (a.eltInternal(0).isNil() || a.eltInternal(1).convertToString().getByteList().length() > 0) {
            IRubyObject s = recv.callMethod(context, "inspect");
            throw context.runtime.newArgumentError("invalid value for convert(): " + s.convertToString());
        }
        return a.eltInternal(0);
    }   
}
View Full Code Here

        int length = RubyNumeric.fix2int(args[0]);
        if (length < 0) throw runtime.newArgumentError("negative length " + length + " given");

        // String/Buffer to read it into
        IRubyObject stringArg = args.length > 1 ? args[1] : runtime.getNil();
        RubyString string = stringArg.isNil() ? RubyString.newEmptyString(runtime) : stringArg.convertToString();
        string.empty();
        string.setTaint(true);
       
        try {
            OpenFile myOpenFile = getOpenFileChecked();
View Full Code Here

     * Queries <code>JSON.create_id</code>. Returns <code>null</code> if it is
     * set to <code>nil</code> or <code>false</code>, and a String if not.
     */
    private RubyString getCreateId(ThreadContext context) {
        IRubyObject v = info.jsonModule.get().callMethod(context, "create_id");
        return v.isTrue() ? v.convertToString() : null;
    }

    /**
     * A string parsing session.
     *
 
View Full Code Here

                } else if(rubyValue instanceof RubyBigDecimal) {
                    return ((RubyBigDecimal)rubyValue).getValue();
        } else if(isRubyProxy(rubyValue)) {
          return rubyValue;
                } else if(type.getReturnedClass() == java.sql.Blob.class) {
                    return new org.hibernate.lob.BlobImpl(rubyValue.convertToString().getBytes());
                } else if(type.getReturnedClass() == java.sql.Clob.class) {
                    return new org.hibernate.lob.ClobImpl(rubyValue.convertToString().toString());
        } else {
          return JavaUtil.convertRubyToJava(rubyValue);
        }
View Full Code Here

        } else if(isRubyProxy(rubyValue)) {
          return rubyValue;
                } else if(type.getReturnedClass() == java.sql.Blob.class) {
                    return new org.hibernate.lob.BlobImpl(rubyValue.convertToString().getBytes());
                } else if(type.getReturnedClass() == java.sql.Clob.class) {
                    return new org.hibernate.lob.ClobImpl(rubyValue.convertToString().toString());
        } else {
          return JavaUtil.convertRubyToJava(rubyValue);
        }
      }
View Full Code Here

     * Queries <code>JSON.create_id</code>. Returns <code>null</code> if it is
     * set to <code>nil</code> or <code>false</code>, and a String if not.
     */
    private RubyString getCreateId(ThreadContext context) {
        IRubyObject v = info.jsonModule.get().callMethod(context, "create_id");
        return v.isTrue() ? v.convertToString() : null;
    }

    /**
     * A string parsing session.
     *
 
View Full Code Here

                        val = pkey.callMethod(tc,"to_der");
                    } else {
                        val = ASN1.decode(getRuntime().getClassFromPath("OpenSSL::ASN1"), pkey.callMethod(tc, "to_der")).callMethod(tc, "value")
                                .callMethod(tc, "[]", getRuntime().newFixnum(1)).callMethod(tc, "value");
                    }
                    byte[] b = getSHA1Digest(getRuntime(), val.convertToString().getBytes());
                    value = new String(ByteList.plain(new DEROctetString(b).getDEREncoded()));
                } else if(valuex.length() == 20 || !isHexString(valuex)) {
                    value = new String(ByteList.plain(new DEROctetString(ByteList.plain(valuex)).getDEREncoded()));
                } else {
                    StringBuffer nstr = new StringBuffer();
View Full Code Here

                        val = pkey.callMethod(tc,"to_der");
                    } else {
                        val = ASN1.decode(getRuntime().getClassFromPath("OpenSSL::ASN1"), pkey.callMethod(tc, "to_der")).callMethod(tc, "value")
                                .callMethod(tc, "[]", getRuntime().newFixnum(1)).callMethod(tc, "value");
                    }
                    byte[] b = getSHA1Digest(getRuntime(), val.convertToString().getBytes());
                    asnv.add(new DEROctetString(b));
                } else if(ourV.startsWith("keyid")) {
                    ourV = ourV.substring("keyid".length());
                    IRubyObject pkey = getInstanceVariable("@issuer_certificate").callMethod(tc,"public_key");
                    IRubyObject val = null;
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.