📄 parseloggerparam.java
字号:
/*
Loader - tool for transfering data from one JDBC source to another and
doing transformations during copy.
Copyright (C) 2002-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
Loader.java
Date: 03.03.2003.
@version 2.1 alpha
@author:
Radoslav Dutina rale@prozone.co.yu
*/
package org.webdocwf.util.loader;
import java.util.*;
import java.io.*;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import org.w3c.dom.*;
import org.xml.sax.*;
import org.webdocwf.util.loader.logging.*;
/**
* ParseLoggerParam class is use to check needed parameters for Logger object
* @author Radoslav Dutina
* @version 1.0
*/
public class ParseLoggerParam {
private String logClassName = "";
private String pathToLoggerConf = "";
private String pathToLoaderJob="";
/**
* This is the constructor of ParseLoggerParam class
* @param loaderJob defines the string path to loaderJob xml file
* @throws LoaderException
*/
public ParseLoggerParam(String loaderJob) throws LoaderException {
File file = new File(loaderJob);
this.pathToLoaderJob=file.getAbsoluteFile().getParent();
Document doc = null;
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = null;
db = dbf.newDocumentBuilder();
doc = db.parse(file);
}
catch (Exception e) {
System.out.println("Sorry, an error occurred: " + e.getMessage());
BufferOctopusClass.getInstance().writeToBuffer("Sorry, an error occurred: " + e.getMessage()
+ "\n");
LoaderException le = new LoaderException("Exception: ", (Throwable)e);
throw le;
}
if (doc != null) {
NodeList tagLoaderJob = doc.getElementsByTagName("loaderJob");
if (tagLoaderJob.getLength() != 0) {
NamedNodeMap log = tagLoaderJob.item(0).getAttributes();
Node nodeLogClassName = log.getNamedItem("logClassName");
if (nodeLogClassName != null)
this.logClassName = nodeLogClassName.getNodeValue();
Node nodeLogPath = log.getNamedItem("pathToLoggerConf");
if (nodeLogPath != null){
this.pathToLoggerConf = nodeLogPath.getNodeValue();
File fileLogger=new File(this.pathToLoggerConf);
if(!fileLogger.isAbsolute()){
String fullPathToLoggerConf=this.pathToLoaderJob+System.getProperty("file.separator")+
this.pathToLoggerConf;
File loggerFile=new File(fullPathToLoggerConf);
try {
this.pathToLoggerConf=loggerFile.getCanonicalPath();
}
catch (Exception ex) {
System.out.println(ex.getMessage());
ex.printStackTrace();
}
}
}
}
}
}
/**
* This method is use to retrive value of logClassName parameter
* @return value of logClassName parameter
*/
public String getLogClassName() {
return this.logClassName;
}
/**
* This method is use to retrive value of pathToLoggerCong parameter
* @return value of pathToLoggerCong parameter
*/
public String getPathToLoggerConf() {
return this.pathToLoggerConf;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -