📄 searchxmlfile.java
字号:
}
if (driverTag.getLength() != 0) {
NodeList classNameTag = ((Element) driverTag.item(0)).getElementsByTagName("ClassName");
if (classNameTag.getLength() == 0) {
if (fileName != null)
msg = "In " + fileName + " file for this database, you don't have ClassName tag!";
else
msg = "In " + octopusPath + " ( in .jar) file for this database, you don't have ClassName tag!";
LoaderException le = new LoaderException("Exception:", (Throwable) new Exception(msg));
if (this.logger!=null){
this.logger.write("full", "Exception:"+"\n"+le.getStackTraceAsString());
}
throw le;
}
jdbcParameters.setDriverClassName(((Element) classNameTag.item(0)).getAttribute("value"));
NodeList connectionTag = ((Element) driverTag.item(0)).getElementsByTagName("Connection");
if (connectionTag.getLength() == 0) {
if (fileName != null)
msg = "In " + fileName + " file for this database, you don't have Connection tag!";
else
msg = "In " + octopusPath + " ( in .jar) file for this database, you don't have Connection tag!";
LoaderException le = new LoaderException("Exception:", (Throwable) new Exception(msg));
if (this.logger!=null){
this.logger.write("full", "Exception:"+"\n"+le.getStackTraceAsString());
}
throw le;
}
jdbcParameters.setConnection(((Element) connectionTag.item(0)).getAttribute("value"));
// NodeList alterTableTag= ((Element)driverTag.item(0)).getElementsByTagName("AlterTablePrimaryKey");
// if(alterTableTag.getLength()==0){
// if(fileName!=null)
// msg= "In "+fileName+" file for this database, you don't have AlterTablePrimaryKey tag!";
// else
// msg= "In "+octopusPath+" ( in .jar) file for this database, you don't have AlterTablePrimaryKey tag!";
// LoaderException le = new LoaderException(msg);
// throw le;
// }
// jdbcParameters.setAlterTablePrimaryKey(((Element)alterTableTag.item(0)).getAttribute("value"));
// generatorParameters.setAlterTablePrimaryKey(((Element)alterTableTag.item(0)).getAttribute("value"));
} else {
if (fileName != null)
msg = "In " + fileName + " file for this database, specified driver name (" + driverName + ") is not valid!";
else
msg = "In " + octopusPath + " ( in .jar) file for this database, specified driver name (" + driverName + ") is not valid!";
LoaderException le = new LoaderException("Exception:", (Throwable) new Exception(msg));
if (this.logger!=null){
this.logger.write("full", "Exception:"+"\n"+le.getStackTraceAsString());
}
throw le;
}
// if (this.logger!=null){
// this.logger.write("full", "\tgetClassName is finished.");
// }
}
public Vector getFileSystemDatabase(String driverName) throws LoaderException {
setLogger();
// if (this.logger!=null){
// this.logger.write("full", "\tgetFileSystemDatabase is started.");
// }
Vector driverProperties = new Vector();
String strFileSystemDatabase = "";
String strConnection = "";
searchDocument = (SearchElement) SearchElement.newInstance(document);
NodeList driverTag = null;
if (driverName.equalsIgnoreCase("")) {
driverTag = searchDocument.getSubElementsByTagName("Driver");
} else {
driverTag = searchDocument.getSubElementsByCondition("Driver@name=" + driverName);
}
if (driverTag.getLength() != 0) {
//FileSystemDatabase tag
NodeList fileSystemDatabaseTag = ((Element) driverTag.item(0)).getElementsByTagName("FileSystemDatabase");
if (fileSystemDatabaseTag.getLength() == 0) {
if (fileName != null)
msg = "In " + fileName + " file for this database, you don't have FileSystemDatabase tag!";
else
msg = "In " + octopusPath + " ( in .jar) file for this database, you don't have FileSystemDatabase tag!";
LoaderException le = new LoaderException("Exception:", (Throwable) new Exception(msg));
if (this.logger!=null){
this.logger.write("full", "Exception:"+le.getStackTraceAsString());
}
throw le;
} else {
strFileSystemDatabase = ((Element) fileSystemDatabaseTag.item(0)).getAttribute("value");
}
//Connection
NodeList connectionTag = ((Element) driverTag.item(0)).getElementsByTagName("Connection");
if (connectionTag.getLength() == 0) {
if (fileName != null)
msg = "In " + fileName + " file for this database, you don't have Connection tag!";
else
msg = "In " + octopusPath + " ( in .jar) file for this database, you don't have Connection tag!";
LoaderException le = new LoaderException("Exception:", (Throwable) new Exception(msg));
if (this.logger!=null){
this.logger.write("full", "Exception:"+le.getStackTraceAsString());
}
throw le;
} else {
strConnection = ((Element) connectionTag.item(0)).getAttribute("value");
}
} else {
if (fileName != null)
msg = "In " + fileName + " file for this database, specified driver name (" + driverName + ") is not valid!";
else
msg = "In " + octopusPath + " ( in .jar) file for this database, specified driver name (" + driverName + ") is not valid!";
LoaderException le = new LoaderException("Exception:", (Throwable) new Exception(msg));
if (this.logger!=null){
this.logger.write("full", "Exception:"+le.getStackTraceAsString());
}
throw le;
}
driverProperties.add(strFileSystemDatabase);
driverProperties.add(strConnection);
// if (this.logger!=null){
// this.logger.write("full", "\tgetFileSystemDatabase is finished.");
// }
return driverProperties;
}
public String getMaxConstraintLength(String driverName) throws LoaderException {
setLogger();
// if (this.logger!=null){
// this.logger.write("full", "\tgetMaxConstraintLength is started.");
// }
String maxConstraintLength = "-1";
searchDocument = (SearchElement) SearchElement.newInstance(document);
NodeList driverTag = null;
if (driverName.equalsIgnoreCase("")) {
driverTag = searchDocument.getSubElementsByTagName("Driver");
} else {
driverTag = searchDocument.getSubElementsByCondition("Driver@name=" + driverName);
}
if (driverTag.getLength() != 0) {
try {
NodeList maxConstraintLengthTag = ((Element) driverTag.item(0)).getElementsByTagName("MaxConstraintLength");
maxConstraintLength = ((Element) maxConstraintLengthTag.item(0)).getAttribute("value");
} catch (Exception ex) {
if (fileName != null)
msg = "In " + fileName + " file for this database, you don't have maxConstraintLenght tag!";
else
msg = "In " + octopusPath + " ( in .jar) file for this database, you don't have maxConstraintLenght tag!";
LoaderException le = new LoaderException("Exception:", new Exception(msg));
if (this.logger!=null){
this.logger.write("full", "Exception:"+"\n"+le.getStackTraceAsString());
}
throw le;
}
}
// if (this.logger!=null){
// this.logger.write("full", "\tgetMaxConstraintLength is finished.");
// }
return maxConstraintLength;
}
/**
* This method set value of alterTablePrimaryKey parameter
* @param driverName is name of the driver
* @return value of parameter
* @throws LoaderException
*/
public String getAlterTablePrimaryKey(String driverName) throws LoaderException {
setLogger();
// if (this.logger!=null){
// this.logger.write("full", "\tgetAlterTablePrimaryKey is started.");
// }
searchDocument = (SearchElement) SearchElement.newInstance(document);
NodeList driverTag = null;
if (driverName.equalsIgnoreCase("")) {
driverTag = searchDocument.getSubElementsByTagName("Driver");
} else {
driverTag = searchDocument.getSubElementsByCondition("Driver@name=" + driverName);
}
if (driverTag.getLength() != 0) {
NodeList alterTableTag = ((Element) driverTag.item(0)).getElementsByTagName("AlterTablePrimaryKey");
if (alterTableTag.getLength() == 0) {
if (fileName != null)
msg = "In " + fileName + " file for this database, you don't have AlterTablePrimaryKey tag!";
else
msg = "In " + octopusPath + " ( in .jar) file for this database, you don't have AlterTablePrimaryKey tag!";
LoaderException le = new LoaderException("Exception:", (Throwable) new Exception(msg));
if (this.logger!=null){
this.logger.write("full", "Exception:"+le.getStackTraceAsString());
}
throw le;
} else {
String ret = ((Element) alterTableTag.item(0)).getAttribute("value");
// if (this.logger!=null){
// this.logger.write("full", "\tgetAlterTablePrimaryKey is finished.");
// }
return ret;
}
} else {
if (fileName != null)
msg = "In " + fileName + " file for this database, specified driver name (" + driverName + ") is not valid!";
else
msg = "In " + octopusPath + " ( in .jar) file for this database, specified driver name (" + driverName + ") is not valid!";
LoaderException le = new LoaderException("Exception:", (Throwable) new Exception(msg));
if (this.logger!=null){
this.logger.write("full", "Exception:"+le.getStackTraceAsString());
}
throw le;
}
}
/**
* This method search the named xml document, and read the value of jdbcType parameter,
* which represents the jdbc type of data of the named sql type of data.
* @param sql_Type is the sql type of data.
* @return jdbc type of data.
* @throws LoaderException
*/
public String getJDBCFromSQLType(String sql_Type) throws LoaderException {
setLogger();
// if (this.logger!=null){
// this.logger.write("full", "\tgetJDBCFromSQLType is started.");
// }
searchDocument = (SearchElement) SearchElement.newInstance(document);
//TODO zoran added this line
sql_Type = Utils.replaceAll(sql_Type, " ", "_");
NodeList SQLTypeTag = searchDocument.getSubElementsByTagName("SQLType/" + sql_Type.toUpperCase());
if (SQLTypeTag.getLength() != 0) {
jdbcType = SQLTypeTag.item(0).getFirstChild().getNodeValue();
} else {
String msg = "This type of data (" + sql_Type + ") doesn't exists in the source table conf file!";
LoaderException le = new LoaderException("Exception:", new Exception(msg));
if (this.logger!=null){
this.logger.write("full", "Exception:"+le.getStackTraceAsString());
}
throw le;
}
// if (this.logger!=null){
// this.logger.write("full", "\tgetJDBCFromSQLType is finished.");
// }
return jdbcType;
}
//ZK added this method 5.5 2004
/**
* This method search the named xml document, and read the value of hasSize parameter
* @return hasSize.
* @throws LoaderException
*/
public Hashtable getHasSize() throws LoaderException {
setLogger();
// if (this.logger!=null){
// this.logger.write("full", "\tgetHasSize is started.");
// }
Hashtable resHashtable = new Hashtable();
searchDocument = (SearchElement) SearchElement.newInstance(document);
NodeList SQLTypesTagX = searchDocument.getSubElementsByTagName("SQLType");
NodeList SQLTypesTag = SQLTypesTagX.item(0).getChildNodes();
if (SQLTypesTag.getLength() != 0) {
for (int i = 0; i < SQLTypesTag.getLength(); i++) {
if (!(SQLTypesTag.item(i) instanceof org.enhydra.xml.SearchElement))
continue;
String hasSize = ((Element) SQLTypesTag.item(i)).getAttribute("hasSize");
if (hasSize == null || hasSize.equalsIgnoreCase(""))
hasSize = "false";
resHashtable.put(((Element) SQLTypesTag.item(i)).getNodeName(), hasSize);
}
} else {
String msg = "Exception in method getHasSize in class SearchXmlFile.";
LoaderException le = new LoaderException("Exception:", (Throwable) new Exception(msg));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -