Oracle interMedia Audio, Image, and Video Java Classes User's Guide and Reference
Release 8.1.7

Part Number A85374-01

Library

Product

Contents

Index

Go to previous page Go to next page

4
ORDImage Reference Information

interMedia Java Classes describes the ORDImage object type, which supports the storage and management of image data.

Methods invoked at the ORDImage level that are handed off for processing to the database source plug-in have byte[ ] ctx[ ] as a context parameter. In cases where a client system is connecting to a database server, the space for the parameter is created by the client (in the reference examples, 4000 bytes of space), but the content of the context parameter is generated by the server. The context parameter is passed from the client to the server for the processing of context information.


Note:

In the current release, not all source plug-ins will use or generate the context parameter, but if you include the parameter as previously described, your application should work with any current or future source plug-ins. 


See Oracle8i interMedia Audio, Image, and Video User's Guide and Reference for more information.

4.1 Prerequisites

You will need to include the following import statements in your Java file in order to run interMedia methods:

import java.sql.*;
import java.io.*;
import oracle.jdbc.driver.*;
import oracle.sql.*;
import oracle.ord.im.*;

The examples in this reference chapter are based on the assumption that the following operations have already been performed:

For examples of making a connection and populating a local object, see Section 2.2.2.

4.2 Reference Information

This section presents reference information on the methods that operate on ORDImage objects.


checkProperties( )

Format

public boolean checkProperties( )

Description

Checks if the properties stored in the media data of the local object are consistent with the attributes of the local object.

Parameters

None.

Return Value

This method returns TRUE if the attribute values stored in the object attributes are the same as the properties stored in the image data; FALSE otherwise.

Exceptions

java.sql.SQLException

Example

if(imgObj.checkProperties( ))
     System.out.println("checkProperties successful");


clearLocal( )

Format

public void clearLocal( )

Description

Clears the source local field of the application ORDImage object.

Parameters

None.

Return Value

None.

Exceptions

java.sql.SQLException

Example

imgObj.clearLocal( );


copy( )

Format

public void copy(OrdImage dest)

Description

Copies image data from the application ORDImage object source to a destination ORDImage object.

Parameters

dest

The ORDImage object to which the data will be copied.

Return Value

None.

Exceptions

java.sql.SQLException

Example

//create and populate an object named imgObj2
imgObj.copy(imgObj2);

where


deleteContent( )

Format

public void deleteContent( )

Description

Deletes the media data in the BLOB in the application ORDImage object.

Parameters

None.

Return Value

None.

Exceptions

java.sql.SQLException

Example

audObj.deleteContent( );


export( )

Format

public void export (byte[ ] ctx[ ], String sourceType, String sourceLocation, String sourceName)

Description

Exports the data from the application ORDImage object to the location specified in the parameters. The location is of the form:

sourceType://sourceLocation/sourceName

This method will work only if you are running Oracle database release 8.1.7 or later.

See Chapter 4 of Oracle8i interMedia Audio, Image, and Video User's Guide and Reference for more information.

Parameters

ctx[ ]

The source plug-in context information. It is set to NULL if there is no context information.

sourceType

The source type to which the content will be exported. Only "FILE" is natively supported.

sourceLocation

The location on the database server to which the content will be exported.

sourceName

The source name to which the content will be exported.

Return Value

None.

Exceptions

java.sql.SQLException

Example

byte[ ] ctx[ ] = new byte[4000][1];
imgObj.export(ctx,"FILE","IMAGEDIR","image.gif");

where:


getBFILE( )

Format

public oracle.sql.BFILE getBFILE( )

Description

Gets the BFILE attribute of the application ORDImage object.

Parameters

None.

Return Value

This method returns the BFILE.

Exceptions

java.sql.SQLException

Example

BFILE imageBFILE = imgObj.getBFILE( );


getCompressionFormat( )

Format

public String getCompressionFormat( )

Description

Gets the compression format attribute of the application ORDImage object as a String.

Parameters

None.

Return Value

This method returns the compression format attribute, as a String.

Exceptions

java.sql.SQLException

Example

String compression = imgObj.getCompressionFormat( );


getContent( )

Format

public oracle.sql.BLOB getContent( )

Description

Gets the LOB locator from the application ORDImage object.

Parameters

None.

Return Value

This method returns the LOB locator of the application object.

Exceptions

java.sql.SQLException

Example

BLOB localContent = imgObj.getContent( );


getContentFormat( )

Format

public String getContentFormat( )

Description

Gets the content format attribute of the application ORDImage object as a String.

Parameters

None.

Return Value

This method returns the content format attribute, as a String.

Exceptions

java.sql.SQLException

Example

String format = imgObj.getContentFormat( );


getContentLength( )

Format

public int getContentLength( )

Description

