XBRLAPI

A Java API for XBRL


org.xbrlapi.data
Class BaseStoreImpl

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

public abstract class BaseStoreImpl
extends Object
implements Store

Abstract base implementation of the data store providing all methods of the store interface that do not depend on the nature of the underlying data store implementation.

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

Field Summary
protected  DOMImplementationLS domImplementation
           
protected  Matcher matcher
          Resource matcher
protected  HashMap<URI,String> namespaceBindings
          Namespace bindings
protected  Document storeDOM
          The DOM document used to construct DOM representations of subtrees of documents in the store.
 
Constructor Summary
BaseStoreImpl()
           
 
Method Summary
 void augmentNetworkForFragment(Fragment fragment, Network network)
          This method is recursive.
 void augmentNetworksForFragment(Fragment fragment, URI arcrole, Networks networks)
          This method is recursive.
 void clearFilteringURIs()
          Specify that the data store is not to filter query results to only come from a specified set of URIs.
 void close()
          Does nothing.
 void deleteDocument(URI uri)
          Algorithm: Check if the matcher indicate that the URI has matching URIs. If the URI has matching URIs: If the URI is the one used for the document in the data store: Delete the URI from the matcher, getting the new matching URI back as a result of the deletion operation and update the document fragments to use the new matching URI instead of the deleted URI. Otherwise, just delete the URI from the matcher and we are done. Otherwise, the URI does not have matching URIs so just delete the URI from the matcher and delete the relevant fragments from the data store.
 void deleteRelatedDocuments(URI uri)
          This deletion method ensures that all related documents are also deleted from the data store.
protected  String DOM2String(Element element)
          Convert a DOM element (and its descendents) to a string.
 boolean equals(Object obj)
           
protected  void finalize()
           
 Set<String> getAllFactIndices()
           
 List<Fact> getAllFacts()
           
 List<Fact> getAllFacts(URI uri)
           
 Analyser getAnalyser()
           
 Set<String> getArcIndices(String linkIndex)
           
 Set<String> getArcIndices(URI arcrole)
           
 Set<URI> getArcroles()
           
 Set<URI> getArcroles(URI linkRole)
           
 List<ArcroleType> getArcroleTypes()
           
 List<ArcroleType> getArcroleTypes(URI uri)
           
 List<Arc> getArcs(String linkIndex)
           
 List<Arc> getArcs(URI arcrole, String linkIndex)
           
<F extends Fragment>
List<F>
getChildFragments(Class<?> childClass, String parentIndex)
           
<F extends Fragment>
List<F>
getChildFragments(String interfaceName, String parentIndex)
           
 Document getCompositeDocument()
          Get all data in the store as a single XML DOM object including the annotations used in the XBRLComposer project.
 Concept getConcept(URI namespace, String name)
           
 Element getDocumentAsDOM(URI uri)
          Get a single document in the store as a DOM.
 List<URI> getDocumentsToDiscover()
           
 Set<URI> getDocumentURIs()
          Get a list of the URIs that have been stored.
 Set<String> getExtendedLinkIndices(URI linkRole)
           
 List<ExtendedLink> getExtendedLinks(URI linkrole)
           
 Set<String> getFactIndices()
           
 List<Fact> getFacts()
           
 List<Fact> getFacts(Concept concept)
           
 List<Fact> getFacts(URI uri)
           
 List<Fact> getFacts(URI namespace, String localname)
           
 Set<URI> getFilteringURIs()
           
protected  Element getFollowingSibling(Element parentElement, int precedingSiblings)
          Get the following sibling of this fragment's root in the parent fragment's data.
 Set<String> getFragmentIndices(String interfaceName)
           
 Set<String> getFragmentIndicesFromDocument(URI uri)
           
 Set<String> getFragmentIndicesFromDocument(URI uri, String interfaceName)
           
<F extends Fragment>
List<F>
getFragmentsFromDocument(URI uri, Class<?> fragmentClass)
           
<F extends Fragment>
List<F>
getFragmentsFromDocument(URI uri, String interfaceName)
          Utility method to return a list of fragments in a data store that have a type corresponding to the specified fragment interface name and that are in the document with the specified URI.
<D extends SchemaDeclaration>
D
getGlobalDeclaration(URI namespace, String name)
           
 String getId(String input)
          This implementation generates the an ID for a document being stored with a prefix that is a random string of characters including a-z, A-Z and 0-9.
 List<Item> getItems()
           
 List<Item> getItems(URI uri)
           
 List<LabelResource> getLabels(String fragment)
          Implemented by Store.getLabels(String,URI,URI,String).
 List<LabelResource> getLabels(String fragment, String language)
          Implemented by Store.getLabels(String,URI,URI,String).
 List<LabelResource> getLabels(String fragment, URI resourceRole)
          Implemented by Store.getLabels(String,URI,URI,String).
 List<LabelResource> getLabels(String fragment, URI resourceRole, String language)
          Implemented by Store.getLabels(String,URI,URI,String).
 List<LabelResource> getLabels(String fragment, URI linkRole, URI resourceRole, String language)
          If using persisted relationships then the set of relationships used to generate the results can be modified by appropriate choice of
 Language getLanguage(String encoding, String code)
           
 Map<String,Language> getLanguageMap(String code)
           
 List<Language> getLanguages(String code)
           
 Set<URI> getLinkRoles()
           
 Set<URI> getLinkRoles(URI arcrole)
           
 Matcher getMatcher()
           
 Network getMinimalNetwork(Set<Fragment> fragments, URI linkRole, URI arcrole)
           
 Networks getMinimalNetworksWithArcrole(Fragment fragment, URI arcrole)
          Convenience method for a single fragment.
 Networks getMinimalNetworksWithArcrole(Set<Fragment> fragments, URI arcrole)
          Get the networks that, at a minimum, contain the relationships from each of the given fragments working back through ancestor relationships as far as possible.
 Set<URI> getMinimumDocumentSet(Collection<URI> starters)
           
 Set<URI> getMinimumDocumentSet(URI uri)
          This is just a convenience method.
 Set<URI> getMissingDocumentURIs()
           
<F extends Fragment>
Set<F>
getNetworkRoots(URI linkRole, URI arcrole)
          This implementation is not as strict as the XBRL 2.1 specification requires but it is generally faster and delivers sensible results.
 Networks getNetworks()
          Note that this can massively overload resources if the data store is large because much of the information in the store will be reflected in -in-memory objects.
 Networks getNetworks(URI arcrole)
           
 Networks getNetworks(URI linkRole, URI arcrole)
           
 Networks getNetworksFrom(String sourceIndex)
          Implemented by Store.getNetworksFrom(String,URI,URI).
 Networks getNetworksFrom(String sourceIndex, URI arcrole)
          Implemented by Store.getNetworksFrom(String,URI,URI).
 Networks getNetworksFrom(String sourceIndex, URI linkRole, URI arcrole)
           
 Networks getNetworksTo(String targetIndex)
          Implemented by Store.getNetworksTo(String,URI,URI).
 Networks getNetworksTo(String targetIndex, URI arcrole)
          Implemented by Store.getNetworksTo(String,URI,URI).
 Networks getNetworksTo(String targetIndex, URI linkRole, URI arcrole)
          If using persisted relationships then the set of relationships used to generate the results can be modified by appropriate choice of
 long getNumberOfXMLResources(Class<?> specifiedClass)
           
 Set<URI> getReferencedDocuments(URI uri)
          Override this method in a data store implementation if the data store implementation supports XQuery (rather than XPath).
 List<ReferenceResource> getReferences(String fragment)
          Implemented by Store.getReferences(String,URI,URI,String).
 List<ReferenceResource> getReferences(String fragment, String language)
          Implemented by Store.getReferences(String,URI,URI,String).
 List<ReferenceResource> getReferences(String fragment, URI resourceRole)
          Implemented by Store.getReferences(String,URI,URI,String).
 List<ReferenceResource> getReferences(String fragment, URI resourceRole, String language)
          Implemented by Store.getReferences(String,URI,URI,String).
 List<ReferenceResource> getReferences(String fragment, URI linkRole, URI resourceRole, String language)
          If using persisted relationships then the set of relationships used to generate the results can be modified by appropriate choice of
 List<URI> getReferencingDocuments(URI uri)
           
 List<Fragment> getReferencingFragments(URI uri)
           
 SortedSet<Relationship> getRelationshipsFrom(String sourceIndex, URI linkRole, URI arcrole)
          If using persisted relationships then the set of relationships used to generate the results can be modified by appropriate choice of
 SortedSet<Relationship> getRelationshipsTo(String targetIndex, URI linkRole, URI arcrole)
           
 List<URI> getResourceRoles()
           
 List<RoleType> getRoleTypes()
           
 List<RoleType> getRoleTypes(URI uri)
           
