XBRLAPI

A Java API for XBRL


org.xbrlapi.aspects
Class AspectModelImpl

java.lang.Object
  extended by org.xbrlapi.aspects.AspectModelImpl
All Implemented Interfaces:
Serializable, AspectModel
Direct Known Subclasses:
DimensionalAspectModelImpl, StandardAspectModel

public class AspectModelImpl
extends Object
implements AspectModel

Implementation of common aspect model methods.

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

Constructor Summary
AspectModelImpl(Store store)
           
 
Method Summary
 void addAspect(Aspect aspect)
          The aspect will be added as the last aspect in the default axis.
 void addAspect(Aspect parentAspect, Aspect aspect)
          The aspect will be added to the aspect model in the default axis and it will be immediately follow the parent aspect ID in the list of aspects associated with the default axis if that axis has the parent aspect in it.
 void addAspect(String axis, Aspect aspect)
          The aspect will be added as the last aspect in the given axis.
 void addAspect(String axis, Aspect parentAspect, Aspect aspect)
          The aspect will be added to the aspect model in the specified axis and it will be immediately follow the parent aspect ID in the list of aspects associated with the given axis if that axis has the parent aspect in it.
 boolean axisContainsAspect(String axis, URI aspectId)
           
 AspectModel duplicate()
           
 Aspect getAspect(URI aspectId)
           
 String getAspectLabel(URI aspectId, String locale, URI resourceRole, URI linkRole)
          This is a convenience method to give access to the labels generated by the labellers for each aspect in the aspect model.
 Collection<Aspect> getAspects()
           
 List<Aspect> getAspects(String axis)
           
 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 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 aspect model.
 Map<URI,AspectValue> getAspectValues(Context context)
           
 Map<URI,AspectValue> getAspectValues(Context context, Map<URI,AspectValue> existingValues)
           
 Map<URI,AspectValue> getAspectValues(Fact fact)
           
 Map<URI,AspectValue> getAspectValues(Fact fact, Map<URI,AspectValue> existingValues)
           
 Map<URI,AspectValue> getAspectValues(Unit unit)
           
 Map<URI,AspectValue> getAspectValues(Unit unit, Map<URI,AspectValue> existingValues)
           
 Set<String> getAxes()
           
 String getDefaultAxis()
           
 Labeller getLabeller(URI aspectId)
           
protected  Store getStore()
           
 boolean hasAspect(URI aspectId)
           
 boolean hasAxis(String axis)
           
 boolean hasLabeller(URI aspectId)
           
 void initialise()
          Initialises the aspects and the aspect value labellers in the aspect model.
 void moveAspects(String originalAxis, String newAxis)
           
 void setDefaultAxis(String defaultAxis)
           
 void setLabeller(URI aspectId, Labeller labeller)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AspectModelImpl

public AspectModelImpl(Store store)
                throws XBRLException
Parameters:
store - The data store required to create domains for some aspects.
Throws:
XBRLException - if the store is null.
Method Detail

initialise

public void initialise()
                throws XBRLException
Description copied from interface: AspectModel
Initialises the aspects and the aspect value labellers in the aspect model. This should be called after the constructor has been run. Implementations of this class should always start by calling the initialise method of their super-class, if such a method exists. This use of initialise enables us to separate the resource intensive initialisation process from the constructor process. This can be useful if there are ways to avoid the initialisation process because of information that is already available, eg in another aspect model. In particular, this is useful for aspect model duplication.

Specified by:
initialise in interface AspectModel
Throws:
XBRLException
See Also:
AspectModel.initialise()

getStore

protected Store getStore()
Returns:
the data store underlying this aspect model.

getDefaultAxis

public String getDefaultAxis()
Specified by:
getDefaultAxis in interface AspectModel
Returns:
the axis that new aspects are added to by default.
See Also:
AspectModel.getDefaultAxis()

setDefaultAxis

public void setDefaultAxis(String defaultAxis)
Specified by:
setDefaultAxis in interface AspectModel
Parameters:
defaultAxis - the axis to add aspects to by default.
See Also:
AspectModel.setDefaultAxis(String)

hasAxis

public boolean hasAxis(String axis)
Specified by:
hasAxis in interface AspectModel
Parameters:
axis - the axis.
Returns:
true if the aspect model has the specified axis and false otherwise.
See Also:
AspectModel.hasAxis(String)

hasAspect

public boolean hasAspect(URI aspectId)
Specified by:
hasAspect in interface AspectModel
Parameters:
aspectId - the aspect ID.
Returns:
true if the aspect model includes the aspect and false otherwise.
See Also:
AspectModel.hasAspect(URI)

getAspect

public Aspect getAspect(URI aspectId)
                 throws XBRLException
Specified by:
getAspect in interface AspectModel
Parameters:
aspectId - the aspect ID.
Returns:
The aspect if it is in the model.
Throws:
XBRLException - if the aspect is not in the model.
See Also:
AspectModel.getAspect(URI)

