ExpressionCompiler compiler = new ExpressionCompiler( this.text );
this.expr = compiler.compile( parserContext );
}
XLSReadStatus readStatus = null;
Map<String, Object> beans = null;
try {
beans = (Map<String, Object>) MVEL.executeExpression( this.expr,
object );
// error check beans
if ( beans == null || !(beans instanceof Map) ) {
throw new RuntimeException( "Bean map expression must evaluate to a populated Map interface" );
}
if ( object instanceof InputStream ) {
readStatus = xlsReader.read( (InputStream) object,
beans );
} else if ( object instanceof Resource ) {
readStatus = xlsReader.read( ((Resource) object).getInputStream(),
beans );
} else {
throw new IllegalArgumentException( "signal object must be instance of InputStream or Resource" );
}
// error check xls reader
if ( readStatus == null || !readStatus.isStatusOK() ) {
StringBuilder builder = new StringBuilder();
builder.append( "Unable to parse resource with XLS:\n" );
for ( XLSReadMessage message : ((List<XLSReadMessage>) readStatus.getReadMessages()) ) {
builder.append( message.getMessage() + "\n" );
}
throw new RuntimeException( "Unable to parse resource with XLS:\n" + builder.toString() );
}