<F extends Fragment>
F
getRootFragmentForDocument(URI uri)
           
 Set<String> getRootFragmentIndices(String interfaceName)
           
<F extends Fragment>
List<F>
getRootFragments()
           
<F extends Fragment>
List<F>
getRootFragments(String interfaceName)
           
 Schema getSchema(URI targetNamespace)
           
<F extends SchemaContent>
F
getSchemaContent(URI namespace, String name)
           
 Set<String> getSourceIndices(String targetIndex, URI linkRole, URI arcrole)
           
<F extends Fragment>
List<F>
getSources(String targetIndex, URI linkRole, URI arcrole)
           
 Document getStoreAsDOM()
          Get all data in the store as a single XML DOM object.
 List<Stub> getStubs()
           
 List<Stub> getStubs(URI uri)
           
 Element getSubtree(Fragment f)
          Returns the root element of the subtree starting with the fragment with the specified index.
<F extends Fragment>
List<F>
getTargets(String sourceIndex, URI linkRole, URI arcrole)
           
 List<Tuple> getTuples()
           
 List<Tuple> getTuples(URI uri)
           
protected  String getURIFilteringPredicate()
           
<F extends XML>
List<F>
getXMLResources(Class<?> specifiedClass)
          Return a list of XML resources in a data store that have a type corresponding to the specified XML resource interface name.
<F extends XML>
List<F>
getXMLResources(String interfaceName)
          Return a list of XML resources in a data store that have a type corresponding to the specified XML resource interface name.
 boolean hasAllRelationships(URI document)
           
 boolean hasDocument(URI uri)
          Test if a particular URI is already in the data store.
 int hashCode()
           
 boolean isFilteringByURIs()
           
 boolean isLoading()
           
 boolean isPersistingRelationships()
           
 void persistLoaderState(Map<URI,String> documents)
          Stores the state of the document discovery process.
 void persistStub(URI uri, String reason)
           
 String queryForString(String query)
          Run a query that is required to return a single string.
 void recindLoadingRightsFor(Loader loader, URI document)
          Loaders need to call this method to indicate that they are recinding responsibility for loading the document.
 void remove(XML xml)
          Remove a XML resource from the underlying data structure.
 void removeStub(Stub stub)
           
 boolean requestLoadingRightsFor(Loader loader, URI document)
          Loaders need to call this method to indicate that they are going to take responsibility for loading the document.
 void saveDocuments(File destination)
          Serializes the individual documents in the data store, saving them into a directory structure that is placed into the specified directory.
 void saveDocuments(File destination, String uriPrefix)
          Serializes those documents in the data store with a URI that begins with the specified URI prefix.
 void saveStoreAsSingleDocument(File file)
          Creates a single DOM structure from all documents in the data store and saves this single XML structure in the specified file.
 String serialize(Element what)
          Serialize the specified XML DOM node.
 void serialize(Element what, File destination)
          Serialize the specified XML DOM to the specified destination.
 void serialize(Element what, OutputStream destination)
          Serialize the specified XML DOM to the specified destination.
 void setAnalyser(Analyser analyser)
           
 void setFilteringURIs(Set<URI> uris)
           
 void setMatcher(Matcher matcher)
          Sets the matcher for the store to use.
 void setNamespaceBinding(URI namespace, String prefix)
           
 void startLoading(Loader loader)
           
 void stopLoading(Loader loader)
           
 void sync()
          Default implementation does nothing.
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.xbrlapi.data.Store
delete, getSize, getXMLResource, hasXMLResource, persist, queryCount, queryForIndices, queryForStrings, queryForXMLResources, remove
 

Field Detail

storeDOM

protected transient Document storeDOM
The DOM document used to construct DOM representations of subtrees of documents in the store.


domImplementation

protected transient DOMImplementationLS domImplementation

matcher

protected Matcher matcher
Resource matcher


namespaceBindings

protected HashMap<URI,String> namespaceBindings
Namespace bindings

Constructor Detail

BaseStoreImpl

public BaseStoreImpl()
              throws XBRLException
Throws:
XBRLException
Method Detail

getNumberOfXMLResources

public long getNumberOfXMLResources(Class<?> specifiedClass)
                             throws XBRLException
Specified by:
getNumberOfXMLResources in interface Store
Parameters:
specifiedClass - The class of XML resource to count.
Returns:
The number of XML resources of the given class type in the data store.
Throws:
XBRLException
See Also:
Store.getNumberOfXMLResources(Class)

setMatcher

public void setMatcher(Matcher matcher)
                throws XBRLException
Description copied from interface: Store
Sets the matcher for the store to use. Care should be taken to ensure that the one matcher is used for all documents in the store.

Specified by:
setMatcher in interface Store
Parameters:
matcher - the matcher to use to identify identical resources.
Throws:
XBRLException - if the matcher is null;
See Also:
Store.setMatcher(Matcher)

getMatcher

public Matcher getMatcher()
Specified by:
getMatcher in interface Store
Returns:
the matcher used by the store to identify identical resources.
See Also:
Store.getMatcher()

setNamespaceBinding

public void setNamespaceBinding(URI namespace,
                                String prefix)
                         throws XBRLException
Specified by:
setNamespaceBinding in interface Store
Parameters:
namespace - The namespace to bind a prefix to for querying
prefix - The prefix to bind to the namespace for querying
Throws:
XBRLException - if either argument is null.
See Also:
Store.setNamespaceBinding(URI,String)

setFilteringURIs

public void setFilteringURIs(Set<URI> uris)
Specified by:
setFilteringURIs in interface Store
Parameters:
uris - The set of URIs to restrict query results to coming from. The set of URIs is set to the empty set if this parameter is null.
See Also:
Store.setFilteringURIs(Set)

getFilteringURIs

public Set<URI> getFilteringURIs()
Specified by:
getFilteringURIs in interface Store
Returns:
the set of URIs to filter query results. Empty set if no URIs are being used to filter query results.
See Also:
Store.getFilteringURIs()

clearFilteringURIs

public void clearFilteringURIs()
Description copied from interface: Store
Specify that the data store is not to filter query results to only come from a specified set of URIs.

Specified by:
clearFilteringURIs in interface Store
See Also:
Store.clearFilteringURIs()

isFilteringByURIs

public boolean isFilteringByURIs()
Specified by:
isFilteringByURIs in interface Store
Returns:
true if the data store is restricting query results to come from a specific set of documents and false otherwise.
See Also:
Store.isFilteringByURIs()

getURIFilteringPredicate

protected String getURIFilteringPredicate()
Returns:
an X Query clause that restricts the set of fragments returned by a query to those from a specific set of URIs.

close

public void close()
           throws XBRLException
Does nothing.

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

persistLoaderState

public void persistLoaderState(Map<URI,String> documents)
                        throws XBRLException
Description copied from interface: Store
Stores the state of the document discovery process.

Specified by:
persistLoaderState in interface Store
Parameters:
documents - The map from URIs of the documents remaining to be discovered to the textual reason why the document has not yet been discovered.
Throws:
XBRLException
See Also:
Store.persistLoaderState(Map)

persistStub

public void persistStub(URI uri,
                        String reason)
                 throws XBRLException
Specified by:
persistStub in interface Store
Parameters:
uri - The document to store a stub for.
reason - The reason the document has not been stored.
Throws:
XBRLException
See Also:
Store.persistStub(URI,String)

sync

public void sync()
          throws XBRLException
Default implementation does nothing.

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

getId

public String getId(String input)
             throws XBRLException
This implementation generates the an ID for a document being stored with a prefix that is a random string of characters including a-z, A-Z and 0-9. If, by chance, the random string has already been used for another document in the data store, then another random string is generated and this repeats until the random string is unique in the data store.

Specified by:
getId in interface Store
Parameters:
input - The string that may be used to generate the id.
Returns:
the ID to be used for storing XML resources in the data store. One of these IDs is generated for each document in the data store and then a counter is appended to that ID to get uniqueness for each fragment in that document. These IDs are also used for a variety of other kinds of XML resources stored in the data store.
Throws:
XBRLException
See Also:
Store.getId(String)

