/** @return whether or not the MetaDD should be written out at the end. */ private static boolean processMetaDD(Config config) throws IOException { boolean needToWriteMetaDD = false; MetaDD mdd; // // Either creates the metaDD file or read the existing one // if (config.getMddFile() != null || config.getMddIn() != null) { File file = config.getMddFile(); if (config.getMddIn() == null && !file.exists()) { config.setDoGeneration(false); if (!config.isAuto()) { if (!askYesOrNo( config.messageOut, "The mdd file " + config.getMddFile() + // NOI18N " doesn't exist. Should we create it (y/n)? ")) { // NOI18N config.messageOut.println("Generation aborted."); // NOI18N return false; } } needToWriteMetaDD = true; mdd = new MetaDD(); } else { try { InputStream is = config.getMddIn(); if (config.getMddIn() == null) { is = new FileInputStream(config.getMddFile()); config.messageOut.println(Common.getMessage("MSG_UsingMdd", config.getMddFile())); } mdd = MetaDD.read(is); if (config.getMddIn() == null) { is.close(); } } catch (IOException e) { if (config.isTraceParse()) e.printStackTrace(); throw new IOException(Common.getMessage("CantCreateMetaDDFile_msg", e.getMessage())); } catch (javax.xml.parsers.ParserConfigurationException e) { if (config.isTraceParse()) e.printStackTrace(); throw new IOException(Common.getMessage("CantCreateMetaDDFile_msg", e.getMessage())); } catch (org.xml.sax.SAXException e) { if (config.isTraceParse()) e.printStackTrace(); throw new IOException(Common.getMessage("CantCreateMetaDDFile_msg", e.getMessage())); } } } else { // Create a MetaDD to look stuff up in later on, even though // it wasn't read in, and we're not going to write it out. mdd = new MetaDD(); } config.setMetaDD(mdd); return needToWriteMetaDD; }