XBRLAPI

A Java API for XBRL


org.xbrlapi.aspects
Class CombinationsImpl

java.lang.Object
  extended by org.xbrlapi.aspects.CombinationsImpl
All Implemented Interfaces:
Serializable, Combinations

public class CombinationsImpl
extends Object
implements Combinations

Aspect value combinations implementation

This implementation requires a constructor that specifies the aspect model and the specific axis that the aspect value combinations will be required for. Thereafter, the list of values for each aspect must be set. How the list of aspect values is obtained is determined externally. It may be from a fact set or it may be from an aspect domain or it may be from a combination of the two. The ordering of aspect values is also determined externally to this object.

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

Constructor Summary
CombinationsImpl(AspectModel model, String axis)
          The aspect value lists are initialised to a list containing a single missing value.
 
Method Summary
 void clearAspectValues(URI aspectId)
          Removes the aspect values for the specified aspect.
 int getAncestorCount(URI aspectId)
           
 List<Aspect> getAspects()
           
 int getAspectValueCount(URI aspectId)
           
 List<AspectValue> getAspectValues(URI aspectId)
           
 String getAxis()
           
 int getCombinationCount()
           
 AspectValue getCombinationValue(URI aspectId, int combination)
          This method is useful when setting up filters for a specific combination of aspect values.
 Map<URI,AspectValue> getCombinationValues(int combination)
          This method is particularly useful in setting up fact set filtering based upon a combination of aspect values.
 int getDescendantCount(URI aspectId)
           
 boolean hasAspect(URI aspectId)
           
 void setAspectValues(FactSet factSet)
          For each aspect in the combination, its aspect values are set equal to the list of aspect values obtained from the fact set, sorted based on the comparator provided by the aspect's domain.
 void setAspectValues(URI aspectId, List<AspectValue> values)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CombinationsImpl

public CombinationsImpl(AspectModel model,
                        String axis)
                 throws XBRLException
The aspect value lists are initialised to a list containing a single missing value.

Parameters:
model - The model containing the aspects and their arrangement into axes.
axis - The model axis to generate a combination for.
Throws:
XBRLException - If the model does not have the specified axis.
Method Detail

getAncestorCount

public int getAncestorCount(URI aspectId)
                     throws XBRLException
Specified by:
getAncestorCount in interface Combinations
Parameters:
aspectId - The ID of the aspect of interest.
Returns:
the number of unique combinations of values for the aspects that precede the aspect of interest in the list of aspects associated with this combination. This value is useful in determining the number of times that you need to iterate over the values for the aspect of interest when building up a set of table headings. The value is one if this aspect is the first in the list of aspects.
Throws:
XBRLException - if the combinations do not include the specified Aspect.
See Also:
Combinations.getAncestorCount(URI)

hasAspect

public boolean hasAspect(URI aspectId)
                  throws XBRLException
Specified by:
hasAspect in interface Combinations
Parameters:
aspectId - The ID of the aspect of interest.
Returns:
true if the aspects in this combination include the one specified and false otherwise.
Throws:
XBRLException - if the aspect ID is null
See Also:
Combinations.hasAspect(URI)

setAspectValues

public void setAspectValues(URI aspectId,
                            List<AspectValue> values)
                     throws XBRLException
Specified by:
setAspectValues in interface Combinations
Parameters:
aspectId - The aspect whose values are being set.
values - The list of aspect values for the specified aspect.
Throws:
XBRLException - if a parameter is null or the aspect is not in the specified axis of the aspect model or if a value is for an aspect with an aspect ID that differs from the one provided as a parameter.
See Also:
Combinations.setAspectValues(URI, List)

clearAspectValues

public void clearAspectValues(URI aspectId)
                       throws XBRLException
Description copied from interface: Combinations
Removes the aspect values for the specified aspect.

Specified by:
clearAspectValues in interface Combinations
Parameters:
aspectId - The ID of the aspect of interest.
Throws:
XBRLException - if the combinations do not include the specified Aspect.
See Also:
Combinations.clearAspectValues(URI)

getAspectValueCount

public int getAspectValueCount(URI aspectId)
                        throws XBRLException
Specified by:
getAspectValueCount in interface Combinations
Parameters:
aspectId - The ID of the aspect of interest.
Returns:
the number of values for the specified aspect
Throws:
XBRLException - if the combinations do not include the specified Aspect.
See Also:
Combinations.getAspectValueCount(URI)

getAspectValues

public List<AspectValue> getAspectValues(URI aspectId)
                                  throws XBRLException
Specified by:
getAspectValues in interface Combinations
Parameters:
aspectId - The ID of the aspect of interest.
Returns:
the list of aspect values for the aspect of interest or the empty list of no aspect values have been set for the aspect of interest.
Throws:
XBRLException - if the combinations do not include the specified Aspect.
See Also:
Combinations.getAspectValues(URI)

getAspects

public List<Aspect> getAspects()
Specified by:
getAspects in interface Combinations
Returns:
the ordered list of the underlying aspects.
See Also:
Combinations.getAspects()

getDescendantCount

public int getDescendantCount(URI aspectId)
                       throws XBRLException
Specified by:
getDescendantCount in interface Combinations
Parameters:
aspectId - The ID of the aspect of interest.
Returns:
the number of unique combinations of values for the aspects that follow the aspect of interest in the list of aspects associated with this combination. This value is useful in determining the column or row span that you need for each value of the aspect of interest when building up a set of table headings. The value is 1 if there are no following aspects.
Throws:
XBRLException - if the combinations do not include the specified Aspect.
See Also:
Combinations.getDescendantCount(URI)

getAxis

public String getAxis()
Specified by:
getAxis in interface Combinations
Returns:
the axis of the model that this combinations object relates to.
See Also:
Combinations.getAxis()

getCombinationCount

public int getCombinationCount()
Specified by:
getCombinationCount in interface Combinations
Returns:
the total number of different combinations of aspect values.
See Also:
Combinations.getCombinationCount()

getCombinationValue

public AspectValue getCombinationValue(URI aspectId,
                                       int combination)
                                throws XBRLException
Description copied from interface: Combinations
This method is useful when setting up filters for a specific combination of aspect values. The combinations are numbered from zero to the total number of combinations less one.

Specified by:
getCombinationValue in interface Combinations
Parameters:
aspectId - The ID of the aspect that the value is being sought for.
combination - The index of the combination that an aspect value is being sought for.
Returns:
The value for the specified aspect in the specified combination.
Throws:
XBRLException
See Also:
Combinations.getCombinationValue(URI, int)

getCombinationValues

public Map<URI,AspectValue> getCombinationValues(int combination)
                                          throws XBRLException
Description copied from interface: Combinations
This method is particularly useful in setting up fact set filtering based upon a combination of aspect values.

Specified by:
getCombinationValues in interface Combinations
Parameters:
combination - The index of the combination of aspect values to retrieve
Returns:
a map from aspect IDs to the values of those aspects for the specified combination.
Throws:
XBRLException
See Also:
Combinations.getCombinationValues(int)

setAspectValues

public void setAspectValues(FactSet factSet)
                     throws XBRLException
Description copied from interface: Combinations
For each aspect in the combination, its aspect values are set equal to the list of aspect values obtained from the fact set, sorted based on the comparator provided by the aspect's domain.

Specified by:
setAspectValues in interface Combinations
Parameters:
factSet - set of facts to use when obtaining the aspect values.
Throws:
XBRLException - if the aspects parameter is null or the aspect is not in the specified axis of the aspect model.
See Also:
Combinations.setAspectValues(FactSet)

Get Java XBRL API implementation at SourceForge.net.