Enterprise Information Portal APIs

com.ibm.mm.sdk.common
Class dkResource

java.lang.Object
  |
  +--com.ibm.mm.sdk.common.dkAbstractDataObjectBase
        |
        +--com.ibm.mm.sdk.common.dkDataObject
              |
              +--com.ibm.mm.sdk.common.DKDDOBase
                    |
                    +--com.ibm.mm.sdk.common.DKDDO
                          |
                          +--com.ibm.mm.sdk.common.dkResource
All Implemented Interfaces:
DKConstant, dkDataObjectBase, DKMessageId, dkXDO, dkXDOBase, java.io.Serializable
Direct Known Subclasses:
DKLobICM

public abstract class dkResource
extends DKDDO
implements dkXDO, java.io.Serializable

dkResource: a common abstract class user to represent resources and provides a generic interface to resource object functions. It can represent a simle LOB (large object) or a more complex type defined by user, such as video stream, audio, large text, etc. A resource object consists of a content, usually a LOB (large object), and the meta-data or attributes describing the content. Applications are expected to subclass dkResource to implement more specific resource types. Currently, this class library provides the following subclasses:

See Also:
Serialized Form

Fields inherited from interface com.ibm.mm.sdk.common.DKConstant
    For details, see the class or interface
 
Fields inherited from interface com.ibm.mm.sdk.common.DKMessageId
    For details, see the class or interface
 
Constructor Summary
dkResource(dkDatastore ds, java.lang.String objectType)
          Constructs a resource object for a given object type and the datastore associated with it.
dkResource(dkDatastore ds, java.lang.String objectType, short initialSize)
          Constructs a resource object for a given object type, with an initial number of data-items and the datastore associated with it.
 
Method Summary
 void add()
          Adds or stores the content and meta-data of this resource object into the persistent store.
 void add(java.lang.String aFullFileName)
          Adds or stores the content and meta-data of this resource object into the persistent store with an input file.
 void addExtension(java.lang.String extensionName, dkExtension extensionObj)
          Add the extension to this resource object.
abstract  dkXDO cloneSkeleton()
          Clone this resource with its persistent-identifier only, that is, with its data content set to empty.
abstract  boolean compareData(dkXDO aXDO)
          Compares the content of this object with the content of another resource object.
abstract  void copyData(dkXDO aXDO)
          Replaces the content of this object with the content of another resource object.
 void del()
          Deletes this resource from the persistent store.
 void del(boolean flush)
          Deletes this resource from the persistent store and apply the specified option.
 boolean equals(dkXDOBase aXDOBase)
          Check if this resource is equal to the given resource Each subclass must override this method to provide a specific implemntation appropriate for it.
 int getAffiliatedType()
          Gets the affiliated type of this object.
 java.lang.String getClassName()
          Gets the class name of this object.
abstract  byte[] getContent()
          Gets the content of this object
abstract  void getContentToClientFile(java.lang.String afileName, int fileOption)
          Copies the content of this resource to the specified file
 java.lang.String getContentType()
          Gets the content type of this object.
 dkExtension getExtension(java.lang.String extensionName)
          Gets the extension object with the given name.
 java.lang.String getMimeType()
          Gets the MIME type of this object.
 java.lang.String getOpenHandler()
          Gets the current program name of the executable handler for this object's instance.
 java.lang.Object getOption(int option)
          Gets the value of a specified option The subclass need to override the behaviour of the default implementation of this method.
 int getRank()
          Gets the ranking value of a query.
abstract  boolean isContentChanged()
          Checks if the content of this resource in-memory has changed
abstract  boolean isNull()
          Checks if the content of this resource is null.
 boolean isOpenSynchronous()
          Checks the synchronization property of the current executable handler program.
