public void print(java.io.PrintWriter pw) { try { // write helper file String fullName = helperName(); String className; if (fullName.indexOf('.') > 0) { pack_name = fullName.substring(0, fullName.lastIndexOf('.')); className = fullName.substring(fullName.lastIndexOf('.') + 1); } else { pack_name = ""; className = fullName; } String path = parser.out_dir + fileSeparator + pack_name.replace('.', fileSeparator); File dir = new File(path); if (!dir.exists()) { if (!dir.mkdirs()) { org.jacorb.idl.parser.fatal_error("Unable to create " + path, null); } } String fname = className + "Helper.java"; File f = new File(dir, fname); if (GlobalInputStream.isMoreRecentThan(f)) { PrintWriter ps = new PrintWriter(new java.io.FileWriter(f)); printHelperClass(className, ps); ps.close(); } } catch (java.io.IOException i) { throw new RuntimeException("File IO error" + i); } }
/** * Open a PrintWriter to write to the .java file for typeName. * * @return null, if the output file already exists and is more recent than the input IDL file. */ protected PrintWriter openOutput(String typeName) { String path = parser.out_dir + fileSeparator + pack_name.replace('.', fileSeparator); File dir = new File(path); if (!dir.exists()) { if (!dir.mkdirs()) { org.jacorb.idl.parser.fatal_error("Unable to create " + path, null); } } try { final File f = new File(dir, typeName + ".java"); if (GlobalInputStream.isMoreRecentThan(f)) { PrintWriter ps = new PrintWriter(new java.io.FileWriter(f)); return ps; } // no need to open file for printing, existing file is more // recent than IDL file. return null; } catch (IOException e) { throw new RuntimeException("Could not open output file for " + typeName + " (" + e + ")"); } }
/** prints a constant declaration outside of an enclosing interface into a separate interface */ public void print(PrintWriter ps) { if (contained() || (included && !generateIncluded())) return; try { String fullName = ScopedName.unPseudoName(full_name()); String className; if (fullName.indexOf('.') > 0) { pack_name = fullName.substring(0, fullName.lastIndexOf('.')); className = fullName.substring(fullName.lastIndexOf('.') + 1); } else { pack_name = ""; className = fullName; } String path = parser.out_dir + fileSeparator + pack_name.replace('.', fileSeparator); File dir = new File(path); if (!dir.exists()) { if (!dir.mkdirs()) { org.jacorb.idl.parser.fatal_error("Unable to create " + path, null); } } String fname = className + ".java"; File f = new File(dir, fname); if (GlobalInputStream.isMoreRecentThan(f)) { PrintWriter pw = new PrintWriter(new java.io.FileWriter(f)); if (logger.isDebugEnabled()) logger.debug("ConstDecl.print " + fname); if (!pack_name.equals("")) pw.println("package " + pack_name + ";"); printClassComment("const", className, pw); pw.println("public interface " + className); pw.println("{"); pw.print("\t" + const_type.toString() + " value = "); pw.print(getValue()); pw.println(";"); pw.println("}"); pw.close(); } } catch (java.io.IOException i) { throw new RuntimeException("File IO error" + i); } }