fr.gouv.culture.sdx.document
Class AbstractDocument

java.lang.Object
  extended byfr.gouv.culture.sdx.utils.SdxObjectImpl
      extended byfr.gouv.culture.sdx.document.AbstractDocument
All Implemented Interfaces:
Document, org.apache.avalon.framework.logger.LogEnabled, SdxObject
Direct Known Subclasses:
AbstractIndexableDocument, BinaryDocument

public abstract class AbstractDocument
extends SdxObjectImpl
implements Document

An abstract representation of a document.

Implements all methods from the Document interface.


Field Summary
protected  IDGenerator idGenerator
          The id generator for the document
protected  java.lang.String idPrefix
          Prefix for generated id's
protected  java.lang.String idSuffix
          Suffix for generated id's
protected  java.lang.String mimeType
          The mime type of the document.
protected  java.lang.String storeRepo
          The id of the repository in which the document should be stored
 
Fields inherited from class fr.gouv.culture.sdx.utils.SdxObjectImpl
encoding, logger
 
Fields inherited from interface fr.gouv.culture.sdx.document.Document
DOCTYPE_BINARY, DOCTYPE_GROUP, DOCTYPE_HTML, DOCTYPE_USER, DOCTYPE_XML
 
Constructor Summary
AbstractDocument()
           
 
Method Summary
 java.lang.String getId()
          Returns the document's id.
protected  org.xml.sax.InputSource getInputSource()
          Returns a SAX InputSource for this document
 int getLength()
          Returns the length of the document.
 java.lang.String getMimeType()
          Returns the mimeType field (A String) for this document
 java.lang.String getPreferredFilename()
          Returns a preferred filename for this document.
 java.lang.String getRepositoryForStorage()
          Sets the URL according to the source.
 java.net.URL getURL()
          Returns a URL for this document, null if no URL can be given.
 java.io.InputStream openStream()
          Opens a stream for reading the document's content.
 void save(Repository r)
          Saves the document within a repository.
 void setContent(byte[] b)
          Sets the content from a memory representation of the raw data.
 void setContent(java.io.File f)
          Sets the content from a file.
 void setContent(java.io.InputStream is)
          Sets the content from an InputStream.
 void setContent(java.net.URL u)
          Sets the content from a URL.
 void setId(java.lang.String id)
          Sets the document's id.
 void setIdGenerator(IDGenerator idGen)
           
 void setIdGenerator(IDGenerator idGen, java.lang.String idPrefix, java.lang.String idSuffix)
           
 void setMimeType(java.lang.String mimeType)
          Sets the mimeType field (A String) for this document
protected  void setPreferredFilename()
          Sets the preferred filename according to the source.
 void setPreferredFilename(java.lang.String filename)
          Sets the preferred filename.
 void setRepositoryForStorage(java.lang.String repoId)
          Sets the id of the repository in which the document should be stored
 void setURL(java.net.URL url)
          Sets the URL of this document.
 
Methods inherited from class fr.gouv.culture.sdx.utils.SdxObjectImpl
enableLogging, getChildLogger, setEncoding
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface fr.gouv.culture.sdx.document.Document
getDocType
 
Methods inherited from interface org.apache.avalon.framework.logger.LogEnabled
enableLogging
 

Field Detail

storeRepo

protected java.lang.String storeRepo
The id of the repository in which the document should be stored


mimeType

protected java.lang.String mimeType
The mime type of the document.


idGenerator

protected IDGenerator idGenerator
The id generator for the document


idPrefix

protected java.lang.String idPrefix
Prefix for generated id's


idSuffix

protected java.lang.String idSuffix
Suffix for generated id's

Constructor Detail

AbstractDocument

public AbstractDocument()
Method Detail

getId

public java.lang.String getId()
Returns the document's id.

Specified by:
getId in interface Document

setId

public void setId(java.lang.String id)
           throws SDXException
Sets the document's id.

Specified by:
setId in interface Document
Parameters:
id - The id to set.
Throws:
SDXException

openStream

public java.io.InputStream openStream()
                               throws SDXException
Opens a stream for reading the document's content.

Specified by:
openStream in interface Document
Throws:
SDXException

getInputSource

protected org.xml.sax.InputSource getInputSource()
                                          throws SDXException
Returns a SAX InputSource for this document

Throws:
SDXException

getMimeType

public java.lang.String getMimeType()
Returns the mimeType field (A String) for this document

Specified by:
getMimeType in interface Document

setMimeType

public void setMimeType(java.lang.String mimeType)
Sets the mimeType field (A String) for this document

Specified by:
setMimeType in interface Document

setContent

public void setContent(byte[] b)
Sets the content from a memory representation of the raw data.

Specified by:
setContent in interface Document

setContent

public void setContent(java.io.File f)
Sets the content from a file.

Specified by:
setContent in interface Document

setContent

public void setContent(java.net.URL u)
Sets the content from a URL.

Specified by:
setContent in interface Document

setContent

public void setContent(java.io.InputStream is)
Description copied from interface: Document
Sets the content from an InputStream.

Specified by:
setContent in interface Document

save

public void save(Repository r)
          throws SDXException
Saves the document within a repository. Use with caution, we will use this method in the future but its ramifications are not known yet.

Specified by:
save in interface Document
Parameters:
r - The repository where to save the document.
Throws:
SDXException

getLength

public int getLength()
Returns the length of the document.

Specified by:
getLength in interface Document

getPreferredFilename

public java.lang.String getPreferredFilename()
Returns a preferred filename for this document.

Specified by:
getPreferredFilename in interface Document

setPreferredFilename

protected void setPreferredFilename()
Sets the preferred filename according to the source.


getURL

public java.net.URL getURL()
                    throws SDXException
Returns a URL for this document, null if no URL can be given.

Specified by:
getURL in interface Document
Throws:
SDXException

setURL

public void setURL(java.net.URL url)
Sets the URL of this document.

Specified by:
setURL in interface Document

setPreferredFilename

public void setPreferredFilename(java.lang.String filename)
Sets the preferred filename.

Specified by:
setPreferredFilename in interface Document
Parameters:
filename - The filename (may be null).

setIdGenerator

public void setIdGenerator(IDGenerator idGen)
Specified by:
setIdGenerator in interface Document

setIdGenerator

public void setIdGenerator(IDGenerator idGen,
                           java.lang.String idPrefix,
                           java.lang.String idSuffix)
Specified by:
setIdGenerator in interface Document

getRepositoryForStorage

public java.lang.String getRepositoryForStorage()
Sets the URL according to the source.

Specified by:
getRepositoryForStorage in interface Document

setRepositoryForStorage

public void setRepositoryForStorage(java.lang.String repoId)
Description copied from interface: Document
Sets the id of the repository in which the document should be stored

Specified by:
setRepositoryForStorage in interface Document


Copyright © 2000-2004 Ministere de la culture et de la communication / AJLSM. All Rights Reserved.