Package org.apache.shale.clay.config.beans

Examples of org.apache.shale.clay.config.beans.SymbolBean


         
        // test vertical inheritance
        ComponentBean bean = standardConfigBean.getElement("baseSymbolLabel");
        assertNotNull(bean);
        //look for a base symbol definition
        SymbolBean symbol = (SymbolBean) bean.getSymbols().get("@mystyle");
        assertNotNull(symbol);
        assertEquals("@mystyle == color:blue", "color:blue", symbol.getValue());

        // symbol1Label extends baseSymbolLabel
        bean = standardConfigBean.getElement("symbol1Label");
        assertNotNull(bean);
        //look for inherited symbol
        symbol = (SymbolBean) bean.getSymbols().get("@mystyle");
        assertNotNull(symbol);
        assertEquals("@mystyle == color:blue", "color:blue", symbol.getValue());

        // symbol2Label extends symbol1Label
        bean = standardConfigBean.getElement("symbol2Label");
        assertNotNull(bean);
        //look for an overridden symbol
        symbol = (SymbolBean) bean.getSymbols().get("@mystyle");
        assertNotNull(symbol);
        assertEquals("@mystyle == color:red", "color:red", symbol.getValue());

       
        //test nested/inner element inheritance
        bean = standardConfigBean.getElement("symbolPanel");
        assertNotNull(bean);
       
        assertEquals(bean.getChildren().size(), 2);
        Iterator ei = bean.getChildrenIterator();
        while (ei.hasNext()) {
            ElementBean ebean = (ElementBean) ei.next();
            if (ebean.getRenderId() == 1) {
                //look for inherited symbol
                symbol = (SymbolBean) ebean.getSymbols().get("@mystyle");
                assertNotNull(symbol);
                assertEquals("@mystyle == color:blue", "color:blue", symbol.getValue());               
            } else if (ebean.getRenderId() == 2) {
                //look for an overridden symbol
                symbol = (SymbolBean) ebean.getSymbols().get("@mystyle");
                assertNotNull(symbol);
                assertEquals("@mystyle == color:red", "color:red", symbol.getValue());
               
            }
        }
       
              
View Full Code Here


    protected void encodeBegin(Node node, ElementBean target, ComponentBean root) {
        super.encodeBegin(node, target, root);

        if (node.getName().equals("directive.include")) {
            AttributeBean attr = target.getAttribute("clayJsfid");
            SymbolBean symbol = target.getSymbol("file");
            if (symbol != null && attr != null) {
                createAttribute(attr, "@file", target);
            }
        } else if (node.getName().equals("include")) {
            AttributeBean attr = target.getAttribute("clayJsfid");
            SymbolBean symbol = target.getSymbol("@page");
            if (symbol != null && attr != null) {
                createAttribute(attr, "@page", target);
            }
            Iterator ai = node.getChildren().iterator();
            while (ai.hasNext()) {
                Node child = (Node) ai.next();
                if (child.getName() != null && child.getName().equals("param")) {
                    String name = (String) child.getAttributes().get("name");
                    String value = (String) child.getAttributes().get("value");

                    SymbolBean paramSymbol = new SymbolBean();
                    paramSymbol.setName(name);
                    paramSymbol.setValue(value);
                    target.addSymbol(paramSymbol);
                }
            }
            // remove the children, don't waste any more time processing
            node.getChildren().clear();
View Full Code Here

                String name = (String) child.getAttributes().get("name");
                String value = (String) child.getAttributes().get("value");

                if (name != null && name.length() > 0) {
                    SymbolBean symbol = new SymbolBean();
                    StringBuffer tmp = new StringBuffer(name);
                    if (tmp.charAt(0) != '@') {
                       tmp.insert(0, '@');
                    }

                    symbol.setName(tmp.toString());
                    symbol.setValue(value);
                    target.addSymbol(symbol);
                }
            }
        }
    }
