.
*/
/** ***********************************************************
*
*
* PURPOSE:
* This exception extends the ODMGQueryInvalidException by offering direct access to the
* RasDaMan error number and the line, column and token in the querystring that produced the error.
* @version $Revision: 1.10 $
*
*
* COMMENTS:
*
*
*********************************************************** */
public class RasQueryExecutionFailedException extends QueryInvalidException
{
static final String rcsid = "@(#)Package rasj, class RasQueryExecutionFailedException: $Header: /home/rasdev/CVS-repository/rasdaman/java/rasj/RasQueryExecutionFailedException.java,v 1.10 2003/12/19 16:22:27 rasdev Exp $";
/**
* the official RasDaMan error number
*/
private int errNo;
/**
* line number of the error
*/
private int line;
/**
* column of the error
*/
private int column;
/**
* token that caused the error
*/
private String token;
public RasQueryExecutionFailedException(String string)
{
if (string==null)
{
line = 0;
column = 0;
token = "(null)";
}
else
{
StringTokenizer tokenizer= new StringTokenizer( string, RasGlobalDefs.KEYWORD_TAB );
String Ttoken=tokenizer.nextToken();
Ttoken=tokenizer.nextToken();
errNo=Integer.parseInt(Ttoken);
if(tokenizer.hasMoreTokens())
{
line=Integer.parseInt(tokenizer.nextToken());
column=Integer.parseInt(tokenizer.nextToken());
token=tokenizer.nextToken();
}
else
{
line=0;
column=0;
token="";
}
}
}
/**
* Default Constructor setting the error specification
*@param errorNo official RasDaMan error number
*@param lineNo line in the query string that contained the error
*@param colNo column in the query string that contains the error
*@param tok token that caused the error
*/
public RasQueryExecutionFailedException( int errorNo, int lineNo, int colNo, String tok )
{
super();
errNo = errorNo;
line = lineNo;
column = colNo;
token = ( (tok==null) ? "(null)" : tok );
}
public String getMessage()
{
int index;
if(super.getMessage() == null)
{
String msg = RasErrorTexts.getErrorMessage(errNo);
StringBuffer buf = new StringBuffer(msg);
index = msg.indexOf( RasGlobalDefs.KEYWORD_TOKEN );
if(index != -1)
buf.replace(index, index+RasGlobalDefs.KEYWORD_TOKEN.length(), token);
msg = buf.toString();
index = msg.indexOf( RasGlobalDefs.KEYWORD_ERRNO );
if(index != -1)
buf.replace(index, index+RasGlobalDefs.KEYWORD_ERRNO.length(), String.valueOf(errNo));
msg = buf.toString();
index = msg.indexOf( RasGlobalDefs.KEYWORD_LINENO );
if(index != -1)
buf.replace(index, index+RasGlobalDefs.KEYWORD_LINENO.length(), String.valueOf(line));
msg = buf.toString();
index = msg.indexOf( RasGlobalDefs.KEYWORD_COLNO );
if(index != -1)
buf.replace(index, index+RasGlobalDefs.KEYWORD_COLNO.length(), String.valueOf(column));
return buf.toString();
}
else
return super.getMessage();
}
/**
* returns the line number of the error
*/
public int getLine()
{
return line;
}
/**
* return the column number of the error
*/
public int getColumn()
{
return column;
}
/**
* returns the token that caused the error
*/
public String getToken()
{
return token;
}
}