mil.dod.th.ose.jaxb.proto.converter/src/mil/dod/th/ose/jaxbprotoconverter/ProtoFileGenerator.java
public void generateProtoFile(final ProtoFile protoFile, final File xsdFilesDir, final File outputDir, 
            final String baseJavaPackageName) throws JaxbProtoConvertException, IOException
    {
        final File xsdFile = protoFile.getXsdFile();
        //Name of the file without any extension.
        final String baseName = xsdFile.getName().replace(".xsd", "");
        //Name of the Java class when compiled.
        final String javaClassName = baseName + "Gen";
        //Name of the proto file to be generated.
        final String protoFileName = baseName + ".proto";
        //Build the relative path the proto file should be generated to based on the XSD path.
        final Path relativePath = PathUtils.getRelativePath(xsdFile.getParentFile(), xsdFilesDir);
        //Get the file that the proto file should be generated to.
        final File protoFileDir = new File(outputDir.getAbsolutePath() + File.separator + relativePath.toString());
        //Create any directories that don't exist.
        if (!protoFileDir.exists() && !protoFileDir.mkdirs())
        {
            throw new JaxbProtoConvertException(String.format("Couldn't create proto file output directory: %s", 
                    protoFileDir.getAbsolutePath()));
        }
        //Build the Java package the proto file belongs to when compiled.
        final String javaPackage = baseJavaPackageName + PACKAGE_SEPARATOR 
                + relativePath.toString().replace(File.separator, PACKAGE_SEPARATOR);
        
        //Get the print stream used to write the proto file.
        final PrintStream outStream = m_FileService.createPrintStream(new File(protoFileDir, protoFileName));
         
        final DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss\n", Locale.US);
        final long currentDate = new Date().getTime();
        
        //Output the date the proto file was generated on, Java package the compiled proto belongs to, and the class 
        //name of the compiled Java file.
        outStream.format("//Generated By: JAXB to Proto Converter on %s%n", dateFormat.format(currentDate));
        outStream.format("option java_package = \"%s\";%n", javaPackage);
        outStream.format("option java_outer_classname = \"%s\";%n", javaClassName);
        outStream.println();
        
        //Output all import statements needed by the proto file.
        for (String importStatement: protoFile.getImports())
        {
            outStream.format("import \"%s\";%n", importStatement);
        }
        outStream.println();
        
        //Output all messages contained within the proto file.
        for (ProtoMessage message: protoFile.getMessageMap().values())
        {
            printMessage(outStream, message);
        }
    }
/**
     * Method that generates proto file based on the {@link ProtoFile} model.
     * 
     * @param protoFile
     *      The proto file model that represents the proto file to be generated.
     * @param xsdFilesDir
     *      Base directory in which all XSD schema files are located.
     * @param outputDir
     *      File that represents the directory the proto file should be generated to.
     * @param baseJavaPackageName
     *      Base package name used for Java package proto file option.
     * @throws JaxbProtoConvertException
     *      Thrown if an exception occurs creating the proto file.
     * @throws IOException
     *      Thrown if an exception occurs writing to the proto file.
     */
Method that generates proto file based on the  ProtoFile model.