View Full Code Here

        Iterator ci = clayIncludes.iterator();
        while (ci.hasNext()) {
            ComponentBean clayInclude = (ComponentBean) ci.next();
            if (clayInclude.getSymbol("@file") != null) {

                SymbolBean symbol = clayInclude.getSymbol("@file");
                assertNotNull("file symbol", symbol);
                assertEquals("/org/apache/shale/clay/config/address1.html", symbol.getValue());

                AttributeBean attr = clayInclude.getAttribute("clayJsfid");
                assertNotNull("clayJsfid", attr);
                assertEquals("@file", attr.getValue());


            } else if (clayInclude.getSymbol("@page") != null) {

                SymbolBean symbol = clayInclude.getSymbol("@page");
                assertNotNull("file symbol", symbol);
                assertEquals("/org/apache/shale/clay/config/address1.html", symbol.getValue());

                AttributeBean attr = clayInclude.getAttribute("clayJsfid");
                assertNotNull("clayJsfid", attr);
                assertEquals("@page", attr.getValue());

                for (int i = 0; i < 5; i++) {
                    symbol = clayInclude.getSymbol("@symbol" + i);
                    assertNotNull("@symbol" + i, symbol);
                    assertEquals("value" + i, symbol.getValue());
                }

            } else {
                assertFalse("invalid include mapping", true);
            }
View Full Code Here

        Map dependenciesMap = new TreeMap();
        TreeSet allNestedSymbols = new TreeSet();

        while (si.hasNext()) {
            Map.Entry e = (Map.Entry) si.next();
            SymbolBean symbol = (SymbolBean) e.getValue();
            if (symbol.getValue() != null) {
                List symbolDependencies = findSymbols(context, symbol.getValue());
                if (!symbolDependencies.isEmpty()) {
                    dependenciesMap.put(symbol.getName(), symbolDependencies);
                    allNestedSymbols.addAll(symbolDependencies);
                    allNestedSymbols.add(symbol.getName());
                }
            }
        }

        List allNestedSymbolsOrdered = getOrderedByDependencies(allNestedSymbols, dependenciesMap);
        for (int i = 0; i < allNestedSymbolsOrdered.size(); i++) {
            String symbolName = (String) allNestedSymbolsOrdered.get(i);
            SymbolBean sourceSymbol = (SymbolBean) symbols.get(symbolName);
            if (sourceSymbol != null && sourceSymbol.getValue() != null) {
                String value =  replaceMnemonic(context, sourceSymbol.getValue());
                SymbolBean targetSymbol = new SymbolBean();
                targetSymbol.setDescription(sourceSymbol.getDescription());
                targetSymbol.setName(sourceSymbol.getName());
                targetSymbol.setValue(value);

                symbols.put(targetSymbol.getName(), targetSymbol);
            }
        }

    }
View Full Code Here

        Iterator si = symbols.entrySet().iterator();
        boolean wasSymbolFound = false;
        int i = buff.indexOf("@");
        replace: while (i > -1 && si.hasNext()) {
            Map.Entry e = (Map.Entry) si.next();
            SymbolBean symbol = (SymbolBean) e.getValue();
            String key = symbol.getName();
            i = (wasSymbolFound ? buff.indexOf("@") : i);
            if (i == -1) {
                break replace;
            }
View Full Code Here

        Iterator si = symbols.entrySet().iterator();
        boolean wasReplacementMade = false;
        int i = buff.indexOf("@");
        replace: while (i > -1 && si.hasNext()) {
            Map.Entry e = (Map.Entry) si.next();
            SymbolBean symbol = (SymbolBean) e.getValue();
            String key = symbol.getName();
            String value = (symbol.getValue() == null ? "" : symbol.getValue());
            i = (wasReplacementMade ? buff.indexOf("@") : i);
            if (i == -1) {
              break replace;
            }
View Full Code Here

     */
    protected void addSymbol(Node node, ElementBean target) {
        String value = (String) node.getAttributes().get("value");
        String name = (String) node.getAttributes().get("name");
        if (name != null && name.length() > 0) {
            SymbolBean symbol = new SymbolBean();
            StringBuffer tmp = new StringBuffer(name);
            if (tmp.charAt(0) != '@') {
               tmp.insert(0, '@');
            }

            symbol.setName(tmp.toString());
            symbol.setValue(value);
            target.addSymbol(symbol);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.shale.clay.config.beans.SymbolBean

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.