oracle.toplink.xml
Class XMLFileAccessor

java.lang.Object
  |
  +--oracle.toplink.sdk.SDKAccessor
        |
        +--oracle.toplink.xml.XMLFileAccessor
All Implemented Interfaces:
oracle.toplink.internal.databaseaccess.Accessor, java.lang.Cloneable, XMLAccessor
Direct Known Subclasses:
XMLZipFileAccessor

public class XMLFileAccessor
extends SDKAccessor
implements XMLAccessor

XMLFileAccessor is an implementation of the XMLAccessor interface that uses the native O/S file system to store XML documents:

If necessary, this Accessor will dynamically load a DefaultXMLTranslator, either by using a JARClassLoader, to load the translator from specific set of JAR files, or by using the current class loader, if no JAR files have been specified. The static method DatabaseLogin.setXMLParserJARFileNames() is used to set the paths to the JAR files to be used for custom class loading.

Since:
TOPLink/Java 3.0
See Also:
XMLCall, XMLFileLogin, JARClassLoader, DatabaseLogin

Field Summary
TypeField
static java.lang.String DEFAULT_INVALID_FILENAME_CHARACTERS
          A list of the default invalid file name characters that will be morphed into escape sequences.
 
Constructor Summary
XMLFileAccessor()
          Default constructor.
 
Method Summary
TypeMethod
 boolean cachesDocumentDirectories()
          Return whether the document directories are cached.
 void connect(DatabaseLogin login, Session session)
          Establish a connection to the "data store".
 DatabaseRow convert(DatabaseRow row, Session session)
          Everything in XML must be strings.
 boolean createsDirectoriesAsNeeded()
          Return whether the accessor will create directories as needed, if they do not exist already.
 void createStreamSource(java.lang.String rootElementName)
          Create a source for data streams for the XML documents with the specified root element name.
 java.lang.Integer deleteStream(java.lang.String rootElementName, DatabaseRow row, java.util.Vector orderedPrimaryKeyElements)
          Delete the data for the specified root element and primary key.
 void disconnect(Session session)
          Drop the connection to the "data store".
 void dropStreamSource(java.lang.String rootElementName)
          Drop the source for data streams for the XML documents with the specified root element name.
 java.io.Reader getExistenceCheckStream(java.lang.String rootElementName, DatabaseRow row, java.util.Vector orderedPrimaryKeyElements)
          If it exists, return a read stream on the data for the specified root element and primary key.
 java.io.Writer getExistingWriteStream(java.lang.String rootElementName, DatabaseRow row, java.util.Vector orderedPrimaryKeyElements)
          Return a write stream that will overwrite the data for the specified root element and primary key.
 java.lang.String getFileExtension()
          Return the standard file extension that will be appended to the primary key element value(s) to generate the complete file name.
 java.lang.String getFileExtension(java.lang.String rootElementName)
          Return the standard file extension that will be appended to the primary key element value(s) to generate the complete file name.
 java.lang.String getInvalidFileNameCharacters()
          Return a list of the invalid file name characters that will be morphed into escape sequences.
 java.io.Writer getNewWriteStream(java.lang.String rootElementName, DatabaseRow row, java.util.Vector orderedPrimaryKeyElements)
          Return a new write stream for the specified root element and primary key.
 java.io.Reader getReadStream(java.lang.String rootElementName, DatabaseRow row, java.util.Vector orderedPrimaryKeyElements)
          Return a read stream on the data for the specified root element and primary key.
 java.util.Enumeration getReadStreams(java.lang.String rootElementName)
          Return an enumeration on a collection of read streams, one for *every* document with the specified root element.
 java.util.Enumeration getReadStreams(java.lang.String rootElementName, java.util.Vector foreignKeyRows, java.util.Vector orderedForeignKeyElements)
          Return an enumeration on a collection of streams, one for every specified foreign key.
 XMLTranslator getXMLTranslator()
          Return the default XML translator for all data store calls.
 void setCachesDocumentDirectories(boolean cachesDocumentDirectories)
          Set whether the document directories are cached.
 void setCreatesDirectoriesAsNeeded(boolean createsDirectoriesAsNeeded)
          Set whether the accessor will create directories as needed, if they do not exist already.
 void setFileExtension(java.lang.String fileExtension)
          Set the standard file extension that will be appended to the primary key element value(s) to generate the complete file name.
 void setInvalidFileNameCharacters(java.lang.String invalidFileNameCharacters)
          Set the list of the invalid file name characters that will be morphed into escape sequences.
 void setXMLTranslator(XMLTranslator translator)
          Set the default XML translator for all data store calls.
 
Methods inherited from class oracle.toplink.sdk.SDKAccessor
afterJTSTransactionCommit, afterJTSTransactionRollback, beginTransaction, clearLocalPreallocatedSequences, clone, closeConnection, commitTransaction, decrementCallCount, executeCall, getCallCount, getColumnInfo, getConnection, getLocalPreallocatedSequences, getLocalPreallocatedSequences, getTableInfo, incrementCallCount, isConnected, logMessage, reestablishConnection, rollbackTransaction, toString, usesExternalTransactionController
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface oracle.toplink.internal.databaseaccess.Accessor
afterJTSTransactionCommit, afterJTSTransactionRollback, beginTransaction, clone, closeConnection, commitTransaction, decrementCallCount, executeCall, getCallCount, getColumnInfo, getConnection, getLocalPreallocatedSequences, getTableInfo, incrementCallCount, isConnected, reestablishConnection, rollbackTransaction, usesExternalTransactionController
 

Field Detail

DEFAULT_INVALID_FILENAME_CHARACTERS

public static java.lang.String DEFAULT_INVALID_FILENAME_CHARACTERS
A list of the default invalid file name characters that will be morphed into escape sequences.

\ is the filename separator in DOS/Windows and the escape character in Unix

/ is the filename separator in Unix and the command option tag in DOS

: is the filename separator in MacOS and the drive indicator in DOS

* is a DOS wildcard character

? is a DOS wildcard character

" is used by DOS to delimit file names with spaces

< is a DOS redirection character

> is a DOS redirection character

| is a DOS redirection character

& is our own escape character

Constructor Detail

XMLFileAccessor

public XMLFileAccessor()
Default constructor.
Method Detail

cachesDocumentDirectories

public boolean cachesDocumentDirectories()
Return whether the document directories are cached.

connect

public void connect(DatabaseLogin login,
                    Session session)
             throws XMLDataStoreException
Establish a connection to the "data store".
Specified by:
connect in interface oracle.toplink.internal.databaseaccess.Accessor
Overrides:
connect in class SDKAccessor

convert

public DatabaseRow convert(DatabaseRow row,
                           Session session)
Everything in XML must be strings.
Specified by:
convert in interface XMLAccessor

createsDirectoriesAsNeeded

public boolean createsDirectoriesAsNeeded()
Return whether the accessor will create directories as needed, if they do not exist already.

createStreamSource

public void createStreamSource(java.lang.String rootElementName)
                        throws XMLDataStoreException
Create a source for data streams for the XML documents with the specified root element name.
Specified by:
createStreamSource in interface XMLAccessor

deleteStream

public java.lang.Integer deleteStream(java.lang.String rootElementName,
                                      DatabaseRow row,
                                      java.util.Vector orderedPrimaryKeyElements)
                               throws XMLDataStoreException
Delete the data for the specified root element and primary key. Return the stream count (1 or 0).
Specified by:
deleteStream in interface XMLAccessor

disconnect

public void disconnect(Session session)
                throws XMLDataStoreException
Drop the connection to the "data store".
Specified by:
disconnect in interface oracle.toplink.internal.databaseaccess.Accessor
Overrides:
disconnect in class SDKAccessor

dropStreamSource

public void dropStreamSource(java.lang.String rootElementName)
                      throws XMLDataStoreException
Drop the source for data streams for the XML documents with the specified root element name.
Specified by:
dropStreamSource in interface XMLAccessor

getExistenceCheckStream

public java.io.Reader getExistenceCheckStream(java.lang.String rootElementName,
                                              DatabaseRow row,
                                              java.util.Vector orderedPrimaryKeyElements)
                                       throws XMLDataStoreException
If it exists, return a read stream on the data for the specified root element and primary key. If it does not exist, return null.
Specified by:
getExistenceCheckStream in interface XMLAccessor

getExistingWriteStream

public java.io.Writer getExistingWriteStream(java.lang.String rootElementName,
                                             DatabaseRow row,
                                             java.util.Vector orderedPrimaryKeyElements)
                                      throws XMLDataStoreException
Return a write stream that will overwrite the data for the specified root element and primary key.
Specified by:
getExistingWriteStream in interface XMLAccessor

getFileExtension

public java.lang.String getFileExtension()
Return the standard file extension that will be appended to the primary key element value(s) to generate the complete file name.

getFileExtension

public java.lang.String getFileExtension(java.lang.String rootElementName)
Return the standard file extension that will be appended to the primary key element value(s) to generate the complete file name.

getInvalidFileNameCharacters

public java.lang.String getInvalidFileNameCharacters()
Return a list of the invalid file name characters that will be morphed into escape sequences.

getNewWriteStream

public java.io.Writer getNewWriteStream(java.lang.String rootElementName,
                                        DatabaseRow row,
                                        java.util.Vector orderedPrimaryKeyElements)
                                 throws XMLDataStoreException
Return a new write stream for the specified root element and primary key.
Specified by:
getNewWriteStream in interface XMLAccessor

getReadStream

public java.io.Reader getReadStream(java.lang.String rootElementName,
                                    DatabaseRow row,
                                    java.util.Vector orderedPrimaryKeyElements)
                             throws XMLDataStoreException
Return a read stream on the data for the specified root element and primary key. If the stream is not found return null.
Specified by:
getReadStream in interface XMLAccessor

getReadStreams

public java.util.Enumeration getReadStreams(java.lang.String rootElementName)
                                     throws XMLDataStoreException
Return an enumeration on a collection of read streams, one for *every* document with the specified root element.
Specified by:
getReadStreams in interface XMLAccessor

getReadStreams

public java.util.Enumeration getReadStreams(java.lang.String rootElementName,
                                            java.util.Vector foreignKeyRows,
                                            java.util.Vector orderedForeignKeyElements)
                                     throws XMLDataStoreException
Return an enumeration on a collection of streams, one for every specified foreign key. If a particular stream is not found the enumeration will return null in its place.
Specified by:
getReadStreams in interface XMLAccessor

getXMLTranslator

public XMLTranslator getXMLTranslator()
Return the default XML translator for all data store calls.
Specified by:
getXMLTranslator in interface XMLAccessor

setCachesDocumentDirectories

public void setCachesDocumentDirectories(boolean cachesDocumentDirectories)
Set whether the document directories are cached.

setCreatesDirectoriesAsNeeded

public void setCreatesDirectoriesAsNeeded(boolean createsDirectoriesAsNeeded)
Set whether the accessor will create directories as needed, if they do not exist already.

setFileExtension

public void setFileExtension(java.lang.String fileExtension)
Set the standard file extension that will be appended to the primary key element value(s) to generate the complete file name.

setInvalidFileNameCharacters

public void setInvalidFileNameCharacters(java.lang.String invalidFileNameCharacters)
Set the list of the invalid file name characters that will be morphed into escape sequences.

setXMLTranslator

public void setXMLTranslator(XMLTranslator translator)
Set the default XML translator for all data store calls.
Specified by:
setXMLTranslator in interface XMLAccessor