XBRLAPI

A Java API for XBRL


org.xbrlapi.aspects
Class FactSetImpl

java.lang.Object
  extended by org.xbrlapi.aspects.FactSetImpl
All Implemented Interfaces:
Serializable, FactSet

public class FactSetImpl
extends Object
implements FactSet

Fact Set Implementation

The implementation requires high performance for the FactSet.getAspectValues(Fact) method and the FactSet.getFacts(AspectValue) method. It should be noted that a fact will map to multiple aspect values and that an aspect value will, in general, map to multiple facts.

To support this performance requirement, a FactSet is implemented using three one-to-many maps . These are based on synchronised versions of the Google Collections Multimap.

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

Constructor Summary
FactSetImpl(AspectModel model)
           
 
Method Summary
 void addFact(Fact fact)
          Adds the fact to the fact set, computing the aspect values for the fact for each aspect in the fact set's aspect model.
<F extends Fact>
void
addFacts(Collection<F> facts)
          Adds the facts to the fact set, computing the aspect values for the facts for each aspect in the fact set's aspect model.
 void emptyLocalLabelCache()
          This method simply empties the label cache that is a local property of the fact set.
 AspectModel getAspectModel()
           
 AspectValue getAspectValue(URI aspectId, Fact fact)
           
 int getAspectValueCount(URI aspectId)
           
 String getAspectValueLabel(AspectValue value, List<String> locales, List<URI> resourceRoles, List<URI> linkRoles)
          This is a convenience method to give access to the labels generated by the labellers for the values of each aspect in the fact set's aspect model.
 String getAspectValueLabel(AspectValue value, String locale, URI resourceRole, URI linkRole)
          This is a convenience method to give access to the labels generated by the labellers for the values of each aspect in the fact set's aspect model.
 Set<AspectValue> getAspectValues()
           
 Collection<AspectValue> getAspectValues(Fact fact)
           
 Collection<AspectValue> getAspectValues(URI aspectId)
           
 Set<Fact> getFacts()
           
 Set<Fact> getFacts(AspectValue value)
           
 Set<Fact> getFacts(Collection<AspectValue> values)
           
 AspectModel getModel()
           
 Collection<Aspect> getPopulatedAspects()
           
 List<Fact> getRootFacts(URI aspectId)
           
 long getSize()
           
 boolean hasAspectValue(AspectValue value)
           
 boolean hasFact(Fact fact)
           
 boolean isPopulated(URI aspectId)
           
 boolean isSingular(URI aspectId)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FactSetImpl

public FactSetImpl(AspectModel model)
            throws XBRLException
Parameters:
model - The aspect model determining the aspects to work with.
Throws:
XBRLException
Method Detail

getModel

public AspectModel getModel()
Specified by:
getModel in interface FactSet
Returns:
the aspect model underpinning the fact set.
See Also:
FactSet.getModel()

getAspectModel

public AspectModel getAspectModel()
Specified by:
getAspectModel in interface FactSet
Returns:
the aspect model underpinning this fact set.
See Also:
FactSet.getAspectModel()

addFacts

public <F extends Fact> void addFacts(Collection<F> facts)
              throws XBRLException
Description copied from interface: FactSet
Adds the facts to the fact set, computing the aspect values for the facts for each aspect in the fact set's aspect model.

Specified by:
addFacts in interface FactSet
Parameters:
facts - The facts to add.
Throws:
XBRLException
See Also:
FactSet.addFacts(Collection)

addFact

public void addFact(Fact fact)
             throws XBRLException
Description copied from interface: FactSet
Adds the fact to the fact set, computing the aspect values for the fact for each aspect in the fact set's aspect model.

Specified by:
addFact in interface FactSet
Parameters:
fact - The fact to add.
Throws:
XBRLException
See Also:
FactSet.addFact(Fact)

getAspectValues

public Set<AspectValue> getAspectValues()
Specified by:
getAspectValues in interface FactSet
Returns:
the set of all aspect values.
See Also:
FactSet.getAspectValues()

getAspectValues

public Collection<AspectValue> getAspectValues(Fact fact)
                                        throws XBRLException
Specified by:
getAspectValues in interface FactSet
Parameters:
fact - The fact.
Returns:
the set of aspect values for the given fact, including missing values for those aspects for which the fact does not have a value.
Throws:
XBRLException
See Also:
FactSet.getAspectValues(Fact)

getAspectValue

public AspectValue getAspectValue(URI aspectId,
                                  Fact fact)
                           throws XBRLException
Specified by:
getAspectValue in interface FactSet
Parameters:
aspectId - the ID of the aspect to get the aspect value for.
fact - The fact.
Returns:
the aspect value for the given fact and aspect.
Throws:
XBRLException
See Also:
FactSet.getAspectValue(URI, Fact)

getAspectValues

public Collection<AspectValue> getAspectValues(URI aspectId)
Specified by:
getAspectValues in interface FactSet
Parameters:
aspectId - The ID of the aspect.
Returns:
the set of all values for the aspect, also always including the missing value.
See Also:
FactSet.getAspectValues(URI)

getAspectValueCount

