XBRLAPI

A Java API for XBRL


org.xbrlapi.networks
Class NetworkImpl

java.lang.Object
  extended by org.xbrlapi.networks.NetworkImpl
All Implemented Interfaces:
Serializable, Network

public class NetworkImpl
extends Object
implements Network, Serializable

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

Constructor Summary
NetworkImpl(Store store, URI linkRole, URI arcrole)
           
 
Method Summary
 void add(Network network)
          Adds relationships from the supplied network to this network where they are not already included.
 void addRelationship(Relationship relationship)
          Adds the relationship to the network.
 void addRelationships(Collection<Relationship> relationships)
          Adds the set of relationships to the network.
 void complete()
          Complete the network, finding all active relationships in the data store that participate in the network.
 boolean contains(String index)
           
 boolean equals(Object obj)
           
 Fragment get(String index)
           
 SortedSet<Relationship> getActiveRelationshipsFrom(String index)
           
 SortedSet<Relationship> getActiveRelationshipsTo(String index)
           
 List<Relationship> getAllActiveRelationships()
           
 List<Relationship> getAllRelationships()
           
 URI getArcrole()
           
<F extends Fragment>
List<F>
getChildren(String index)
           
 URI getLinkRole()
           
 int getNumberOfActiveRelationships()
           
 int getNumberOfRelationships()
           
<F extends Fragment>
List<F>
getParents(String index)
          Note that a fragment can have more than one parent fragment given that the networks are not just trees.
 Set<String> getRootFragmentIndices()
           
<F extends Fragment>
List<F>
getRootFragments()
           
 HashMap<String,HashMap<String,EquivalentRelationships>> getSourceRelationships()
           
 Store getStore()
           
 HashMap<String,HashMap<String,EquivalentRelationships>> getTargetRelationships()
           
 boolean hasActiveRelationshipsFrom(String index)
           
 boolean hasActiveRelationshipsTo(String index)
           
 boolean hasFragment(String index)
           
 int hashCode()
           
 boolean hasSingleParent(String index)
           
 boolean isLeaf(String index)
           
 boolean isRoot(String index)
           
 void setArcrole(URI arcrole)
           
 void setLinkRole(URI linkRole)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NetworkImpl

public NetworkImpl(Store store,
                   URI linkRole,
                   URI arcrole)
            throws XBRLException
Parameters:
store - The data store.
linkRole - The link role defining the network.
arcrole - The arc role defining the network.
Throws:
XBRLException - if the data store is null.
Method Detail

getArcrole

public URI getArcrole()
Specified by:
getArcrole in interface Network
Returns:
the arc role.
See Also:
Network.getArcrole()

setArcrole

public void setArcrole(URI arcrole)
                throws XBRLException
Specified by:
setArcrole in interface Network
Parameters:
arcrole - the arc role to set.
Throws:
XBRLException - if the arc role is null.
See Also:
Network.setArcrole(URI)

getLinkRole

public URI getLinkRole()
Specified by:
getLinkRole in interface Network
Returns:
the link role.
See Also:
Network.getLinkRole()

setLinkRole

public void setLinkRole(URI linkRole)
                 throws XBRLException
Specified by:
setLinkRole in interface Network
Parameters:
linkRole - the linkRole to set.
Throws:
XBRLException - if the link role is null.
See Also:
Network.setLinkRole(URI)

hasFragment

public boolean hasFragment(String index)
                    throws XBRLException
Specified by:
hasFragment in interface Network
Parameters:
index - The index of the fragment to check.
Returns:
true if the fragment with the supplied index is already included in the set of fragments participating in the network.
Throws:
XBRLException
See Also:
Network.hasFragment(String)

get

public Fragment get(String index)
             throws XBRLException
Specified by:
get in interface Network
Parameters:
index - The index of the fragment to get from the set of fragments already participating in the network.
Returns:
The requested fragment or null if the fragment is not already included in the set of fragments stored by the network.
Throws:
XBRLException
See Also:
Network.get(String)

getRootFragments

public <F extends Fragment> List<F> getRootFragments()
Specified by:
getRootFragments in interface Network
Type Parameters:
F - The type of fragment to use for the fragments in the list.
Returns:
a list of the fragments in the network that are roots in the sense that they are sources of relationships but not targets of relationships.
See Also:
Network.getRootFragments()

getRootFragmentIndices

public Set<String> getRootFragmentIndices()
Specified by:
getRootFragmentIndices in interface Network
Returns:
a list of the indexes of the fragments in the network that are roots in the sense that they are sources of relationships but not targets of relationships.
See Also:
Network.getRootFragmentIndices()

getStore

public Store getStore()
Specified by:
getStore in interface Network
Returns:
The data store that contains the network information.
See Also:
Network.getStore()

addRelationship

public void addRelationship(Relationship relationship)
                     throws XBRLException
Description copied from interface: Network
Adds the relationship to the network. If the relationship has already been recorded in the network, then it is not added again because that would be redundant and potentially confusing.

Specified by:
addRelationship in interface Network
Parameters:
relationship - The relationship to add.
Throws:
XBRLException
See Also:
Network.addRelationship(Relationship)

addRelationships

public void addRelationships(Collection<Relationship> relationships)
                      throws XBRLException
Description copied from interface: Network
Adds the set of relationships to the network.

Specified by:
addRelationships in interface Network
Parameters:
relationships - The relationship to add.
Throws:
XBRLException
See Also:
Network.addRelationships(Collection)

getActiveRelationshipsFrom