Gets the content length of the media data in the application ORDImage object.

Parameters

None.

Return Value

This method returns the content length of the media data, in bytes.

Exceptions

java.sql.SQLException

Example

int length = imgObj.getContentLength( );


getDataInByteArray( )

Format

public byte[ ] getDataInByteArray( )

Description

Gets data from the LOB locator of the application ORDImage object and puts it in a local byte array.

Parameters

None.

Return Value

This method returns the byte array from which the data will be read.

Exceptions

java.sql.SQLException

java.io.IOException

java.lang.OutOfMemoryError

Example

byte[ ] byteArr = imgObj.getDataInByteArray( );


getDataInFile( )

Format

public boolean getDataInFile(String filename)

Description

Gets data from the LOB locator of the application ORDImage object and puts it in a local file.

Parameters

filename

The file into which the data will be loaded.

Return Value

This method returns TRUE if loading is successful; FALSE otherwise.

Exceptions

java.sql.SQLException

java.io.IOException

Example

boolean load = imgObj.getDataInFile("output1.dat");
if(load)
     System.out.println("getDataInFile completed successfully");
else
     System.out.println("Error in getDataInFile");

where:


getDataInStream( )

Format

public InputStream getDataInStream( )

Description

Gets data from the LOB locator of the application ORDImage file and puts it in a local input stream.

Parameters

None.

Return Value

This method returns the input stream from which the data will be read.

Exceptions

java.sql.SQLException

Example

InputStream inpStream = imgObj.getDataInStream( );


getFormat( )

Format

public String getFormat( )

Description

Gets the format attribute of the application ORDImage object as a String.

Parameters

None.

Return Value

This method returns the format attribute as a String.

Exceptions

java.sql.SQLException

Example

String format = imgObj.getFormat( );


getHeight( )

Format

public int getHeight( )

Description

Gets the height of the application ORDImage object.

Parameters

None.

Return Value

This method returns the height of the ORDImage object, in pixels.

Exceptions

java.sql.SQLException

Example

int height = imgObj.getHeight( );


getMimeType( )

Format

public String getMimeType( )

Description

Gets the MIME type of the application ORDImage object as a String.

Parameters

None.

Return Value

This method returns the MIME type of the ORDImage object, as a String.

Exceptions

java.sql.SQLException

Example

String mime = imgObj.getMimeType( );


getSource( )

Format

public String getSource( )

Description

Gets the application ORDImage object source information, including the source location, name, and type.

Parameters

None.

Return Value

This method returns a String containing the object source information.

Exceptions

java.sql.SQLException

Example

String sourceName = imgObj.getSource( );


getSourceLocation( )

Format

public String getSourceLocation( )

Description

Gets the application ORDImage object source location as a String.

Parameters

None.

Return Value

This method returns a String containing the object source location.

Exceptions

java.sql.SQLException

Example

String location = imgObj.getSourceLocation( );


getSourceName( )

Format

public String getSourceName( )

Description

Gets the application ORDImage object source name as a String.

Parameters

None.

Return Value

This method returns a String containing the object source name.

Exceptions

java.sql.SQLException

Example

String name = imgObj.getSourceName( );


getSourceType( )

Format

public String getSourceType( )

Description

Gets the application ORDImage object source location as a String.

Parameters

None.

Return Value

This method returns a String containing the object source type.

Exceptions

java.sql.SQLException

Example

String type = imgObj.getSourceType( );


getUpdateTime( )

Format

public java.sql.Timestamp getUpdateTime( )

Description

Gets a Timestamp object that contains information on when the application ORDImage object was most recently updated.

Parameters

None.

Return Value

This method returns a Timestamp object that contains the time of the most recent update.

Exceptions

java.sql.SQLException

Example

Timestamp time = imgObj.getUpdateTime( );


getWidth( )

Format

public int getWidth( )

Description

Gets the width of the application ORDImage object.

Parameters

None.

Return Value

This method returns the width of the ORDImage object, in pixels.

Exceptions

java.sql.SQLException

Example

int width = imgObj.getWidth( );


importData( )

Format

public void importData(byte[ ] ctx[ ])

Description

Imports data from an external source into the application ORDImage object.

The srcType, srcLocation, and srcName attributes must all be defined for this method to work.

Parameters

ctx[ ]

The source plug-in context information. It is set to NULL if there is no context information.

Return Value

None.

Exceptions

java.sql.SQLException

Example

byte[ ] ctx[ ] = new byte[4000][1];
imgObj.importData(ctx)

where:


importFrom( )

Format

public void importFrom(byte[ ] ctx[ ], String sourceType, String sourceLocation, String sourceName)

Description

Imports data from an external source into the application ORDImage object. The location of the external source is of the form:

sourceType://sourceLocation/sourceName

