protected void generateClassFile()

in src/main/java/org/apache/activemq/nms/openwire/tool/commands/CommandGenerator.java [75:119]


    protected void generateClassFile() throws Exception {

        File headerFile = new File(destDir, className + ".cs");

        CommandCodeGenerator generator = generatorsFactory.getCodeGenerator( className );

        generator.setJClass( getJclass() );
        generator.setProperties( getProperties() );
        generator.setMarshalAware( isMarshallerAware() );
        generator.setClassName( getClassName() );
        generator.setBaseClassName( getBaseClass() );
        generator.setOpenWireOpCode( getOpenWireOpCode(getJclass()) );
        generator.setComparable( className.endsWith("Id") || generator.isComparable() );

        for (int i = 0; i < getJclass().getInterfaces().length; i++) {
            JClass intf = getJclass().getInterfaces()[i];

            String name = generator.toCSharpType( intf );
            if( name != null && !name.endsWith("DataStructure") && !name.equals("Command") ) {
                generator.addAdditionalBase( name );
            }
        }

        PrintWriter out = null;
        try {
            out = new PrintWriter(new FileWriter(headerFile));
            generator.generate(out);
        } catch( Exception e ) {
            throw new RuntimeException(e);
        } finally {
            if( out != null ) {
                out.close();
            }
        }

        // Use the FixCRLF Ant Task to make sure the file has consistent
        // newlines so that SVN does not complain on checkin.
        Project project = new Project();
        project.init();
        FixCRLF fixCRLF = new FixCRLF();
        fixCRLF.setProject(project);
        fixCRLF.setSrcdir(headerFile.getParentFile());
        fixCRLF.setIncludes(headerFile.getName());
        fixCRLF.execute();
    }