@param protoFile
The proto file model that represents the proto file to be generated.
@param xsdFilesDir
Base directory in which all XSD schema files are located.
@param outputDir
File that represents the directory the proto file should be generated to.
@param baseJavaPackageName
Base package name used for Java package proto file option.
@throws JaxbProtoConvertException
Thrown if an exception occurs creating the proto file.
@throws IOException
Thrown if an exception occurs writing to the proto file.
Method that generates proto file based on the ProtoFile model . @param protoFile The proto file model that represents the proto file to be generated . @param xsdFilesDir Base directory in which all XSD schema files are located . @param outputDir File that represents the directory the proto file should be generated to . @param baseJavaPackageName Base package name used for Java package proto file option . @throws JaxbProtoConvertException Thrown if an exception occurs creating the proto file . @throws IOException Thrown if an exception occurs writing to the proto file .
public void generateProtoFile(final ProtoFile protoFile, final File xsdFilesDir, final File outputDir, 
            final String baseJavaPackageName) throws JaxbProtoConvertException, IOException
    {
        final File xsdFile = protoFile.getXsdFile();
        final String baseName = xsdFile.getName().replace(".xsd", "");
        final String javaClassName = baseName + "Gen";
        final String protoFileName = baseName + ".proto";
        final Path relativePath = PathUtils.getRelativePath(xsdFile.getParentFile(), xsdFilesDir);
        final File protoFileDir = new File(outputDir.getAbsolutePath() + File.separator + relativePath.toString());
        if (!protoFileDir.exists() && !protoFileDir.mkdirs())
        {
            throw new JaxbProtoConvertException(String.format("Couldn't create proto file output directory: %s", 
                    protoFileDir.getAbsolutePath()));
        }
        final String javaPackage = baseJavaPackageName + PACKAGE_SEPARATOR 
                + relativePath.toString().replace(File.separator, PACKAGE_SEPARATOR);
        final PrintStream outStream = m_FileService.createPrintStream(new File(protoFileDir, protoFileName));
        final DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss\n", Locale.US);
        final long currentDate = new Date().getTime();
        outStream.format("//Generated By: JAXB to Proto Converter on %s%n", dateFormat.format(currentDate));
        outStream.format("option java_package = \"%s\";%n", javaPackage);
        outStream.format("option java_outer_classname = \"%s\";%n", javaClassName);
        outStream.println();
        for (String importStatement: protoFile.getImports())
        {
            outStream.format("import \"%s\";%n", importStatement);
        }
        outStream.println();
        for (ProtoMessage message: protoFile.getMessageMap().values())
        {
            printMessage(outStream, message);
        }
    }
public void generateProtoFile ( final ProtoFile protoFile , final File xsdFilesDir , final File outputDir , final String baseJavaPackageName ) throws JaxbProtoConvertException , IOException { final File xsdFile = protoFile . getXsdFile ( ) ; final String baseName = xsdFile . getName ( ) . replace ( ".xsd" , "" ) ; final String javaClassName = baseName + "Gen" ; final String protoFileName = baseName + ".proto" ; final Path relativePath = PathUtils . getRelativePath ( xsdFile . getParentFile ( ) , xsdFilesDir ) ; final File protoFileDir = new File ( outputDir . getAbsolutePath ( ) + File . separator + relativePath . toString ( ) ) ; if ( ! protoFileDir . exists ( ) && ! protoFileDir . mkdirs ( ) ) { throw new JaxbProtoConvertException ( String . format ( "Couldn't create proto file output directory: %s" , protoFileDir . getAbsolutePath ( ) ) ) ; } final String javaPackage = baseJavaPackageName + PACKAGE_SEPARATOR + relativePath . toString ( ) . replace ( File . separator , PACKAGE_SEPARATOR ) ; final PrintStream outStream = m_FileService . createPrintStream ( new File ( protoFileDir , protoFileName ) ) ; final DateFormat dateFormat = new SimpleDateFormat ( "MM/dd/yyyy HH:mm:ss\n" , Locale . US ) ; final long currentDate = new Date ( ) . getTime ( ) ; outStream . format ( "//Generated By: JAXB to Proto Converter on %s%n" , dateFormat . format ( currentDate ) ) ; outStream . format ( "option java_package = \"%s\";%n" , javaPackage ) ; outStream . format ( "option java_outer_classname = \"%s\";%n" , javaClassName ) ; outStream . println ( ) ; for ( String importStatement : protoFile . getImports ( ) ) { outStream . format ( "import \"%s\";%n" , importStatement ) ; } outStream . println ( ) ; for ( ProtoMessage message : protoFile . getMessageMap ( ) . values ( ) ) { printMessage ( outStream , message ) ; } }
Method that generates proto file based on the {@link ProtoFile} model.
Method that generates proto file based on the { @link ProtoFile } model .
//Name of the file without any extension. //Name of the Java class when compiled. //Name of the proto file to be generated. //Build the relative path the proto file should be generated to based on the XSD path. //Get the file that the proto file should be generated to. //Create any directories that don't exist. //Build the Java package the proto file belongs to when compiled. //Get the print stream used to write the proto file. //Output the date the proto file was generated on, Java package the compiled proto belongs to, and the class  //name of the compiled Java file. //Output all import statements needed by the proto file. //Output all messages contained within the proto file.