XBRLAPI

A Java API for XBRL


org.xbrlapi.data.bdbxml
Class StoreImpl

java.lang.Object
  extended by org.xbrlapi.data.BaseStoreImpl
      extended by org.xbrlapi.data.bdbxml.StoreImpl
All Implemented Interfaces:
Serializable, Store

public class StoreImpl
extends BaseStoreImpl
implements Store

Implementation of the data store using the Oracle Berkeley Database. Note that this store implementation does not use the XML:DB API and so does not require a DBConnection implementation.

Author:
Geoffrey Shuetrim (geoff@galexy.net)
See Also:
Serialized Form

Field Summary
 com.sleepycat.dbxml.XmlContainer dataContainer
           
 com.sleepycat.dbxml.XmlManager dataManager
           
 
Fields inherited from class org.xbrlapi.data.BaseStoreImpl
domImplementation, matcher, namespaceBindings, storeDOM
 
Constructor Summary
StoreImpl(String location, String container)
          This uses the default 1 GB cache size.
StoreImpl(String location, String container, int cacheSize)
           
 
Method Summary
 void addIndex(URI namespace, String name, String type)
           
 void close()
          The closure operation entails closing the XML container and the XML data manager that are used by the store.
 void delete()
          Close and then delete the data store.
 boolean equals(Object obj)
           
 int getSize()
           
<F extends XML>
F
getXMLResource(String index)
          Retrieves an XML Resource from a data store.
 int hashCode()
           
 boolean hasXMLResource(String index)
          Test if a store contains a specific fragment, as identified by its index.
 void logIndexes()
          Log information about all the indexes in the data store.
 void persist(XML xml)
          Store a fragment.
 long queryCount(String query)
          This method must be synchronised
 Set<String> queryForIndices(String query)
          Run a query against the collection of all fragments in the store.
 Set<String> queryForStrings(String query)
          Run a query that is required to return a sequence of strings.
<F extends XML>
List<F>
queryForXMLResources(String query)
          Run a query against the collection of all fragments in the store.
 void remove(String index)
          Remove a fragment from the underlying data structure.
 void remove(XML fragment)
          Remove a XML resource from the underlying data structure.
 void sync()
          Default implementation does nothing.
 String toString()
           
 
Methods inherited from class org.xbrlapi.data.BaseStoreImpl
augmentNetworkForFragment, augmentNetworksForFragment, clearFilteringURIs, deleteDocument, deleteRelatedDocuments, DOM2String, finalize, getAllFactIndices, getAllFacts, getAllFacts, getAnalyser, getArcIndices, getArcIndices, getArcroles, getArcroles, getArcroleTypes, getArcroleTypes, getArcs, getArcs, getChildFragments, getChildFragments, getCompositeDocument, getConcept, getDocumentAsDOM, getDocumentsToDiscover, getDocumentURIs, getExtendedLinkIndices, getExtendedLinks, getFactIndices, getFacts, getFacts, getFacts, getFacts, getFilteringURIs, getFollowingSibling, getFragmentIndices, getFragmentIndicesFromDocument, getFragmentIndicesFromDocument, getFragmentsFromDocument, getFragmentsFromDocument, getGlobalDeclaration, getId, getItems, getItems, getLabels, getLabels, getLabels, getLabels, getLabels, getLanguage, getLanguageMap, getLanguages, getLinkRoles, getLinkRoles, getMatcher, getMinimalNetwork, getMinimalNetworksWithArcrole, getMinimalNetworksWithArcrole, getMinimumDocumentSet, getMinimumDocumentSet, getMissingDocumentURIs, getNetworkRoots, getNetworks, getNetworks, getNetworks, getNetworksFrom, getNetworksFrom, getNetworksFrom, getNetworksTo, getNetworksTo, getNetworksTo, getNumberOfXMLResources, getReferencedDocuments, getReferences, getReferences, getReferences, getReferences, getReferences, getReferencingDocuments, getReferencingFragments, getRelationshipsFrom, getRelationshipsTo, getResourceRoles, getRoleTypes, getRoleTypes, getRootFragmentForDocument, getRootFragmentIndices, getRootFragments, getRootFragments, getSchema, getSchemaContent, getSourceIndices, getSources, getStoreAsDOM, getStubs, getStubs, getSubtree, getTargets, getTuples, getTuples, getURIFilteringPredicate, getXMLResources, getXMLResources, hasAllRelationships, hasDocument, isFilteringByURIs, isLoading, isPersistingRelationships, persistLoaderState, persistStub, queryForString, recindLoadingRightsFor, removeStub, requestLoadingRightsFor, saveDocuments, saveDocuments, saveStoreAsSingleDocument, serialize, serialize, serialize, setAnalyser, setFilteringURIs, setMatcher, setNamespaceBinding, startLoading, stopLoading
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.xbrlapi.data.Store
augmentNetworkForFragment, augmentNetworksForFragment, clearFilteringURIs, deleteDocument, deleteRelatedDocuments, getAllFactIndices, getAllFacts, getAllFacts, getAnalyser, getArcIndices, getArcIndices, getArcroles, getArcroles, getArcroleTypes, getArcroleTypes, getArcs, getArcs, getChildFragments, getChildFragments, getCompositeDocument, getConcept, getDocumentAsDOM, getDocumentsToDiscover, getDocumentURIs, getExtendedLinkIndices, getExtendedLinks, getFactIndices, getFacts, getFacts, getFacts, getFacts, getFilteringURIs, getFragmentIndices, getFragmentIndicesFromDocument, getFragmentIndicesFromDocument, getFragmentsFromDocument, getFragmentsFromDocument, getGlobalDeclaration, getId, getItems, getItems, getLabels, getLabels, getLabels, getLabels, getLabels, getLanguage, getLanguageMap, getLanguages, getLinkRoles, getLinkRoles, getMatcher, getMinimalNetwork, getMinimalNetworksWithArcrole, getMinimalNetworksWithArcrole, getMinimumDocumentSet, getMinimumDocumentSet, getMissingDocumentURIs, getNetworkRoots, getNetworks, getNetworks, getNetworks, getNetworksFrom, getNetworksFrom, getNetworksFrom, getNetworksTo, getNetworksTo, getNetworksTo, getNumberOfXMLResources, getReferencedDocuments, getReferences, getReferences, getReferences, getReferences, getReferences, getReferencingDocuments, getReferencingFragments, getRelationshipsFrom, getRelationshipsTo, getResourceRoles, getRoleTypes, getRoleTypes, getRootFragmentForDocument, getRootFragmentIndices, getRootFragments, getRootFragments, getSchema, getSchemaContent, getSourceIndices, getSources, getStoreAsDOM, getStubs, getStubs, getSubtree, getTargets, getTuples, getTuples, getXMLResources, getXMLResources, hasAllRelationships, hasDocument, isFilteringByURIs, isLoading, isPersistingRelationships, persistLoaderState, persistStub, queryForString, recindLoadingRightsFor, removeStub, requestLoadingRightsFor, saveDocuments, saveDocuments, saveStoreAsSingleDocument, serialize, serialize, serialize, setAnalyser, setFilteringURIs, setMatcher, setNamespaceBinding, startLoading, stopLoading
 

