Oracle interMedia Audio, Image, and Video Java Classes User's Guide and Reference Release 8.1.7 Part Number A85374-01 |
|
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.
See Oracle8i interMedia Audio, Image, and Video User's Guide and Reference for more information.
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.
This section presents reference information on the methods that operate on ORDImage objects.
public boolean checkProperties( )
Checks if the properties stored in the media data of the local object are consistent with the attributes of the local object.
None.
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.
java.sql.SQLException
if(imgObj.checkProperties( )) System.out.println("checkProperties successful");
public void clearLocal( )
Clears the source local field of the application ORDImage object.
None.
None.
java.sql.SQLException
imgObj.clearLocal( );
public void copy(OrdImage dest)
Copies image data from the application ORDImage object source to a destination ORDImage object.
The ORDImage object to which the data will be copied.
None.
java.sql.SQLException
//create and populate an object named imgObj2 imgObj.copy(imgObj2);
where
public void deleteContent( )
Deletes the media data in the BLOB in the application ORDImage object.
None.
None.
java.sql.SQLException
audObj.deleteContent( );
public void export (byte[ ] ctx[ ], String sourceType, String sourceLocation, String sourceName)
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.
The source plug-in context information. It is set to NULL if there is no context information.
The source type to which the content will be exported. Only "FILE" is natively supported.
The location on the database server to which the content will be exported.
The source name to which the content will be exported.
None.
java.sql.SQLException
byte[ ] ctx[ ]
= new byte[4000][1];
imgObj.export(ctx,"FILE","IMAGEDIR","image.gif");
where:
public oracle.sql.BFILE getBFILE( )
Gets the BFILE attribute of the application ORDImage object.
None.
This method returns the BFILE.
java.sql.SQLException
BFILE imageBFILE = imgObj.getBFILE( );
public String getCompressionFormat( )
Gets the compression format attribute of the application ORDImage object as a String.
None.
This method returns the compression format attribute, as a String.
java.sql.SQLException
String compression = imgObj.getCompressionFormat( );
public oracle.sql.BLOB getContent( )
Gets the LOB locator from the application ORDImage object.
None.
This method returns the LOB locator of the application object.
java.sql.SQLException
BLOB localContent = imgObj.getContent( );
public String getContentFormat( )
Gets the content format attribute of the application ORDImage object as a String.
None.
This method returns the content format attribute, as a String.
java.sql.SQLException
String format = imgObj.getContentFormat( );
public int getContentLength( )
Gets the content length of the media data in the application ORDImage object.
None.
This method returns the content length of the media data, in bytes.
java.sql.SQLException
int length = imgObj.getContentLength( );
public byte[ ] getDataInByteArray( )
Gets data from the LOB locator of the application ORDImage object and puts it in a local byte array.
None.
This method returns the byte array from which the data will be read.
java.sql.SQLException
java.io.IOException
java.lang.OutOfMemoryError
byte[ ] byteArr = imgObj.getDataInByteArray( );
public boolean getDataInFile(String filename)
Gets data from the LOB locator of the application ORDImage object and puts it in a local file.
The file into which the data will be loaded.
This method returns TRUE if loading is successful; FALSE otherwise.
java.sql.SQLException
java.io.IOException
boolean load = imgObj.getDataInFile("output1.dat"); if(load) System.out.println("getDataInFile completed successfully"); else System.out.println("Error in getDataInFile");
where:
public InputStream getDataInStream( )
Gets data from the LOB locator of the application ORDImage file and puts it in a local input stream.
None.
This method returns the input stream from which the data will be read.
java.sql.SQLException
InputStream inpStream = imgObj.getDataInStream( );
public String getFormat( )
Gets the format attribute of the application ORDImage object as a String.
None.
This method returns the format attribute as a String.
java.sql.SQLException
String format = imgObj.getFormat( );
public int getHeight( )
Gets the height of the application ORDImage object.
None.
This method returns the height of the ORDImage object, in pixels.
java.sql.SQLException
int height = imgObj.getHeight( );
public String getMimeType( )
Gets the MIME type of the application ORDImage object as a String.
None.
This method returns the MIME type of the ORDImage object, as a String.
java.sql.SQLException
String mime = imgObj.getMimeType( );
public String getSource( )
Gets the application ORDImage object source information, including the source location, name, and type.
None.
This method returns a String containing the object source information.
java.sql.SQLException
String sourceName = imgObj.getSource( );
public String getSourceLocation( )
Gets the application ORDImage object source location as a String.
None.
This method returns a String containing the object source location.
java.sql.SQLException
String location = imgObj.getSourceLocation( );
public String getSourceName( )
Gets the application ORDImage object source name as a String.
None.
This method returns a String containing the object source name.
java.sql.SQLException
String name = imgObj.getSourceName( );
public String getSourceType( )
Gets the application ORDImage object source location as a String.
None.
This method returns a String containing the object source type.
java.sql.SQLException
String type = imgObj.getSourceType( );
public java.sql.Timestamp getUpdateTime( )
Gets a Timestamp object that contains information on when the application ORDImage object was most recently updated.
None.
This method returns a Timestamp object that contains the time of the most recent update.
java.sql.SQLException
Timestamp time = imgObj.getUpdateTime( );
public int getWidth( )
Gets the width of the application ORDImage object.
None.
This method returns the width of the ORDImage object, in pixels.
java.sql.SQLException
int width = imgObj.getWidth( );
public void importData(byte[ ] ctx[ ])
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.
The source plug-in context information. It is set to NULL if there is no context information.
None.
java.sql.SQLException
byte[ ] ctx[ ]
= new byte[4000][1];
imgObj.importData(ctx)
where:
public void importFrom(byte[ ] ctx[ ], String sourceType, String sourceLocation, String sourceName)
Imports data from an external source into the application ORDImage object. The location of the external source is of the form:
sourceType://sourceLocation/sourceName
The source plug-in context information. See Chapter 4 of Oracle8i interMedia Audio, Image, and Video User's Guide and Reference for more information.
The source type from which the data will be imported.
The source location from which the data will be imported.
The source name from which the data will be imported.
None.
java.sql.SQLException
byte[ ] ctx[ ]
= new byte[4000][1];
imgObj.importFrom(ctx,"FILE","IMAGEDIR","testimg.dat");
where:
public boolean isLocal( )
Checks if the application ORDImage object local attribute is set.
None.
This method returns TRUE if the ORDImage object local attribute is set; FALSE otherwise.
java.sql.SQLException
if(imgObj.isLocal( )) System.out.println("local attribute is true"); else System.out.println("local attribute is false");
public boolean loadDataFromByteArray(byte[ ] byteArr)
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.
The name of the local byte array from which to load data.
This method returns TRUE if loading is successful; FALSE otherwise.
java.sql.SQLException
java.io.IOException
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:
public boolean loadDataFromFile(String filename)
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.
The name of the local file from which to load data.
This method returns TRUE if loading is successful; FALSE otherwise.
java.sql.SQLException
java.io.IOException
imgObj.loadDataFromFile("testimg.dat");
where:
public boolean loadDataFromInputStream(InputStream inpStream)
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.
The name of the local input stream from which to load data.
This method returns TRUE if loading is successful; FALSE otherwise.
java.sql.SQLException
java.io.IOException
FileInputStream fStream = new FileInputStream("testimg.dat"); imgObj.loadDataFromInputStream(fStream);
where:
public OrdImage( )
Creates an ORDImage object.
This method is the default ORDImage constructor.
None.
None.
None.
None.
public void process(String command)
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.
The command to be executed.
None.
java.sql.SQLException
imgObj.process("fileFormat=JFIF");
where:
public void processCopy(String command, OrdImage dest)
Copies image data from the application ORDImage object to a destination ORDImage object and modifies the copy according to the specified command.
The command to be executed.
The object that will receive the results of the command.
None.
java.sql.SQLException
//create and populate an OrdImage object named imgObj2 imgObj.processCopy("maxScale=32 32, fileFormat= GIFF", imgObj2);
where:
public void setCompressionFormat(String CompressionFormat)
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.
The compression format to be set.
None.
java.sql.SQLException
None.
public void setContentFormat(String ContentFormat)
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.
The content format to be set.
None.
java.sql.SQLException
None.
public void setContentLength(int newContentLength)
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.
The new content length to be set, in bytes.
None.
java.sql.SQLException
None.
public void setFormat(String Format)
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.
The format of the contents of the ORDImage object, as a String.
None.
java.sql.SQLException
None.
public void setHeight(int newHeight)
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.
The new height to be set, in pixels.
None.
java.sql.SQLException
imgObj.setHeight(24);
where:
public void setLocal( )
Sets the source local field of the application ORDImage object.
None
None.
java.sql.SQLException
imgObj.setLocal( );
public void setMimeType(String MimeType)
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.
The MIME type of the contents of the ORDImage object, as a String.
None.
java.sql.SQLException
imgObj.setMimeType("image/bmp");
where:
public void setSource(String sourceType, String sourceLocation, String sourceName)
Sets the application ORDImage object source information.
The type of the source.
The location of the source.
The name of the source.
None.
java.sql.SQLException
imgObj.setSource("FILE","IMAGEDIR","jdoe.gif");
where:
public void setProperties( )
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.
None.
None.
java.sql.SQLException
imgObj.setProperties( );
public void setProperties(String command)
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.
The object attribute values to be set.
None.
java.sql.SQLException
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:
public void setUpdateTime(java.sql.Timestamp currentTime)
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.
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.
None.
java.sql.SQLException
imgObj.setUpdateTime(null);
public void setWidth(int newWidth)
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.
The width to be set, in pixels.
None.
java.sql.SQLException
imgObj.setWidth(24);
where:
|
![]() Copyright © 1996-2000, Oracle Corporation. All Rights Reserved. |
|