abstract  boolean isSet()
          Checks if the content of this resource is set
 int length()
          Gets the length of this resource content in memory The subclass need to override the behaviour of the default implementation of this method.
 boolean notEqual(dkXDOBase aXDOBase)
          Check if this resource is not equal to the given resource Each subclass must override this method to provide a specific implemntation appropriate for it.
 void open()
          Unloads the object's content to a client file with a system generated name and then synchronously invoke a default handler against the file.
 void open(java.lang.String afileName)
          Unloads the object's content to the given file name and then synchronously invoke a default handler against the file.
 short protocol()
          Returns the protocol supported by this object.
 void removeExtension(java.lang.String extensionName)
          Removes the extension object with the given name.
 void retrieve()
          Retrieves the meta-data and the content from the persistent store.
 void retrieve(java.lang.String aFullFileName)
          Retrieves the meta-data and the content from the persistent store to memory, but streams the content directly into the specified filename.
 void setAffiliatedType(int affiliatedType)
          Sets the affiliated type for this object.
 void setClassName(java.lang.String className)
          Sets the class name of this object.
 void setClassOpenHandler(java.lang.String ahandler, boolean newSynchronousFlag)
          Sets the executable handler program name and whether this handler should be invoked synchronously or asynchronously for this object class.
abstract  void setContent(byte[] aByteArr)
          Sets the content of this object to the given byte array value.
abstract  void setContentFromClientFile(java.lang.String afileName)
          Replaces the content of this resource in memory with the content obtained from the specified filename.
 void setContentType(java.lang.String contentType)
          Sets the content type for this object.
 void setInstanceOpenHandler(java.lang.String ahandler, boolean newSynchronousFlag)
          Sets the executable handler program name and whether this handler should be invoked synchronously or asynchronously for this object instance.
 void setMimeType(java.lang.String mimeType)
          Sets the MIME type for this object.
abstract  void setNull()
          Sets the content of this resource to null.
 void setOption(int option, java.lang.Object value)
          Sets the value from the specified option.
 void setRank(int aRank)
          Sets the ranking value of a query.
 int size()
          Gets the actual size of this resource content in the persistent store.
 void update()
          Updates the meta-data and content of this resource in the persistent store from the value in-memory.
 void update(java.lang.String aFullFileName)
          Updates the meta-data and content of this resource in the persistent store, but updates the content directly from the content from the specified file name.
 
Methods inherited from class com.ibm.mm.sdk.common.DKDDO
add, add, del, del, fromXML, fromXML, getDatastore, retrieve, retrieve, setDatastore, toXML, update, update
 
Methods inherited from class com.ibm.mm.sdk.common.DKDDOBase
addData, addData, addData, addDataProperty, addDataProperty, addDataProperty, addProperty, addProperty, addProperty, dataCount, dataId, dataId, dataIdsByNameSpace, dataNameSpaceCount, dataPropertyCount, dataPropertyId, getData, getDataByName, getDataByName, getDataName, getDataNameSpace, getDataProperty, getDataPropertyByName, getDataPropertyByName, getDataPropertyByName, getDataPropertyName, getObjectType, getProperty, getPropertyByName, getPropertyName, isDataPropertySet, isDataSet, isNull, isPropertySet, propertyCount, propertyId, setData, setDataName, setDataName, setDataNameSpace, setDataProperty, setDataPropertyName, setNull, setObjectType, setProperty, setPropertyName, updatable
 
Methods inherited from class com.ibm.mm.sdk.common.dkDataObject
getPid, getPidObject, setPid, setPidObject
 
Methods inherited from class com.ibm.mm.sdk.common.dkAbstractDataObjectBase
getParent, getRootObject, setParent, setRootObject
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.ibm.mm.sdk.common.dkXDO
datastore, getDatastore, getPid, getPidObject, setDatastore, setPid, setPidObject
 
Methods inherited from interface com.ibm.mm.sdk.common.dkDataObjectBase
getObjectType, getParent, getRootObject, setParent, setRootObject
 

Constructor Detail

dkResource

public dkResource(dkDatastore ds,
                  java.lang.String objectType)
Constructs a resource object for a given object type and the datastore associated with it.
Parameters:
ds - a datastore object.
objectType - an object-type. Usually it is the entity name defined in this datastore and represented by this class.

dkResource

public dkResource(dkDatastore ds,
                  java.lang.String objectType,
                  short initialSize)
Constructs a resource object for a given object type, with an initial number of data-items and the datastore associated with it.
Parameters:
ds - a datastore object.
objectType - an object-type. Usually it is the entity name defined in this datastore and represented by this class.
initialSize - the number of data-items initially allocated in this object.
Method Detail

setNull

public abstract void setNull()
Sets the content of this resource to null.
Specified by:
setNull in interface dkXDOBase

isNull

public abstract boolean isNull()
Checks if the content of this resource is null.
Specified by:
isNull in interface dkXDOBase
Returns:
true if the content is null; false otherwise.

equals

public boolean equals(dkXDOBase aXDOBase)
               throws DKException
Check if this resource is equal to the given resource Each subclass must override this method to provide a specific implemntation appropriate for it.
Specified by:
equals in interface dkXDOBase
Parameters:
aXDOBase - an instance of dkXDOBase
Returns:
true if these resources are equal false otherwise.
Throws:
DKException, - Exception If error occurred

notEqual

public boolean notEqual(dkXDOBase aXDOBase)
                 throws DKException
Check if this resource is not equal to the given resource Each subclass must override this method to provide a specific implemntation appropriate for it.
Specified by:
notEqual in interface dkXDOBase
Parameters:
aXDOBase - an instance of dkXDOBase
Returns:
true if these resources are equal false otherwise.
Throws:
DKException, - Exception If error occurred

add

public void add()
         throws DKException,
                java.lang.Exception
Adds or stores the content and meta-data of this resource object into the persistent store.

If the content is not available, then only the meta-data is created. The content can be added later.

Note:DKUsageError exception thrown if method is not implemented

Specified by:
add in interface dkXDO
Overrides:
add in class DKDDO
Throws:
DKException, - Exception If error occurred

add

public void add(java.lang.String aFullFileName)
         throws DKException,
                java.lang.Exception
Adds or stores the content and meta-data of this resource object into the persistent store with an input file.

If the content is stored directly from the input file into the persistent store.

Note:DKUsageError exception thrown if method is not implemented

Specified by:
add in interface dkXDO
Parameters:
aFullFileName - a fully qualified path and file name, The default is in the current directory
Throws:
DKException, - Exception If error occurred

retrieve

public void retrieve()
              throws DKException,
                     java.lang.Exception
Retrieves the meta-data and the content from the persistent store.
Specified by:
retrieve in interface dkXDO
Overrides:
retrieve in class DKDDO
Throws:
DKException, - Exception If error occurred

retrieve

public void retrieve(java.lang.String aFullFileName)
              throws DKException,
                     java.lang.Exception
Retrieves the meta-data and the content from the persistent store to memory, but streams the content directly into the specified filename.
Specified by:
retrieve in interface dkXDO
Parameters:
aFullFileName - a fully qualified path and file name, The default is in the current directory
Throws:
DKException, - Exception If error occurred

update

public void update()
            throws DKException,
                   java.lang.Exception
Updates the meta-data and content of this resource in the persistent store from the value in-memory.

Note:DKUsageError exception thrown if method is not implemented

Specified by:
update in interface dkXDO
Overrides:
update in class DKDDO
Throws:
DKException, - Exception If error occurred

update

public void update(java.lang.String aFullFileName)
            throws DKException,
                   java.lang.Exception
Updates the meta-data and content of this resource in the persistent store, but updates the content directly from the content from the specified file name.

Note:DKUsageError exception thrown if method is not implemented

Specified by:
update in interface dkXDO
Parameters:
aFullFileName - a fully qualified path and file name, The default is in the current directory
Throws:
DKException, - Exception If error occurred

del

public void del()
         throws DKException,
                java.lang.Exception
Deletes this resource from the persistent store. The in-memory copy is not changed.

Note:DKUsageError exception thrown if method is not implemented

Specified by:
del in interface dkXDO
Overrides:
del in class DKDDO
Throws:
DKException, - Exception If error occurred

del

public void del(boolean flush)
         throws DKException,
                java.lang.Exception
Deletes this resource from the persistent store and apply the specified option.