serialize

public void serialize(Element what,
                      OutputStream destination)
               throws XBRLException
Description copied from interface: Store
Serialize the specified XML DOM to the specified destination.

Specified by:
serialize in interface Store
Parameters:
what - the root element of the DOM to be serialised.
destination - The destination output stream to be serialised to.
Throws:
XBRLException - if the DOM cannot be serialised because the destination cannot be written to or some other different problem occurs during serialisation.
See Also:
Store.serialize(Element, OutputStream)

serialize

public String serialize(Element what)
                 throws XBRLException
Description copied from interface: Store
Serialize the specified XML DOM node.

Specified by:
serialize in interface Store
Parameters:
what - the root element of the DOM to be serialised.
Returns:
a string containing the serialized XML.
Throws:
XBRLException
See Also:
Store.serialize(Element)

deleteDocument

public void deleteDocument(URI uri)
                    throws XBRLException
Algorithm:
  1. Check if the matcher indicate that the URI has matching URIs.
  2. If the URI has matching URIs:
  3. If the URI is the one used for the document in the data store:
  4. Delete the URI from the matcher, getting the new matching URI back as a result of the deletion operation and update the document fragments to use the new matching URI instead of the deleted URI.
  5. Otherwise, just delete the URI from the matcher and we are done.
  6. Otherwise, the URI does not have matching URIs so just delete the URI from the matcher and delete the relevant fragments from the data store.

Specified by:
deleteDocument in interface Store
Parameters:
uri - The URI of the document to delete from the data store.
Throws:
XBRLException
See Also:
Store.deleteDocument(URI)

deleteRelatedDocuments

public void deleteRelatedDocuments(URI uri)
                            throws XBRLException
Description copied from interface: Store
This deletion method ensures that all related documents are also deleted from the data store. A related document is defined as a document that causes the discovery of this document. Note that this means that applying this method to an XBRL instance only causes the XBRL instance to be deleted because no other documents cause discovery of this document. This method is intended to allow document deletions to occur without violating the closure property of a DTS. In otherwords, if you want to delete the specified document from the DTS defined by the content of the data store, you also delete all documents that would require it to be in the DTS.

Specified by:
deleteRelatedDocuments in interface Store
Parameters:
uri - The URI of the document to delete.
Throws:
XBRLException
See Also:
Store.deleteRelatedDocuments(URI)

getReferencingDocuments

public List<URI> getReferencingDocuments(URI uri)
                                  throws XBRLException
Specified by:
getReferencingDocuments in interface Store
Parameters:
uri - The URI of the referenced document.
Returns:
a list of the URIs of the documents directly referencing the specified document as targets of their XLinks (custom or otherwise).
Throws:
XBRLException - if the list of referencing documents cannot be populated.
See Also:
Store.getReferencingDocuments(URI)

getReferencingFragments

public List<Fragment> getReferencingFragments(URI uri)
                                       throws XBRLException
Specified by:
getReferencingFragments in interface Store
Parameters:
uri - The URI of the referenced document.
Returns:
a list of the fragments directly referencing the specified document as targets of their XLinks (custom or otherwise). The list is empty if there are no fragments with the specified URI as the target URI of their link.
Throws:
XBRLException
See Also:
Store.getReferencingFragments(URI)

getReferencedDocuments

public Set<URI> getReferencedDocuments(URI uri)
                                throws XBRLException
Description copied from interface: Store
Override this method in a data store implementation if the data store implementation supports XQuery (rather than XPath).

Specified by:
getReferencedDocuments in interface Store
Parameters:
uri - The URI of the referencing document.
Returns:
a set of the documents directly referenced by this document.
Throws:
XBRLException - if the set of referenced documents cannot be populated.
See Also:
Store.getReferencedDocuments(URI)

serialize

public void serialize(Element what,
                      File destination)
               throws XBRLException
Description copied from interface: Store
Serialize the specified XML DOM to the specified destination.

Specified by:
serialize in interface Store
Parameters:
what - the root element of the DOM to be serialised.
destination - The destination file to be serialised to.
Throws:
XBRLException - if the DOM cannot be serialised because the destination cannot be written to or some other different problem occurs during serialisation.
See Also:
Store.serialize(Element, File)

getDocumentURIs

public Set<URI> getDocumentURIs()
                         throws XBRLException
Description copied from interface: Store
Get a list of the URIs that have been stored.

Specified by:
getDocumentURIs in interface Store
Returns:
a list of the URIs in the data store.
Throws:
XBRLException - if the list cannot be constructed.
See Also:
Store.getDocumentURIs()

hasDocument

public boolean hasDocument(URI uri)
                    throws XBRLException
Description copied from interface: Store
Test if a particular URI is already in the data store.

Specified by:
hasDocument in interface Store
Parameters:
uri - the string representation of the URI to be tested for.
Returns:
true if the document is in the store and false otherwise.
Throws:
XBRLException
See Also:
Store.hasDocument(URI)

getDocumentAsDOM

public Element getDocumentAsDOM(URI uri)
                         throws XBRLException
Description copied from interface: Store
Get a single document in the store as a DOM.

Specified by:
getDocumentAsDOM in interface Store
Parameters:
uri - The URI of the document to be retrieved.
Returns:
a DOM Document containing the XML representation of the file at the specified URI. Returns null if the store does not contain a document with the given URI.
Throws:
XBRLException - if the document cannot be constructed as a DOM.
See Also:
Store.getDocumentAsDOM(URI)

getSubtree

public Element getSubtree(Fragment f)
                   throws XBRLException
Description copied from interface: Store
Returns the root element of the subtree starting with the fragment with the specified index. All subtrees for a given store instance are produced from the one XML DOM and so can be appended to each other as required.

Specified by:
getSubtree in interface Store
Parameters:
f - The fragment at the root of the subtree.
Returns:
The root element of the subtree headed by the fragment with the specified index.
Throws:
XBRLException - if the subtree cannot be constructed.
See Also:
Store.getSubtree(Fragment)

getFollowingSibling

protected Element getFollowingSibling(Element parentElement,
                                      int precedingSiblings)
Get the following sibling of this fragment's root in the parent fragment's data.

Parameters:
parentElement - The parent element in the parent fragment's data.
precedingSiblings - The number of sibling elements preceding the element of interest.
Returns:
the following sibling of this fragment's root (or null if there is no preceding sibling).

getStoreAsDOM

public Document getStoreAsDOM()
                       throws XBRLException
Description copied from interface: Store
Get all data in the store as a single XML DOM object.

Specified by:
getStoreAsDOM in interface Store
Returns:
the XML DOM representation of the XBRL information in the data store.
Throws:
XBRLException - if the DOM cannot be constructed.
See Also:
Store.getStoreAsDOM()

getCompositeDocument

public Document getCompositeDocument()
                              throws XBRLException
Description copied from interface: Store
Get all data in the store as a single XML DOM object including the annotations used in the XBRLComposer project.

Specified by:
getCompositeDocument in interface Store
Returns:
the composed data store as a DOM object.
Throws:
XBRLException - if the composed data store cannot be constructed.
See Also:
Store.getCompositeDocument()

getStubs

public List<Stub> getStubs()
                    throws XBRLException
Specified by:
getStubs in interface Store
Returns:
a list of stub fragments (Those fragments indicating a document that needs to be added to the data store).
Throws:
XBRLException
See Also:
Store.getStubs()

getStubs

public List<Stub> getStubs(URI uri)
                    throws XBRLException
Specified by:
getStubs in interface Store
Parameters:
uri - The string value of the URI of the document to get the stub for.
Returns:
the list of stub fragments for the given URI.
Throws:
XBRLException
See Also:
Store.getStubs(URI)

removeStub

public void removeStub(Stub stub)
                throws XBRLException
Specified by:
removeStub in interface Store
Parameters:
stub - The stub to be removed from the data store.
Throws:
XBRLException
See Also:
Store.removeStub(Stub)

remove

public void remove(XML xml)
            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
Parameters:
xml - The XML resource to remove.
Throws:
XBRLException - if the XML resource cannot be removed from the store.
See Also:
Store.remove(XML)

getDocumentsToDiscover

public List<URI> getDocumentsToDiscover()
                                 throws XBRLException
Specified by:
getDocumentsToDiscover in interface Store
Returns:
the list of URIs of the documents remaining to be analysed.
Throws:
XBRLException - if any of the document URIs are malformed.
See Also:
Store.getDocumentsToDiscover()