Field Detail

dataManager

public transient com.sleepycat.dbxml.XmlManager dataManager

dataContainer

public transient com.sleepycat.dbxml.XmlContainer dataContainer
Constructor Detail

StoreImpl

public StoreImpl(String location,
                 String container)
          throws XBRLException
This uses the default 1 GB cache size.

Parameters:
location - The location of the database (The path to where the database exists)
container - The name of the container to hold the data in the store.
Throws:
XBRLException

StoreImpl

public StoreImpl(String location,
                 String container,
                 int cacheSize)
          throws XBRLException
Parameters:
location - The location of the database (The path to where the database exists)
container - The name of the container to hold the data in the store.
cacheSize - The number of megabytes to use for the cache size.
Throws:
XBRLException
Method Detail

logIndexes

public void logIndexes()
Log information about all the indexes in the data store.


getSize

public int getSize()
            throws XBRLException
Specified by:
getSize in interface Store
Returns:
the number of fragments in the data store.
Throws:
XBRLException - if the number of fragments cannot be determined.
See Also:
Store.persist(XML)

close

public void close()
           throws XBRLException
The closure operation entails closing the XML container and the XML data manager that are used by the store.

Specified by:
close in interface Store
Overrides:
close in class BaseStoreImpl
Throws:
XBRLException
See Also:
Store.close()

delete

public void delete()
            throws XBRLException
Description copied from interface: Store
Close and then delete the data store. This method must be synchronized.

Specified by:
delete in interface Store
Throws:
XBRLException - if the data store cannot be deleted.
See Also:
Store.delete()

persist

public void persist(XML xml)
             throws XBRLException
Description copied from interface: Store
Store a fragment. Implementations of this method must always be synchronized.

Specified by:
persist in interface Store
Parameters:
xml - The fragment to be added to the store.
Throws:
XBRLException - if the fragment cannot be added to the store.
See Also:
Store.persist(XML)

hasXMLResource

public boolean hasXMLResource(String index)
                       throws XBRLException
Description copied from interface: Store
Test if a store contains a specific fragment, as identified by its index. Implementations of this method must be synchronized.

Specified by:
hasXMLResource in interface Store
Parameters:
index - The index of the fragment to test for.
Returns:
true iff the store contains a fragment with the specified fragment index.
Throws:
XBRLException - If the test cannot be conducted.
See Also:
Store.hasXMLResource(String)

getXMLResource

