Package org.syrup.helpers

Examples of org.syrup.helpers.ResultImpl


     */
    public Result execute(Context context)
    {
        try
        {
            ResultImpl im = null;

            if (Utils.isFull(context.in_1_link()))
            {
                ResultImpl r = new ResultImpl(context, true, true, null, context.in_1_link().content());

                // [TODO: optimize by prefabricating the NetworkImpl]
                NetworkImpl network = new NetworkParser().parse(replaceWorkflow.getBytes());
                // Returns the Workflow.
                return new WorkflowImpl(r, network);
            }
            else
            {
                throw new Exception("first input needs to be full");
            }
        }
        catch (Throwable e1)
        {
            return new ResultImpl(context, true, true, null, org.syrup.helpers.Utils.manageError(logger, e1, "Concat error"));
        }
    }
View Full Code Here


                }

                /*
                 * Return the first input to indicate that the alarm is raised.
                 */
                return new ResultImpl(context, true, true, context.in_1_link().content(), null);
            }
            else
            {
                throw new Exception("in-1 is mandatory");
            }
        }
        catch (Throwable e1)
        {
            return new ResultImpl(context, true, true, null, org.syrup.helpers.Utils.manageError(logger, e1, "Alarm error"));
        }
    }
View Full Code Here

                }

                if (error.size() > 0
                    && output.size() == 0)
                {
                    return new ResultImpl(context, consume_command, true, null, new DataImpl(error.toByteArray()));
                }
                else
                {
                    if (error.size() > 0)
                    {
                        return new ResultImpl(context, consume_command, true, new DataImpl(output.toByteArray()), new DataImpl(error.toByteArray()));
                    }
                    else
                    {
                        /*
                         * This indicates stdout without stderr.
                         */
                        if (output.size() > 0)
                        {
                            return new ResultImpl(context, consume_command, true, new DataImpl(output.toByteArray()), null);
                        }
                        else
                        {
                            return new ResultImpl(context, consume_command, true, null, null);
                        }
                    }
                }
            }
            else
            {
                throw new Exception("first input is mandatory");
            }
        }
        catch (Throwable e1)
        {
            return new ResultImpl(context, true, true, null, org.syrup.helpers.Utils.manageError(logger, e1, "BShell error"));
        }
        finally
        {
            Runtime.getRuntime().removeShutdownHook(this);
        }
View Full Code Here

            if (Utils.isFull(context.in_1_link())
                && Utils.isFull(context.in_2_link()))
            {
                out = context.in_1_link().content();

                return new ResultImpl(context, true, false, out, out);
            }
            else
            {
                if (Utils.isFull(context.in_2_link()))
                {
                    out = context.in_2_link().content();
                }
                else
                {
                    out = context.in_1_link().content();
                }
            }

            return new ResultImpl(context, true, true, out, out);
        }
        catch (Throwable e1)
        {
            // Something is *very* wrong.

            return new ResultImpl(context, true, true, null, org.syrup.helpers.Utils.manageError(logger, e1, "Concat error"));
        }
    }
View Full Code Here

            if (Utils.isFull(context.in_1_link()))
            {
                Data d = context.in_1_link().content();
                // Parses first input.
                NetworkImpl i = new NetworkParser().parse(d.bytes());
                ResultImpl r = new ResultImpl(context, true, false, null, null);
                // Returns the Workflow.
                WorkflowImpl impl =  new WorkflowImpl(r, i);
                Utils.validate(impl);
                return impl;
            }
            else
            {
                throw new Exception("first input is mandatory");
            }
        }
        catch (Throwable e)
        {
            return new ResultImpl(context, true, true, null, org.syrup.helpers.Utils.manageError(logger, e, "Launch error"));
        }
    }
View Full Code Here

        }
        if (Utils.isFull(context.in_2_link()))
        {
            out2 = context.in_2_link().content();
        }
        return new ResultImpl(context, true, true, out1, out2);
    }
