in contribs/ThomasFenner/JDBCLogger.java [213:296]
public void setLogType(String _name, int _logtype, Object _value) throws Exception
{
if(!isconfigured) throw new Exception("JDBCLogger::setLogType(), Not configured !");
//setLogType() makes only sense for further configuration of configureTable()
if(sql != null) return;
_name = _name.toUpperCase();
if(_name == null || !(_name.trim().length() > 0)) throw new Exception("JDBCLogger::setLogType(), Missing argument name !");
if(!LogType.isLogType(_logtype)) throw new Exception("JDBCLogger::setLogType(), Invalid logtype '" + _logtype + "' !");
if((_logtype != LogType.MSG && _logtype != LogType.EMPTY) && _value == null) throw new Exception("JDBCLogger::setLogType(), Missing argument value !");
LogColumn logcol;
for(int i=0; i<num; i++)
{
logcol = (LogColumn)logcols.get(i);
if(logcol.name.equals(_name))
{
if(!logcol.isWritable) throw new Exception("JDBCLogger::setLogType(), Column " + _name + " is not writeable !");
//Column gets the message
if(_logtype == LogType.MSG)
{
logcol.logtype = _logtype;
return;
}
//Column will be provided by JDBCIDHandler::getID()
else if(_logtype == LogType.ID)
{
logcol.logtype = _logtype;
try
{
//Try to cast directly Object to JDBCIDHandler
logcol.idhandler = (JDBCIDHandler)_value;
}
catch(Exception e)
{
try
{
//Assuming _value is of class string which contains the classname of a JDBCIDHandler
logcol.idhandler = (JDBCIDHandler)(Class.forName((String)_value).newInstance());
}
catch(Exception e2)
{
throw new Exception("JDBCLogger::setLogType(), Cannot cast value of class " + _value.getClass() + " to class JDBCIDHandler !");
}
}
return;
}
//Column will be statically defined with Object _value
else if(_logtype == LogType.STATIC)
{
logcol.logtype = _logtype;
logcol.value = _value;
return;
}
//Column will be provided with a actually timestamp
else if(_logtype == LogType.TIMESTAMP)
{
logcol.logtype = _logtype;
return;
}
//Column will be fully ignored during process.
//If this column is not nullable, the column has to be filled by a database trigger,
//else a database error occurs !
//Columns which are not nullable, but should be not filled, must be explicit assigned with LogType.EMPTY,
//else a value is required !
else if(_logtype == LogType.EMPTY)
{
logcol.logtype = _logtype;
logcol.ignore = true;
return;
}
}
}
}