XBRLAPI

A Java API for XBRL


org.xbrlapi.data.dom
Class StoreImpl

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

public class StoreImpl
extends BaseStoreImpl
implements Store

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.xbrlapi.data.BaseStoreImpl
domImplementation, matcher, namespaceBindings, storeDOM
 
Constructor Summary
StoreImpl()
          Initialise the data store.
 
Method Summary
 void close()
          Does nothing.
 void delete()
          The store is in memory so no actions are required to remove the data store from persistent storage.
 boolean equals(Object obj)
          The two stores are equal if they have equal caches and matchers and if they have the same number of fragments with the same indices.
 int getSize()
           
 Document getStoreAsDOM()
          Get the actual DOM that is used to hold the data store.
<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 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 store.
 
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, getStubs, getStubs, getSubtree, getTargets, getTuples, getTuples, getURIFilteringPredicate, getXMLResources, getXMLResources, hasAllRelationships, hasDocument, isFilteringByURIs, isLoading, isPersistingRelationships, persistLoaderState, persistStub, queryForString, recindLoadingRightsFor, remove, removeStub, requestLoadingRightsFor, saveDocuments, saveDocuments, saveStoreAsSingleDocument, serialize, serialize, serialize, setAnalyser, setFilteringURIs, setMatcher, setNamespaceBinding, startLoading, stopLoading, sync
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, toString, 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, getStubs, getStubs, getSubtree, getTargets, getTuples, getTuples, getXMLResources, getXMLResources, hasAllRelationships, hasDocument, isFilteringByURIs, isLoading, isPersistingRelationships, persistLoaderState, persistStub, queryForString, recindLoadingRightsFor, remove, removeStub, requestLoadingRightsFor, saveDocuments, saveDocuments, saveStoreAsSingleDocument, serialize, serialize, serialize, setAnalyser, setFilteringURIs, setMatcher, setNamespaceBinding, startLoading, stopLoading, sync
 

Constructor Detail

StoreImpl

public StoreImpl()
          throws XBRLException
Initialise the data store.

Throws:
XBRLException - if the loader state cannot be initialised or the XML DOM builder cannot be instantiated.
Method Detail

close

public void close()
           throws XBRLException
Description copied from class: BaseStoreImpl
Does nothing.

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

delete

public void delete()
            throws XBRLException
The store is in memory so no actions are required to remove the data store from persistent storage.

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

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)

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(String index)
            throws XBRLException
Remove a fragment from the store.

Specified by:
remove in interface Store
Parameters:
index - The index of the fragment to be removed from the store.
Throws:
XBRLException - if the fragment exists but cannot be removed from the store.

getStoreAsDOM

public Document getStoreAsDOM()
Get the actual DOM that is used to hold the data store.

Specified by:
getStoreAsDOM in interface Store
Overrides:
getStoreAsDOM in class BaseStoreImpl
Returns:
the XML DOM that is the data store. Note that this uses a different format for the DOM than that returned by the getStoreAsDOM method. Contributed by Howard Ungar 13 February, 2007.
See Also:
Store.getStoreAsDOM()

queryForXMLResources

public <F extends XML> List<F> queryForXMLResources(String query)
                                         throws XBRLException
Run a query against the collection of all fragments in the store.

Specified by:
queryForXMLResources in interface Store
Parameters:
query - The XPath query to run.
Returns:
a resource set that contains data for each matching fragment.
Throws:
XBRLException - if the query cannot be executed.

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)

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)

hashCode

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

equals

public boolean equals(Object obj)
The two stores are equal if they have equal caches and matchers and if they have the same number of fragments with the same indices. This is an incomplete way of assessing equality but it does get us there for most purposes and dodges the issue of XML DOM equality assessment.

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

Get Java XBRL API implementation at SourceForge.net.