Oracle interMedia Java Classes User's Guide and Reference Release 9.0.1 Part Number A88785-01 |
|
interMedia Java Classes describes the OrdDoc object type, which supports the storage and management of any multimedia data, including audio, image, text, and video data.
Some methods invoked at the OrdDoc level are handed off to the database source plug-in or database format plug-in for processing; these methods 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 Oracle interMedia User's Guide and Reference for more information about plug-ins.
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 OrdDoc objects.
public void clearLocal( )
Clears the source local field of the application OrdDoc object.
None.
None.
java.sql.SQLException
docObj.clearLocal( )
public int closeSource(byte[ ] ctx[ ])
Closes the application OrdDoc file source.
The source plug-in context information.
This method returns 0 if the operation is successful, or an integer greater than 0 in case of failure.
java.sql.SQLException
byte[ ] ctx[ ] = new byte[4000][1]; int i = docObj.closeSource(ctx); if(i == 0) System.out.println("Source close successful"); else System.out.println("Source close unsuccessful");
where:
public void deleteContent( )
Deletes the multimedia data in the BLOB in the application OrdDoc object.
None.
None.
java.sql.SQLException
docObj.deleteContent( );
public void export (byte[ ] ctx[ ], String sourceType, String sourceLocation, String sourceName)
Exports the data from the application OrdDoc object BLOB to the location specified in the parameters.
This method will work only if you are running Oracle database server release 8.1.7 or later.
This method writes only to a directory object that the user has privileges to access. That is, you can access a directory that you have created using the SQL CREATE DIRECTORY statement, or one to which you have been granted READ access. See Oracle interMedia User's Guide and Reference for more information about the required privileges.
The source plug-in 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. It must be created with a SQL CREATE OR REPLACE DIRECTORY statement, as shown in step 2 of Example 2-19.
The name of the source to which the content will be exported.
None.
java.sql.SQLException
byte[ ] ctx[ ] = new byte[4000][1]; docObj.export(ctx,"file","DOCDIR","complete.xml");
where:
public oracle.sql.BFILE getBFILE( )
Generate a BFILE from the application OrdDoc object, if the value of srcType is "file." This method uses the srcLocation and srcName attributes to generate the BFILE.
None.
This method returns the BFILE.
java.sql.SQLException
BFILE documentBFILE = docObj.getBFILE( );
public oracle.sql.CLOB getComments( )
Returns the comments CLOB from the application OrdDoc object.
None.
This method returns a CLOB that contains the comments from the OrdDoc object.
java.sql.SQLException
CLOB comments = docObj.getComments( )
public oracle.sql.BLOB getContent( )
Gets the LOB locator from the application OrdDoc object.
None.
This method returns the LOB locator of the application OrdDoc object.
java.sql.SQLException
BLOB localContent = docObj.getContent( );
public BLOB getContentInLob(byte[ ] ctx[ ], String mimetype[ ], String format[ ])
Gets the content of the application OrdDoc object and puts it in a BLOB.
The source plug-in context information.
The MIME type of the content returned, stored in mimetype[0].
The format of the content returned, stored in format[0].
This method returns the LOB content of the application OrdDoc object in a LOB locator.
java.sql.SQLException
byte[ ] ctx[ ] = new byte[4000][1]; String mimeType[ ] = new String[1]; String format[ ] = new String[1]; BLOB localContent = docObj.getContentInLob(ctx,mimeType,format);
where:
public int getContentLength( )
Gets the content length of the data in the application OrdDoc object.
None.
This method returns the content length of the data.
java.sql.SQLException
int contentLength = docObj.getContentLength( );
public byte[ ] getDataInByteArray( )
Gets data from the LOB locator of the application OrdDoc 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 = docObj.getDataInByteArray( );
public boolean getDataInFile(String filename)
Gets data from the LOB locator of the application OrdDoc object and puts it in a local file.
The name of 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 = docObj.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 OrdDoc object and returns it as a local input stream.
None.
This method returns the input stream from which the data will be read.
java.sql.SQLException
java.io.IOException
InputStream inpStream = docObj.getDataInStream( );
public String getFormat( )
Gets the format attribute of the application OrdDoc object as a String.
None.
This method returns the format attribute as a String.
java.sql.SQLException
String format = docObj.getFormat( );
public String getMimeType( )
Gets the MIME type of the application OrdDoc object as a String.
None.
This method returns the MIME type of the OrdDoc object as a String.
java.sql.SQLException
String mimeType = docObj.getMimeType( );
public String getSource( )
Gets the object source information of the application OrdDoc object, including the source location, name, and type.
None.
This method returns a String containing the object source information.
java.sql.SQLException
String source = docObj.getSource( );
public String getSourceLocation( )
Gets the source location of the application OrdDoc object as a String.
None.
This method returns a String containing the object source location.
java.sql.SQLException
String location = docObj.getSourceLocation( );
public String getSourceName( )
Gets the source name of the application OrdDoc object as a String.
None.
This method returns a String containing the object source name.
java.sql.SQLException
String name = docObj.getSourceName( );
public String getSourceType( )
Gets the source type of the application OrdDoc object as a String.
None.
This method returns a String containing the object source type.
java.sql.SQLException
String type = docObj.getSourceType( );
public java.sql.Timestamp getUpdateTime( )
Gets a Timestamp object that contains information on when the application OrdDoc 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 = docObj.getUpdateTime( );
public void importData(byte[ ] ctx[ ])
Imports data from an external source into the application OrdDoc object.
The srcType, srcLocation, and srcName attributes must all be set for this method to work. If srcType is "file," then srcLocation and srcName are values of a file local to the server.
The source plug-in context information.
None.
java.sql.SQLException
byte[ ] ctx[ ] = new byte[4000][1]; docObj.importData(ctx);
where:
public void importFrom(byte[ ] ctx[ ], String sourceType, String sourceLocation, String sourceName)
Imports data from an external source into the application OrdDoc object.
The source plug-in context information. See Oracle interMedia User's Guide and Reference for more information.
The source type from which the data will be imported.
The source location on the database server from which the data will be imported. If sourceType is "file," the directory must be created with a SQL CREATE OR REPLACE DIRECTORY statement, as shown in step 2 of Example 2-19.
The source name from which the data will be imported.
None.
java.sql.SQLException
byte[ ] ctx[ ] = new byte[4000][1]; docObj.importFrom("file","DOCDIR","testdoc.dat");
where:
public boolean isLocal( )
Checks if the application OrdDoc object local attribute is set.
None.
This method returns true if the OrdDoc object local attribute is set; false otherwise.
java.sql.SQLException
if(docObj.isLocal( )) System.out.println("local attribute is set to true"); else System.out.println("local attribute is set to false");
public boolean loadDataFromByteArray(byte[ ] byteArr)
Loads data from the local byte buffer into the database OrdDoc object LOB locator and into the application object. It also calls setLocal( ) (which sets the local field of the application OrdDoc 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 the data will be loaded.
This method returns true if loading is successful; false otherwise.
java.sql.SQLException
java.io.IOException
byte[ ] data = new byte[32000]; FileInputStream fStream = new FileInputStream("testdoc.dat"); fStream.read(data,0,32300); boolean success = docObj.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 OrdDoc object LOB locator and into the application object. It also calls setLocal( ) (which sets the local field of the application OrdDoc 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
docObj.loadDataFromFile("testdoc.dat");
where:
public boolean loadDataFromInputStream(InputStream inpStream)
Loads data from the local input stream into the database OrdDoc object LOB locator and into the application object. It also calls setLocal( ) (which sets the local field of the application OrdDoc 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("testdoc.dat"); docObj.loadDataFromInputStream(fStream);
where:
public int openSource(byte[ ] userarg, byte[ ] ctx[ ])
Opens the OrdDoc file source.
Permission-related parameters that are supplied by the user, such as READONLY. These may be used by user-defined source plug-ins.
The source plug-in context information. See Oracle interMedia User's Guide and Reference for more information.
This method returns 0 if the operation is successful, or an integer greater than 0 in case of failure.
java.lang.Exception
byte[ ] userarg = new byte[4000]; byte[ ] ctx[ ] = new byte[4000][1]; int i = docObj.openSource(userarg,ctx); if(i == 0) System.out.println("openSource successful"); else System.out.println("openSource unsuccessful");
where:
public byte[ ] processSourceCommand(byte[ ] ctx[ ], String command, String args, byte[ ] result[ ])
Processes the specified command on the application OrdDoc object by calling the database processSourceCommand( ) method. This method is for use with user-written plug-ins only; this method will raise an exception if used with the default plug-in supplied by Oracle.
The source plug-in context information. See Oracle interMedia User's Guide and Reference for more information.
The command to be executed. The command must be recognized by the database source plug-in.
The arguments of the command to be executed.
The results of the command.
This method returns the results of executing the command.
java.sql.SQLException
byte[ ] ctx[ ] = new byte[4000][1]; String command; String arguments; byte[ ] result[ ]; //assign a command value to command //assign any arguments to args byte[ ] commandResults = docObj.processSourceCommand(ctx,command, arguments,result);
where:
public int readFromSource(byte[ ] ctx[ ], int startpos, int numbytes, byte[ ] buffer[ ])
Reads data from the OrdSource localData field of the application OrdDoc object. into the first position of the buffer array.
The source plug-in context information. See Oracle interMedia User's Guide and Reference for more information.
The initial position in the localData field.
The number of bytes to be read.
The buffer into which to read the content.
This method returns the number of bytes read.
java.sql.SQLException
byte[ ] ctx[ ] = new byte[4000][1]; byte[ ] buffer[ ] = new byte[12][1]; int i = docObj.readFromSource(ctx,0,12,buffer);
where:
public void setComments(oracle.sql.CLOB comments)
Sets the comments in the application OrdDoc object.
The comments attribute is reserved for use by interMedia. You can set your own value, but it could be overwritten by interMedia Annotator or by the setProperties( ) method.
A CLOB that contains attributes for the OrdDoc object.
None.
java.sql.SQLException
docObj.setComments(commentsData);
where:
public void setContentLength(int newContentLength)
Sets the content length of the data in the application OrdDoc object.
setProperties( ) will automatically set this attribute for known formats; use this method only if you are not using setProperties( ) or for unknown formats. Also, this method will set only the attribute value; it does not change the multimedia 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 OrdDoc object.
setProperties( ) will automatically set this attribute for known formats; use this method only if you are not using setProperties( ) or for unknown formats. Also, this method will set only the attribute value; it does not change the multimedia file itself.
The format of the contents of the OrdDoc object, as a String.
None.
java.sql.SQLException
docObj.setFormat("AUFF");
where:
public void setLocal( )
Sets the source local field of the application OrdDoc object.
None.
None.
java.sql.SQLException
docObj.setLocal( );
public void setMimeType(String MimeType)
Sets the MIME type of the application OrdDoc object.
setProperties( ) will automatically set this attribute for known formats; use this method only if you are not using setProperties( ) or for unknown formats. Also, this method will set only the attribute value; it does not change the multimedia file itself.
The MIME type of the contents of the OrdDoc object, as a String.
None.
java.sql.SQLException
docObj.setMimeType("application/pdf");
where:
public void setProperties(byte[ ] ctx[ ], boolean setComments)
Reads the multimedia data, extracts the properties, and sets the properties in the application OrdDoc object. This method will work for known audio, image, and video formats.
The format plug-in context information.
A boolean value to determine whether or not to set the comments in the OrdDoc object. If true, the comments field is populated with a set of format and application properties of the object in XML. If false, the comments field remains unpopulated. The default value is false.
None.
java.sql.SQLException
byte[ ] ctx[ ] = new byte[4000][1]; docObj.setProperties(ctx,true);
where:
public void setSource(String sourceType, String sourceLocation, String sourceName)
Sets the application OrdDoc object source information.
The type of the source.
The location of the source. If sourceType is "file," it must be created with a SQL CREATE OR REPLACE DIRECTORY statement, as shown in step 2 of Example 2-19.
The name of the source.
None.
java.sql.SQLException
audObj.setSource("file","DOCDIR","sample.pdf");
where:
public void setUpdateTime(java.sql.Timestamp currentTime)
Sets the update time in the application OrdDoc object to the current time.
setProperties( ) will automatically set this attribute for known formats; use this method only if you are not using setProperties( ) or for unknown formats. Also, this method will set only the attribute value; it does not change the multimedia file itself.
The current time, which will be set in the OrdDoc object. Setting this parameter to null will set the update time to the current SYSDATE of the database server.
None.
java.sql.SQLException
docObj.setUpdateTime(null);
public int trimSource(byte[ ] ctx[ ], int newLen)
Trim the content source of the application OrdDoc object to the given length.
The source plug-in context information. See Oracle interMedia User's Guide and Reference for more information.
The length to which the source will be trimmed.
This method returns 0 if the operation is successful.
java.sql.SQLException
byte[ ] ctx[ ] = new byte[4000][1]; int i = docObj.trimSource(ctx,10); if (i == 0) System.out.println("trimSource successful"); else System.out.println("trimSource unsuccessful");
where:
public int writeToSource(byte[ ] ctx[ ], int startpos, int numbytes, byte[ ] buffer)
Writes data to the source localData field of the application OrdDoc object.
The source plug-in context information. See Oracle interMedia User's Guide and Reference for more information.
The initial position in the localData field.
The number of bytes to be written.
The buffer containing the content to be written.
This method returns the number of bytes written.
java.sql.SQLException
byte[ ] ctx[ ] = new byte[4000][1]; byte[ ] data = new byte[20]; //populate data with 20 bytes of content int i = docObj.writeToSource(ctx,1,20,data);
where:
|
Copyright © 1996-2001, Oracle Corporation. All Rights Reserved. |
|