Note:DKUsageError exception thrown if method is not implemented

Specified by:
del in interface dkXDO
Parameters:
flush - if true the memory content will be flush, if false and content is not set, the object will be retrieved before delete it. The default is to flush.
Throws:
DKException, - Exception If error occurred

getContentToClientFile

public abstract void getContentToClientFile(java.lang.String afileName,
                                            int fileOption)
                                     throws DKException,
                                            java.lang.Exception
Copies the content of this resource to the specified file
Specified by:
getContentToClientFile in interface dkXDO
Parameters:
afileName - a fully qualified path with file name, default is current directory(if no path)
fileOption -
  • DK_CM_XDO_FILE_OVERWRITE create or overwrite an existing file
  • DK_CM_XDO_FILE_NOOVERWRITE only create file, but throw an exception if the file already exists
  • DK_CM_XDO_FILE_APPEND appends to an existing file
Throws:
DKException, - Exception If error occurred

setContentFromClientFile

public abstract void setContentFromClientFile(java.lang.String afileName)
                                       throws DKException
Replaces the content of this resource in memory with the content obtained from the specified filename.
Specified by:
setContentFromClientFile in interface dkXDO
Parameters:
afileName - a fully qualified path with file name, if no path, the default is in the current directory
Throws:
DKException - If error occurred

isContentChanged

public abstract boolean isContentChanged()
Checks if the content of this resource in-memory has changed
Specified by:
isContentChanged in interface dkXDO
Returns:
true if the content is changed; false otherwise.

isSet

public abstract boolean isSet()
Checks if the content of this resource is set
Specified by:
isSet in interface dkXDO
Returns:
true if the content is set; false otherwise.

copyData

public abstract void copyData(dkXDO aXDO)
                       throws DKException,
                              java.lang.Exception
Replaces the content of this object with the content of another resource object.
Specified by:
copyData in interface dkXDO
Parameters:
aXDO - the other XDO object
Throws:
DKException, - Exception If error occurred

compareData

public abstract boolean compareData(dkXDO aXDO)
                             throws DKException,
                                    java.lang.Exception
Compares the content of this object with the content of another resource object.
Specified by:
compareData in interface dkXDO
Parameters:
aXDO - the other XDO object
Returns:
true if content of this object is equal. Otherwise false.
Throws:
DKException, - Exception If object type is different

protocol

public short protocol()
Returns the protocol supported by this object.
Specified by:
protocol in interface dkXDOBase
Overrides:
protocol in class DKDDO
Returns:
the protocol "DK_CM_RESOURCE"

size

public int size()
         throws DKException,
                java.lang.Exception
Gets the actual size of this resource content in the persistent store.

Note:DKUsageError exception thrown if method is not implemented

Specified by:
size in interface dkXDO
Returns:
a byte length of this resource content in the persistent store.

length

public int length()
           throws DKException,
                  java.lang.Exception
Gets the length of this resource content in memory The subclass need to override the behaviour of the default implementation of this method.

Note:DKUsageError exception thrown if method is not implemented

Specified by:
length in interface dkXDO
Returns:
a byte length of this resource content in memory.

cloneSkeleton

public abstract dkXDO cloneSkeleton()
                             throws DKUsageError,
                                    java.lang.Exception
Clone this resource with its persistent-identifier only, that is, with its data content set to empty.
Specified by:
cloneSkeleton in interface dkXDO
Returns:
the new resource

getAffiliatedType

public int getAffiliatedType()
                      throws DKException,
                             java.lang.Exception
Gets the affiliated type of this object. An affiliated type could be ANNOTATION, NOTES, etc. The subclass need to override the behaviour of the default implementation of this method.
Specified by:
getAffiliatedType in interface dkXDO
Returns:
the affiliated type for this object, for example: DK_CM_ANNOTATION, DK_CM_NOTE, etc.

setAffiliatedType

public void setAffiliatedType(int affiliatedType)
                       throws DKException,
                              java.lang.Exception
Sets the affiliated type for this object. The subclass need to override the behaviour of the default implementation of this method.

Note:DKUsageError exception thrown if method is not implemented

