📄 writedomlfile.java
字号:
/*
LoaderGenerator - tool for generated xml, sql and doml file needed for Octopus.
Copyright (C) 2003 Together
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.webdocwf.util.loader.generator;
import java.io.File;
import java.io.FileOutputStream;
import org.apache.xml.serialize.Method;
import org.apache.xml.serialize.OutputFormat;
import org.apache.xml.serialize.XMLSerializer;
import org.w3c.dom.Document;
import org.webdocwf.util.loader.LoaderException;
import org.webdocwf.util.loader.logging.Logger;
import org.webdocwf.util.loader.logging.StandardLogger;
/**
* WriteDomlFile class writes the doml file.
* @author Radoslav Dutina
* @version 1.0
*/
public class WriteDomlFile {
private String domlName = null;
private Logger logger;
/**
* Construct object WriteDomlFile with associated parameters.
* @param documentDoml is reference object of the Document class.
* @param generatorParameters represents the references to InputParameter object.
* database.
* @throws LoaderException
*/
public WriteDomlFile(Document documentDoml, InputParameters generatorParameters) throws LoaderException {
setLogger();
this.logger.write("full", "WriteDomlFile is started.");
domlName = generatorParameters.getTargetType();
try {
File xmlFile = null;
if (generatorParameters.getGeneratorOutput().equalsIgnoreCase("")) {
xmlFile = new File("doml");
} else {
xmlFile = new File(generatorParameters.getGeneratorOutput() + "/doml");
}
if (!xmlFile.exists())
xmlFile.mkdirs();
FileOutputStream os = new FileOutputStream(xmlFile + "/" + domlName + ".doml");
OutputFormat of = new OutputFormat(); //xerces apache.xml.serializer
of.setIndenting(true);
of.setIndent(4);
of.setMethod(Method.XML);
of.setPreserveSpace(false);
of.setLineWidth(0);
//of.setOmitXMLDeclaration(true);
XMLSerializer out = new XMLSerializer(os, of);
//IOException
out.serialize(documentDoml);
} catch (Exception e) {
String msg = "Exception in class WriteDomlFile: Error has occurred when trying to write doml file!";
LoaderException le = new LoaderException(msg, (Throwable) e);
this.logger.write("full","Exception:"+ msg + "\n" + le.getStackTraceAsString());
throw le;
}
this.logger.write("full", "WriteDomlFile is finished.");
}
/**
* This method will set logger object
* @param logger
*/
private void setLogger() {
this.logger = StandardLogger.getCentralLogger();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -