Package org.jruby

Examples of org.jruby.RubyClass.callMethod()


        RubyClass klazz = runtime.fastGetClass("DateTime");

        IRubyObject rbOffset = runtime.getKernel().callMethod("Rational",
                runtime.newFixnum(zoneOffset), runtime.newFixnum(86400));

        return klazz.callMethod(runtime.getCurrentContext(), "civil",
                new IRubyObject[] { runtime.newFixnum(stamp.getYear()),
                        runtime.newFixnum(stamp.getMonthOfYear()),
                        runtime.newFixnum(stamp.getDayOfMonth()),
                        runtime.newFixnum(stamp.getHourOfDay()),
                        runtime.newFixnum(stamp.getMinuteOfHour()),
View Full Code Here


     */
    public static IRubyObject prepareRubyDateFromSqlDate(Ruby runtime, java.util.Date date) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        RubyClass klazz = runtime.fastGetClass("Date");
        return klazz.callMethod(runtime.getCurrentContext(), "civil",
                new IRubyObject[] { runtime.newFixnum(c.get(Calendar.YEAR)),
                        runtime.newFixnum(c.get(Calendar.MONTH) + 1),
                        runtime.newFixnum(c.get(Calendar.DAY_OF_MONTH)) });
    }

View Full Code Here

        return new X509AuxCertificate(cert);
    }

    public static IRubyObject wrap(Ruby runtime, Certificate c) throws CertificateEncodingException {
        RubyClass cr = Utils.getClassFromPath(runtime, "OpenSSL::X509::Certificate");
        return cr.callMethod(runtime.getCurrentContext(), "new", RubyString.newString(runtime, c.getEncoded()));
    }

    // this is the javax.security counterpart of the previous wrap method
    public static IRubyObject wrap(Ruby runtime, javax.security.cert.Certificate c) throws javax.security.cert.CertificateEncodingException {
        RubyClass cr = Utils.getClassFromPath(runtime, "OpenSSL::X509::Certificate");
View Full Code Here

    }

    // this is the javax.security counterpart of the previous wrap method
    public static IRubyObject wrap(Ruby runtime, javax.security.cert.Certificate c) throws javax.security.cert.CertificateEncodingException {
        RubyClass cr = Utils.getClassFromPath(runtime, "OpenSSL::X509::Certificate");
        return cr.callMethod(runtime.getCurrentContext(), "new", RubyString.newString(runtime, c.getEncoded()));
    }

    @JRubyMethod(name="initialize", optional = 1, frame=true)
    public IRubyObject initialize(ThreadContext context, IRubyObject[] args, Block unusedBlock) {
        Ruby runtime = context.runtime;
View Full Code Here

        final RubyArray methodNames = (args.length > 0) ? runtime.newArray(args) : null;

        RubyClass implClass = RubyClass.newClass(runtime, runtime.getObject());
        implClass.include(new IRubyObject[] {self});

        IRubyObject implObject = implClass.callMethod(context, "new");

        implClass.addMethod("method_missing",
                new org.jruby.internal.runtime.methods.JavaMethod(implClass, Visibility.PUBLIC) {
                    @Override
                    public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args, Block block) {
View Full Code Here

        ThreadContext tc = asnM.getRuntime().getCurrentContext();
        if(null != v_name) {
            RubyClass c = asnM.getClass(v_name);
            if(v instanceof DERBitString) {
                ByteList bl = new ByteList(((DERBitString)v).getBytes(), false);
                IRubyObject bString = c.callMethod(tc,"new",asnM.getRuntime().newString(bl));
                bString.callMethod(tc,"unused_bits=",asnM.getRuntime().newFixnum(((DERBitString)v).getPadBits()));
                return bString;
            } else if(v instanceof DERString) {
                ByteList val;
                if (v instanceof DERUTF8String) {
View Full Code Here

                if (v instanceof DERUTF8String) {
                    val = new ByteList(((DERUTF8String) v).getString().getBytes("UTF-8"));
                } else {
                    val = ByteList.create(((DERString)v).getString());
                }
                return c.callMethod(tc,"new",asnM.getRuntime().newString(val));
            } else if(v instanceof ASN1Sequence) {
                List<IRubyObject> l = new ArrayList<IRubyObject>();
                for(Enumeration enm = ((ASN1Sequence)v).getObjects(); enm.hasMoreElements(); ) {
                    l.add(decodeObj(asnM,enm.nextElement()));
                }
View Full Code Here

            } else if(v instanceof ASN1Sequence) {
                List<IRubyObject> l = new ArrayList<IRubyObject>();
                for(Enumeration enm = ((ASN1Sequence)v).getObjects(); enm.hasMoreElements(); ) {
                    l.add(decodeObj(asnM,enm.nextElement()));
                }
                return c.callMethod(tc,"new",asnM.getRuntime().newArray(l));
            } else if(v instanceof DERSet) {
                List<IRubyObject> l = new ArrayList<IRubyObject>();
                for(Enumeration enm = ((DERSet)v).getObjects(); enm.hasMoreElements(); ) {
                    l.add(decodeObj(asnM,enm.nextElement()));
                }
View Full Code Here

            } else if(v instanceof DERSet) {
                List<IRubyObject> l = new ArrayList<IRubyObject>();
                for(Enumeration enm = ((DERSet)v).getObjects(); enm.hasMoreElements(); ) {
                    l.add(decodeObj(asnM,enm.nextElement()));
                }
                return c.callMethod(tc,"new",asnM.getRuntime().newArray(l));
            } else if(v instanceof DERNull) {
                return c.callMethod(tc,"new",asnM.getRuntime().getNil());
            } else if(v instanceof DERInteger) {
                return c.callMethod(tc, "new", BN.newBN(asnM.getRuntime(), ((DERInteger) v).getValue()));
            } else if(v instanceof DERUTCTime) {
View Full Code Here

                for(Enumeration enm = ((DERSet)v).getObjects(); enm.hasMoreElements(); ) {
                    l.add(decodeObj(asnM,enm.nextElement()));
                }
                return c.callMethod(tc,"new",asnM.getRuntime().newArray(l));
            } else if(v instanceof DERNull) {
                return c.callMethod(tc,"new",asnM.getRuntime().getNil());
            } else if(v instanceof DERInteger) {
                return c.callMethod(tc, "new", BN.newBN(asnM.getRuntime(), ((DERInteger) v).getValue()));
            } else if(v instanceof DERUTCTime) {
                Date d = dateF.parse(((DERUTCTime)v).getAdjustedTime());
                Calendar cal = Calendar.getInstance();
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.