Package eu.admire.dispel.parser.types

Examples of eu.admire.dispel.parser.types.Variable


        ConcurrentHashMap<String, Variable> variables =
            new ConcurrentHashMap<String, Variable>(parameterVariables);
        // Add only use processing element types to the variables
        for (String typeName : executionState.getUsedProcessingElements().getTypeNames())
        {
            Variable var = executionState.getVariables().get(typeName);
            if (var != null)
            {
                variables.put(typeName, var);
            }
        }
View Full Code Here


            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;
View Full Code Here

                "Type DataProjector is PE( <Connection:String::\"dispel:URI\" source;\n" +
                "Connection[]:[Integer]::\"data:Vector\" vectors> " +
                "=> <Connection:[<rest>]::\"data:Projection\" projection> ) " +
                "with lockstep(source, vectors);");
        TestCase.assertNull(mGraphBuilder.getError());
        Variable var =
            builder.getDispelExecutionState().getVariables().get("DataProjector");
        TestCase.assertTrue(var.getValue() instanceof ProcessingElementType);
        ProcessingElementType pe = (ProcessingElementType) var.getValue();
        TestCase.assertEquals(1, pe.getAnnotationKeys().size());
        Object annotation = pe.getAnnotation(AnnotationKeys.ASSERTION_EXPRESSIONS);
        TestCase.assertTrue(annotation instanceof List<?>);
        TestCase.assertEquals(1, ((List<?>)annotation).size());
        TestCase.assertTrue(((List<?>)annotation).get(0) instanceof Function);
View Full Code Here

   
    @Override
    public void setProcessingElementType(String text)
        throws UnknownTypeException, TypeMismatchException
    {
        Variable var = mExecutionState.getVariables().get(text);
        if (var == null)
        {
            throw new UnknownTypeException(text);
        }
        if (!(var.getType() instanceof ProcessingElementTypeType))
        {
            throw new TypeMismatchException("ProcessingElementTypeType", var.getValue());
        }
        ProcessingElementTypeType type = (ProcessingElementTypeType)var.getType();
        SimpleProcessingElementDescriptor descriptor = null;
        if (type.getDescriptor() != null)
        {
            descriptor =
                new SimpleProcessingElementDescriptor(
View Full Code Here

                }
            }
            else
            {
                Object value;
                Variable variable =
                    mExecutionState.getVariables().get(connection.mPE);
                if (variable == null)
                {
                    throw new UnresolvedVariableException(connection.mPE);
                }
                value = variable.getValue(connection.mArrayIndices);
                if (value instanceof RequestNode)
                {
                    RequestNode node = (RequestNode)value;
                    mConnection = node.getOutput(connection.mName, connection.mIndex.intValue());
                }
                else
                {
                    throw new TypeMismatchException("ProcessingElement", value);
                }
            }
            break;
        }
        case INPUT:
        {
            ConnectionStrategy connection = (ConnectionStrategy)strategy;
            if (connection.mConnectionVar != null)
            {
                Connection c = (Connection) connection.mConnectionVar.getValue(connection.mArrayIndices);
                if (c == null ||
                        !(c.getSource() instanceof LiteralValuesNode &&
                                mConnection.getSource() instanceof LiteralValuesNode))
                {
                    connection.mConnectionVar.setValue(mConnection, connection.mArrayIndices);
                }
                else
                {
                    LiteralValuesNode literal = (LiteralValuesNode) c.getSource();
                    LiteralValuesNode current = (LiteralValuesNode) mConnection.getSource();
                    literal.add(current.getValues());
                }
            }
            else
            {
                Object value;
                Variable variable =
                    mExecutionState.getVariables().get(connection.mPE);
                if (variable == null)
                {
                    throw new UnresolvedVariableException(connection.mPE);
                }
                value = variable.getValue(connection.mArrayIndices);
                if (value instanceof RequestNode)
                {
                    RequestNode node = (RequestNode)value;
                    if (node.getAllInputs().containsKey(connection.mName))
                    {
View Full Code Here

   
    @Override
    public void setProcessingElementType(String text)
        throws UnknownTypeException, TypeMismatchException
    {
        Variable var = mExecutionState.getVariables().get(text);
        if (var == null)
        {
            throw new UnknownTypeException(text);
        }
        if (!(var.getType() instanceof ProcessingElementTypeType))
        {
            throw new TypeMismatchException(
                    "ProcessingElementTypeType", var.getValue());
        }
        ProcessingElementTypeType type = (ProcessingElementTypeType)var.getType();
        SimpleProcessingElementDescriptor descriptor = null;
        if (type.getDescriptor() != null)
        {
            descriptor =
                new SimpleProcessingElementDescriptor(null, type.getDescriptor(), null);
View Full Code Here

            return (Connection)mConnectionVar.getValue();
        }
        else
        {
            Object value;
            Variable variable = mExecutionState.getVariables().get(mPE);
            if (variable == null)
            {
                throw new UnresolvedVariableException(mPE);
            }
            if (mArrayIndices == null)
            {
                value = variable.getValue();
            }
            else
            {
                value = variable.getValue(mArrayIndices);
            }
            if (value instanceof RequestNode)
            {
                RequestNode node = (RequestNode)value;
                if (mIsInput)
View Full Code Here

    public void testDynamicAnnotation() throws Exception
    {
        DISPELGraphBuilder builder =
            runDISPEL("use a.A; A a = new A; String c = \"x\"; a@b = c; ");
        assertNull(mError);
        Variable var = builder.getDispelExecutionState().getVariables().get("a");
        assertTrue(var.getValue() instanceof ProcessingElementNode);
        assertEquals("x",
                ((ProcessingElementNode)var.getValue()).getAnnotation("b"));
    }
View Full Code Here

            runDISPEL("Stype Time is <Integer year; Integer day; Integer seconds>;\n " +
            "Time time = <year=2010, day=21, seconds=0>; " +
            "Type MyPE is PE(<Connection:Time time> => <>);");
        System.out.println(builder.getDispelExecutionState());
        assertNull(mError);
        Variable time = builder.getDispelExecutionState().getVariables().get("time");
        assertTrue(time.getValue() instanceof Map<?,?>);
        @SuppressWarnings("unchecked")
        Map<String, Object> tuple = (Map<String, Object>)time.getValue();
        assertEquals(Long.valueOf(2010), tuple.get("year"));
        assertEquals(Long.valueOf(21), tuple.get("day"));
        assertEquals(Long.valueOf(0), tuple.get("seconds"));
    }
View Full Code Here

    {
        DISPELGraphBuilder builder =
            runDISPEL("Stype StringList is [String]; " +
                "StringList l = [\"a\", \"b\", \"c\"];");
        assertNull(mError);
        Variable list = builder.getDispelExecutionState().getVariables().get("l");
        assertTrue(list.getValue() instanceof List<?>);
        List<?> l = (List<?>)list.getValue();
        assertEquals(3, l.size());
        assertEquals("a", l.get(0));
        assertEquals("b", l.get(1));
        assertEquals("c", l.get(2));
    }
View Full Code Here

TOP

Related Classes of eu.admire.dispel.parser.types.Variable

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.