getAspects

public Collection<Aspect> getAspects()
                              throws XBRLException
Specified by:
getAspects in interface AspectModel
Returns:
a collection of all aspects in the aspect model, regardless of their axis.
Throws:
XBRLException
See Also:
AspectModel.getAspects()

getAspects

public List<Aspect> getAspects(String axis)
Specified by:
getAspects in interface AspectModel
Parameters:
axis - The unique (for the aspect model) identifier for an axis of the aspect model. Aspect models can have zero or more axes, each of which has an ordered sequence of aspects.
Returns:
the list of aspects for the specified axis. The list is empty if there are no aspects assigned to the chosen axis or the aspect model does not have the specified axis.
See Also:
AspectModel.getAspects(String)

axisContainsAspect

public boolean axisContainsAspect(String axis,
                                  URI aspectId)
Specified by:
axisContainsAspect in interface AspectModel
Parameters:
axis - The axis
aspectId - the aspect
Returns:
true if the axis is in the aspect model and contains the aspect and false otherwise.
See Also:
AspectModel.axisContainsAspect(String, URI)

addAspect

public void addAspect(String axis,
                      Aspect aspect)
Description copied from interface: AspectModel
The aspect will be added as the last aspect in the given axis. If the aspect model does not already have the given axis, that axis will be added to the aspect model. If the aspect model does not have a labeller, the labeller for the aspect is set to the default labeller.

Specified by:
addAspect in interface AspectModel
Parameters:
axis - the axis to put the aspect in, in last place in the ordering.
aspect - The aspect to add to the aspect model.
See Also:
AspectModel.addAspect(String, Aspect)

addAspect

public void addAspect(Aspect aspect)
Description copied from interface: AspectModel
The aspect will be added as the last aspect in the default axis. If the aspect model does not already have the default axis, that axis will be added to the aspect model.

Specified by:
addAspect in interface AspectModel
Parameters:
aspect - The aspect to add to the aspect model.
See Also:
AspectModel.addAspect(Aspect)

addAspect

public void addAspect(String axis,
                      Aspect parentAspect,
                      Aspect aspect)
               throws XBRLException
Description copied from interface: AspectModel
The aspect will be added to the aspect model in the specified axis and it will be immediately follow the parent aspect ID in the list of aspects associated with the given axis if that axis has the parent aspect in it. Otherwise the aspect will be added as the last aspect for the given axis. The labeller for the aspect is set to the default labeller.

Specified by:
addAspect in interface AspectModel
Parameters:
axis - the axis to put the aspect in.
parentAspect - The parent aspect for the aspect being added.
aspect - The aspect to add to the aspect model.
Throws:
XBRLException
See Also:
AspectModel.addAspect(String, Aspect, Aspect)

getLabeller

public Labeller getLabeller(URI aspectId)
                     throws XBRLException
Specified by:
getLabeller in interface AspectModel
Parameters:
aspectId - The ID of the aspect to get the labeller for.
Returns:
the labeller for the specified aspect. If no labeller has been explicitly set for the aspect, then the default labeller is returned.
Throws:
XBRLException - if the aspect ID is null.
See Also:
AspectModel.getLabeller(URI)

hasLabeller

public boolean hasLabeller(URI aspectId)
Specified by:
hasLabeller in interface AspectModel
Parameters:
aspectId - The ID of the aspect.
Returns:
true if the aspect model already has a labeller for the specified aspect and false otherwise. Returns false if the aspect ID is null.
See Also:
AspectModel.hasLabeller(URI)

setLabeller

public void setLabeller(URI aspectId,
                        Labeller labeller)
                 throws XBRLException
Specified by:
setLabeller in interface AspectModel
Parameters:
aspectId - The ID of the aspect that the labeller is to be used for.
labeller - The labeller to use.
Throws:
XBRLException - if a parameter is null or if the labeller is not for the specified aspect.
See Also:
AspectModel.setLabeller(URI, Labeller)

addAspect

public void addAspect(Aspect parentAspect,
                      Aspect aspect)
               throws XBRLException
Description copied from interface: AspectModel
The aspect will be added to the aspect model in the default axis and it will be immediately follow the parent aspect ID in the list of aspects associated with the default axis if that axis has the parent aspect in it. Otherwise the aspect will be added as the last aspect for the default axis.

Specified by:
addAspect in interface AspectModel
Parameters:
parentAspect - The parent aspect for the aspect being added.
aspect - The aspect to add to the aspect model.
Throws:
XBRLException
See Also:
AspectModel.addAspect(Aspect, Aspect)

getAxes

public Set<String> getAxes()
                    throws XBRLException
Specified by:
getAxes in interface AspectModel
Returns:
a set of strings, each of which is an axis of the aspect model.
Throws:
XBRLException
See Also:
AspectModel.getAxes()

getAspectValues

public Map<URI,AspectValue> getAspectValues(Fact fact)
                                     throws XBRLException
