Package org.boris.xlloop.xloper

Examples of org.boris.xlloop.xloper.XLString


    public void add(String name, XLoper value) {
        map.put(name, value);
    }

    public void add(String name, String value) {
        map.put(name, new XLString(value));
    }
View Full Code Here


        int size = map.size() << 1;
        XLoper[] data = new XLoper[size];
        Iterator iter = map.keySet().iterator();
        for (int i = 0; i < size; i += 2) {
            String key = (String) iter.next();
            data[i] = new XLString(key);
            data[i + 1] = (XLoper) map.get(key);
        }
        return new XLArray(data, size >> 1, 2);
    }
View Full Code Here

            XLoper res = handler.execute(null, fr.getName(), fr.getArgs());
            System.out.println(JSONCodec.encode(res).toString(4));
            JSONCodec.encodeXLoper(res, bw);
        } catch (RequestException e) {
            e.printStackTrace();
            XLoper res = new XLString(e.getMessage());
            JSONCodec.encodeXLoper(res, bw);
            bw.flush();
        } finally {
            if (bw != null)
                bw.flush();
View Full Code Here

        case XLoper.xlTypeNil:
            return XLNil.NIL;
        case XLoper.xlTypeNum:
            return new XLNum(jo.getDouble("num"));
        case XLoper.xlTypeStr:
            return new XLString(jo.getString("str"));
        case XLoper.xlTypeSRef:
            return new XLSRef(jo.getInt("colFirst"), jo.getInt("colLast"), jo.getInt("rowFirst"), jo.getInt("rowLast"));
        }

        return null;
View Full Code Here

     *
     * @return XLObject.
     */
    public XLoper createFrom(Object obj) {
        if (obj instanceof String) {
            return new XLString((String) obj);
        } else if (obj instanceof Boolean) {
            return new XLBool(((Boolean) obj).booleanValue());
        } else if (obj instanceof Integer) {
            return new XLNum(((Integer) obj).intValue());
        } else if (obj instanceof Long) {
            return new XLNum(((Long) obj).longValue());
        } else if (obj instanceof Float) {
            return new XLNum(((Float) obj).floatValue());
        } else if (obj instanceof Double) {
            return new XLNum(((Double) obj).doubleValue());
        } else if (obj instanceof String[]) {
            String[] arr = (String[]) obj;
            XLoper[] array = new XLoper[arr.length];
            for (int i = 0; i < arr.length; i++) {
                array[i] = new XLString(arr[i]);
            }

            return new XLArray(array, arr.length, 1);
        } else if (obj instanceof String[][]) {
            String[][] arr = (String[][]) obj;
            if (arr.length == 0 || arr[0] == null)
                return XLError.NA;
            XLArray array = new XLArray(arr.length, arr[0].length);

            for (int i = 0; i < arr.length; i++) {
                for (int j = 0; j < arr[0].length && j < arr[i].length; j++) {
                    array.set(i, j, arr[i][j]);
                }
            }

            return array;
        } else if (obj instanceof double[]) {
            double[] arr = (double[]) obj;
            XLoper[] array = new XLoper[arr.length];

            for (int i = 0; i < arr.length; i++) {
                array[i] = new XLNum(arr[i]);
            }

            return new XLArray(array, array.length, 1);
        } else if (obj instanceof double[][]) {
            double[][] arr = (double[][]) obj;
            if (arr.length == 0 || arr[0] == null)
                return XLError.NA;
            XLArray array = new XLArray(arr.length, arr[0].length);

            for (int i = 0; i < arr.length; i++) {
                for (int j = 0; j < arr[0].length && j < arr[i].length; j++) {
                    array.set(i, j, arr[i][j]);
                }
            }

            return array;
        } else if (obj instanceof Double[]) {
            Double[] arr = (Double[]) obj;
            XLoper[] array = new XLoper[arr.length];

            for (int i = 0; i < arr.length; i++) {
                array[i] = arr[i] == null ? (XLoper) XLNil.NIL : new XLNum(
                        arr[i].doubleValue());
            }

            return new XLArray(array, arr.length, 1);
        } else if (obj instanceof Double[][]) {
            Double[][] arr = (Double[][]) obj;
            if (arr.length == 0 || arr[0] == null)
                return XLError.NA;
            XLArray array = new XLArray(arr.length, arr[0].length);

            for (int i = 0; i < arr.length; i++) {
                for (int j = 0; j < arr[0].length && j < arr[i].length; j++) {
                    array.set(i, j, arr[i][j]);
                }
            }

            return array;
        } else if (obj instanceof int[]) {
            int[] arr = (int[]) obj;
            XLoper[] array = new XLoper[arr.length];

            for (int i = 0; i < arr.length; i++) {
                array[i] = new XLInt(arr[i]);
            }

            return new XLArray(array, arr.length, 1);
        } else if (obj instanceof int[][]) {
            int[][] arr = (int[][]) obj;
            if (arr.length == 0 || arr[0] == null)
                return XLError.NA;
            XLArray array = new XLArray(arr.length, arr[0].length);

            for (int i = 0; i < arr.length; i++) {
                for (int j = 0; j < arr[0].length && j < arr[i].length; j++) {
                    array.set(i, j, arr[i][j]);
                }
            }

            return array;
        } else if (obj instanceof Integer[]) {
            Integer[] arr = (Integer[]) obj;
            XLoper[] array = new XLoper[arr.length];

            for (int i = 0; i < arr.length; i++) {
                array[i] = arr[i] == null ? (XLoper) XLNil.NIL : new XLInt(
                        arr[i].intValue());
            }

            return new XLArray(array, arr.length, 1);
        } else if (obj instanceof Integer[][]) {
            Integer[][] arr = (Integer[][]) obj;
            if (arr.length == 0 || arr[0] == null)
                return XLError.NA;
            XLArray array = new XLArray(arr.length, arr[0].length);

            for (int i = 0; i < arr.length; i++) {
                for (int j = 0; j < arr[0].length && j < arr[i].length; j++) {
                    array.set(i, j, arr[i][j]);
                }
            }

            return array;
        } else if (obj instanceof boolean[]) {
            boolean[] arr = (boolean[]) obj;
            XLoper[] array = new XLoper[arr.length];

            for (int i = 0; i < arr.length; i++) {
                array[i] = new XLBool(arr[i]);
            }

            return new XLArray(array, arr.length, 1);
        } else if (obj instanceof boolean[][]) {
            boolean[][] arr = (boolean[][]) obj;
            if (arr.length == 0 || arr[0] == null)
                return XLError.NA;
            XLArray array = new XLArray(arr.length, arr[0].length);

            for (int i = 0; i < arr.length; i++) {
                for (int j = 0; j < arr[0].length && j < arr[i].length; j++) {
                    array.set(i, j, arr[i][j]);
                }
            }

            return array;
        } else if (obj instanceof Boolean[]) {
            Boolean[] arr = (Boolean[]) obj;
            XLoper[] array = new XLoper[arr.length];

            for (int i = 0; i < arr.length; i++) {
                array[i] = arr[i] == null ? (XLoper) XLNil.NIL : new XLBool(
                        arr[i].booleanValue());
            }

            return new XLArray(array, arr.length, 1);
        } else if (obj instanceof Boolean[][]) {
            Boolean[][] arr = (Boolean[][]) obj;
            if (arr.length == 0 || arr[0] == null)
                return XLError.NA;
            XLArray array = new XLArray(arr.length, arr[0].length);

            for (int i = 0; i < arr.length; i++) {
                for (int j = 0; j < arr[0].length && j < arr[i].length; j++) {
                    array.set(i, j, arr[i][j]);
                }
            }

            return array;
        } else if (obj instanceof Object[][]) {
            Object[][] arr = (Object[][]) obj;
            if (arr.length == 0 || arr[0] == null)
                return XLError.NA;
            XLArray array = new XLArray(arr.length, arr[0].length);

            for (int i = 0; i < arr.length; i++) {
                for (int j = 0; j < arr[0].length && j < arr[i].length; j++) {
                    array.set(i, j, createFrom(arr[i][j]));
                }
            }

            return array;
        } else if (obj instanceof Object[]) {
            Object[] arr = (Object[]) obj;
            XLoper[] array = new XLoper[arr.length];

            for (int i = 0; i < arr.length; i++) {
                array[i] = createFrom(arr[i]);
            }

            return new XLArray(array, arr.length, 1);
        } else if (obj instanceof XLoper) {
            return (XLoper) obj;
        } else if (obj != null) {
            return new XLString(registry.put(obj));
        } else {
            return XLNil.NIL;
        }
    }
