Examples of VariableStore


Examples of com.nexirius.framework.htmlview.VariableStore

            throw new Exception("Child " + childName + " of " + parser.getModel().getFieldName() + " is not an ArrayModel");
        }

        ArrayModel array = (ArrayModel) child;
        DataModelEnumeration e = array.getEnumeration();
        VariableStore variableStore = parser.getResolver().getVariableStore();
        int index = 0;
        String oldIndex = variableStore.getValueOf(VariableStore.INDEX);
        String oldCount = variableStore.getValueOf(VariableStore.COUNT);
        String template = getTemplate();
        boolean childIsEditor = parser.isEditor();
        Boolean type = getIsEditor();

        if (type != null) {
            childIsEditor = type.booleanValue();
        }

        variableStore.setVariable(VariableStore.COUNT, Integer.toString(array.getSize()));

        while (e.hasMore()) {
            DataModel item = e.next();

            variableStore.setVariable(VariableStore.INDEX, Integer.toString(index + 1));

            byte result[] = parser.getResolver().resolve(sessionVariable, item, template, childIsEditor);

            parser.getOut().write(result);

            ++index;
        }

        variableStore.setVariable(VariableStore.COUNT, oldCount);
        variableStore.setVariable(VariableStore.INDEX, oldIndex);
    }
View Full Code Here

Examples of org.apache.torque.generator.variable.VariableStore

            // Only consider variables visible from the namespace
            // of this outlet. If a name exists in different
            // namespaces visible from this namespace,
            // only consider the most significant name.
            Namespace namespace = getName().getNamespace();
            VariableStore variableStore
                    = controllerState.getVariableStore();
            QualifiedNameMap<Variable> visibleVariables
                    = variableStore
                        .getContent()
                        .getInHierarchy(namespace);
            for (Variable variable : visibleVariables.values())
            {
                QualifiedName qualifiedName = variable.getName();
View Full Code Here

Examples of org.apache.torque.generator.variable.VariableStore

        Variable variable
                = new Variable(
                        qualifiedName,
                        value,
                        scope);
        VariableStore variableStore = controllerState.getVariableStore();
        variableStore.set(variable);
    }
View Full Code Here