Specified by:
getAspectValues in interface AspectModel
Parameters:
fact - The fact to get the aspect values for.
Returns:
the map from Aspect IDs to values for those aspects, for the fact, with missing values for all aspects in the aspect model, that do not have a value for the given fact.
Throws:
XBRLException
See Also:
AspectModel.getAspectValues(Fact)

getAspectValues

public Map<URI,AspectValue> getAspectValues(Fact fact,
                                            Map<URI,AspectValue> existingValues)
                                     throws XBRLException
Specified by:
getAspectValues in interface AspectModel
Parameters:
fact - The fact to get the aspect values for.
existingValues - The map of aspect values that we already have and so do not need to get now.
Returns:
the map of existing and new aspect values, one for each aspect in this aspect model.
Throws:
XBRLException
See Also:
AspectModel.getAspectValues(Fact, Map)

getAspectValues

public Map<URI,AspectValue> getAspectValues(Context context)
                                     throws XBRLException
Specified by:
getAspectValues in interface AspectModel
Parameters:
context - The context to determine the aspect values from.
Returns:
the map of aspect values that can be constructed from the given context.
Throws:
XBRLException
See Also:
AspectModel.getAspectValues(Context)

getAspectValues

public Map<URI,AspectValue> getAspectValues(Context context,
                                            Map<URI,AspectValue> existingValues)
                                     throws XBRLException
Specified by:
getAspectValues in interface AspectModel
Parameters:
context - The context to get the aspect values for.
existingValues - The map of aspect values that we already have and so do not need to get now.
Returns:
the map of existing and new aspect values, one for each aspect in this aspect model.
Throws:
XBRLException
See Also:
AspectModel.getAspectValues(Context, Map)

getAspectValues

public Map<URI,AspectValue> getAspectValues(Unit unit)
                                     throws XBRLException
Specified by:
getAspectValues in interface AspectModel
Parameters:
unit - The unit to determine the aspect values from.
Returns:
the map of aspect values that can be constructed from the given unit.
Throws:
XBRLException
See Also:
AspectModel.getAspectValues(Unit)

getAspectValues

public Map<URI,AspectValue> getAspectValues(Unit unit,
                                            Map<URI,AspectValue> existingValues)
                                     throws XBRLException
Specified by:
getAspectValues in interface AspectModel
Parameters:
unit - The unit to get the aspect values for.
existingValues - The map of aspect values that we already have and so do not need to get now.
Returns:
the map of existing and new aspect values, one for each aspect in this aspect model.
Throws:
XBRLException
See Also:
AspectModel.getAspectValues(Unit, Map)

moveAspects

public void moveAspects(String originalAxis,
                        String newAxis)
                 throws XBRLException
Specified by:
moveAspects in interface AspectModel
Parameters:
originalAxis - The axis to move the aspects from
newAxis - The axis to move the aspects to
Throws:
XBRLException - if the original axis does not exist.
See Also:
AspectModel.moveAspects(String, String)

duplicate

public AspectModel duplicate()
                      throws XBRLException
Specified by:
duplicate in interface AspectModel
Returns:
a new aspect model that is a duplicate of this model. The aspects in the new aspect model are references to the same aspects as are in this aspect model (so this is not generating a real clone of the original aspect model) but the mapping from axis to aspects are cloned so that they can be changed in the duplicate aspect model without altering those mappings in the original aspect model. The data store is also not duplicated. In general, this does the work of the initialise method without doing a formal initialisation on the duplicate aspect model.
Throws:
XBRLException - if the aspect model does not support duplication.
See Also:
AspectModel.duplicate()

getAspectLabel

public String getAspectLabel(URI aspectId,
                             String locale,
                             URI resourceRole,
                             URI linkRole)
                      throws XBRLException
Description copied from interface: AspectModel
This is a convenience method to give access to the labels generated by the labellers for each aspect in the aspect model.

Specified by:
getAspectLabel in interface AspectModel
Parameters:
aspectId - the ID of the aspect being labelled.
locale - The label locale
resourceRole - The label XLink resource role
linkRole - The label link role
Returns:
the label for the given aspect.
Throws:
XBRLException - if the aspect is not in the aspect model.
See Also:
AspectModel.getAspectLabel(URI, String, URI, URI)

getAspectValueLabel

public String getAspectValueLabel(AspectValue value,
                                  String locale,
                                  URI resourceRole,
                                  URI linkRole)
                           throws XBRLException
Description copied from interface: AspectModel
This is a convenience method to give access to the labels generated by the labellers for the values of each aspect in the aspect model.

Specified by:
getAspectValueLabel in interface AspectModel
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:
AspectModel.getAspectValueLabel(AspectValue, String, URI, URI)

getAspectValueLabel

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

Specified by:
getAspectValueLabel in interface AspectModel
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:
AspectModel.getAspectValueLabel(AspectValue, List, List, List)

Get Java XBRL API implementation at SourceForge.net.