Package net.sf.laja.parser.cdd.behaviour

Examples of net.sf.laja.parser.cdd.behaviour.Behaviour


    private DirectoryConverter directoryConverter = new DirectoryConverter();

    public Behaviour asBehaviour(StateTemplate template) {
        String packagename = asBehaviourPackage(template.rootStatePackage, template.packagename, template.rootBehaviourPackage);

        Behaviour behaviour = new Behaviour();
        behaviour.exists = false;
        behaviour.packagename = packagename;
        behaviour.sourceDir = directoryConverter.asDirectoryPath(template.rootSrcDir, packagename);
        behaviour.outputDir = directoryConverter.asDirectoryPath(template.rootOutDir, packagename);
        behaviour.srcFilename = behaviour.sourceDir + "/" + template.classname + ".java";
        behaviour.setClassname(template.classname);
        behaviour.setStateClass(template.classname + "State");
        behaviour.setParameters(new Parameters());

        AsMethod asMethod = new AsMethod();
        asMethod.setComment("(factory)");
        asMethod.setMethodName("as" + template.classname);
        asMethod.setReturnclass(template.classname);
        Statement statement = new Statement();
        statement.setInnerStatement("        return new " + behaviour.classname + "(state);");
        asMethod.setStatement(statement);
        asMethod.setParameters(new Parameters());
        behaviour.addAsMethod(asMethod);

        Imports imports = new Imports();
        Importstatement importstatement = new Importstatement();
        String fullclassname = template.packagename + "." + template.stateClass;
        importstatement.setFullclassname(fullclassname);
        importstatement.setStatement("import " + fullclassname + ";");
        imports.addImportstatement(importstatement);
        behaviour.setImports(imports);

        return behaviour;
    }
View Full Code Here


     * Only used from the IDE to test the grammar!
     */
    public static void main(String[] args) throws IOException {
        CddParser parser = new CddParser();

        Behaviour behaviour = parser.parseBehaviour("C:/Source/IDEA/CSB/src/main/java/csb/domain/customer/Customer.java");
    }
View Full Code Here

        if (!result.success()) {
            return null;
        }

        BehaviourFactory behaviourFactory = (BehaviourFactory)parser.getFactory();
        Behaviour behaviour = behaviourFactory.getBehaviour();

        return behaviour;
    }
View Full Code Here

TOP

Related Classes of net.sf.laja.parser.cdd.behaviour.Behaviour

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.