Package abstrasy

Examples of abstrasy.Buffer


        this.setOptAccessList(new OptAccessList(DEFAULT_OPTIONS));
    }

    public Node external_encrypt(Node startAt) throws Exception {
        startAt.isGoodArgsCnt(2);
        Buffer src = ((External_Buffer) AExtTools.getArgExternalInstance(startAt, 1, External_Buffer.class, Node.ACCESSVTYPE_MUTABLE_WRITELOCK)).getBuffer();
        Cipher cipher = Cipher.getInstance("Blowfish");
        cipher.init(Cipher.ENCRYPT_MODE, secretKey);
        External_Buffer res = new External_Buffer();
        Buffer bu = new Buffer(cipher.doFinal(src.getArray()));
        res.setBuffer(bu);
        return Node.createExternal(res);
    }
View Full Code Here


        return Node.createExternal(res);
    }

    public Node external_decrypt(Node startAt) throws Exception {
        startAt.isGoodArgsCnt(2);
        Buffer src = ((External_Buffer) AExtTools.getArgExternalInstance(startAt, 1, External_Buffer.class, Node.ACCESSVTYPE_MUTABLE_WRITELOCK)).getBuffer();
        Cipher cipher = Cipher.getInstance("Blowfish");
        cipher.init(Cipher.DECRYPT_MODE, secretKey);
        External_Buffer res = new External_Buffer();
        Buffer bu = new Buffer(cipher.doFinal(src.getArray()));
        res.setBuffer(bu);
        return Node.createExternal(res);
    }
View Full Code Here

        startAt.isGoodArgsCnt(2);
        SELF.require_SELF_mutable();
        if (opened) {
            throw new InterpreterException(StdErrors.extend(StdErrors.Already_used, "File already open"));
        }
        Buffer buffer = ((External_Buffer) AExtTools.getArgExternalInstance(startAt, 1, External_Buffer.class, Node.ACCESSVTYPE_MUTABLE_WRITELOCK)).getBuffer();
        setInputStream(buffer.getInputStream());
        setOutputStream(buffer.getOutputStream());
        this.setOptAccessList(new OptAccessList(this.getDEFAULT_OPTIONS()));
        // pas besoin de placer un hook...
        return null;
    }
View Full Code Here

    }

    public Node external_mutator_read_buffer(Node startAt) throws Exception {
        startAt.isGoodArgsCnt(1, 2);
        SELF.require_SELF_mutable();
        Buffer buffer = new Buffer();
        buffer.setCharset(charset);
        if (startAt.size() == 2) {
            int sz = (int) startAt.getSubNode(1, Node.TYPE_NUMBER).getNumber();
            byte[] buf = new byte[sz];
            int cread = input.read(buf);
            if (cread > 0) {
                buffer.write_bytes(buf, cread);
            }
            else {
                return Node.createNothing();
            }
        }
        else {
            byte[] buf = new byte[4096];
            int cread;
            while ((cread = input.read(buf)) != -1) {
                if (cread > 0) {
                    buffer.write_bytes(buf, cread);
                }
            }
            if (buffer.size() == 0 && cread == -1) {
                return Node.createNothing();
            }
        }
        External_Buffer res = new External_Buffer();
        res.setBuffer(buffer);
View Full Code Here

    }

    public Node external_mutator_read_chunked_buffer(Node startAt) throws Exception {
        startAt.isGoodArgsCnt(1);
        SELF.require_SELF_mutable();
        Buffer buffer = new Buffer();
        buffer.setCharset(charset);
        int sz = 0;
        try {
            sz = read_int();
        }
        catch (EOFException eofe) {
            return Node.createNothing();
        }
        if (sz > 0) {
            byte[] buf = new byte[sz];
            int cread = input.read(buf);
            if (cread > 0) {
                buffer.write_bytes(buf, cread);
            }
            if (buffer.size() == 0 && cread == -1) {
                return Node.createNothing();
            }
        }
        External_Buffer res = new External_Buffer();
        res.setBuffer(buffer);
View Full Code Here

    }

    public Node external_mutator_write_buffer(Node startAt) throws Exception {
        startAt.isGoodArgsCnt(2);
        SELF.require_SELF_mutable();
        Buffer buffer = ((External_Buffer) AExtTools.getArgExternalInstance(startAt, 1, External_Buffer.class, Node.ACCESSVTYPE_MUTABLE_WRITELOCK)).getBuffer();
        if (buffer.length() > 0) {
            byte[] buf = buffer.read_bytes();
            output.write(buf);
            output.flush();
        }
        return null;
    }
View Full Code Here

    }

    public Node external_mutator_write_chunked_buffer(Node startAt) throws Exception {
        startAt.isGoodArgsCnt(2);
        SELF.require_SELF_mutable();
        Buffer buffer = ((External_Buffer) AExtTools.getArgExternalInstance(startAt, 1, External_Buffer.class, Node.ACCESSVTYPE_MUTABLE_WRITELOCK)).getBuffer();
        int len = buffer.length();
        write_int(len);
        if (buffer.length() > 0) {
            byte[] buf = buffer.read_bytes();
            output.write(buf);
        }
        if (isAutoflush())
            output.flush();
        return null;
View Full Code Here

    public Node external_mutator_poke_buffer(Node startAt) throws Exception {
        startAt.isGoodArgsCnt(3);
        SELF.require_SELF_mutable();
        int rel_pos = (int) startAt.getSubNode(1, Node.TYPE_NUMBER).getNumber();
        Buffer data = ((External_Buffer) AExtTools.getArgExternalInstance(startAt, 2, External_Buffer.class, Node.ACCESSVTYPE_MUTABLE_WRITELOCK)).buffer;
        buffer.poke_buffer(rel_pos, data);
        return null;
    }
View Full Code Here

     * @return
     * @throws Exception
     */
    public Node external_split_buffer(Node startAt) throws Exception {
        startAt.isGoodArgsCnt(2);
        Buffer match = ((External_Buffer) AExtTools.getArgExternalInstance(startAt, 1, External_Buffer.class, Node.ACCESSVTYPE_MUTABLE_WRITELOCK)).buffer;
        if (match.length() == 0)
            throw new Exception("sought buffer cannot be empty");
        ArrayList<Buffer> parts = buffer.split_array(match.getArray());
        //System.out.println("parts:"+parts.size());
        Node res = Node.createCList();
        for (int i = 0; i < parts.size(); i++) {
            External_Buffer part = new External_Buffer();
            part.setBuffer(parts.get(i));
View Full Code Here

     * @return
     * @throws Exception
     */
    public Node external_offset_of_buffer(Node startAt) throws Exception {
        startAt.isGoodArgsCnt(2, 3);
        Buffer match = ((External_Buffer) AExtTools.getArgExternalInstance(startAt, 1, External_Buffer.class, Node.ACCESSVTYPE_MUTABLE_WRITELOCK)).buffer;
        int spos = 0;
        if (startAt.size() == 3)
            spos = (int) startAt.getSubNode(1, Node.TYPE_NUMBER).getNumber();
        if (match.length() == 0)
            throw new Exception("sought buffer cannot be empty");
        if (match.length() > buffer.length())
            return new Node(-1);
        return new Node(buffer.find_array(match.getArray(), spos));
    }
View Full Code Here

TOP

Related Classes of abstrasy.Buffer

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.