saveDocuments

public void saveDocuments(File destination)
                   throws XBRLException
Description copied from interface: Store
Serializes the individual documents in the data store, saving them into a directory structure that is placed into the specified directory. The directory structure that is created mirrors the structure of the URIs of the documents. Note that the URIs of the documents that are written out will be reflected in the paths to those documents using the same rules as those applied for document caching.

Specified by:
saveDocuments in interface Store
Parameters:
destination - The folder in which the directory structure and the documents in the data store are to be saved.
Throws:
XBRLException - If the root folder does not exist or is not a directory or if the documents in the store cannot be saved to the local file system.
See Also:
Store.saveDocuments(File)

saveDocuments

public void saveDocuments(File destination,
                          String uriPrefix)
                   throws XBRLException
Description copied from interface: Store
Serializes those documents in the data store with a URI that begins with the specified URI prefix. They are saved to the local file system in the same manner as is applied for the saveDocuments method that operates on all documents in the data store.

Specified by:
saveDocuments in interface Store
Parameters:
destination - The folder in which the directory structure and the documents in the data store are to be saved.
uriPrefix - All documents in the data store with a URI that begins with the string specified by uriPrefix will be saved to the local file system.
Throws:
XBRLException - If the root folder does not exist or is not a directory or if the documents in the store cannot be saved to the local file system.
See Also:
Store.saveDocuments(File, String)

saveStoreAsSingleDocument

public void saveStoreAsSingleDocument(File file)
                               throws XBRLException
Description copied from interface: Store
Creates a single DOM structure from all documents in the data store and saves this single XML structure in the specified file.

Specified by:
saveStoreAsSingleDocument in interface Store
Parameters:
file - The file to save the Store content to.
Throws:
XBRLException - if the documents in the store cannot be saved to the single file.
See Also:
Store.saveStoreAsSingleDocument(File)

DOM2String

protected String DOM2String(Element element)
                     throws XBRLException
Convert a DOM element (and its descendents) to a string.

Parameters:
element - The element to convert to a string.
Returns:
The string that is the serialised element.
Throws:
XBRLException - if an IO exception occurs.

getXMLResources

public <F extends XML> List<F> getXMLResources(String interfaceName)
                                    throws XBRLException
Description copied from interface: Store
Return a list of XML resources in a data store that have a type corresponding to the specified XML resource interface name.

Specified by:
getXMLResources in interface Store
Parameters:
interfaceName - The name of the interface. EG: If a list of org.xbrlapi.impl.ReferenceArcImpl fragments is required then this parameter would have a value of "ReferenceArc". Note that if the parameter contains full stops, then it is used directly as the value for the fragment type, enabling fragment extensions to exploit this method without placing fragment implementations in the org.xbrlapi package.
Returns:
a list of XML resources with the given fragment type.
Throws:
XBRLException
See Also:
Store.getXMLResources(String)

getXMLResources

public <F extends XML> List<F> getXMLResources(Class<?> specifiedClass)
                                    throws XBRLException
Description copied from interface: Store
Return a list of XML resources in a data store that have a type corresponding to the specified XML resource interface name.

Specified by:
getXMLResources in interface Store
Parameters:
specifiedClass - The class of XML resources to retrieve.
Returns:
a list of XML resources with the given fragment type.
Throws:
XBRLException
See Also:
Store.getXMLResources(Class)

getChildFragments

public <F extends Fragment> List<F> getChildFragments(String interfaceName,
                                                      String parentIndex)
                                           throws XBRLException
Specified by:
getChildFragments in interface Store
Parameters:
interfaceName - The name of the interface. EG: If a list of org.xbrlapi.impl.ReferenceArcImpl fragments is required then this parameter would have a value of "ReferenceArc". Note that this method does not yet recognise fragment subtypes so a request for an Arc would not return all ReferenceArcs as well as other types of arcs.
parentIndex - The index of the parent fragment.
Returns:
a list of fragments with the given fragment type and with the given parent fragment. The list is empty if there are not child fragments.
Throws:
XBRLException
See Also:
Store.getChildFragments(String, String)

getChildFragments

public <F extends Fragment> List<F> getChildFragments(Class<?> childClass,
                                                      String parentIndex)
                                           throws XBRLException
Specified by:
getChildFragments in interface Store
Parameters:
childClass - The class of child fragment.
parentIndex - The index of the parent fragment.
Returns:
a list of fragments in the given fragment class and with the given parent fragment. The list is empty if there are no child fragments.
Throws:
XBRLException
See Also:
Store.getChildFragments(Class, String)

getNetworks

public Networks getNetworks()
                     throws XBRLException
Description copied from interface: Store
Note that this can massively overload resources if the data store is large because much of the information in the store will be reflected in -in-memory objects. Use this method with care.

Specified by:
getNetworks in interface Store
Returns:
the collection of all networks in the store.
Throws:
XBRLException
See Also:
Store.getNetworks()

getNetworks

public Networks getNetworks(URI arcrole)
                     throws XBRLException
Specified by:
getNetworks in interface Store
Parameters:
arcrole - The XLink arcrole value.
Returns:
the collection of networks expressed using arcs that involve this arc role.
Throws:
XBRLException
See Also:
Store.getNetworks(URI)

getNetworks

public Networks getNetworks(URI linkRole,
                            URI arcrole)
                     throws XBRLException
Specified by:
getNetworks in interface Store
Parameters:
linkRole - The linkrole of the networks.
arcrole - The arcrole of the networks.
Returns:
the collection of networks expressed using arcs that involve this linkrole and arcrole.
Throws:
XBRLException
See Also:
Store.getNetworks(URI,URI)

getLabels

public List<LabelResource> getLabels(String fragment,
                                     URI linkRole,
                                     URI resourceRole,
                                     String language)
                              throws XBRLException
Description copied from interface: Store
If using persisted relationships then the set of relationships used to generate the results can be modified by appropriate choice of

Specified by:
getLabels in interface Store
Parameters:
fragment - the index of the fragment that we are getting labels for
linkRole - The required link role or null if not used.
resourceRole - The required resource role or null if not used.
language - The required language code or null if not used.
Returns:
the set of labels matching the specified criteria.
Throws:
XBRLException
See Also:
Store.getLabels(String, URI, URI, String)

getLabels

public List<LabelResource> getLabels(String fragment,
                                     URI resourceRole,
                                     String language)
                              throws XBRLException
Description copied from interface: Store
Implemented by Store.getLabels(String,URI,URI,String).

Specified by:
getLabels in interface Store
Parameters:
fragment - the index of the fragment that we are getting labels for
resourceRole - The required resource role or null if not used.
language - The required language code or null if not used.
Returns:
the set of labels matching the specified criteria.
Throws:
XBRLException
See Also:
Store.getLabels(String, URI, String)

getLabels

public List<LabelResource> getLabels(String fragment,
                                     String language)
                              throws XBRLException
Description copied from interface: Store
Implemented by Store.getLabels(String,URI,URI,String).

Specified by:
getLabels in interface Store
Parameters:
fragment - the index of the fragment that we are getting labels for
language - The required language code or null if not used.
Returns:
the set of labels matching the specified criteria.
Throws:
XBRLException
See Also:
Store.getLabels(String, String)

getLabels

public List<LabelResource> getLabels(String fragment)
                              throws XBRLException
Description copied from interface: Store
Implemented by Store.getLabels(String,URI,URI,String).

Specified by:
getLabels in interface Store
Parameters:
fragment - the index of the fragment that we are getting labels for
Returns:
the set of labels matching the specified criteria.
Throws:
XBRLException
See Also:
Store.getLabels(String)

getLabels

public List<LabelResource> getLabels(String fragment,
                                     URI resourceRole)
                              throws XBRLException
Description copied from interface: Store
Implemented by Store.getLabels(String,URI,URI,String).

Specified by:
getLabels in interface Store
Parameters:
fragment - the index of the fragment that we are getting labels for
resourceRole - The required resource role or null if not used.
Returns:
the set of labels matching the specified criteria.
Throws:
XBRLException
See Also:
Store.getLabels(String, URI)

getReferences

public List<ReferenceResource> getReferences(String fragment,
                                             URI linkRole,
                                             URI resourceRole,
                                             String language)
                                      throws XBRLException
Description copied from interface: Store
If using persisted relationships then the set of relationships used to generate the results can be modified by appropriate choice of