Examples of org.apache.torque.generator.variable.VariableStore

     */
    public Object getVariable(String key, ControllerState controllerState)
    {
        QualifiedName qualifiedName
                = controllerState.getQualifiedName(key);
        VariableStore variableStore = controllerState.getVariableStore();
        Variable variable = variableStore.getInHierarchy(qualifiedName);

        Object value = null;
        if (variable != null)
        {
            value = variable.getValue();
View Full Code Here

Examples of org.apache.torque.generator.variable.VariableStore

public class VariableStoreTest extends BaseTest
{
    @Test
    public void testVariableScopePrecedence()
    {
        VariableStore store = new VariableStore();
        store.startOutlet();
        QualifiedName qualifiedName
            = new QualifiedName("org.apache.torque.name");

        // fill store
        store.set(new Variable(
                qualifiedName,
                "org.apache.torque.GENERATOR",
                Variable.Scope.OUTLET));
        store.set(new Variable(
                qualifiedName,
                "org.apache.torque.CHILDREN1",
                Variable.Scope.CHILDREN));
        store.startOutlet();
        store.set(new Variable(
                qualifiedName,
                "org.apache.torque.CHILDREN2",
                Variable.Scope.CHILDREN));
        store.set(new Variable(
                qualifiedName,
                "org.apache.torque.FILE",
                Variable.Scope.FILE));
        store.set(new Variable(
                qualifiedName,
                "org.apache.torque.GLOBAL",
                Variable.Scope.GLOBAL));

        assertEquals(
                "org.apache.torque.GENERATOR",
                store.getInHierarchy(qualifiedName).getValue());
        assertEquals(
                "org.apache.torque.GENERATOR",
                store.getContent().get(qualifiedName).getValue());

        store.remove(store.getInHierarchy(qualifiedName));

        assertEquals(
                "org.apache.torque.CHILDREN2",
                store.getInHierarchy(qualifiedName).getValue());
        assertEquals(
                "org.apache.torque.CHILDREN2",
                store.getContent().get(qualifiedName).getValue());

        store.endOutlet();

        assertEquals(
                "org.apache.torque.CHILDREN1",
                store.getInHierarchy(qualifiedName).getValue());
        assertEquals(
                "org.apache.torque.CHILDREN1",
                store.getContent().get(qualifiedName).getValue());

        store.endOutlet();

        assertEquals(
                "org.apache.torque.FILE",
                store.getInHierarchy(qualifiedName).getValue());
        assertEquals(
                "org.apache.torque.FILE",
                store.getContent().get(qualifiedName).getValue());

        store.endFile();

        assertEquals(
                "org.apache.torque.GLOBAL",
                store.getInHierarchy(qualifiedName).getValue());
        assertEquals(
                "org.apache.torque.GLOBAL",
                store.getContent().get(qualifiedName).getValue());

        store.endGeneration();

        assertNull(store.getInHierarchy(qualifiedName));
        assertNull(store.getContent().get(qualifiedName));
    }
View Full Code Here

Examples of org.apache.torque.generator.variable.VariableStore

        assertNull(store.getContent().get(qualifiedName));
    }

    public void testNamespaceVisibility()
    {
        VariableStore store = new VariableStore();
        store.set(new Variable(
                new QualifiedName("org.apache.torque.name"),
                "org.apache.torque.GENERATOR",
                Variable.Scope.OUTLET));
        store.set(new Variable(
                new QualifiedName("org.apache.name"),
                "org.apache.FILE",
                Variable.Scope.FILE));
        QualifiedName qualifiedName
            = new QualifiedName("org.apache.torque.name");
        assertEquals(
                "org.apache.torque.GENERATOR",
                store.getInHierarchy(qualifiedName).getValue());

        store.clear();
        store.set(new Variable(
                new QualifiedName("org.apache.name"),
                "org.apache.GENERATOR",
                Variable.Scope.OUTLET));
        store.set(new Variable(
                new QualifiedName("org.apache.torque.name"),
                "org.apache.torque.FILE",
                Variable.Scope.FILE));
        assertEquals(
                "org.apache.torque.FILE",
                store.getInHierarchy(qualifiedName).getValue());

    }
View Full Code Here

Examples of org.apache.torque.generator.variable.VariableStore

    }

    public void testGetInHierarchy()
    {
        VariableStore store = new VariableStore();
        store.set(new Variable(
                new QualifiedName("org.apache.torque.name"),
                "org.apache.torque",
                Variable.Scope.OUTLET));
        QualifiedName qualifiedName
            = new QualifiedName("org.apache.torque.name");
        assertEquals(
                "org.apache.torque",
                store.getInHierarchy(qualifiedName).getValue());
        qualifiedName
            = new QualifiedName("org.apache.torque.generator.name");
        assertEquals(
                "org.apache.torque",
                store.getInHierarchy(qualifiedName).getValue());
        qualifiedName
            = new QualifiedName("org.apache.name");
        assertNull(store.getInHierarchy(qualifiedName));
    }
View Full Code Here

Examples of org.apache.torque.generator.variable.VariableStore

        assertNull(store.getInHierarchy(qualifiedName));
    }

    public void testGetContents()
    {
        VariableStore store = new VariableStore();
        store.startOutlet();
        store.set(new Variable(
                new QualifiedName("org.apache.torque.generator"),
                "org.apache.torque.generator",
                Variable.Scope.OUTLET));
        store.set(new Variable(
                new QualifiedName("org.apache.torque.children1"),
                "org.apache.torque.children1",
                Variable.Scope.CHILDREN));
        store.startOutlet();
        store.set(new Variable(
                new QualifiedName("org.apache.torque.children2"),
                "org.apache.torque.children2",
                Variable.Scope.CHILDREN));
        store.set(new Variable(
                new QualifiedName("org.apache.torque.file"),
                "org.apache.torque.file",
                Variable.Scope.FILE));
        store.set(new Variable(
                new QualifiedName("org.apache.torque.global"),
                "org.apache.torque.global",
                Variable.Scope.GLOBAL));

        QualifiedNameMap<Variable> storeContent = store.getContent();
        assertEquals("storeContent should contain 5 entries",
                5,
                storeContent.size());

        {
View Full Code Here

Examples of org.apache.torque.generator.variable.VariableStore

        }
    }

    public void testRemove()
    {
        VariableStore store = new VariableStore();
        store.startOutlet();
        QualifiedName qualifiedName
            = new QualifiedName("org.apache.torque.name");

        // fill store
        store.set(new Variable(
                qualifiedName,
                "org.apache.torque.GENERATOR",
                Variable.Scope.OUTLET));
        store.set(new Variable(
                qualifiedName,
                "org.apache.torque.CHILDREN",
                Variable.Scope.CHILDREN));
        store.set(new Variable(
                qualifiedName,
                "org.apache.torque.FILE",
                Variable.Scope.FILE));
        store.set(new Variable(
                qualifiedName,
                "org.apache.torque.GLOBAL",
                Variable.Scope.GLOBAL));

        assertEquals(
                "org.apache.torque.GENERATOR",
                store.getInHierarchy(qualifiedName).getValue());

        store.remove(store.getInHierarchy(qualifiedName));

        assertEquals(
                "org.apache.torque.CHILDREN",
                store.getInHierarchy(qualifiedName).getValue());

        store.remove(store.getInHierarchy(qualifiedName));

        assertEquals(
                "org.apache.torque.FILE",
                store.getInHierarchy(qualifiedName).getValue());

        store.remove(store.getInHierarchy(qualifiedName));

        assertEquals(
                "org.apache.torque.GLOBAL",
                store.getInHierarchy(qualifiedName).getValue());

        store.remove(store.getInHierarchy(qualifiedName));

        assertNull(store.getInHierarchy(qualifiedName));

        // test whether we can remove hidden variables
        Variable childrenVariable = new Variable(
                qualifiedName,
                "org.apache.torque.CHILDREN",
                Variable.Scope.CHILDREN);

        store.set(new Variable(
                qualifiedName,
                "org.apache.torque.GENERATOR",
                Variable.Scope.OUTLET));
        store.set(childrenVariable);
        store.set(new Variable(
                qualifiedName,
                "org.apache.torque.FILE",
                Variable.Scope.FILE));

        assertEquals(
                "org.apache.torque.GENERATOR",
                store.getInHierarchy(qualifiedName).getValue());

        store.remove(childrenVariable);

        assertEquals(
                "org.apache.torque.GENERATOR",
                store.getInHierarchy(qualifiedName).getValue());

        store.remove(store.getInHierarchy(qualifiedName));

        assertEquals(
                "org.apache.torque.FILE",
                store.getInHierarchy(qualifiedName).getValue());

    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.