View Full Code Here

                if (d.equals("0"))
                {
                    result = _1;
                }

                return new ResultImpl(context, true, true, result, null);
            }
            else
            {
                throw new Exception("in-1 is mandatory");
            }
        }
        catch (Throwable e)
        {
            // Not a number?
            return new ResultImpl(context, true, true, null, org.syrup.helpers.Utils.manageError(logger, e, "Flip error"));
        }
    }
View Full Code Here

     */
    public Result execute(Context context)
    {
        try
        {
            ResultImpl im = null;

            if (Utils.isFull(context.in_1_link()))
            {
                String content = new String(context.in_1_link().content().bytes());
                // [TODO: make this a parameter taken from the second input]
                String split = "\n";

                int i = content.indexOf(split);
                int t = content.length()
                    - i - split.length();

                if (i > 0)
                {
                    String head = content.substring(0, i);
                    String tail = content.substring(i
                        + split.length(), content.length());

                    if (tail.length() > 0)
                    {
                        return new ResultImpl(context, true, true, new DataImpl(head.getBytes()), new DataImpl(tail.getBytes()));
                    }
                    else
                    {
                        // [TODO: optimize by prefabricating the NetworkImpl]
                        NetworkImpl network = new NetworkParser().parse(replaceWorkflow.getBytes());
                        // Returns the Workflow.
                        return new WorkflowImpl(new ResultImpl(context, true, true, new DataImpl(head.getBytes()), null), network);
                    }
                }
                else
                {
                    // [TODO: optimize by prefabricating the NetworkImpl]
                    NetworkImpl network = new NetworkParser().parse(replaceWorkflow.getBytes());
                    // Returns the Workflow.
                    return new WorkflowImpl(new ResultImpl(context, true, true, context.in_1_link().content(), null), network);
                }
            }
            else
            {
                throw new Exception("first input needs to be full");
            }
        }
        catch (Throwable e1)
        {
            return new ResultImpl(context, true, true, null, org.syrup.helpers.Utils.manageError(logger, e1, "Concat error"));
        }
    }
View Full Code Here

                    + i2.length];

                System.arraycopy(i1, 0, cc, 0, i1.length);
                System.arraycopy(i2, 0, cc, i1.length, i2.length);

                return new ResultImpl(context, true, true, new DataImpl(cc), null);
            }
            else
            {
                throw new Exception("both inputs need to be full");
            }
        }
        catch (Throwable e1)
        {
            return new ResultImpl(context, true, true, null, org.syrup.helpers.Utils.manageError(logger, e1, "Concat error"));
        }
    }
View Full Code Here

                    && output.size() == 0)
                {
                    /*
                     * This problably indicates an error.
                     */
                    return new ResultImpl(context, consume_command, true, null, new DataImpl(error.toByteArray()));
                }
                else
                {
                    if (error.size() > 0)
                    {
                        /*
                         * This indicates stdout + stderr Not clear how to
                         * handle this if it does indicate a real problem.
                         */
                        return new ResultImpl(context, consume_command, true, new DataImpl(output.toByteArray()), new DataImpl(error.toByteArray()));
                    }
                    else
                    {
                        /*
                         * This indicates stdout without stderr.
                         */
                        if (output.size() > 0)
                        {
                            return new ResultImpl(context, consume_command, true, new DataImpl(output.toByteArray()), null);
                        }
                        else
                        {
                            return new ResultImpl(context, consume_command, true, null, null);
                        }
                    }
                }
            }
            else
            {
                throw new Exception("first input is mandatory");
            }
        }
        catch (Throwable e1)
        {
            return new ResultImpl(context, true, true, null, org.syrup.helpers.Utils.manageError(logger, e1, "Shell error"));
        }
        finally
        {
            // Remove shutdown hook after execution.
            Runtime.getRuntime().removeShutdownHook(this);
View Full Code Here

TOP

Related Classes of org.syrup.helpers.ResultImpl

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.