|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.purl.xnode.XNode
org.ceryle.xnode.XNodeImpl
org.ceryle.xnode.XNodeCollectionImpl
public class XNodeCollectionImpl
XNodeCollectionImpl implements XNodeCollection,
an interface for a collection of XNodes, with methods also supporting a
hierarchy of XNodeCollections.
The XNode Implementation (the package org.ceryle.xnode.*, both its source code and documentation), are released under the Apache 2.0 License. For more details, check the LICENSE file contained with the distribution, or see The Ceryle Project for more information. It is distributed with no warranty.
The class extends XNodeImpl, using a modified DOM
version of the XNode as the metadata repository, and adding in the machinery
to communicate with the backing database store.
Note that in this implementation, built upon Berkeley DB JE, individual XNodes are stored within JE Databases, which are not stored within the XNodeCollection itself, only referenced by it. The XNodeCollection is is the link between the metadata and the data; in effect, a registry object. All XNodeCollections are stored within the root XNodeCollection's Database (rather than in their own), and their IDs within the root XNodeCollection's own metadata. This does preclude any subcollection having the same ID as the root (which might be confusing anyway).
The document index is initially read from the DOM <xnode:Collection>
Element's index attribute, then maintained in an internal Collection. If
the XNode is serialized, the DOM is harmonized when the getIndex() method
is called, if the index is dirty.
| Field Summary |
|---|
| Fields inherited from class org.ceryle.xnode.XNodeImpl |
|---|
m_content, m_document, PERMIT_XML_CONTENT, PFX_ATTR_created, PFX_ATTR_modified, PFX_ATTR_xmlns, PFX_ELT_link, PFX_ELT_property, PRESERVE_WS, PROPERTY_DOCTYPE_NAME, PROPERTY_EXTENSION, PROPERTY_PUBLIC_ID, PROPERTY_SYSTEM_ID, VALUE_STORED_AS_ATTRIBUTE |
| Fields inherited from class org.purl.xnode.XNode |
|---|
ATTR_created, ATTR_id, ATTR_index, ATTR_modified, ATTR_name, ATTR_size, ATTR_value, ATTR_version, ATTR_weight, ELT_body, ELT_collection, ELT_envelope, ELT_header, ELT_link, ELT_property, ELT_repository, ELT_revision, ELT_text, VERSION_10, VERSION_11, VERSION_12, VERSION_13, XMLNS_base, XMLNS_pfx, XMLNS_xnode, XMLNS_xnode10, XMLNS_xnode11, XMLNS_xnode12, XMLNS_xnode13 |
| Fields inherited from interface org.purl.xnode.XNodeCollection |
|---|
ROOT_ID |
| Constructor Summary | |
|---|---|
protected |
XNodeCollectionImpl(XNodeStore xnodestore,
String cid,
String created,
Node node)
Constructor for a new XNodeCollection, with a required ID cid. |
| Method Summary | |
|---|---|
boolean |
addCollection(XNodeCollection collection)
Add a child XNodeCollection collection to this XNodeCollection. |
boolean |
addXNode(XNode xnode,
boolean overwrite)
Writes the XNode xnode to this XNodeCollection. |
boolean |
close()
Close this XNodeCollection's database. |
int |
compareTo(Object o)
Compares this object with the specified object for order. |
XNodeCollection |
getCollection(String cid)
Return the child XNodeCollection with ID cid of this XNodeCollection, or null if unavailable. |
protected Element |
getCollectionElement()
Return this Collection's <xnode:Collection> Element. |
List |
getCollectionIndex()
Returns a List containing the IDs of child XNodeCollections, based on the internally-stored metadata. |
List |
getIndex()
Returns a List containing this XNodeCollection's index of XNode IDs. |
int |
getIndexCount()
Returns the number of XNodes in this XNodeCollection. |
XNodeCollection |
getParentCollection()
Return the parent XNodeCollection of this XNodeCollection, or null if no parent XNodeCollection exists. |
static XNodeCollection |
getRootCollection()
Return the root XNodeCollection, null if not yet instantiated. |
XNode |
getXNode(String nid)
Retrieves the XNode with ID nid from this XNodeCollection, returning null if it does not exist. |
boolean |
hasCollection(String cid)
Returns true if a child XNodeCollection with ID cid exists as a child XNodeCollection of this XNodeCollection, false otherwise. |
boolean |
hasXNode(String nid)
Returns true if the XNode ID nid exists as a key in this XNodeCollection. |
boolean |
isDirty()
Returns the dirty state of the collection (true if any changes have occurred). |
void |
printCollections()
Prints the collections currently found in the cache to System.err. |
boolean |
removeCollection(String cid)
Remove a child XNodeCollection with ID cid from this XNodeCollection. |
boolean |
removeXNode(String nid)
Removes the XNode whose ID is xnode from this XNodeCollection. |
void |
setCollectionIndexDirty()
|
void |
setContent(Node node)
Sets the content of this XNodeCollection to the Node node (which can be a DOM Document or Element node), throwing an XNodeException if the content is already set. |
void |
setDirty()
Sets the dirty state of the collection to true. |
protected void |
setIndex(List list)
Forceably sets the node index to the contents of the provided List. |
String |
toString()
Return a String representation of this XNodeCollection. |
| Methods inherited from class org.ceryle.xnode.XNodeImpl |
|---|
getBodyElement, getContent, getCreated, getDocument, getEnvelopeElement, getHeaderElement, getID, getModified, getProperties, getProperty, getRepository, getRepositoryElement, hasRepository, modifyContent, setCreated, setID, setModified, setProperty, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.purl.xnode.XNodeCollection |
|---|
getContent, getCreated, getID, getModified, getProperties, getProperty, setCreated, setID, setModified, setProperty |
| Constructor Detail |
|---|
protected XNodeCollectionImpl(XNodeStore xnodestore,
String cid,
String created,
Node node)
throws XNodeException
xnodestore - the XNodeStore supporting the collection.cid - the XNodeCollection ID.created - the required creation timestamp.node - the XNodeCollection ID.
XNodeException - if the ID value is not an XML Name.| Method Detail |
|---|
public static XNodeCollection getRootCollection()
This is not an XNode API method.
public void setDirty()
public boolean isDirty()
public XNodeCollection getParentCollection()
getParentCollection in interface XNodeCollectionpublic void setCollectionIndexDirty()
public List getCollectionIndex()
throws XNodeException
Note that this does not load the collection, only indicate its existence in the index.
getCollectionIndex in interface XNodeCollectionXNodeException - if an error occurs while indexing the root XNodeCollection.public boolean hasCollection(String cid)
IMPORTANT:
This is an indication of the existence of the XNodeCollection in the
root collection cache, not simply its ID occurring in the index
(which is the answer returned from getCollectionIndex().
This method always returns false for all non-root XNodeCollections.
hasCollection in interface XNodeCollectioncid - the ID of the child XNodeCollection.
public XNodeCollection getCollection(String cid)
throws XNodeException
getCollection in interface XNodeCollectioncid - the ID of the child XNodeCollection.
XNodeException - if an error occurs while getting the XNodeCollection.
public boolean addCollection(XNodeCollection collection)
throws XNodeException
addCollection in interface XNodeCollectioncollection - the XNodeCollection to be added.
XNodeException - if an error occurs while adding the XNodeCollection.
public boolean removeCollection(String cid)
throws XNodeException
removeCollection in interface XNodeCollectioncid - the ID of the XNodeCollection to be removed.
XNodeException - if an error occurs during removal of the XNodeCollection.
public boolean close()
throws XNodeException
close in interface XNodeCollectionXNodeException - if an error occurs during closing of the Database.public void printCollections()
protected void setIndex(List list)
This is not an XNode API method.
public List getIndex()
throws XNodeException
getIndex in interface XNodeCollectionXNodeException - if an error occurs obtaining the index.public int getIndexCount()
getIndexCount in interface XNodeCollectionXNodeException - if an error occurs obtaining the index.
protected Element getCollectionElement()
throws XNodeException
XNodeException - if there is no collection element.
public boolean addXNode(XNode xnode,
boolean overwrite)
throws XNodeException
addXNode in interface XNodeCollectionxnode - the XNode to add to the XNodeCollection.
XNodeException - if the XNode could not be written, or if a matching
XNode ID exists and overwrite is false.
public boolean hasXNode(String nid)
throws XNodeException
hasXNode in interface XNodeCollectionnid - the ID of the XNode to be queried.
XNodeException - if an error occurs during retrieval.
public XNode getXNode(String nid)
throws XNodeException
getXNode in interface XNodeCollectionnid - the ID of the XNode to be retrieved.
XNodeException - if an error occurs during retrieval.
public boolean removeXNode(String nid)
throws XNodeException
removeXNode in interface XNodeCollectionnid - the ID of the XNode to remove from the XNodeCollection.
XNodeException - if the String is not a valid ID.
public void setContent(Node node)
throws XNodeException
setContent in class XNodeImplnode - the Node to set as the content of this XNode.
XNodeException - if there is existing content.public String toString()
toString in interface XNodeCollectiontoString in class XNodeImplpublic int compareTo(Object o)
compareTo in interface Comparable
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||