View Full Code Here

    public void add(XLoper xl) {
        list.add(xl);
    }

    public void add(String str) {
        list.add(new XLString(str));
    }
View Full Code Here

    public int rows() {
        return maxRow;
    }

    public void set(int row, int column, String value) {
        set(row, column, new XLString(value));
    }
View Full Code Here

            String submenu = null;
            return provider.execute(item, submenu).toXLoper();
        } else if (GET_MENU.equals(name)) {
            return MenuCodec.toXLoper(provider.getMenu());
        }
        return new XLString("#Unknown function: " + name);
    }
View Full Code Here

        }
    }

    private XLoper makeResult(LispValue value) {
        if (value instanceof StandardLispString) {
            return new XLString(((StandardLispString) value).getValue());
        } else if (value instanceof StandardLispInteger) {
            return new XLInt((int) ((StandardLispInteger) value).getValue());
        } else if (value instanceof StandardLispReal) {
            return new XLNum(((StandardLispReal) value).getDoubleValue());
        } else if (value instanceof StandardLispCons) {
            StandardLispCons c = (StandardLispCons) value;
            XLList coll = new XLList();
            for (int i = 0; i < c.basic_length(); i++) {
                coll.add(makeResult(c.elt(i)));
            }
            return coll.toXLoper();
        } else if (value instanceof StandardLispNIL || value == null) {
            return XLNil.NIL;
        } else {
            return new XLString(registry.put(value));
        }
    }
View Full Code Here

import org.boris.xlloop.xloper.XLoper;

public class CommandResult
{
    public XLoper toXLoper() {
        return new XLString("command result testing");
    }
View Full Code Here

TOP

Related Classes of org.boris.xlloop.xloper.XLString

Copyright © 2018 www.massapicom. 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.