Package com.javaforge.bobber.archetype.model

Examples of com.javaforge.bobber.archetype.model.Variable


    protected void processVariables(Iterator variables, VelocityContext context, final boolean interactiveMode) throws ArchetypeTemplateProcessingException
    {
        while (variables.hasNext())
        {
            Variable var = (Variable) variables.next();
            String val = System.getProperty(var.getName(), var.getDefvalue());

            if (interactiveMode)
            {

                StringBuilder message = new StringBuilder();
                message.append(var.getName()).append(": ")
                        .append(NEW_LINE)
                        .append(StringUtils.repeat("*", MESSAGE_LINE_LENGTH))
                        .append(NEW_LINE)
                        .append(NEW_LINE)
                        .append(StringUtils.center(var.getDescription(), MESSAGE_LINE_LENGTH))
                        .append(NEW_LINE)
                        .append(StringUtils.leftPad("[default: " + val + "]", MESSAGE_LINE_LENGTH))
                        .append(NEW_LINE)
                        .append(StringUtils.repeat("*", MESSAGE_LINE_LENGTH));
                getLogger().info(message.toString());
                try
                {
                    String answer = inputHandler.readLine();
                    if (!StringUtils.isEmpty(answer))
                    {
                        val = answer;
                    }
                }
                catch (IOException ie)
                {
                    throw new ArchetypeTemplateProcessingException(ie);
                }
                context.put(var.getName(), val);
            }
            else
            {
                context.put(var.getName(), val);
            }

            if (val.toLowerCase().equals("false") || val.toLowerCase().equals("n"))
            {
                if (var.getVariables() != null)
                {
                    //keep processing the variables picking up the default values
                    processVariables(var.getVariables().iterator(), context, false);

                }
            }
            else if (var.getVariables() != null)
            {
                //keep processing the variables in the current interaction mode
                processVariables(var.getVariables().iterator(), context, interactiveMode);

            }
        }

    }
View Full Code Here


    protected Object findVariable(String variableName, List variables)
    {

        for (int i = 0; i < variables.size(); i++)
        {
            Variable var = (Variable) variables.get(i);
            if (variableName.equals(var.getName()))
            {
                return var;
            }
            else if (var.getVariables() != null)
            {
                Object o = findVariable(variableName, var.getVariables());
                if (o != null)
                {
                    return o;
                }
            }
View Full Code Here

TOP

Related Classes of com.javaforge.bobber.archetype.model.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.