Specified by:
getReferences in interface Store
Parameters:
fragment - the index of the fragment that we are getting references for
linkRole - The required link role or null if not used.
resourceRole - The required resource role or null if not used.
language - The required language code or null if not used.
Returns:
the set of references matching the specified criteria.
Throws:
XBRLException
See Also:
Store.getReferences(String, URI, URI, String)

getReferences

public List<ReferenceResource> getReferences(String fragment,
                                             URI resourceRole,
                                             String language)
                                      throws XBRLException
Description copied from interface: Store
Implemented by Store.getReferences(String,URI,URI,String).

Specified by:
getReferences in interface Store
Parameters:
fragment - the index of the fragment that we are getting references for
resourceRole - The required resource role or null if not used.
language - The required language code or null if not used.
Returns:
the set of references matching the specified criteria.
Throws:
XBRLException
See Also:
Store.getReferences(String, URI, String)

getReferences

public List<ReferenceResource> getReferences(String fragment,
                                             String language)
                                      throws XBRLException
Description copied from interface: Store
Implemented by Store.getReferences(String,URI,URI,String).

Specified by:
getReferences in interface Store
Parameters:
fragment - the index of the fragment that we are getting references for
language - The required language code or null if not used.
Returns:
the set of references matching the specified criteria.
Throws:
XBRLException
See Also:
Store.getReferences(String, String)

getReferences

public List<ReferenceResource> getReferences(String fragment)
                                      throws XBRLException
Description copied from interface: Store
Implemented by Store.getReferences(String,URI,URI,String).

Specified by:
getReferences in interface Store
Parameters:
fragment - the index of the fragment that we are getting references for
Returns:
the set of references matching the specified criteria.
Throws:
XBRLException
See Also:
Store.getReferences(String)

getReferences

public List<ReferenceResource> getReferences(String fragment,
                                             URI resourceRole)
                                      throws XBRLException
Description copied from interface: Store
Implemented by Store.getReferences(String,URI,URI,String).

Specified by:
getReferences in interface Store
Parameters:
fragment - the index of the fragment that we are getting references for
resourceRole - The required resource role or null if not used.
Returns:
the set of references matching the specified criteria.
Throws:
XBRLException
See Also:
Store.getReferences(String, URI)

getArcs

public List<Arc> getArcs(URI arcrole,
                         String linkIndex)
                  throws XBRLException
Specified by:
getArcs in interface Store
Parameters:
arcrole - The arcrole to use to identify the arcs to retrieve.
linkIndex - The index of the extended link containing the arcs to retrieve.
Returns:
the list of indices of arcs matching the selection criteria.
Throws:
XBRLException
See Also:
Store.getArcs(URI, String)

getArcs

public List<Arc> getArcs(String linkIndex)
                  throws XBRLException
Specified by:
getArcs in interface Store
Parameters:
linkIndex - The index of the extended link containing the arcs to retrieve.
Returns:
the list of indices of arcs matching the selection criteria.
Throws:
XBRLException
See Also:
Store.getArcs(String)

getArcIndices

public Set<String> getArcIndices(URI arcrole)
                          throws XBRLException
Specified by:
getArcIndices in interface Store
Parameters:
arcrole - The arcrole to use to identify the arcs to retrieve.
Returns:
the list of indices of arcs with a given arc role value.
Throws:
XBRLException
See Also:
Store.getArcIndices(URI)

getArcIndices

public Set<String> getArcIndices(String linkIndex)
                          throws XBRLException
Specified by:
getArcIndices in interface Store
Parameters:
linkIndex - The index of the extended link containing the arcs to retrieve.
Returns:
the list of indices of arcs matching the selection criteria.
Throws:
XBRLException
See Also:
Store.getArcIndices(String)

getExtendedLinkIndices

public Set<String> getExtendedLinkIndices(URI linkRole)
                                   throws XBRLException
Specified by:
getExtendedLinkIndices in interface Store
Parameters:
linkRole - The link role to use to identify the extended links to retrieve.
Returns:
the list of indices of extended links with the given link role value.
Throws:
XBRLException
See Also:
Store.getExtendedLinkIndices(URI)

getFragmentsFromDocument

public <F extends Fragment> List<F> getFragmentsFromDocument(URI uri,
                                                             String interfaceName)
                                                  throws XBRLException
Description copied from interface: Store
Utility method to return a list of fragments in a data store that have a type corresponding to the specified fragment interface name and that are in the document with the specified URI.

Specified by:
getFragmentsFromDocument in interface Store
Parameters:
uri - The URI of the document to get the fragments from.
interfaceName - The name of the interface. EG: If a list of fragments is required then this parameter would have a value of "ReferenceArc". Note that this method does not yet recognise fragment subtypes so a request for an Arc would not return all ReferenceArcs as well as other types of arcs.
Returns:
a list of fragments with the given fragment type and in the given document.
Throws:
XBRLException
See Also:
Store.getFragmentsFromDocument(URI, String)

getFragmentsFromDocument

public <F extends Fragment> List<F> getFragmentsFromDocument(URI uri,
                                                             Class<?> fragmentClass)
                                                  throws XBRLException
Specified by:
getFragmentsFromDocument in interface Store
Parameters:
uri - The URI of the document to get the fragments from.
fragmentClass - The class of fragment being sought.
Returns:
a list of fragments in the given fragment class and in the given document.
Throws:
XBRLException
See Also:
Store.getFragmentsFromDocument(URI, Class)

getFragmentIndicesFromDocument

public Set<String> getFragmentIndicesFromDocument(URI uri,
                                                  String interfaceName)
                                           throws XBRLException
Specified by:
getFragmentIndicesFromDocument in interface Store
Parameters:
uri - The URI of the document to get the fragments from.
interfaceName - The name of the interface. EG: If a list of concept fragments is required then this parameter would have a value of "Concept". Note that this method does not yet recognise fragment subtypes so a request for an ElementDeclaration would not return all concepts as well as other XML Schema element declarations.
Returns:
a list of fragment indices with the given fragment type and in the given document.
Throws:
XBRLException
See Also:
Store.getFragmentIndicesFromDocument(URI, String)

getFragmentIndicesFromDocument

public Set<String> getFragmentIndicesFromDocument(URI uri)
                                           throws XBRLException
Specified by:
getFragmentIndicesFromDocument in interface Store
Parameters:
uri - The URI of the document to get the fragments from.
Returns:
a list of indices for fragments in the given document.
Throws:
XBRLException
See Also:
Store.getFragmentIndicesFromDocument(URI)

getFragmentIndices

public Set<String> getFragmentIndices(String interfaceName)
                               throws XBRLException
Specified by:
getFragmentIndices in interface Store
Parameters:
interfaceName - The name of the interface. EG: If a list of Concept fragments is required then this parameter would have a value of "Concept". Note that this method does not yet recognise fragment subtypes so a request for an ElementDeclaration would not return all concepts as well as other XML Schema element declarations.
Returns:
a list of fragment indices with the given fragment type.
Throws:
XBRLException
See Also:
Store.getFragmentIndices(String)

getFacts

public List<Fact> getFacts()
                    throws XBRLException
Specified by:
getFacts in interface Store
Returns:
a list of all of the root-level facts in the data store (those facts that are children of the root element of an XBRL instance). Returns an empty list if no facts are found.
Throws:
XBRLException
See Also:
Store.getFacts()

getFacts

public List<Fact> getFacts(URI uri)
                    throws XBRLException
Specified by:
getFacts in interface Store
Parameters:
uri - The URI of the document to get the facts from.
Returns:
a list of all of the root-level facts in the specified document.
Throws:
XBRLException
See Also:
Store.getFacts(URI)

getAllFacts

public List<Fact> getAllFacts(URI uri)
                       throws XBRLException
Specified by:
getAllFacts in interface Store
Parameters:
uri - The URI of the document to get the facts from.
Returns:
a list of all of the facts (root level and those nested in tuples) in the document with the specified URI.
Throws:
XBRLException
See Also:
Store.getAllFacts(URI)

getAllFacts

public List<Fact> getAllFacts()
                       throws XBRLException
Specified by:
getAllFacts in interface Store
Returns:
a list of all of the facts (root level and those nested in tuples) in the data store.
Throws:
XBRLException
See Also:
Store.getAllFacts()

getRootFragmentForDocument

public <F extends Fragment> F getRootFragmentForDocument(URI uri)
                                              throws XBRLException
