|
Oracle interMedia Java Classes API Reference 10g Release 1 (10.1) Part No. B12248-01 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
oracle.ord.im.OrdAudio
The OrdAudio class is used to represent an instance of the ORDSYS.ORDAudio database type in a Java application. The OrdAudio class includes a set of methods to get and set various object attributes, plus a set of methods that perform various operations on an OrdAudio Java object.
Users of this class are assumed to be familiar with Oracle interMedia Java Classes User's Guide and Reference and Oracle interMedia User's Guide and Reference.
All methods operate on the attributes of the OrdAudio Java object in the application with the exception of those methods that access the audio data for read or write purposes.
If your application modifies the OrdAudio Java object, or the audio data in the database, you must update the ORDAudio SQL object in the database to make those changes permanent.
Some methods in the OrdAudio Java class are handed off to a database source plug-in or database format plug-in for processing; these methods have byte [] ctx []
as a context parameter. Applications should allocate a 64-byte array to hold any context information that may be required by a source plug-in or a format plug-in. For example, a plug-in may initialize the context information in one call and use that information in a subsequent call. Note that one array is required for source plug-in context and another array is required for format plug-in context. Note that 64 bytes should be sufficient for most plug-ins, however, some user-defined plug-ins may need additional space. The following example illustrates how to allocate a plug-in context information array:
byte [] ctx [] = new byte[1][64];
Constructor Summary | |
OrdAudio() Internal constructor used only by the Oracle ORAData interface factory method to create an instance of the class. |
Method Summary | |
boolean |
checkProperties(byte[][] ctx) Checks if the properties of the audio data are consistent with the attributes of the OrdAudio Java object. |
void |
clearLocal() Clears the local attribute to indicate that the audio data is stored externally. |
int |
closeSource(byte[][] ctx) Closes a data source. |
oracle.sql.CustomDatum |
create(oracle.sql.Datum d, int sqlType) Internal method used only by the Oracle CustomDatum interface. |
void |
deleteContent() Deletes any data stored in the database BLOB specified by the localData attribute. |
void |
export(byte[][] ctx, java.lang.String srcType, java.lang.String srcLocation, java.lang.String srcName) Exports the data from the BLOB specified by the localData attribute. |
oracle.sql.CLOB |
getAllAttributes(byte[][] ctx) Returns the audio properties in a temporary CLOB in a form defined by the format plug-in. |
java.lang.String |
getAttribute(byte[][] ctx, java.lang.String name) Returns the value of the requested audio property. |
int |
getAudioDuration() Returns the audioDuration attribute. |
oracle.sql.BFILE |
getBFILE() Returns a BFILE locator from the database when the srcType attribute is "FILE". |
oracle.sql.CLOB |
getComments() Returns the CLOB locator from the comments attribute. |
java.lang.String |
getCompressionType() Returns the compressionType attribute. |
oracle.sql.BLOB |
getContent() Returns the BLOB locator from the localData attribute. |
oracle.sql.BLOB |
getContentInLob(byte[][] ctx, java.lang.String[] mimetype, java.lang.String[] format) Returns the data from the BLOB specified by the localData attribute in a temporary BLOB in the database. |
int |
getContentLength() Returns the length of the audio data. |
int |
getContentLength(byte[][] ctx) Returns the length of the audio data using source plug-in context information. |
byte[] |
getDataInByteArray() Returns a byte array containing the data from the database BLOB specified by the localData attribute. |
boolean |
getDataInFile(java.lang.String filename) Writes the data from the database BLOB specified by the localData attribute to a local file. |
java.io.InputStream |
getDataInStream() Returns an InputStream from which the data in the database BLOB specified by the localData attribute can be read. |
java.lang.String |
getDescription() Returns the description attribute. |
java.lang.String |
getEncoding() Returns the encoding attribute. |
static oracle.sql.CustomDatumFactory |
getFactory() Deprecated. CustomDatumFactory method. New applications should use the ORADataFactory interface |
java.lang.String |
getFormat() Returns the format attribute. |
java.lang.String |
getMimeType() Returns the mimeType attribute. |
int |
getNumberOfChannels() Returns the numberOfChannels attribute. |
static oracle.sql.ORADataFactory |
getORADataFactory() Returns the OrdAudio ORADataFactory for use by the getORAData method. |
int |
getSampleSize() Returns the sampleSize attribute. |
int |
getSamplingRate() Returns the samplingRate attribute. |
java.lang.String |
getSource() Returns the source information in the form srcType://srcLocation/srcName . |
java.lang.String |
getSourceLocation() Returns the srcLocation attribute. |
java.lang.String |
getSourceName() Returns the srcName attribute. |
java.lang.String |
getSourceType() Returns the srcType attribute. |
java.sql.Timestamp |
getUpdateTime() Returns the updateTime attribute. |
void |
importData(byte[][] ctx) Imports data from an external source into the database BLOB specified by the localData attribute. |
void |
importFrom(byte[][] ctx, java.lang.String srcType, java.lang.String srcLocation, java.lang.String srcName) Imports data from an external source into the database BLOB specified by the localData attribute. |
boolean |
isLocal() Indicates if the audio data is stored locally in the database in a BLOB specified by the localData attribute. |
boolean |
loadDataFromByteArray(byte[] byteArr) Loads data from a byte array into the database BLOB specified by the localData attribute. |
boolean |
loadDataFromFile(java.lang.String filename) Loads data from a file into the database BLOB specified by the localData attribute. |
boolean |
loadDataFromInputStream(java.io.InputStream inpStream) Loads data from an InputStream into the database BLOB specified by the localData attribute. |
int |
openSource(byte[] userarg, byte[][] ctx) Opens a data source. |
byte[] |
processAudioCommand(byte[][] ctx, java.lang.String cmd, java.lang.String args, byte[][] result) Calls the format plug-in in the database to execute a command. |
byte[] |
processSourceCommand(byte[][] ctx, java.lang.String cmd, java.lang.String args, byte[][] result) Calls the source plug-in in the database to execute a command. |
int |
readFromSource(byte[][] ctx, int startpos, int numbytes, byte[][] buffer) Reads data from the data source. |
void |
setAudioDuration(int audioDuration) Sets the audioDuration attribute. |
void |
setComments(oracle.sql.CLOB comments) Sets the comments attribute. |
void |
setCompressionType(java.lang.String compressionType) Sets the compressionType attribute. |
void |
setDescription(java.lang.String description) Sets the description attribute. |
void |
setEncoding(java.lang.String encoding) Sets the encoding attribute. |
void |
setFormat(java.lang.String format) Sets the format attribute. |
void |
setKnownAttributes(java.lang.String format, java.lang.String encoding, int numberOfChannels, int samplingRate, int sampleSize, java.lang.String compressionType, int audioDuration) Sets the known attributes of the OrdAudio Java object. |
void |
setLocal() Sets the local attribute to indicate that the audio data is stored locally in the database in a BLOB specified by the localData attribute. |
void |
setMimeType(java.lang.String mimeType) Sets the mimeType attribute. |
void |
setNumberOfChannels(int numberOfChannels) Sets the numberOfChannels attribute. |
void |
setProperties(byte[][] ctx) Parses the audio data properties and sets the attributes in the OrdAudio Java object. |
void |
setProperties(byte[][] ctx, boolean setComments) Parses the audio data properties, sets the attributes in the OrdAudio Java object, and optionally populates the CLOB specified by the comments attribute. |
void |
setSampleSize(int sampleSize) Sets the sampleSize attribute. |
void |
setSamplingRate(int samplingRate) Sets the samplingRate attribute. |
void |
setSource(java.lang.String srcType, java.lang.String srcLocation, java.lang.String srcName) Sets the srcType, srcLocation, and srcName attributes. |
void |
setUpdateTime(java.sql.Timestamp currentTime) Sets the updateTime attribute. |
int |
trimSource(byte[][] ctx, int newLen) Trims the data to the specified length. |
int |
writeToSource(byte[][] ctx, int startpos, int numbytes, byte[] buffer) Writes data to the data source. |
Constructor Detail |
public OrdAudio()
Method Detail |
public boolean isLocal() throws java.sql.SQLException
true
if the data is stored locally in the database in a BLOB, false
otherwise.public void setLocal() throws java.sql.SQLException
public void clearLocal() throws java.sql.SQLException
public java.lang.String getSourceType() throws java.sql.SQLException
String
.public java.lang.String getSourceLocation() throws java.sql.SQLException
String
.public java.lang.String getSourceName() throws java.sql.SQLException
String
.public java.lang.String getSource() throws java.sql.SQLException
srcType://srcLocation/srcName
.String
.public void setSource(java.lang.String srcType, java.lang.String srcLocation, java.lang.String srcName) throws java.sql.SQLException
srcType
- the source type, for example, "FILE", "HTTP".srcLocation
- the source location, for example, SOUNDS_DIR, www.xyzcosounds.com/films.srcName
- the source name, for example, filmtrack1.aupublic java.sql.Timestamp getUpdateTime() throws java.sql.SQLException
java.sql.Timestamp
.public void setUpdateTime(java.sql.Timestamp currentTime) throws java.sql.SQLException
currentTime
- the update time in a java.sql.Timestamp
, or null
to set the update time to the database server's current SYSDATE time.public oracle.sql.BLOB getContent() throws java.sql.SQLException
oracle.sql.BLOB
.public oracle.sql.BFILE getBFILE() throws java.sql.SQLException
oracle.sql.BFILE
.public int getContentLength() throws java.sql.SQLException
int
.public int getContentLength(byte[][] ctx) throws java.sql.SQLException
ctx
- the source plug-in context information.int
.public java.lang.String getDescription() throws java.sql.SQLException
String
.public void setDescription(java.lang.String description) throws java.sql.SQLException
description
- the new attribute value.public java.lang.String getFormat() throws java.sql.SQLException
String
.public void setFormat(java.lang.String format) throws java.sql.SQLException
setProperties
method for more information on how to initialize the format attribute before calling the setProperties method, and for information on how the setProperties method in the default, Oracle-supplied plug-in, sets the format attribute. Note that calling the setFormat method sets the attribute value only; it does not modify the audio data itself.format
- the new attribute value.public java.lang.String getMimeType() throws java.sql.SQLException
String
.public void setMimeType(java.lang.String mimeType) throws java.sql.SQLException
setProperties
sets this attribute automatically for certain audio formats; use this method only if you are not using setProperties. This method sets the attribute value only; it does not modify the audio data itself.mimeType
- the new attribute value.public oracle.sql.CLOB getComments() throws java.sql.SQLException
oracle.sql.CLOB
.public void setComments(oracle.sql.CLOB comments) throws java.sql.SQLException
setProperties
method.comments
- the new attribute value.public java.lang.String getEncoding() throws java.sql.SQLException
String
.public void setEncoding(java.lang.String encoding) throws java.sql.SQLException
setProperties
sets this attribute automatically for certain audio formats; use this method only if you are not using setProperties. This method sets the attribute value only; it does not modify the audio data itself.encoding
- the new attribute value.public int getNumberOfChannels() throws java.sql.SQLException
int
.public void setNumberOfChannels(int numberOfChannels) throws java.sql.SQLException
setProperties
sets this attribute automatically for certain audio formats; use this method only if you are not using setProperties. This method sets the attribute value only; it does not modify the audio data itself.numberOfChannels
- the new attribute value.public int getSamplingRate() throws java.sql.SQLException
int
.public void setSamplingRate(int samplingRate) throws java.sql.SQLException
setProperties
sets this attribute automatically for certain audio formats; use this method only if you are not using setProperties. This method sets the attribute value only; it does not modify the audio data itself.samplingRate
- the new attribute value.public int getSampleSize() throws java.sql.SQLException
int
.public void setSampleSize(int sampleSize) throws java.sql.SQLException
setProperties
sets this attribute automatically for certain audio formats; use this method only if you are not using setProperties. This method sets the attribute value only; it does not modify the audio data itself.sampleSize
- the new attribute value.public java.lang.String getCompressionType() throws java.sql.SQLException
int
.public void setCompressionType(java.lang.String compressionType) throws java.sql.SQLException
setProperties
sets this attribute automatically for certain audio formats; use this method only if you are not using setProperties. This method sets the attribute value only; it does not modify the audio data itself.compressionType
- the new attribute value.public int getAudioDuration() throws java.sql.SQLException
int
.public void setAudioDuration(int audioDuration) throws java.sql.SQLException
setProperties
sets this attribute automatically for certain audio formats; use this method only if you are not using setProperties. This method sets the attribute value only; it does not modify the audio data itself.audioDuration
- the new attribute value.public boolean loadDataFromFile(java.lang.String filename) throws java.sql.SQLException, java.io.IOException
deleteContent()
, to delete any existing data in the BLOB.setLocal()
, to set the local flag.setUpdateTime()
, to set the updateTime attribute to the database server's current SYSDATE time.filename
- name of the file from which to load data.true
if the data is loaded successfully; otherwise, an exception is raised if an error occurs. This method never returns false
.public boolean loadDataFromInputStream(java.io.InputStream inpStream) throws java.sql.SQLException, java.io.IOException
deleteContent()
, to delete any existing data in the BLOB.setLocal()
, to set the local flag.setUpdateTime()
, to set the updateTime attribute to the database server's current SYSDATE time.inpStream
- the InputStream
from which to load data.true
if the data is loaded successfully; otherwise, an exception is raised if an error occurs. This method never returns false
.public boolean loadDataFromByteArray(byte[] byteArr) throws java.sql.SQLException, java.io.IOException
deleteContent()
, to delete any existing data in the BLOB.setLocal()
, to set the local flag.setUpdateTime()
, to set the updateTime attribute to the database server's current SYSDATE time.byteArr
- a byte[]
arrary from which to load data.true
if the data is loaded successfully; otherwise, an exception is raised if an error occurs. This method never returns false
.public boolean getDataInFile(java.lang.String filename) throws java.sql.SQLException, java.io.IOException
filename
- name of the file to which the data is to be written.true
if the data is written to the file successfully; otherwise, an exception is raised if an error occurs. This method never returns false
.public java.io.InputStream getDataInStream() throws java.sql.SQLException
InputStream
from which the data can be read.public byte[] getDataInByteArray() throws java.sql.SQLException, java.io.IOException, java.lang.OutOfMemoryError
byte[]
array containng the data.public oracle.sql.BLOB getContentInLob(byte[][] ctx, java.lang.String[] mimetype, java.lang.String[] format) throws java.sql.SQLException
ctx
- the format plug-in context information.mimetype
- a String[]
array, 1 element in length, into which the mimeType attribute is written as element 0.format
- a String[]
array, 1 element in length, into which the format attribute is written as element 0.oracle.sql.BLOB
.public void deleteContent() throws java.sql.SQLException
public void importData(byte[][] ctx) throws java.sql.SQLException
ctx
- the source plug-in context information.public void importFrom(byte[][] ctx, java.lang.String srcType, java.lang.String srcLocation, java.lang.String srcName) throws java.sql.SQLException
ctx
- the source plug-in context information.srcType
- the source type, for example, "FILE", "HTTP".srcLocation
- the source location, for example, SOUNDS_DIR, www.xyzcosounds.com/films.srcName
- the source name, for example, filmtrack1.au.public void export(byte[][] ctx, java.lang.String srcType, java.lang.String srcLocation, java.lang.String srcName) throws java.sql.SQLException
Not all source plug-ins support the export method. For example, the "FILE" source type is the only Oracle-supplied source type that supports the export method. In addition, this method is supported only by Oracle database server release 8.1.7 or later.
The remainder of this description illustrates the use of the export method and the Oracle-supplied "FILE" source plug-in. User-written plug-ins will have different behaviors.
The export method implemented by the Oracle-supplied "FILE" source plug-in copies the audio data from the BLOB specified by the localData attribute, but does not modify the audio data stored in the database BLOB in any way.
After exporting the audio data, all the audio property attributes remain unchanged, however, the srcType, srcLocation, and srcName attributes are updated with values of the srcType, srcLocation, and srcName parameters passed to the export method. After calling the export method, if you no longer intend to manage the audio data within the database, call the clearLocal()
method to indicate the audio data is stored outside the database and call the deleteContent()
method to delete the audio data stored in the database BLOB.
The export method in the database writes only to a database directory object that the user has privilege 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. To execute the CREATE DIRECTORY statement, you must have the CREATE ANY DIRECTORY privilege. In addition, you must use the DBMS_JAVA.GRANT_PERMISSION method to specify which files can be written.
For example, the following SQL*Plus command grants the user, MEDIAUSER
, the permission to write to the file named filmtrack1.au
.
CALL DBMS_JAVA.GRANT_PERMISSION( 'MEDIAUSER', 'java.io.FilePermission', '/audio/movies/filmtrack1.au', 'write');
The previous example illustrates how to authorize access to write to a single file. In addition, there are various wildcard path specifications that authorize write access to multiple directories and file names. For example, a path specification that ends in "/*"
(where "/"
is the operating-system dependent file separator character) indicates all the files contained in the specified directory. A path specification that ends with "/-"
indicates all files contained in the specified directory and all its subdirectories. A pathname consisting of the special token "<<ALL FILES>>"
authorizes access to any file.
See the security and performance section in Oracle Java Developer's Guide and the java.io.FilePermission class in the Java API for more information.
ctx
- the source plug-in context information.srcType
- the source type, for example, "FILE".srcLocation
- the source location, for example, SOUNDS_DIR.srcName
- the source name, for example, filmtrack1.au.public void setProperties(byte[][] ctx) throws java.sql.SQLException
ctx
- the format plug-in context information.public void setProperties(byte[][] ctx, boolean setComments) throws java.sql.SQLException
setComments
is true, this method also populates the CLOB specified by the comments attribute with all extracted properties in XML form. If setComments
is false, the comments attribute is not modified. This method throws a SQLException if the audio format is not recognized.
ctx
- the format plug-in context information.setComments
- a boolean
that specifies whether or not to populate the CLOB specified by the comments attribute.public boolean checkProperties(byte[][] ctx) throws java.sql.SQLException
ctx
- the format plug-in context information.true
if the properties of the audio data are consistent with the attributes of the OrdAudio Java object; false
otherwise.public java.lang.String getAttribute(byte[][] ctx, java.lang.String name) throws java.sql.SQLException
ctx
- the format plug-in context information.name
- the property or attribute name.String
.public oracle.sql.CLOB getAllAttributes(byte[][] ctx) throws java.sql.SQLException
attributeName=attributeValue
, where the list contains the following attributes: format, mimeType, encoding, numberOfChannels, samplingRate, sampleSize, compressionType, and audioDuration. For user-defined formats, the information is presented in a form defined by the format plug-in.
ctx
- the format plug-in context information.oracle.sql.CLOB
.public void setKnownAttributes(java.lang.String format, java.lang.String encoding, int numberOfChannels, int samplingRate, int sampleSize, java.lang.String compressionType, int audioDuration) throws java.sql.SQLException
setProperties
sets the following attributes automatically for certain audio formats: format, encoding, numberOfChannels, samplingRate, sampleSize, compressionType, and audioDuration; use this method only if you are not using setProperties. This method sets the specified attribute values only; it does not modify the audio data itself.format
- the new attribute value as a String
.encoding
- the new attribute value as a String
.numberOfChannels
- the new attribute value as an int
.samplingRate
- the new attribute value as an int
.sampleSize
- the new attribute value as an int
.compressionType
- the new attribute value as a String
.audioDuration
- the new attribute value as an int
.public byte[] processAudioCommand(byte[][] ctx, java.lang.String cmd, java.lang.String args, byte[][] result) throws java.sql.SQLException
ctx
- the format plug-in context information.cmd
- the command to be executed by the format plug-in.args
- the command arguments.result
- a byte[][]
array of the form [1][n
] into which the result of the command execution is written.public int openSource(byte[] userarg, byte[][] ctx) throws java.sql.SQLException
userarg
- additional source plug-in information that may be required by user-defined source plug-ins.ctx
- the source plug-in context information.int
, where 0 indicates success and a non-0 value indicates a failure code specific to the source plug-in.public int closeSource(byte[][] ctx) throws java.sql.SQLException
ctx
- the source plug-in context information.int
, where 0 indicates success and a non-0 value indicates a failure code specific to the source plug-in.public int readFromSource(byte[][] ctx, int startpos, int numbytes, byte[][] buffer) throws java.sql.SQLException
Not all source plug-ins require that the data source be opened before it can be read. However, if you call the openSource
method before calling readFromSource, your application should work with any current or future source plug-ins.
ctx
- the source plug-in context information.startpos
- the start position in the data source.numbytes
- the number of bytes to read from the data source.buffer
- a byte[][]
array of the form [1][n
], where n
>= numbytes
int
.public int writeToSource(byte[][] ctx, int startpos, int numbytes, byte[] buffer) throws java.sql.SQLException
Not all source plug-ins support write operations. For example, applications can write to a BLOB specified by the localData attribute; however, the "FILE" and "HTTP" source types do not support writable data sources and so do not support this method. Furthermore, those source plug-ins that do support write access may support only sequential write access and may not support write access to arbitrary starting positions within the data source.
Not all source plug-ins require that the data source be opened before it can be written. However, if you call the openSource
method before calling writeToSource, your application should work with any current or future source plug-ins.
ctx
- the source plug-in context information.startpos
- the start position in the data source.numbytes
- the number of bytes to write to the data source.buffer
- a byte[]
array containing the data to be written.int
.public int trimSource(byte[][] ctx, int newLen) throws java.sql.SQLException
Not all source plug-ins support trim operations. For example, applications can trim the data stored in a BLOB specified by the localData attribute; however, the "FILE" and "HTTP" source types do not support writable data sources and so do not support this method. Furthermore, those source plug-ins that do support write access may not support the trim operation.
Not all source plug-ins require that the data source be opened before it can be modified. However, if you call the openSource
method before calling trimSource, your application should work with any current or future source plug-ins.
ctx
- the source plug-in context information.new
- the length to which the data is to be trimmed.int
, where 0 indicates success and a non-0 value indicates a failure code specific to the source plug-in.public byte[] processSourceCommand(byte[][] ctx, java.lang.String cmd, java.lang.String args, byte[][] result) throws java.sql.SQLException
ctx
- the source plug-in context information.cmd
- the command to be executed by the source plug-in.args
- the command arguments.result
- a byte[][]
array of the form [1][n
] into which the result of the command execution is written.public static oracle.sql.ORADataFactory getORADataFactory()
OrdAudio aud = (OrdAudio)rset.getORAData( 1, OrdAudio.getORADataFactory() );
public static oracle.sql.CustomDatumFactory getFactory()
public oracle.sql.CustomDatum create(oracle.sql.Datum d, int sqlType) throws java.sql.SQLException
|
Oracle interMedia Java Classes API Reference 10g Release 1 (10.1) Part No. B12248-01 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |