|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--org.sixdml.excelon.xlnSixdmlCollection
xlnSixdmlCollection.java
An implementation of the SixdmlCollection interface which maps to a directory in
the eXcelon's Dynamic XML Server (DXE). This class is NOT thread safe.
Created: Fri Jan 11 21:56:01 2002
| Field Summary | |
private String |
indexFile
The name of this Collection's index file. |
private boolean |
open
Flag indicates whether the collection is open or not. |
private HashMap |
properties
This is the table of properties for the needed by the Configurable interface. |
private String |
schemaName
The name of this Collection's schema file. |
private com.exln.dxe.Session |
session
A session provides the context in which an application can access XMLStores. |
private com.exln.dxe.filesystem.Directory |
xlnDir
The underlying DXE directory that this class uses to interact with the database. |
| Fields inherited from interface org.sixdml.SixdmlConstants |
SIXDML_NS, SIXDML_VERSION |
| Constructor Summary | |
private |
xlnSixdmlCollection()
Default constructor private because an instance of this class must always be instantiated with an underlying DXE Directory object. |
(package private) |
xlnSixdmlCollection(com.exln.dxe.filesystem.Directory dir,
com.exln.dxe.Session session)
Initializes this Collection by mapping it to a DXE directory. |
| Method Summary | |
void |
addIndex(org.sixdml.dbmanagement.SixdmlIndex index)
Adds an index to apply to the collection. |
void |
close()
Releases all resources consumed by the Collection. |
(package private) org.sixdml.excelon.xlnSixdmlCollection |
createDescendantCollection(String name)
Used to create a descendant collection of this collection. |
String |
createId()
Creates a new unique ID within the context of the Collection. |
Resource |
createResource(String id,
String type)
Creates a new empty Resource with the provided id. |
Collection |
getChildCollection(String name)
Returns a Collection instance for the requested child collection if it exists. |
int |
getChildCollectionCount()
Returns the number of child collections under this Collection or 0 if no child collections exist. |
static String |
getContentsOfURL(URL source)
Obtains the contents at a particular URL and returns them as a string. |
org.sixdml.dbmanagement.SixdmlIndex[] |
getIndices()
Returns an array of SixdmlIndex objects that apply to this collection. |
String |
getName()
Returns the name associated with the Collection instance. |
Collection |
getParentCollection()
Returns the parent collection for this collection or null if no parent collection exists. |
String |
getProperty(String name)
Returns the value of the property identified by name. |
Resource |
getResource(String id)
Retrieves a Resource from the database. |
int |
getResourceCount()
Returns the number of XML resources in this Collection or 0 if no child collections exist. |
Service |
getService(String name,
String version)
Returns a Service instance for the requested service name and version. |
Service[] |
getServices()
Provides a list of all services known to the collection. |
(package private) com.exln.dxe.XMLStore |
getXMLStore()
Returns the eXcelon DXE XMLStore this collection's underlying Directory object belongs to. |
void |
insertDocument(String name,
String xmlString)
Adds an XML document created from the string argument to the collection. |
void |
insertDocument(String name,
URL documentSource)
Adds an XML document loaded from the specified URL to the collection. |
boolean |
isOpen()
Returns true if the Collection is open false otherwise. |
String[] |
listChildCollections()
Returns a list of collection names naming all child collections of the current collection. |
String[] |
listResources()
Returns a list of resource names naming all the resources in the current collection. |
static void |
main(String[] args)
Main used for testing class. |
void |
removeDocument(String name)
Removes an XML document from the collection. |
void |
removeIndex(String name)
Removes a particular index from the collection. |
void |
removeResource(Resource res)
Removes the Resource from the database. |
void |
setProperty(String name,
String value)
Sets the property name to have the value provided in value. |
void |
setSchema(URL schemaFile)
Sets the XML schema or DTD that will be used to constrain the documents in this collection. |
String |
showSchema()
Returns the contents of the schema for the collection as a string. |
void |
storeResource(Resource res)
Stores the provided resource into the database. |
void |
unsetSchema()
Unsets the schema for this collection. |
private void |
validate(String xmlStr)
Helper Method: Validates an XML document against the collection's schema. |
private static File |
writeToFile(String file,
String contents,
boolean append)
Helper Method: Writes the contents of a string to a file. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private String indexFile
private String schemaName
private com.exln.dxe.filesystem.Directory xlnDir
private com.exln.dxe.Session session
private HashMap properties
Configurable interface.
Configurableprivate boolean open
| Constructor Detail |
private xlnSixdmlCollection()
xlnSixdmlCollection(com.exln.dxe.filesystem.Directory dir,
com.exln.dxe.Session session)
dir - the Directory that will be this object's interface to the database.session - the DXE session associated with the underlying directory.| Method Detail |
com.exln.dxe.XMLStore getXMLStore()
org.sixdml.excelon.xlnSixdmlCollection createDescendantCollection(String name)
throws XMLDBException
name - the name or path of the new collection.
XMLDBException - if the collection already exists or if
one of the collections in the path given does not exist.ErrorCodes.NO_SUCH_COLLECTION,
ErrorMessages.DUPLICATE_COLLECTION
public void addIndex(org.sixdml.dbmanagement.SixdmlIndex index)
throws UnsupportedIndexTypeException,
IndexAlreadyExistsException,
XMLDBException
addIndex in interface SixdmlCollectionindex - the index to add
UnsupportedIndexTypeException - if the index is of a type unsupported
by the database.
IndexAlreadyExistsException - if an index with the same name already exists
for the collection.
XMLDBException - if the close method has been called on the CollectionErrorMessages.COLLECTION_CLOSED
public void removeIndex(String name)
throws NonExistentIndexException,
XMLDBException
removeIndex in interface SixdmlCollectionXMLDBException - if the close method has been called on the Collection
NonExistentIndexExceptionErrorMessages.COLLECTION_CLOSED
public org.sixdml.dbmanagement.SixdmlIndex[] getIndices()
throws XMLDBException
getIndices in interface SixdmlCollectionXMLDBException - if the close method has been called on the CollectionErrorMessages.COLLECTION_CLOSED
private void validate(String xmlStr)
throws Exception
xmlStr - the document to validate as a string.
Exception - if anything goes wrong.
private static File writeToFile(String file,
String contents,
boolean append)
throws IOException
file - the file to write to.contents - the string to write to the file.append - boolean if true, then data will be written to the
end of the file rather than the beginning.
IOException - if an error occurs in writing the file.
public void removeDocument(String name)
throws NonExistentDocumentException,
XMLDBException
removeDocument in interface SixdmlCollectionname - the name of the document.
NonExistentDocumentException - if the document does not exist
in the collection.
XMLDBException - if the close method has been called on the CollectionErrorMessages.COLLECTION_CLOSED,
ErrorMessages.PERMISSION_DENIED_SCHEMA,
ErrorMessages.PERMISSION_DENIED_INDEX
public void insertDocument(String name,
URL documentSource)
throws DocumentAlreadyExistsException,
IOException,
InvalidCollectionDocumentException,
XMLDBException,
NonWellFormedXMLException
insertDocument in interface SixdmlCollectionname - the name of the document.
DocumentAlreadyExistsException - if there already exists a document with
the specified name in the database.
IOException - if an error occurs while trying to retrieve the file.
InvalidCollectionDocumentException - if the document fails to validate against
the collection's schema.
XMLDBException - if the close method has been called on the Collection or the
document does validate against the collection's schema if any.
NonWellFormedXMLException - if the XML is not well formed.ErrorMessages.COLLECTION_CLOSED,
ErrorMessages.PERMISSION_DENIED_SCHEMA,
ErrorMessages.PERMISSION_DENIED_INDEX
public void insertDocument(String name,
String xmlString)
throws DocumentAlreadyExistsException,
InvalidCollectionDocumentException,
NonWellFormedXMLException,
XMLDBException
insertDocument in interface SixdmlCollectionname - the name of the document.xmlString - the string representation of a well-formed XML document
DocumentAlreadyExistsException - if there already exists a document with
the specified name in the database.
InvalidCollectionDocumentException - if the document fails to validate against
the collection's schema.
NonWellFormedXMLException - if the XML is not well formed.
XMLDBException - if the close method has been called on the Collection or the
document does validate against the collection's schema if any.ErrorMessages.COLLECTION_CLOSED,
ErrorMessages.PERMISSION_DENIED_SCHEMA,
ErrorMessages.PERMISSION_DENIED_INDEX
public String showSchema()
throws XMLDBException
showSchema in interface SixdmlCollectionXMLDBException - if the close method has been called on the Collection or the
document does validate against the collection's schema if any.ErrorMessages.COLLECTION_CLOSED
public void unsetSchema()
throws XMLDBException
unsetSchema in interface SixdmlCollectionXMLDBException - if the close method has been called on the Collection or the
document does validate against the collection's schema if any.ErrorMessages.COLLECTION_CLOSED
public void setSchema(URL schemaFile)
throws InvalidCollectionDocumentException,
IOException,
InvalidSchemaException,
XMLDBException
setSchema in interface SixdmlCollectionschemaFile - the location of the schema file either on the local file
system or over the internet.
InvalidCollectionDocumentException - if an XML document in the
collection fails to be validated by the schema.
IOException - if an error occurs while trying to retrieve the file.
InvalidSchemaException - if the schema is invalid.
XMLDBException - if the close method has been called on the Collection or the
document does validate against the collection's schema if any.ErrorMessages.COLLECTION_CLOSED
public void storeResource(Resource res)
throws XMLDBException
storeResource in interface Collectionres - the resource to store in the database.
XMLDBException - if the close method has been called on the Collection or the
document does validate against the collection's schema if any.ErrorMessages.COLLECTION_CLOSED,
ErrorMessages.WRONG_CONTENT_TYPE_STORE,
ErrorMessages.PERMISSION_DENIED_SCHEMA,
ErrorMessages.PERMISSION_DENIED_INDEX
public void removeResource(Resource res)
throws XMLDBException
removeResource in interface Collectionres - the resource to remove.
XMLDBException - if the close method has been called on the CollectionErrorMessages.COLLECTION_CLOSED,
ErrorMessages.NO_SUCH_RESOURCE,
ErrorMessages.PERMISSION_DENIED_SCHEMA,
ErrorMessages.PERMISSION_DENIED_INDEX
public String[] listChildCollections()
throws XMLDBException
listChildCollections in interface CollectionXMLDBException - if the close method has been called on the CollectionErrorMessages.COLLECTION_CLOSED
public String[] listResources()
throws XMLDBException
listResources in interface CollectionXMLDBException - if the close method has been called on the CollectionErrorMessages.COLLECTION_CLOSED
public Service getService(String name,
String version)
getService in interface Collectionname - the name of theservice to return.version - the version number of the service to return.public Service[] getServices()
getServices in interface Collectionpublic String getName()
getName in interface Collection
public Resource getResource(String id)
throws XMLDBException
getResource in interface Collectionid - the unique id for the requested resource.
XMLDBException - if the close method has been called on the Collection or the
user attempts to access the collection's schema.ErrorMessages.COLLECTION_CLOSED,
ErrorMessages.PERMISSION_DENIED_SCHEMA,
ErrorMessages.PERMISSION_DENIED_INDEX
public int getResourceCount()
throws XMLDBException
getResourceCount in interface CollectionXMLDBException - if the close method has been called on the CollectionErrorMessages.COLLECTION_CLOSED
public int getChildCollectionCount()
throws XMLDBException
getChildCollectionCount in interface CollectionXMLDBException - if the close method has been called on the CollectionErrorMessages.COLLECTION_CLOSED
public Collection getParentCollection()
throws XMLDBException
getParentCollection in interface CollectionXMLDBException - if the close method has been called on the CollectionErrorMessages.COLLECTION_CLOSED
public Collection getChildCollection(String name)
throws XMLDBException
getChildCollection in interface Collectionname - the name of the child collection to retrieve.
XMLDBException - if the close method has been called on the CollectionErrorMessages.COLLECTION_CLOSED
public Resource createResource(String id,
String type)
throws XMLDBException
createResource in interface Collectionid - the unique id to associate with the created Resource.type - the Resource type to create.
XMLDBException - if the close method has been called on the Collection or the resource
type is unknown.ErrorMessages.COLLECTION_CLOSED,
ErrorMessages.UNKNOWN_RESOURCE_TYPEpublic String createId()
createId in interface Collectionpublic String getProperty(String name)
getProperty in interface Configurable
public void setProperty(String name,
String value)
setProperty in interface Configurablename - the name of the property to set.value - the value to set for the property.public boolean isOpen()
isOpen in interface Collectionpublic void close()
close in interface Collection
public static String getContentsOfURL(URL source)
throws IOException
source - the URL to obtaion the data from.
IOException - if an error occurs while trying to retrieve the file.public static void main(String[] args)
args - IGNORED
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||