Specified by:
setAffiliatedType in interface dkXDO
Parameters:
affiliatedType - the affiliated type
See Also:
getAffiliatedType()

getMimeType

public java.lang.String getMimeType()
                             throws DKException,
                                    java.lang.Exception
Gets the MIME type of this object. The subclass need to override the behaviour of the default implementation of this method.
Specified by:
getMimeType in interface dkXDO
Returns:
the MIME type for this object,

setMimeType

public void setMimeType(java.lang.String mimeType)
                 throws DKException,
                        java.lang.Exception
Sets the MIME type for this object. The subclass need to override the behaviour of the default implementation of this method.

Note:DKUsageError exception thrown if method is not implemented

Specified by:
setMimeType in interface dkXDO
Parameters:
mimeType - the MIME type
See Also:
getMimeType()

getContentType

public java.lang.String getContentType()
                                throws DKException,
                                       java.lang.Exception
Gets the content type of this object. A content type could be ASCII, JPG, AVI, GIF, HTML, etc The subclass need to override the behaviour of the default implementation of this method.
Specified by:
getContentType in interface dkXDO
Returns:
the content type for this object. If not supported empty string is returned. This is the default.

setContentType

public void setContentType(java.lang.String contentType)
                    throws DKException,
                           java.lang.Exception
Sets the content type for this object. The subclass need to override the behaviour of the default implementation of this method.

Note:DKUsageError exception thrown if method is not implemented

Specified by:
setContentType in interface dkXDO
Parameters:
contentType - the content type
See Also:
getContentType()

addExtension

public void addExtension(java.lang.String extensionName,
                         dkExtension extensionObj)
                  throws DKException,
                         java.lang.Exception
Add the extension to this resource object. The extension has an identifier and the corresponding object that implements the extension functions.

Note:DKUsageError exception thrown if method is not implemented

Specified by:
addExtension in interface dkXDO
Parameters:
extensionName - the extension name
extensionObj - a source extension object
Throws:
DKException, - Exception If error occurred
See Also:
#removeExtension(java.lang.String,com.ibm.mm.sdk.common.dkExtension)

removeExtension

public void removeExtension(java.lang.String extensionName)
                     throws DKException
Removes the extension object with the given name.

Note:DKUsageError exception thrown if method is not implemented

Specified by:
removeExtension in interface dkXDO
Parameters:
extensionName - the extension name
Throws:
DKException - If error occurred
See Also:
addExtension(java.lang.String,com.ibm.mm.sdk.common.dkExtension)

getExtension

public dkExtension getExtension(java.lang.String extensionName)
                         throws DKException,
                                java.lang.Exception
Gets the extension object with the given name.

Note:DKUsageError exception thrown if method is not implemented

Specified by:
getExtension in interface dkXDO
Parameters:
extensionName - the extension name
Returns:
a dkExtension object
Throws:
DKException, - Exception If error occurred
See Also:
addExtension(java.lang.String,com.ibm.mm.sdk.common.dkExtension)

getContent

public abstract byte[] getContent()
                           throws DKException,
                                  java.lang.Exception
Gets the content of this object
Specified by:
getContent in interface dkXDO
Returns:
the object content as a byte array stream
Throws:
DKException, - Exception If a problem is encountered.

setContent

public abstract void setContent(byte[] aByteArr)
                         throws DKException
Sets the content of this object to the given byte array value.
Specified by:
setContent in interface dkXDO
Parameters:
aByteArr - a byte array
Throws:
DKException - If a problem is encountered.

getOption

public java.lang.Object getOption(int option)
                           throws DKException,
                                  java.lang.Exception
Gets the value of a specified option The subclass need to override the behaviour of the default implementation of this method.

Note:DKUsageError exception thrown if method is not implemented

Specified by:
getOption in interface dkXDO
Parameters:
option - a specified option
Returns:
the object contains the option value
Throws:
DKException, - Exception If a problem is encountered.

setOption

public void setOption(int option,
                      java.lang.Object value)
               throws DKException,
                      java.lang.Exception
