Examples of XLString


Examples of org.boris.xlloop.xloper.XLString

            l.add(363.51324173151755);
            l.add(false);
            return l.toXLoper();

        }
        return new XLString("#Unknown Function");
    }
View Full Code Here

Examples of org.boris.xlloop.xloper.XLString

    public static XLoper makeRandom() {
        int choice = (int) (Math.random() * 7);
        switch (choice) {
        case 0:
            return new XLString(makeRandomString());
        case 1:
            return new XLNum(Math.random() * 1000);
        case 2:
            return new XLInt((int) (Math.random() * 1000));
        case 3:
            return new XLBool(Math.random() > 0.5);
        case 4:
            return new XLString(makeRandomString(0));
        case 5:
            return new XLString(makeRandomString(30, true));
        case 6:
            return new XLArray(2, 1);
        default:
            return XLMissing.MISSING;
        }
View Full Code Here

Examples of org.boris.xlloop.xloper.XLString

            l.add(363.51324173151755);
            l.add(false);
            return l.toXLoper();

        } else if (name.equals("MakeRandomString")) {
            return new XLString(makeRandomString((int) ((XLNum) args[0]).num));
        } else if (name.equals("LongRunner")) {
            pause(8000);
            return new XLString("Finally...");
        } else if (name.equals("Pause")) {
            pause((long) ((XLNum) args[0]).num);
            return args[0];
        }
        return new XLString("#Unknown Function");
    }
View Full Code Here

Examples of org.boris.xlloop.xloper.XLString

    public static XLoper makeRandom() {
        int choice = (int) (Math.random() * 7);
        switch (choice) {
        case 0:
            return new XLString(makeRandomString());
        case 1:
            return new XLNum(Math.random() * 1000);
        case 2:
            return new XLInt((int) (Math.random() * 1000));
        case 3:
            return new XLBool(Math.random() > 0.5);
        case 4:
            return new XLString(makeRandomString(0));
        case 5:
            return new XLString(makeRandomString(30, true));
        case 6:
            return new XLArray(2, 1);
        default:
            return XLMissing.MISSING;
        }
View Full Code Here

Examples of org.boris.xlloop.xloper.XLString

        return socket != null && socket.isConnected();
    }

    public XLoper execute(String name, XLoper[] args) throws RequestException, IOException {
        connect();
        protocol.send(socket, new XLString(name));
        protocol.send(socket, new XLInt(args.length));
        for (int i = 0; i < args.length; i++) {
            protocol.send(socket, args[i]);
        }
        return receive();
View Full Code Here

Examples of org.boris.xlloop.xloper.XLString

            int s = is.read(b, r, len - r);
            if (s == -1)
                throw new EOFException();
            r += s;
        }
        return new XLString(new String(b));
    }
View Full Code Here

Examples of org.boris.xlloop.xloper.XLString

        case XLOperType.xltypeNil:
            return XLNil.NIL;
        case XLOperType.xltypeNum:
            return new XLNum(x.num);
        case XLOperType.xltypeStr:
            return new XLString(x.str);
        }
        return null;
    }
View Full Code Here

Examples of org.boris.xlloop.xloper.XLString

    }

    public static void handleRequest(IFunctionHandler handler, IRequestProtocol protocol, Socket socket, Session session) {
        try {
            XLoper nameOrVersion = protocol.receive(socket);
            XLString name = null;
            IFunctionContext context = null;
            if (nameOrVersion.type == XLoper.xlTypeInt) {
                int version = ((XLInt) nameOrVersion).w;
                if (version == 20) {
                    XLBool b = (XLBool) protocol.receive(socket);
                    if (b.bool) {
                        XLoper caller = protocol.receive(socket);
                        XLoper sheetName = protocol.receive(socket);
                        XLSRef cref = null;
                        if (caller instanceof XLSRef)
                            cref = (XLSRef) caller;
                        String namestr = null;
                        if (sheetName instanceof XLString)
                            namestr = ((XLString) sheetName).str;
                        context = new FunctionContext(handler, session, cref, namestr);
                    }
                } else {
                    protocol.send(socket, new XLString("#Unknown protocol version"));
                    socket.close();
                    return;
                }
                name = (XLString) protocol.receive(socket);
            } else {
                name = (XLString) nameOrVersion;
            }
            XLInt argCount = (XLInt) protocol.receive(socket);
            XLoper[] args = new XLoper[argCount.w];
            for (int i = 0; i < argCount.w; i++) {
                args[i] = protocol.receive(socket);
            }
            if (!session.init && name.str.equals(INITIALIZE)) {
                initializeSession(session, args);
            }

            if (session.init && context == null)
                context = new FunctionContext(handler, session, null, null);

            XLoper res = handler.execute(context, name.str, args);
            if (res == null)
                res = XLError.NULL;
            protocol.send(socket, res);
        } catch (RequestException e) {
            try {
                protocol.send(socket, new XLString(e.getMessage()));
            } catch (IOException ex) {
                System.err.println(e.getMessage());
                try {
                    socket.close();
                } catch (IOException iex) {
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.