public SortedSet<Relationship> getActiveRelationshipsFrom(String index)
                                                   throws XBRLException
Specified by:
getActiveRelationshipsFrom in interface Network
Parameters:
index - The index of the source fragment.
Returns:
the relationships that override or prohibit all other equivalent relationships in the network and that run from the same source fragment. The list is ordered by the order attributes on the relationships from lowest to highest.
Throws:
XBRLException
See Also:
Network.getActiveRelationshipsFrom(String)

hasSingleParent

public boolean hasSingleParent(String index)
                        throws XBRLException
Specified by:
hasSingleParent in interface Network
Parameters:
index - the index of the fragment.
Returns:
true if the fragment with the given index has a single parent fragment in the network and false otherwise.
Throws:
XBRLException
See Also:
Network.hasSingleParent(String)

isRoot

public boolean isRoot(String index)
               throws XBRLException
Specified by:
isRoot in interface Network
Parameters:
index - the index of the fragment.
Returns:
true if the fragment with the given index has no parent fragments and false otherwise.
Throws:
XBRLException
See Also:
Network.isRoot(String)

isLeaf

public boolean isLeaf(String index)
               throws XBRLException
Specified by:
isLeaf in interface Network
Parameters:
index - the index of the fragment.
Returns:
true if the fragment with the given index has no child fragments in the network and false otherwise.
Throws:
XBRLException
See Also:
Network.isLeaf(String)

hasActiveRelationshipsFrom

public boolean hasActiveRelationshipsFrom(String index)
Specified by:
hasActiveRelationshipsFrom in interface Network
Parameters:
index - The index of the fragment to check.
Returns:
true if the network contains active relationships from the specified fragment and false otherwise.
See Also:
Network.hasActiveRelationshipsFrom(String)

hasActiveRelationshipsTo

public boolean hasActiveRelationshipsTo(String index)
Specified by:
hasActiveRelationshipsTo in interface Network
Parameters:
index - The index of the fragment to check.
Returns:
true if the network contains active relationships to the specified fragment and false otherwise.
See Also:
Network.hasActiveRelationshipsTo(String)

getActiveRelationshipsTo

public SortedSet<Relationship> getActiveRelationshipsTo(String index)
                                                 throws XBRLException
Specified by:
getActiveRelationshipsTo in interface Network
Parameters:
index - The index of the target fragment.
Returns:
the relationships that override or prohibit all other equivalent relationships in the network and that run to the same target fragment.
Throws:
XBRLException
See Also:
Network.getActiveRelationshipsTo(String)

getChildren

public <F extends Fragment> List<F> getChildren(String index)
                                     throws XBRLException
Specified by:
getChildren in interface Network
Type Parameters:
F - The type of org.xbrlapi.Fragment
Parameters:
index - The parent fragment index
Returns:
the list of children fragments for the specified parent fragment, or an empty list if there are no children fragments.
Throws:
XBRLException
See Also:
Network.getChildren(String)

getParents

public <F extends Fragment> List<F> getParents(String index)
                                    throws XBRLException
Description copied from interface: Network
Note that a fragment can have more than one parent fragment given that the networks are not just trees.

Specified by:
getParents in interface Network
Type Parameters:
F - The type of org.xbrlapi.Fragment
Parameters:
index - The child fragment index
Returns:
the list of parent fragments for the specified child fragment, or an empty list if there are no parent fragments.
Throws:
XBRLException
See Also:
Network.getParents(String)

getNumberOfRelationships

public int getNumberOfRelationships()
Specified by:
getNumberOfRelationships in interface Network
Returns:
the number of relationships (active or otherwise) in the network.
See Also:
Network.getNumberOfRelationships()

getNumberOfActiveRelationships

public int getNumberOfActiveRelationships()
Specified by:
getNumberOfActiveRelationships in interface Network
Returns:
the number of active relationships in the network.
See Also:
Network.getNumberOfActiveRelationships()

complete

public void complete()
              throws XBRLException
Description copied from interface: Network
Complete the network, finding all active relationships in the data store that participate in the network.

Specified by:
complete in interface Network
Throws:
XBRLException
See Also:
Network.complete()

contains

public boolean contains(String index)
Specified by:
contains in interface Network
Parameters:
index - The index of the fragment to check for in the network.
Returns:
true if the fragment is in the network and false otherwise.
See Also:
Network.contains(String)

getAllRelationships

public List<Relationship> getAllRelationships()
                                       throws XBRLException
Specified by:
getAllRelationships in interface Network
Returns:
the list of all relationships (active and inactive) in the network.
Throws:
XBRLException
See Also:
Network.getAllRelationships()

getAllActiveRelationships

public List<Relationship> getAllActiveRelationships()
                                             throws XBRLException
Specified by:
getAllActiveRelationships in interface Network
Returns:
the list of all active relationships in the network.
Throws:
XBRLException
See Also:
Network.getAllActiveRelationships()

add

public void add(Network network)
         throws XBRLException
Description copied from interface: Network
Adds relationships from the supplied network to this network where they are not already included.

Specified by:
add in interface Network
Parameters:
network - The network to be merged into this network.
Throws:
XBRLException
See Also:
Network.add(Network)

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)

getSourceRelationships

public HashMap<String,HashMap<String,EquivalentRelationships>> getSourceRelationships()

getTargetRelationships

public HashMap<String,HashMap<String,EquivalentRelationships>> getTargetRelationships()

Get Java XBRL API implementation at SourceForge.net.