Sets the value from the specified option. The subclass need to override the behaviour of the default implementation of this method.

Note:DKUsageError exception thrown if method is not implemented

Specified by:
setOption in interface dkXDO
Parameters:
option - a specified option
value - an object contains the option value
Throws:
DKException, - Exception If a problem is encountered.

setRank

public void setRank(int aRank)
Sets the ranking value of a query. If not supported rank is zero.
Specified by:
setRank in interface dkXDO
Parameters:
aRank - a ranking value

getRank

public int getRank()
Gets the ranking value of a query. If not supported rank is zero.
Specified by:
getRank in interface dkXDO
Returns:
a ranking value

open

public void open()
          throws DKException,
                 java.lang.Exception
Unloads the object's content to a client file with a system generated name and then synchronously invoke a default handler against the file. The executable handler program name must be set before calling this method. A handler is a program which knows how to process the file, it could be simply a text editor or a viewer for a particular content type.

Note:DKUsageError exception thrown if method is not implemented

Specified by:
open in interface dkXDOBase
Throws:
DKException, - Exception If error occurred

open

public void open(java.lang.String afileName)
          throws DKException,
                 java.lang.Exception
Unloads the object's content to the given file name and then synchronously invoke a default handler against the file. The executable handler program name must be set before calling this method. A handler is a program which knows how to process the file, it could be simply a text editor or a viewer for a particular content type.

Note:DKUsageError exception thrown if method is not implemented

Specified by:
open in interface dkXDOBase
Parameters:
afileName - a provided file name
Throws:
DKException, - Exception If error occurred
See Also:
open()

setInstanceOpenHandler

public void setInstanceOpenHandler(java.lang.String ahandler,
                                   boolean newSynchronousFlag)
Sets the executable handler program name and whether this handler should be invoked synchronously or asynchronously for this object instance. The method setClassOpenHandler(String, boolean) sets the handler for the whole class, instead of only for this instance.
Specified by:
setInstanceOpenHandler in interface dkXDOBase
Parameters:
ahandler - the handler program name to view the content. It could be simply a text editor or a specific viewer for this content type.
newSynchronousFlag - true for synchronous process; false otherwise.
See Also:
setClassOpenHandler(java.lang.String,boolean)

setClassOpenHandler

public void setClassOpenHandler(java.lang.String ahandler,
                                boolean newSynchronousFlag)
Sets the executable handler program name and whether this handler should be invoked synchronously or asynchronously for this object class. The method setInstanceOpenHandler(String, boolean) sets the handler for the instance only, instead of for the whole class.
Specified by:
setClassOpenHandler in interface dkXDOBase
Parameters:
ahandler - the handler program name to view the content. It could be simply a text editor or a specific viewer for this content type.
ahandler - the handler program name to view the content
newSynchronousFlag - true for synchronous process; false otherwise.
See Also:
setInstanceOpenHandler(java.lang.String,boolean)

getOpenHandler

public java.lang.String getOpenHandler()
Gets the current program name of the executable handler for this object's instance.
Specified by:
getOpenHandler in interface dkXDOBase
Returns:
the handler program name. This will return an empty string by default.
See Also:
setInstanceOpenHandler(java.lang.String,boolean)

isOpenSynchronous

public boolean isOpenSynchronous()
Checks the synchronization property of the current executable handler program.
Specified by:
isOpenSynchronous in interface dkXDOBase
Returns:
true if it operates synchronously, or false otherwise
See Also:
setInstanceOpenHandler(java.lang.String,boolean), setClassOpenHandler(java.lang.String,boolean)

getClassName

public java.lang.String getClassName()
                              throws DKException,
                                     java.lang.Exception
Gets the class name of this object.
Specified by:
getClassName in interface dkXDO
Returns:
the class name

setClassName

public void setClassName(java.lang.String className)
                  throws DKException,
                         java.lang.Exception
Sets the class name of this object.
Specified by:
setClassName in interface dkXDO
Parameters:
className - the class name

EIP Java APIs

(c) Copyright International Business Machines Corporation 1996, 2002. IBM Corp. All rights reserved.