org.xiruss.repository.server
Class StorageObjectBase

java.lang.Object
  extended by org.xiruss.repository.server.RepositoryObjectBase
      extended by org.xiruss.repository.server.VersionBase
          extended by org.xiruss.repository.server.CompoundDocumentBase
              extended by org.xiruss.repository.server.StorageObjectBase
All Implemented Interfaces:
java.lang.Comparable, CompoundDocument, StorageObject, RepositoryObject, Version
Direct Known Subclasses:
CompoundDocumentStorageObject, TextStorageObjectBase

public class StorageObjectBase
extends CompoundDocumentBase
implements StorageObject

Implements the base methods for storage objects. Specializations are normally created to handling the setting of additional storage object type properties, i.e., TextStorageObject, XmlStorageObject, WordStorageObject, as well as to simply enable version-type-level distinction of different data formats (which could also be captured as version properties).


Field Summary
protected  long length
           
(package private) static org.apache.log4j.Logger logger
           
 
Fields inherited from class org.xiruss.repository.server.CompoundDocumentBase
membersCache
 
Fields inherited from class org.xiruss.repository.server.VersionBase
isFixed, nextVersions, previousVersions, resource
 
Fields inherited from class org.xiruss.repository.server.RepositoryObjectBase
id, name, objectTypeConstant, properties, rep
 
Constructor Summary
StorageObjectBase()
           
 
Method Summary
 boolean canWrite()
          Checks if the storage object can be written to (because it is not fixed and is not already open).
 void close()
          Closes the storage object if it has been opened for writing via getWriter();
protected  void closeWriter()
          Subclasses must implement the appropriate close action for their implementation-specific writer.
 byte[] getBytes()
          Gets the bytes of the storage object's content (as distinct from its other properties).
 java.lang.String getMimeType()
          Returns the MIME type of the storage object.
 java.lang.String getOriginalSystemId()
          Gets the value of the original system ID property.
protected  java.io.Writer getWriterForImpl()
          Returns an implementation-specific Writer instance that allows the storage object's content to be written.
 long length()
          Returns the length, in bytes, of the storage object content
 java.io.InputStream openInputStream()
           
 java.io.OutputStream openOutputStream()
          Open a writer for writing to the storage object.
 void setStorageObjectData(StorageObjectData data)
          Sets the storage object data object that provides access to the data as managed by the repository's storage manager.
 
Methods inherited from class org.xiruss.repository.server.CompoundDocumentBase
accept, getMemberVersions
 
Methods inherited from class org.xiruss.repository.server.VersionBase
addDependency, addNextVersion, addPreviousVersion, checkIsNotFixed, collectTargetVersions, compareTo, dependsOn, dependsOn, getDependencies, getDependenciesByType, getNext, getPrevious, getResource, initialize, initialize, isFixed, setAsFixed, setPrevious, setResource
 
Methods inherited from class org.xiruss.repository.server.RepositoryObjectBase
getId, getName, getProperties, getProperty, getPropertyNames, getRepository, getType, hasProperty, initialize, initialize, isNull, setId, setName, setProperties, setProperty, setRepository, setType, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.xiruss.snapcm.api.Version
addDependency, addNextVersion, addPreviousVersion, checkIsNotFixed, collectTargetVersions, dependsOn, dependsOn, getDependencies, getDependenciesByType, getNext, getPrevious, getResource, initialize, initialize, isFixed, setAsFixed, setPrevious
 
Methods inherited from interface org.xiruss.snapcm.api.RepositoryObject
accept, compareTo, getId, getName, getProperties, getProperty, getPropertyNames, getRepository, getType, hasProperty, initialize, isNull, setId, setName, setProperty, toString
 

Field Detail

logger

static org.apache.log4j.Logger logger

length

protected long length
Constructor Detail

StorageObjectBase

public StorageObjectBase()
Method Detail

getBytes

public byte[] getBytes()
                throws java.io.IOException
Description copied from interface: StorageObject
Gets the bytes of the storage object's content (as distinct from its other properties).

Specified by:
getBytes in interface StorageObject
Returns:
Byte array
Throws:
java.io.IOException

getOriginalSystemId

public java.lang.String getOriginalSystemId()
Gets the value of the original system ID property.

Specified by:
getOriginalSystemId in interface StorageObject
Returns:

length

public long length()
Returns the length, in bytes, of the storage object content

Specified by:
length in interface StorageObject
Returns:

getMimeType

public java.lang.String getMimeType()
Description copied from interface: StorageObject
Returns the MIME type of the storage object. The default is "unknown/unknown".

Specified by:
getMimeType in interface StorageObject
Returns:
MIME type string.

openOutputStream

public java.io.OutputStream openOutputStream()
                                      throws java.io.IOException
Open a writer for writing to the storage object. To close the output stream you must call the close() method on the StorageObject otherwise the output stream is still considered open, even if it has been closed directly by a call to the stream or a writer.

Specified by:
openOutputStream in interface StorageObject
Returns:
Throws:
java.io.IOException

getWriterForImpl

protected java.io.Writer getWriterForImpl()
                                   throws java.io.IOException
Returns an implementation-specific Writer instance that allows the storage object's content to be written.

Returns:
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Description copied from interface: StorageObject
Closes the storage object if it has been opened for writing via getWriter();

Specified by:
close in interface StorageObject
Throws:
java.io.IOException

closeWriter

protected void closeWriter()
                    throws java.io.IOException
Subclasses must implement the appropriate close action for their implementation-specific writer.

Throws:
java.io.IOException

canWrite

public boolean canWrite()
Description copied from interface: StorageObject
Checks if the storage object can be written to (because it is not fixed and is not already open).

Specified by:
canWrite in interface StorageObject
Returns:
true if storage object can be written to.

setStorageObjectData

public void setStorageObjectData(StorageObjectData data)
Description copied from interface: StorageObject
Sets the storage object data object that provides access to the data as managed by the repository's storage manager.

Specified by:
setStorageObjectData in interface StorageObject
Parameters:
data - StorageObjectData instance

openInputStream

public java.io.InputStream openInputStream()
                                    throws java.io.IOException
Specified by:
openInputStream in interface StorageObject
Throws:
java.io.IOException