EmbeddedImage embededImage = context.getReport( )
EmbeddedImage embeddedImage = context.getReport( )
	public void execute( ReportItemDesign item, IReportEmitter emitter )	{		assert item instanceof ImageItemDesign;		ImageItemDesign imageItem = (ImageItemDesign) item;		IReportItemEmitter imageEmitter = emitter.getEmitter( "image" );		if ( imageEmitter == null )		{			return;		}		// Initializes		IImageItemContent imageContent = ContentFactory				.createImageContent( imageItem );		imageContent.setHelpText( getLocalizedString( imageItem				.getHelpTextKey( ), imageItem.getHelpText( ) ) );		imageContent.setAltText( getLocalizedString(				imageItem.getAltTextKey( ), imageItem.getAltText( ) ) );		setStyles( imageContent, item );		setVisibility( item, imageContent );		String fileExt = null;		// Handles the image according to its type		switch ( imageItem.getImageSource( ) )		{			case ImageItemDesign.IMAGE_URI : // URI				assert imageItem.getImageUri( ) != null;				imageContent.setUri( imageItem.getImageUri( ) );				break;			case ImageItemDesign.IMAGE_FILE : // File				String imageFile = imageItem.getImageFile( );				assert imageFile != null;				//image file may be file: or a file path.				try				{					URL url = new URL( imageFile );					if ( url.getProtocol( ).equals( "file" ) )					{						imageFile = url.getPath( );					}				}				catch ( MalformedURLException ex )				{					//imageFile is a file name				}				File file = new File( context.getReport( ).getBasePath( ),						imageFile );				imageFile = FileUtil.getAbsolutePath( context.getReport( )						.getBasePath( ), imageFile );				imageContent.setExtension( FileUtil.getExtFromFileName(						imageFile, FileUtil.SEPARATOR_PATH ) );				//Here uses the absolute file name as the URI for the image				// resource. The content of the file is loaded lazily to improve				// the performance.				imageContent.setUri( imageFile );				if ( imageFile == null )				{				    logger.log( Level.SEVERE, "[ImageItemExecutor] Source image file is missing" ); //$NON-NLS-1$				}				break;			case ImageItemDesign.IMAGE_NAME : // embedded image				String imageName;				imageName = imageItem.getImageName( );				assert imageName != null;				imageContent.setUri( null );				try				{					EmbeddedImage embededImage = context.getReport( )							.getReportDesign( ).findImage( imageName );					imageContent.setData( embededImage.getData( ) );					String extension = FileUtil.getExtFromType( embededImage							.getType( ) );					if ( extension == null )					{						extension = FileUtil.getExtFromFileName( imageName,								FileUtil.SEPARATOR_PATH );					}					imageContent.setExtension( extension );					imageContent.setUri( imageName );				}				catch ( Exception e )				{				    logger.log( Level.SEVERE, "[ImageItemExecutor] Fail to handle embedded image with an exception below:", e ); //$NON-NLS-1$				}				break;			case ImageItemDesign.IMAGE_EXPRESSION : // get image from database				assert imageItem.getImageExpression( ) != null;				IResultSet rs = null;				try				{					rs = openResultSet( item );					if ( rs != null )					{						rs.next( );					}					Expression imgExpr = imageItem.getImageExpression( );					Object value = context.evaluate( imgExpr );					byte[] blob = null;					if ( value != null							&& value.getClass( ).isArray( )							&& value.getClass( ).getComponentType( ) == byte.class )					{						blob = (byte[]) value;					}					Expression fmtExpr = imageItem.getImageFormat( );					if ( fmtExpr != null )					{						Object strValue = context.evaluate( fmtExpr );						if ( strValue != null )						{							fileExt = strValue.toString( );							fileExt = FileUtil.getExtFromType( fileExt );						}					}					if ( blob != null )					{						imageContent.setData( blob );						imageContent.setExtension( fileExt );						imageContent.setUri( null );					}					else					{					    logger.log( Level.SEVERE, "[ImageItemExecutor] cannot query image data from database"); //$NON-NLS-1$					}					closeResultSet( rs );				}				catch ( Exception e )				{				    logger.log( Level.SEVERE,"[ImageItemExecutor] fail to handle database image with an exception below:", e ); //$NON-NLS-1$				}				break;			default :			    logger.log( Level.SEVERE, "[ImageItemExecutor] invalid image source" ); //$NON-NLS-1$				assert false;		}		// handle the Action and Bookmark values		processAction( imageItem.getAction( ), imageContent );		String bookmarkStr = evalBookmark( item );		if ( bookmarkStr != null )			imageContent.setBookmarkValue( bookmarkStr );		// forward to emitter for further processing		imageEmitter.start( imageContent );		imageEmitter.end( );	}