Specified by:
getRootFragmentForDocument in interface Store
Type Parameters:
F - The fragment extension class
Parameters:
uri - The URI of the document to get the root fragment for.
Returns:
the root fragment of the document with the given URI or null if no root fragment is available for the given URI.
Throws:
XBRLException - if more than one root fragment is found in the data store.
See Also:
Store.getRootFragmentForDocument(URI)

getRootFragments

public <F extends Fragment> List<F> getRootFragments()
                                          throws XBRLException
Specified by:
getRootFragments in interface Store
Type Parameters:
F - The fragment extension class
Returns:
the list of root fragments of the documents in the store.
Throws:
XBRLException - if more than one root fragment is found in the data store.
See Also:
Store.getRootFragments()

getRootFragments

public <F extends Fragment> List<F> getRootFragments(String interfaceName)
                                          throws XBRLException
Specified by:
getRootFragments in interface Store
Type Parameters:
F - The fragment extension class
Parameters:
interfaceName - The type of fragment to select by. Store.getXMLResources(String) gives details on how the type parameter is to be used.
Returns:
the list of root fragments of the documents in the store where the root fragments are of the specified type.
Throws:
XBRLException
See Also:
Store.getRootFragments(String)

getLanguage

public Language getLanguage(String encoding,
                            String code)
                     throws XBRLException
Specified by:
getLanguage in interface Store
Parameters:
encoding - The code identifying the language that the name of the language is expressed in.
code - The code that identifies the language being named.
Returns:
the Language fragment that specifies the name of the language for the given code, expressed in the language identified by the encoding or null or if there is no matching language name in the data store. The input parameters are converted to upper case before processing.
Throws:
XBRLException - if either parameter equals null.
See Also:
Store.getLanguage(String, String)

getLanguages

public List<Language> getLanguages(String code)
                            throws XBRLException
Specified by:
getLanguages in interface Store
Parameters:
code - The language code to get the language fragments for. The code is converted to upper case before processing.
Returns:
the list of language fragments giving names for the language associated with the specified language code.
Throws:
XBRLException - if the language code is null.
See Also:
Store.getLanguages(String)

getLanguageMap

public Map<String,Language> getLanguageMap(String code)
                                    throws XBRLException
Specified by:
getLanguageMap in interface Store
Parameters:
code - The language code to get a map of language fragments for.
Returns:
a map of languages. Each fragment in the map is keyed by the fragment encoding and it is a fragment supplying a name in the encoding for the language identified by the code.
Throws:
XBRLException
See Also:
Store.getLanguageMap(String)

queryForString

public String queryForString(String query)
                      throws XBRLException
Description copied from interface: Store
Run a query that is required to return a single string. Implementations of this method must be synchronized.

Specified by:
queryForString 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 single string that is the query result or null if the query does not return any strings.
Throws:
XBRLException - if the query cannot be executed or if the query result is not a single string.
See Also:
Store.queryForString(String)

getItems

public List<Item> getItems()
                    throws XBRLException
Specified by:
getItems in interface Store
Returns:
a list of all of the items in the data store.
Throws:
XBRLException
See Also:
Store.getItems()

getTuples

public List<Tuple> getTuples()
                      throws XBRLException
Specified by:
getTuples in interface Store
Returns:
a list of all of the tuples in the data store.
Throws:
XBRLException
See Also:
Store.getTuples()

getItems

public List<Item> getItems(URI uri)
                    throws XBRLException
Specified by:
getItems in interface Store
Parameters:
uri - The URI of the document to get the items from.
Returns:
a list of all of the root-level items in the data store.
Throws:
XBRLException
See Also:
Store.getItems(URI)

getTuples

public List<Tuple> getTuples(URI uri)
                      throws XBRLException
Specified by:
getTuples in interface Store
Parameters:
uri - The URI of the document to get the facts from.
Returns:
a list of all of the root-level tuples in the specified document.
Throws:
XBRLException
See Also:
Store.getTuples(URI)

getNetworkRoots

public <F extends Fragment> Set<F> getNetworkRoots(URI linkRole,
                                                   URI arcrole)
                                        throws XBRLException
Description copied from interface: Store
This implementation is not as strict as the XBRL 2.1 specification requires but it is generally faster and delivers sensible results. It will only fail if people use the same link role and arc role but rely on arc or link element differences to distinguish networks.

Implementation strategy is:
1. Get all extended link elements with the given link role.
2. Get all arcs with the given arc role.
3. Get all resources at the source of the arcs.
4. Return only those source resources that that are not target resources also.

Specified by:
getNetworkRoots in interface Store
Parameters:
linkRole - the role on the extended links that contain the network arcs.
arcrole - the arcrole on the arcs describing the network.
Returns:
The list of fragments for each of the resources that is identified as a root of the specified network (noting that a root resource is defined as a resource that is at the source of one or more relationships in the network and that is not at the target of any relationships in the network).
Throws:
XBRLException
See Also:
Store.getNetworkRoots(URI, URI)

getConcept

public Concept getConcept(URI namespace,
                          String name)
                   throws XBRLException
Specified by:
getConcept in interface Store
Parameters:
namespace - The namespace for the concept.
name - The local name for the concept.
Returns:
the concept fragment for the specified namespace and name.
Throws:
XBRLException - if more than one matching concept is found in the data store or if no matching concepts are found in the data store.
See Also:
Store.getConcept(URI, String)

getGlobalDeclaration

public <D extends SchemaDeclaration> D getGlobalDeclaration(URI namespace,
                                                            String name)
                                                 throws XBRLException
Specified by:
getGlobalDeclaration in interface Store
Parameters:
namespace - The target namespace for the schema containing the global declaration.
name - The local name for the global declaration.
Returns:
the declaration fragment with the specified namespace and name.
Throws:
XBRLException - if more than one matching declaration is found in the data store or if no matching declarations are found in the data store.
See Also:
Store.getGlobalDeclaration(URI, String)

getRoleTypes

public List<RoleType> getRoleTypes()
                            throws XBRLException
Specified by:
getRoleTypes in interface Store
Returns:
a list of roleType fragments
Throws:
XBRLException

getRoleTypes

public List<RoleType> getRoleTypes(URI uri)
                            throws XBRLException
Specified by:
getRoleTypes in interface Store
Returns:
a list of RoleType fragments with a given role
Throws:
XBRLException
See Also:
Store.getRoleTypes(URI)

getArcroleTypes

public List<ArcroleType> getArcroleTypes()
                                  throws XBRLException
Specified by:
getArcroleTypes in interface Store
Returns:
a list of arcroleType fragments
Throws:
XBRLException
See Also:
Store.getArcroleTypes()

getArcroleTypes

public List<ArcroleType> getArcroleTypes(URI uri)
                                  throws XBRLException
Specified by:
getArcroleTypes in interface Store
Returns:
a list of arcroleType fragments with a given arcrole
Throws:
XBRLException
See Also:
Store.getArcroleTypes(URI)

getResourceRoles

public List<URI> getResourceRoles()
                           throws XBRLException
Specified by:
getResourceRoles in interface Store
Returns:
a hash map indexed by resource roles that are used in extended links in the data store.
Throws:
XBRLException
See Also:
Store.getResourceRoles()

getMinimumDocumentSet

public Set<URI> getMinimumDocumentSet(URI uri)
                               throws XBRLException
Description copied from interface: Store
This is just a convenience method.

Specified by:
getMinimumDocumentSet in interface Store
Parameters:
uri - The single document URI to use as starting points for analysis.
Returns:
set of URIs for the documents in the data store that are referenced, directly or indirectly, by the document identified by the supplied URI.
Throws:
XBRLException - if some of the referenced documents are not in the data store.
See Also:
Store.getMinimumDocumentSet(URI)

getMinimumDocumentSet

public Set<URI> getMinimumDocumentSet(Collection<URI> starters)
                               throws XBRLException
Specified by:
getMinimumDocumentSet in interface Store
Parameters:
starters - The collection of URIs of the documents to use as starting points for analysis.
Returns:
set of URIs for the documents in the data store that are referenced, directly or indirectly, by any of the documents identified by the supplied collection of document URIs.
Throws:
XBRLException - if some of the referenced documents are not in the data store.
See Also:
Store.getMinimumDocumentSet(Collection)

getExtendedLinks

public List<ExtendedLink> getExtendedLinks(URI linkrole)
                                    throws XBRLException