public int getAspectValueCount(URI aspectId)
Specified by:
getAspectValueCount in interface FactSet
Parameters:
aspectId - The ID of the aspect.
Returns:
the number of non-missing aspect values for the given aspect.
See Also:
FactSet.getAspectValueCount(URI)

getFacts

public Set<Fact> getFacts()
Specified by:
getFacts in interface FactSet
Returns:
the set of all facts.
See Also:
FactSet.getFacts()

getFacts

public Set<Fact> getFacts(AspectValue value)
Specified by:
getFacts in interface FactSet
Parameters:
value - The aspect value.
Returns:
the set of facts with the given aspect value.
See Also:
FactSet.getFacts(AspectValue)

getFacts

public Set<Fact> getFacts(Collection<AspectValue> values)
Specified by:
getFacts in interface FactSet
Parameters:
values - The collection of aspect values that the returned facts must have.
Returns:
the set of facts that have all of the given aspect values.
See Also:
FactSet.getFacts(Collection)

hasAspectValue

public boolean hasAspectValue(AspectValue value)
Specified by:
hasAspectValue in interface FactSet
Parameters:
value - The aspect value to test for.
Returns:
true if the aspect value is in the set and false otherwise.
See Also:
FactSet.hasAspectValue(AspectValue)

hasFact

public boolean hasFact(Fact fact)
Specified by:
hasFact in interface FactSet
Parameters:
fact - The fact to test for.
Returns:
true if the fact is in the set and false otherwise.
See Also:
FactSet.hasFact(Fact)

getSize

public long getSize()
Specified by:
getSize in interface FactSet
Returns:
the number of facts in the fact set.
See Also:
FactSet.getSize()

isPopulated

public boolean isPopulated(URI aspectId)
Specified by:
isPopulated in interface FactSet
Parameters:
aspectId - The ID of the aspect.
Returns:
true if the fact set has non-missing values for the specified aspect.
See Also:
FactSet.isPopulated(URI)

isSingular

public boolean isSingular(URI aspectId)
Specified by:
isSingular in interface FactSet
Parameters:
aspectId - The ID of the aspect.
Returns:
true if the fact set has only one non-missing values for the specified aspect.
See Also:
FactSet.isSingular(URI)

getRootFacts

public List<Fact> getRootFacts(URI aspectId)
                        throws XBRLException
Specified by:
getRootFacts in interface FactSet
Parameters:
aspectId - The ID of the aspect of interest.
Returns:
a list of the facts in the fact set that have values for the specified aspect that are roots of the heirarchy of aspect values defined by the domain of the specified aspect.
Throws:
XBRLException
See Also:
FactSet.getRootFacts(URI)

getPopulatedAspects

public Collection<Aspect> getPopulatedAspects()
                                       throws XBRLException
Specified by:
getPopulatedAspects in interface FactSet
Returns:
a collection of the populated aspects in the underlying aspect model. This leaves out all aspects that only have the missing value as their aspect value, for all facts in the fact set.
Throws:
XBRLException
See Also:
FactSet.getPopulatedAspects()

emptyLocalLabelCache

public void emptyLocalLabelCache()
Description copied from interface: FactSet
This method simply empties the label cache that is a local property of the fact set.

Specified by:
emptyLocalLabelCache in interface FactSet
See Also:
FactSet.emptyLocalLabelCache()

getAspectValueLabel

public String getAspectValueLabel(AspectValue value,
                                  List<String> locales,
                                  List<URI> resourceRoles,
                                  List<URI> linkRoles)
                           throws XBRLException
Description copied from interface: FactSet
This is a convenience method to give access to the labels generated by the labellers for the values of each aspect in the fact set's aspect model.

Specified by:
getAspectValueLabel in interface FactSet
Parameters:
value - The aspect value
locales - The list of label locales from first, most preferred to last, least preferred. The list can include nulls or it can be null.
resourceRoles - The list of label XLink resource roles from first, most preferred to last, least preferred. The list can include nulls or it can be null.
linkRoles - The label link role from first, most preferred to last, least preferred. The list can include nulls or it can be null.
Returns:
the label for the given aspect value.
Throws:
XBRLException - if the aspect is not in the aspect model.
See Also:
FactSet.getAspectValueLabel(AspectValue, java.util.List, java.util.List, java.util.List)

getAspectValueLabel

public String getAspectValueLabel(AspectValue value,
                                  String locale,
                                  URI resourceRole,
                                  URI linkRole)
                           throws XBRLException
Description copied from interface: FactSet
This is a convenience method to give access to the labels generated by the labellers for the values of each aspect in the fact set's aspect model. Labels are cached, based on the full set of information about the label selection criteria. The label cache, can be emptied.

Specified by:
getAspectValueLabel in interface FactSet
Parameters:
value - The aspect value
locale - The label locale
resourceRole - The label XLink resource role
linkRole - The label link role
Returns:
the label for the given aspect value.
Throws:
XBRLException - if the aspect is not in the aspect model.
See Also:
FactSet.getAspectValueLabel(AspectValue, java.lang.String, java.net.URI, java.net.URI)

Get Java XBRL API implementation at SourceForge.net.