Parameters

ctx[ ]

The source plug-in context information. See Chapter 4 of Oracle8i interMedia Audio, Image, and Video User's Guide and Reference for more information.

sourceType

The source type from which the data will be imported.

sourceLocation

The source location from which the data will be imported.

sourceName

The source name from which the data will be imported.

Return Value

None.

Exceptions

java.sql.SQLException

Example

byte[ ] ctx[ ] = new byte[4000][1];
imgObj.importFrom(ctx,"FILE","IMAGEDIR","testimg.dat");

where:


isLocal( )

Format

public boolean isLocal( )

Description

Checks if the application ORDImage object local attribute is set.

Parameters

None.

Return Value

This method returns TRUE if the ORDImage object local attribute is set; FALSE otherwise.

Exceptions

java.sql.SQLException

Example

if(imgObj.isLocal( ))
     System.out.println("local attribute is true");
else
     System.out.println("local attribute is false");


loadDataFromByteArray( )

Format

public boolean loadDataFromByteArray(byte[ ] byteArr)

Description

Loads data from the local byte buffer into the database ORDImage object LOB locator and into the application object. It also calls setLocal( ), which sets the local field of the application ORDImage object, but not the database object, and setUpdateTime(null), which sets the updateTime attribute to the SYSDATE of the database server.

Parameters

byteArr

The name of the local byte array from which to load data.

Return Value

This method returns TRUE if loading is successful; FALSE otherwise.

Exceptions

java.sql.SQLException

java.io.IOException

Example

byte[ ] data = new byte[32300];
FileInputStream fStream = new FileInputStream("testimg.dat");
fStream.read(data,0,32300);
boolean success = imgObj.loadDataFromByteArray(data);
if(success)
     System.out.println("loadDataFromByteArray was successful");
else
     System.out.println("loadDataFromByteArray was unsuccessful");

where:


loadDataFromFile( )

Format

public boolean loadDataFromFile(String filename)

Description

Loads data from the local file into the database ORDImage object LOB locator and into the application object. It also calls setLocal( ), which sets the local field of the application ORDImage object, but not the database object, and setUpdateTime(null), which sets the updateTime attribute to the SYSDATE of the database server.

Parameters

filename

The name of the local file from which to load data.

Return Value

This method returns TRUE if loading is successful; FALSE otherwise.

Exceptions

java.sql.SQLException

java.io.IOException

Example

imgObj.loadDataFromFile("testimg.dat");

where:


loadDataFromInputStream( )

Format

public boolean loadDataFromInputStream(InputStream inpStream)

Description

Loads data from the local input stream into the database ORDImage object LOB locator and into the application object. It also calls setLocal( ), which sets the local field of the application ORDImage object, but not the database object, and setUpdateTime(null), which sets the updateTime attribute to the SYSDATE of the database server.

Parameters

inpStream

The name of the local input stream from which to load data.

Return Value

This method returns TRUE if loading is successful; FALSE otherwise.

Exceptions

java.sql.SQLException

java.io.IOException

Example

FileInputStream fStream = new FileInputStream("testimg.dat");
imgObj.loadDataFromInputStream(fStream);

where:


OrdImage( )

Format

public OrdImage( )

Description

Creates an ORDImage object.

This method is the default ORDImage constructor.

Parameters

None.

Return Value

None.

Exceptions

None.

Example

None.


process( )

Format

public void process(String command)

Description

Executes a given command on the application ORDImage object.

For more information on the commands that can be processed, see Oracle8i interMedia Audio, Image, and Video User's Guide and Reference.

Parameters

command

The command to be executed.

Return Value

None.

Exceptions

java.sql.SQLException

Example

imgObj.process("fileFormat=JFIF");

where:


processCopy( )

Format

public void processCopy(String command, OrdImage dest)

Description

Copies image data from the application ORDImage object to a destination ORDImage object and modifies the copy according to the specified command.

Parameters

command

The command to be executed.

dest

The object that will receive the results of the command.

Return Value

None.

Exceptions

java.sql.SQLException

Example

//create and populate an OrdImage object named imgObj2
imgObj.processCopy("maxScale=32 32, fileFormat= GIFF", imgObj2);

where:


setCompressionFormat( )

Format

public void setCompressionFormat(String CompressionFormat)

Description

Sets the compression format attribute of the application ORDImage object.

setProperties( ) will automatically set this attribute; use this method only if you are not using setProperties( ). Also, this method will set only the attribute value; it does not change the media file itself.

Parameters

CompressionFormat

The compression format to be set.

Return Value

None.

Exceptions

java.sql.SQLException

Example

None.


setContentFormat( )

Format

public void setContentFormat(String ContentFormat)

Description

Sets the content format attribute of the application ORDImage object.