Specified by:
getExtendedLinks in interface Store
Parameters:
linkrole - The required linkrole value.
Returns:
the list of extended links with the specified linkrole.
Throws:
XBRLException
See Also:
Store.getExtendedLinks(URI)

getMinimalNetworksWithArcrole

public Networks getMinimalNetworksWithArcrole(Fragment fragment,
                                              URI arcrole)
                                       throws XBRLException
Description copied from interface: Store
Convenience method for a single fragment.

Specified by:
getMinimalNetworksWithArcrole in interface Store
Throws:
XBRLException
See Also:
Store.getMinimalNetworksWithArcrole(Fragment, URI)

getMinimalNetworksWithArcrole

public Networks getMinimalNetworksWithArcrole(Set<Fragment> fragments,
                                              URI arcrole)
                                       throws XBRLException
Description copied from interface: Store
Get the networks that, at a minimum, contain the relationships from each of the given fragments working back through ancestor relationships as far as possible. This is useful for building up networks of relationships where you know the leaf nodes you want and need to get the necessary branches back to the relevant heirarchy roots but do not want any branches leading to other leaf nodes. The method only generates networks using active relationships (not overridden or prohibited relationships).

Specified by:
getMinimalNetworksWithArcrole in interface Store
Parameters:
fragments - The fragments to analyse.
arcrole - The required arcrole.
Returns:
The networks containing the relationships.
Throws:
XBRLException
See Also:
Store.getMinimalNetworksWithArcrole(Set, URI)

augmentNetworksForFragment

public void augmentNetworksForFragment(Fragment fragment,
                                       URI arcrole,
                                       Networks networks)
                                throws XBRLException
Description copied from interface: Store
This method is recursive.

Specified by:
augmentNetworksForFragment in interface Store
Parameters:
fragment - The fragment to use as the target for the relationships to be added to the networks.
arcrole - The arcrole for the networks to augment.
networks - The networks to augment.
Throws:
XBRLException
See Also:
Store.augmentNetworksForFragment(Fragment, URI, Networks)

augmentNetworkForFragment

public void augmentNetworkForFragment(Fragment fragment,
                                      Network network)
                               throws XBRLException
Description copied from interface: Store
This method is recursive.

Specified by:
augmentNetworkForFragment in interface Store
Parameters:
fragment - The fragment to use as the target for the relationships to be added to the networks.
network - The network that is to be augmented.
Throws:
XBRLException
See Also:
Store.augmentNetworkForFragment(Fragment, Network)

getMinimalNetwork

public Network getMinimalNetwork(Set<Fragment> fragments,
                                 URI linkRole,
                                 URI arcrole)
                          throws XBRLException
Specified by:
getMinimalNetwork in interface Store
Parameters:
fragments - The set of target node fragments in the network.
linkRole - The network link role value.
arcrole - The network arcrole value.
Returns:
the network built out from relevant roots to the supplied fragments. Branches (and trees) with no nodes in them that correspond to the supplied fragments are not included in the returned network.
Throws:
XBRLException
See Also:
Store.getMinimalNetwork(Set, URI, URI)

getArcroles

public Set<URI> getArcroles()
                     throws XBRLException
Specified by:
getArcroles in interface Store
Returns:
a list of arc roles that are used in extended links in the data store.
Throws:
XBRLException
See Also:
Store.getArcroles()

getLinkRoles

public Set<URI> getLinkRoles()
                      throws XBRLException
Specified by:
getLinkRoles in interface Store
Returns:
a hash map indexed by link roles that are used in extended links in the data store.
Throws:
XBRLException
See Also:
Store.getLinkRoles()

getLinkRoles

public Set<URI> getLinkRoles(URI arcrole)
                      throws XBRLException
Specified by:
getLinkRoles in interface Store
Parameters:
arcrole - The arcrole determining the extended links that are to be examined for linkroles that are used on links containing arcs with the required arcrole.
Returns:
a hashmap of link roles, with one entry for each link role that is used on an extended link that contains an arc with the required arcrole.
Throws:
XBRLException
See Also:
Store.getLinkRoles(URI)

getArcroles

public Set<URI> getArcroles(URI linkRole)
                     throws XBRLException
Specified by:
getArcroles in interface Store
Parameters:
linkRole - the specified linkrole to use in selecting arcroles.
Returns:
a list of arc roles that are used in extended links with the given link role.
Throws:
XBRLException - if any of the arcroles is not a valid URI.
See Also:
Store.getArcroles(URI)

getTargets

public <F extends Fragment> List<F> getTargets(String sourceIndex,
                                               URI linkRole,
                                               URI arcrole)
                                    throws XBRLException
Specified by:
getTargets in interface Store
Type Parameters:
F - The type of fragment.
Parameters:
sourceIndex - The index of the source fragment.
linkRole - The XLink link role.
arcrole - The XLink arcrole.
Returns:
the list of targets from the specified source where the relationship has the given link role and arcrole. If the link role is null then targets of relationships with any linkrole are returned. If the arcrole is null then targets of relationships with any arcrole are returned.
Throws:
XBRLException
See Also:
Store.getTargets(String, URI, URI)

getSources

public <F extends Fragment> List<F> getSources(String targetIndex,
                                               URI linkRole,
                                               URI arcrole)
                                    throws XBRLException
Specified by:
getSources in interface Store
Type Parameters:
F - The type of fragment.
Parameters:
targetIndex - The index of the target fragment.
linkRole - The XLink link role.
arcrole - The XLink arcrole.
Returns:
the set of sources related to the specified target where the relationship has the given link role and arcrole. If the link role is null then sources of relationships with any linkrole are returned. If the arcrole is null then sources of relationships with any arcrole are returned.
Throws:
XBRLException
See Also:
Store.getSources(String, URI, URI)

getSourceIndices

public Set<String> getSourceIndices(String targetIndex,
                                    URI linkRole,
                                    URI arcrole)
                             throws XBRLException
Specified by:
getSourceIndices in interface Store
Parameters:
targetIndex - The index of the target fragment.
linkRole - The XLink link role.
arcrole - The XLink arcrole.
Returns:
the set of indices of sources related to the specified target where the relationship has the given link role and arcrole. If the link role is null then sources of relationships with any linkrole are returned. If the arcrole is null then indices of sources of relationships with any arcrole are returned.
Throws:
XBRLException
See Also:
Store.getSourceIndices(String, URI, URI)

getRelationshipsFrom

public SortedSet<Relationship> getRelationshipsFrom(String sourceIndex,
                                                    URI linkRole,
                                                    URI arcrole)
                                             throws XBRLException
Description copied from interface: Store
If using persisted relationships then the set of relationships used to generate the results can be modified by appropriate choice of

Specified by:
getRelationshipsFrom in interface Store
Parameters:
sourceIndex - The source fragment index
linkRole - The XLink link role
arcrole - The XLink arcrole
Returns:
a sorted set of active relationships from the source fragment with the given link role and arcrole that have been persisted. The relationships are ordered by the order attributes on the arcs expressing the relationships.
Throws:
XBRLException
See Also:
Store.getRelationshipsFrom(String,URI,URI)

hasAllRelationships

public boolean hasAllRelationships(URI document)
                            throws XBRLException
Specified by:
hasAllRelationships in interface Store
Parameters:
document - The document URI.
Returns:
true if the store contains persisted relationships for all of the relationships expressed by the arcs in the specified document and false otherwise.
Throws:
XBRLException
See Also:
Store.hasAllRelationships(URI)

getRelationshipsTo

public SortedSet<Relationship> getRelationshipsTo(String targetIndex,
                                                  URI linkRole,
                                                  URI arcrole)
                                           throws XBRLException
Specified by:
getRelationshipsTo in interface Store
Parameters:
targetIndex - The target fragment index
linkRole - The XLink link role
arcrole - The XLink arcrole
Returns:
a sorted set of active relationships to the target fragment with the given link role and arcrole. The relationships are ordered by the order attribute on the arcs expressing them. The linkRole and the arcrole are ignored as selection criteria if they are null.
Throws:
XBRLException
See Also:
Store.getRelationshipsTo(String, URI, URI)

getNetworksFrom

public Networks getNetworksFrom(String sourceIndex,
                                URI linkRole,
                                URI arcrole)
                         throws XBRLException
Specified by:
getNetworksFrom in interface Store
Parameters:
sourceIndex - The source fragment index
linkRole - The XLink link role
arcrole - The XLink arcrole
Returns:
a set of networks comprising the relationships from the source fragment with the given link role and arcrole.
Throws:
XBRLException
See Also:
Store.getNetworksFrom(String,URI,URI)