public <F extends XML> F getXMLResource(String index)
                             throws XBRLException
Description copied from interface: Store
Retrieves an XML Resource from a data store. Implementations of this method must be synchronized.

Specified by:
getXMLResource in interface Store
Parameters:
index - The index of the XML resource.
Returns:
The XML resource corresponding to the specified index.
Throws:
XBRLException - if the XML resource cannot be retrieved.
See Also:
Store.getXMLResource(String)

remove

public void remove(XML fragment)
            throws XBRLException
Description copied from interface: Store
Remove a XML resource from the underlying data structure. If a XML resource with the same ID does not already exist in the data store then no action is required.

Specified by:
remove in interface Store
Overrides:
remove in class BaseStoreImpl
Parameters:
fragment - The XML resource to remove.
Throws:
XBRLException - if the XML resource cannot be removed from the store.
See Also:
Store.remove(String)

remove

public void remove(String index)
            throws XBRLException
Description copied from interface: Store
Remove a fragment from the underlying data structure. If a fragment with the same ID does not already exist in the data store then no action is required. Implementations of this method must be synchronized.

Specified by:
remove in interface Store
Parameters:
index - The index of the fragment to be removed from the DTS store.
Throws:
XBRLException - if the fragment cannot be removed from the store.
See Also:
Store.remove(String)

queryForXMLResources

public <F extends XML> List<F> queryForXMLResources(String query)
                                         throws XBRLException
Description copied from interface: Store
Run a query against the collection of all fragments in the store. Implementations of this method must be synchronized.

Specified by:
queryForXMLResources in interface Store
Parameters:
query - The XQuery query to run against the set of fragments. Any occurrences of the string #roots# in a query will be deemed to be a marker for the root elements of the fragments in an XML database collection and it will be substituted with the necessary expression to identify those roots in the data store.
Returns:
a list of matching fragments or the empty list if no matching fragments exist.
Throws:
XBRLException - if the query cannot be executed.
See Also:
Store.queryForXMLResources(String)

queryForIndices

public Set<String> queryForIndices(String query)
                            throws XBRLException
Description copied from interface: Store
Run a query against the collection of all fragments in the store. Implementations of this method must be synchronized.

Specified by:
queryForIndices in interface Store
Parameters:
query - The XQuery query to run against the set of fragments. Any occurrences of the string #roots# in a query will be deemed to be a marker for the root elements of the fragments in an XML database collection and it will be substituted with the necessary expression to identify those roots in the data store. The query MUST return a sequence of XML resource metadata root elements matching the query. Otherwise, results from the query will be unpredictable.
Returns:
a set of the indices of XML resources matching the query.
Throws:
XBRLException - if the query cannot be executed.
See Also:
Store.queryForIndices(String)

queryForStrings

public Set<String> queryForStrings(String query)
                            throws XBRLException
Description copied from interface: Store
Run a query that is required to return a sequence of strings. Implementations of this method must be synchronized.

Specified by:
queryForStrings in interface Store
Parameters:
query - The XQuery query to run against the set of fragments. Any occurrences of the string #roots# in a query will be deemed to be a marker for the root elements of the fragments in an XML database collection and it will be substituted with the necessary expression to identify those roots in the data store.
Returns:
a list of strings, each of which is a query result.
Throws:
XBRLException - if the query cannot be executed or if the query results are not strings.
See Also:
Store.queryForStrings(String)

queryCount

public long queryCount(String query)
                throws XBRLException
Description copied from interface: Store
This method must be synchronised

Specified by:
queryCount in interface Store
Parameters:
query - The XQuery to run. Any occurrences of the string #roots# in a query will be deemed to be a marker for the root elements of the fragments in an XML database collection and it will be substituted with the necessary expression to identify those roots in the data store.
Returns:
a count of the number of results returned by the query.
Throws:
XBRLException - if the query cannot be executed.
See Also:
Store.queryCount(String)

sync

public void sync()
          throws XBRLException
Description copied from class: BaseStoreImpl
Default implementation does nothing.

Specified by:
sync in interface Store
Overrides:
sync in class BaseStoreImpl
Throws:
XBRLException - if the sync operation fails.
See Also:
Store.sync()

addIndex

public void addIndex(URI namespace,
                     String name,
                     String type)
              throws XBRLException
Parameters:
namespace - The namespace of the node to index or null if the node does not have a namespace.
name - The local name of the node to index.
type - The index type. See the Oracle Berkeley DB documentation for details on what strings to use.
Throws:
XBRLException

hashCode

public int hashCode()
Overrides:
hashCode in class BaseStoreImpl
See Also:
Object.hashCode()

equals

public boolean equals(Object obj)
Overrides:
equals in class BaseStoreImpl
See Also:
Object.equals(java.lang.Object)

toString

public String toString()
Overrides:
toString in class Object

Get Java XBRL API implementation at SourceForge.net.