setProperties( ) will automatically set this attribute; use this method only if you are not using setProperties( ). Also, this method will set only the attribute value; it does not change the media file itself.

Parameters

ContentFormat

The content format to be set.

Return Value

None.

Exceptions

java.sql.SQLException

Example

None.


setContentLength( )

Format

public void setContentLength(int newContentLength)

Description

Sets the content length of the media data in the application ORDImage object.

setProperties( ) will automatically set this attribute; use this method only if you are not using setProperties( ). Also, this method will set only the attribute value; it does not change the media file itself.

Parameters

newContentLength

The new content length to be set, in bytes.

Return Value

None.

Exceptions

java.sql.SQLException

Example

None.


setFormat( )

Format

public void setFormat(String Format)

Description

Sets the format attribute of the application ORDImage object.

setProperties( ) will automatically set this attribute; use this method only if you are not using setProperties( ). Also, this method will set only the attribute value; it does not change the media file itself.

Parameters

Format

The format of the contents of the ORDImage object, as a String.

Return Value

None.

Exceptions

java.sql.SQLException

Example

None.


setHeight( )

Format

public void setHeight(int newHeight)

Description

Sets the height of the application ORDImage object.

setProperties( ) will automatically set this attribute; use this method only if you are not using setProperties( ). Also, this method will set only the attribute value; it does not change the media file itself.

Parameters

newHeight

The new height to be set, in pixels.

Return Value

None.

Exceptions

java.sql.SQLException

Example

imgObj.setHeight(24);

where:


setLocal( )

Format

public void setLocal( )

Description

Sets the source local field of the application ORDImage object.

Parameters

None

Return Value

None.

Exceptions

java.sql.SQLException

Example

imgObj.setLocal( );


setMimeType( )

Format

public void setMimeType(String MimeType)

Description

Sets the MIME type of the application ORDImage object.

setProperties( ) will automatically set this attribute; use this method only if you are not using setProperties( ). Also, this method will set only the attribute value; it does not change the media file itself.

Parameters

MimeType

The MIME type of the contents of the ORDImage object, as a String.

Return Value

None.

Exceptions

java.sql.SQLException

Example

imgObj.setMimeType("image/bmp");

where:


setSource( )

Format

public void setSource(String sourceType, String sourceLocation, String sourceName)

Description

Sets the application ORDImage object source information.

Parameters

sourceType

The type of the source.

sourceLocation

The location of the source.

sourceName

The name of the source.

Return Value

None.

Exceptions

java.sql.SQLException

Example

imgObj.setSource("FILE","IMAGEDIR","jdoe.gif");

where:


setProperties( )

Format

public void setProperties( )

Description

Reads the image data, extracts attributes according to the values stored in the content data header, and sets the application ORDImage object attributes.

The properties to be set include height, width, data size of the on-disk image, file type, image type, compression type, and MIME type.

Parameters

None.

Return Value

None.

Exceptions

java.sql.SQLException

Example

imgObj.setProperties( );

setProperties(String)

Format

public void setProperties(String command)

Description

Sets the application ORDImage object attributes according to the values stored in the given String. This method is used for foreign image files. For more information on foreign image files and the properties that can be set, see Oracle8i interMedia Audio, Image, and Video User's Guide and Reference.

Parameters

command

The object attribute values to be set.

Return Value

None.

Exceptions

java.sql.SQLException

Example

String properties = "width=123 height=321 compressionformat=NONE 
     userString=DJM dataOffset=128 scanlineOrder=INVERSE 
     pixelOrder=REVERSE interleaving=BIL numberOfBands=1 
     defaultChannelSelection=1";
imgObj.setProperties(properties);

where:


setUpdateTime( )

Format

public void setUpdateTime(java.sql.Timestamp currentTime)

Description

Sets the update time in the application ORDImage object to the current time.

setProperties( ) will automatically set this attribute; use this method only if you are not using setProperties( ). Also, this method will set only the attribute value; it does not change the media file itself.

Parameters

currentTime

The current time, which will be set in the ORDImage object. This value should be NULL; the method will then use the SYSDATE of the database server.

Return Value

None.

Exceptions

java.sql.SQLException

Example

imgObj.setUpdateTime(null);

setWidth( )

Format

public void setWidth(int newWidth)

Description

Sets the width of the application ORDImage object.

setProperties( ) will automatically set this attribute; use this method only if you are not using setProperties( ). Also, this method will set only the attribute value; it does not change the media file itself.

Parameters

newWidth

The width to be set, in pixels.

Return Value

None.

Exceptions

java.sql.SQLException

Example

imgObj.setWidth(24);

where:


Go to previous page Go to next page
Oracle
Copyright © 2000 Oracle Corporation.

All Rights Reserved.

Library

Product

Contents

Index