getNetworksTo

public Networks getNetworksTo(String targetIndex,
                              URI linkRole,
                              URI arcrole)
                       throws XBRLException
Description copied from interface: Store
If using persisted relationships then the set of relationships used to generate the results can be modified by appropriate choice of

Specified by:
getNetworksTo in interface Store
Parameters:
targetIndex - The target fragment index
linkRole - The XLink link role or null if networks for all link roles are sought
arcrole - The XLink arcrole or null if networks for all arcroles are sought
Returns:
a set of networks comprising the relationships to the target fragment meeting the specified criteria.
Throws:
XBRLException
See Also:
Store.getNetworksTo(String,URI,URI)

getAnalyser

public Analyser getAnalyser()
Specified by:
getAnalyser in interface Store
Returns:
the persisted network analyser if one is being used and null otherwise.
See Also:
Store.getAnalyser()

setAnalyser

public void setAnalyser(Analyser analyser)
Specified by:
setAnalyser in interface Store
Parameters:
analyser - The persisted network analyser to use for network analysis when building the aspect model. Set to null if you do not want to build the aspect model using persisted network information.
See Also:
Store.setAnalyser(Analyser)

isPersistingRelationships

public boolean isPersistingRelationships()
Specified by:
isPersistingRelationships in interface Store
Returns:
true if the store is using persisted network information rather than using the raw network information embodied in XBRL fragments. Returns false otherwise.
See Also:
Store.isPersistingRelationships()

getNetworksFrom

public Networks getNetworksFrom(String sourceIndex,
                                URI arcrole)
                         throws XBRLException
Description copied from interface: Store
Implemented by Store.getNetworksFrom(String,URI,URI).

Specified by:
getNetworksFrom in interface Store
Parameters:
sourceIndex - The source fragment index
arcrole - The XLink arcrole
Returns:
a set of networks comprising the relationships from the source fragment with the given arcrole.
Throws:
XBRLException
See Also:
Store.getNetworksFrom(java.lang.String, java.net.URI)

getNetworksFrom

public Networks getNetworksFrom(String sourceIndex)
                         throws XBRLException
Description copied from interface: Store
Implemented by Store.getNetworksFrom(String,URI,URI).

Specified by:
getNetworksFrom in interface Store
Parameters:
sourceIndex - The source fragment index
Returns:
a set of networks comprising the relationships from the source fragment.
Throws:
XBRLException
See Also:
Store.getNetworksFrom(String)

getNetworksTo

public Networks getNetworksTo(String targetIndex,
                              URI arcrole)
                       throws XBRLException
Description copied from interface: Store
Implemented by Store.getNetworksTo(String,URI,URI).

Specified by:
getNetworksTo in interface Store
Parameters:
targetIndex - The target fragment index
arcrole - The XLink arcrole
Returns:
a set of networks comprising the relationships to the target fragment with the given arcrole.
Throws:
XBRLException
See Also:
Store.getNetworksTo(String, URI)

getNetworksTo

public Networks getNetworksTo(String targetIndex)
                       throws XBRLException
Description copied from interface: Store
Implemented by Store.getNetworksTo(String,URI,URI).

Specified by:
getNetworksTo in interface Store
Parameters:
targetIndex - The target fragment index
Returns:
a set of networks comprising the relationships to the target fragment.
Throws:
XBRLException
See Also:
Store.getNetworksTo(String)

getMissingDocumentURIs

public Set<URI> getMissingDocumentURIs()
                                throws XBRLException
Specified by:
getMissingDocumentURIs in interface Store
Returns:
a list of the URIs of documents that are discoverable given the content of the data store but that are not themselves in the data store.
Throws:
XBRLException
See Also:
Store.getMissingDocumentURIs()

requestLoadingRightsFor

public boolean requestLoadingRightsFor(Loader loader,
                                       URI document)
                                throws XBRLException
Description copied from interface: Store
Loaders need to call this method to indicate that they are going to take responsibility for loading the document. This can be used to prevent the same document from being loaded by several loaders operating in parallel.

Specified by:
requestLoadingRightsFor in interface Store
Parameters:
loader - The loader claiming loading rights.
document - The URI of the document that a loader is about to start loading.
Returns:
false if the document is already claimed by a different loader and true otherwise. Only start loading if this function returns true.
Throws:
XBRLException
See Also:
Store.requestLoadingRightsFor(Loader, URI)

recindLoadingRightsFor

public void recindLoadingRightsFor(Loader loader,
                                   URI document)
Description copied from interface: Store
Loaders need to call this method to indicate that they are recinding responsibility for loading the document. This can be used to prevent the same document from being loaded by several loaders operating in parallel.

Specified by:
recindLoadingRightsFor in interface Store
Parameters:
loader - The loader recinding loading rights.
document - The URI of the document whose loading rights are being recinded.
See Also:
Store.recindLoadingRightsFor(Loader, URI)

finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable

hashCode

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

equals

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

isLoading

public boolean isLoading()
Specified by:
isLoading in interface Store
Returns:
true if the store is currently being used by any loader for loading data.
See Also:
Store.isLoading()

startLoading

public void startLoading(Loader loader)
Specified by:
startLoading in interface Store
Parameters:
loader - The loader that has started to use this store for data loading.
See Also:
Store.startLoading(Loader)

stopLoading

public void stopLoading(Loader loader)
Specified by:
stopLoading in interface Store
Parameters:
loader - The loader that has stopped using this store for data loading.
See Also:
Store.stopLoading(Loader)

getSchemaContent

public <F extends SchemaContent> F getSchemaContent(URI namespace,
                                                    String name)
                                         throws XBRLException
Specified by:
getSchemaContent in interface Store
Parameters:
namespace - The target namespace of the schema with the desired content.
name - The name given to the schema component.
Returns:
The Schema content fragment that contains the declaration of the desired XML Schema component or null if no such fragment is in the data store.
Throws:
XBRLException
See Also:
Store.getSchemaContent(URI, String)

getSchema

public Schema getSchema(URI targetNamespace)
                 throws XBRLException
Specified by:
getSchema in interface Store
Parameters:
targetNamespace - The target namespace of the schema.
Returns:
the root fragment of the schema or null if there are no schemas with the specified target namespace.
Throws:
XBRLException - if there is more than one schema with the given target namespace or if the target namespace is null.
See Also:
Store.getSchema(java.net.URI)

getFactIndices

public Set<String> getFactIndices()
                           throws XBRLException
Specified by:
getFactIndices in interface Store
Returns:
a set of the indices of all root-level facts (those facts that are children of the root element of an XBRL instance). Returns an empty set if no such facts are found in the data store.
Throws:
XBRLException
See Also:
Store.getFactIndices()

getAllFactIndices

public Set<String> getAllFactIndices()
                              throws XBRLException
Specified by:
getAllFactIndices in interface Store
Returns:
a set of the indices of all facts (including those facts that are children of tuples). Returns an empty set if no such facts are found in the data store.
Throws:
XBRLException
See Also:
Store.getAllFactIndices()

getRootFragmentIndices

public Set<String> getRootFragmentIndices(String interfaceName)
                                   throws XBRLException
Specified by:
getRootFragmentIndices in interface Store
Parameters:
interfaceName - The name of the interface. EG: If a list of Concept fragments is required then this parameter would have a value of "Concept". Note that this method does not yet recognise fragment subtypes so a request for an ElementDeclaration would not return all concepts as well as other XML Schema element declarations.
Returns:
a list of root fragment indices with the given fragment type.
Throws:
XBRLException
See Also:
Store.getRootFragmentIndices(String)

getFacts

public List<Fact> getFacts(URI namespace,
                           String localname)
                    throws XBRLException
Specified by:
getFacts in interface Store
Parameters:
namespace - The namespace of the facts to select.
localname - The local name of the facts to select.
Returns:
the list of facts with the given namespace and local name in the data store.
Throws:
XBRLException - if either parameter is null.
See Also:
Store.getFacts(URI, String)

getFacts

public List<Fact> getFacts(Concept concept)
                    throws XBRLException
Specified by:
getFacts in interface Store
Parameters:
concept - The concept to get the facts for.
Returns:
the list of facts in the data store reporting values for the specified concept.
Throws:
XBRLException - if the parameter is null.
See Also:
Store.getFacts(Concept)

Get Java XBRL API implementation at SourceForge.net.