Package eu.admire.dispel.parser.v4.builder

Examples of eu.admire.dispel.parser.v4.builder.SequenceStrategy


        case INPUT_DECLARATION:
            return new IOStrategy(this, mExecutionState, Context.INPUT_DECLARATION);
        case OUTPUT_DECLARATION:
            return new IOStrategy(this, mExecutionState, Context.OUTPUT_DECLARATION);
        }
        throw new UnsupportedContextException(Context.TUPLE, context);
    }
View Full Code Here


        case TUPLE:
            return new TupleTypeStrategy(this, mExecutionState);
        case WITH_ASSERTION:
            return new WithAssertionStrategy(this, mExecutionState);
        }
        throw new UnsupportedContextException(Context.TYPE_DEF, context);
    }
View Full Code Here

        switch (context)
        {
        case TUPLE_ELEMENT:
            return new TupleElementStrategy(this);
        }
        throw new UnsupportedContextException(Context.TUPLE, context);
    }
View Full Code Here

        switch (context)
        {
        case TUPLE_ELEMENT:
            return new TypeTupleElementStrategy(this, mExecutionState);
        }
        throw new UnsupportedContextException(Context.TUPLE, context);
    }
View Full Code Here

    }

    public ContextStrategy getStrategy(Context context)
            throws UnsupportedContextException
    {
        throw new UnsupportedContextException(Context.ARRAY, context);
    }
View Full Code Here

        case STYPE_DEF:
            return new STypeDefinitionStrategy(this, mExecutionState);
        case DTYPE_DEF:
            return new DTypeDefinitionStrategy(this, mExecutionState);
        default:
            throw new UnsupportedContextException(Context.GENERIC_PE, context);
        }
    }
View Full Code Here

        case PARAMETER:
            return new ParameterStrategy(this, mExecutionState);
        case GENERIC_PE:
            return new PETypeStrategy(this, mExecutionState);
        }
        throw new UnsupportedContextException(Context.FUNCTION, context);
    }
View Full Code Here

        case TUPLE:
            return new DTypeTupleStrategy(this, mExecutionState);
        case LIST:
            return new DTypeCollectionStrategy(this, mExecutionState);
        }
        throw new UnsupportedContextException(Context.DTYPE, context);
    }
View Full Code Here

    private AdmireRegistry mRegistry;
   
    public void process(String dispel) throws IOException
    {
        DISPELCompiler compiler = new DISPELCompiler();
        DISPELGraphBuilder builder = new DISPELGraphBuilder(
                mRegistry,
                new SimpleDispelOptimiser());
        compiler.setRequestBuilder(builder);
        compiler.addErrorListener(this);
        compiler.parse(dispel);

        Map<String, RegisteredObject> registered = builder.getRegistered();
        Map<String, Variable> variables = builder.getDispelExecutionState().getVariables();
       
        for (Entry<String, RegisteredObject> entry : registered.entrySet())
        {
            LOG.debug("Processing registered object " + entry.getKey());
           
            DispelObject reg = null;
            try
            {
                if (entry.getValue().getObject() instanceof Variable)
                {
                    Variable var = (Variable)entry.getValue().getObject();
                    if (var.getValue() != null)
                    {
                        reg = new DispelObject(entry.getKey(), var.getValue());
                    }
                    else
                    {
                        error(0, 0, new VariableNotInitialisedException(entry.getKey()));
                        return;
                    }
                }
                else
                {
                    reg = new DispelObject(entry.getKey(), entry.getValue());
                }
            }
            catch(IllegalArgumentException e)
            {
              error(0, 0, e);
              return;
            }

            if (reg.getType() == DispelObjectType.PROCESSING_ELEMENT_TYPE)
            {
                ProcessingElementType peType = (ProcessingElementType)entry.getValue().getObject();
                if (peType.getImplementation() != null)
                {
                    LOG.debug("Writing registered composite processing element " + entry.getKey());
                    Graph component = GraphUtilities.getConnectedComponent(
                            peType.getImplementation());
                    String image =
                        convertToImage(component, variables);
                    mRegistered.put(reg.name, image);
                }
                else
                {
                    LOG.debug("Registering processing element type " + entry.getKey());
                    StringBuilder pe = new StringBuilder();
                    pe.append("Type ");
                    pe.append(reg.name);
                    if (peType.getDescriptor().getSuperType() != null
                            && !peType.getDescriptor().getSuperType().isEmpty())
                    {
                        pe.append(" is PE<");
                        pe.append(peType.getDescriptor().getSuperType().iterator().next());
                        pe.append(">;");
                    }
                    else
                    {
                        pe.append(" is PE(<");
                        for (ProcessingElementInputDescriptor input : peType.getDescriptor().getInputs())
                        {
                            pe.append("Connection ");
                            if (input.getIsDataSourceInput())
                            {
                                pe.append("locator ");
                            }
                            pe.append(input.getName());
                            pe.append("; ");
                        }
                        if (!peType.getDescriptor().getInputs().isEmpty())
                        {
                            pe.delete(pe.length()-2, pe.length());
                        }
                        pe.append("> => <");
                        for (ProcessingElementOutputDescriptor output : peType.getDescriptor().getOutputs())
                        {
                            pe.append("Connection ");
                            pe.append(output.getName());
                            pe.append("; ");
                        }
                        if (!peType.getDescriptor().getOutputs().isEmpty())
                        {
                            pe.delete(pe.length()-2, pe.length());
                        }
                        pe.append(">);");
                    }
                    mRegistered.put(reg.name, pe.toString());
                }
            }
            else
            {
                mRegistered.put(reg.getName(), reg.getDispel());
            }
        }
       
        LOG.debug("Writing submitted graphs.");
        for (Graph graph : builder.getSubmittedGraphs())
        {
            String image = convertToImage(graph, variables);
            mSubmitted.add(image);
        }
       
View Full Code Here

   
    @Test
    public void testEmpty() throws Exception
    {
        String function = "Integer A(String a, Real b) {}";
        DISPELGraphBuilder builder = runDISPEL(new StringReader(function));
        String dispel = FunctionToDISPEL.convert(builder.getFunctions().get("A"));
        runDISPEL(new StringReader(dispel));
        TestCase.assertFalse(mHasError);
        System.out.println(dispel);
    }
View Full Code Here

TOP

Related Classes of eu.admire.dispel.parser.v4.builder.SequenceStrategy

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.