コード例 #1
0
    /**
     * Processes the given JClass by creating the
     * corresponding MarshalInfo and print the Java classes
     * @param classInfo the classInfo to process
    **/
    private void processJClass(JClass jClass, SGStateInfo state) {


        boolean allowPrinting = true;

        if (state.promptForOverwrite()) {
            String filename = jClass.getFilename(destDir);
            File file = new File(filename);
            if (file.exists()) {
                String message = filename + " already exists. overwrite?";
                allowPrinting = dialog.confirm(message);
            }
        }
        //-- print class
        if (allowPrinting) {

            //hack for the moment
            //to avoid the compiler complaining with java.util.Date
            jClass.removeImport("org.exolab.castor.types.Date");
            jClass.setHeader(header);
            jClass.print(destDir,lineSeparator);
        }

        //------------------------------------/
        //- Create ClassDescriptor and print -/
        //------------------------------------/

        ClassInfo classInfo = state.resolve(jClass);

        if (_createDescriptors && (classInfo != null)) {

            JClass desc
                = DescriptorSourceFactory.createSource(classInfo);

            allowPrinting = true;
            if (state.promptForOverwrite()) {
                String filename = desc.getFilename(destDir);
                File file = new File(filename);
                if (file.exists()) {
                    String message = filename + " already exists. overwrite?";
                    allowPrinting = dialog.confirm(message);
                }
            }

            if (allowPrinting) {
                desc.setHeader(header);
                desc.print(destDir,lineSeparator);
            }
        }

        state.markAsProcessed(jClass);
    } //-- processJClass