com.ihr.xbrl.dts
Class InstanceExplorer

java.lang.Object
  extended by com.ihr.xbrl.dts.InstanceExplorerAbstract
      extended by com.ihr.xbrl.dts.InstanceExplorer
All Implemented Interfaces:
ContextProvider, InstanceExplorerInterface, InstanceExplorerListener, UnitsProvider

public class InstanceExplorer
extends InstanceExplorerAbstract

This class provides methods to investigate the content of an XBRL instance document from a high level point of view so the development of tools reading the content of instance document will be much easier

Author:
Ignacio

Field Summary
 
Fields inherited from class com.ihr.xbrl.dts.InstanceExplorerAbstract
DAYS, FOREVER, HALVES, HOURS, MINUTES, MONTHS, NONSTANDARD, notesOrderer, QUARTERS, sDays, SECONDS, sForever, sHalves, sHours, sMinutes, sMonths, sNonstandard, sQuarters, sSeconds, sWeeks, sYears, unkownUnit, WEEKS, YEARS
 
Constructor Summary
InstanceExplorer(LangsProvider lp, HasBoySupport hb, NegatedSupport ns, DefaultUnitProviderInterface defaultUnitProvider)
           
 
Method Summary
 void addColumn(CompanyKey ck, ColumnPeriod col)
           
 void addContext(XBRLContext newContext, int dateStep)
          Adds a new context to this context provider.
 void addFact(XBRLFact fact)
          Receives notification a fact has been added to the instance being explored
 void clear()
           
 void delColumn(CompanyKey ck, ColumnPeriod col)
           
 void delContext(XBRLContext ctx)
          Removing a context requires removing all facts using the context.
 void delFact(XBRLFact fact, XBRLFactsList parent)
          Announces a fact has been removed from the instance being explored.
 void factChangedContext(XBRLFactItem fact, XBRLContext oldContext, XBRLContext newContext)
          Informs the Context provider that the fact has changed its context information.
 void factChangedUnit(XBRLFactNumeric fact, XBRLUnit oldUnit, XBRLUnit newUnit)
           
 XBRLFactItem findFact(java.util.ArrayList<Member<?>> allMembers)
          if the allMembers contains LineTitleMember elements, we need to resolve the hierarchy resolution before calling this method.
static java.util.GregorianCalendar gcCloneAndAdd(java.util.GregorianCalendar initial, int dateStep, boolean bSignIsPlus)
          Helper method to calculate the date end as a copy of the initial date and an amount of time since then
 java.util.Collection<XBRLContext> getAllContexts(CompanyKey ck, XBRLItem.PeriodType periodType)
          Access to a collection of all contexts that are associated with factColumns in this InstanceExplorer.
 java.util.Collection<XBRLUnit> getAllUnits(CompanyKey ck, XBRLItem item)
          Returns all the units in the instance document that are used by the company indicated by the CompanyKey parameter.
 ColumnPeriod getColumn(CompanyKey ck, int index, int dateStep)
           
 java.util.Iterator<ColumnPeriod> getColumnKeysIterator(CompanyKey ck, int dateStep)
           
 int[] getColumnsCount(CompanyKey ck, int dateStep, java.util.Collection<XMLElementDefinition> concepts, boolean bSkipEmptyColumns)
          Returns an array of indexes of columns with data for the list of concepts in the concepts parameter.
 java.util.Iterator<XBRLContext> getCompatibleContexts(XBRLFactItem fact, int dateStep)
          Returns an iterator over compatible contexts for this fact.
 int getDateStepForFact(XBRLFactItem item, int dateStep)
          Prepares a dateStep depending on the contextual information of the fact.
 java.util.Iterator<java.lang.String> getDateStepIterator(CompanyKey ck, int dateStep)
           
 int getDateStepNumKeys(CompanyKey ck, int dateStep)
           
 FactsColumn getFactsColumn(CompanyKey ck, ColumnPeriod period, int dateStep)
          This is never null.
 int getMaxGranularityCode()
           
static java.lang.String getStringOfDateStep(XBRLPeriod period, int dateStep, HasBoySupport hb)
           
 java.util.Vector<XBRLContext> getVectorForKey(CompanyKey ck, java.lang.String keyContexts, int dateStep)
          Access to a Vector of XBRLContexts
 void instanceEvent(InstanceExplorerEvent e)
           
static java.lang.String instanceModeToString(HandleDateStep.InstantMode instantMode)
           
static XBRLPeriod makePeriod(XBRLItem.PeriodType periodType, int dateStep, DTSContainer dts)
          Creates a period of a specified period type (Instant or Duration) and sets the values according to the dateStep value.
 void processContexts(java.util.Iterator<XBRLContext> contexts)
           
 void setInstance(XBRLInstance instance)
           
 
Methods inherited from class com.ihr.xbrl.dts.InstanceExplorerAbstract
addInstanceExplorerListener, getCompanyKeys, getFactNotes, getInstanceExplorerListeners, getNumberOfCompanies, getNumTokens, getStringOfDateStep, getSuggestedUnit, getSuggestedUnits, getVNotes, hasDataForCompany, indexOfDateStepCode, intTokenToString, removeInstanceExplorerListener, sendEvent, setSuggestedUnit, stepsCodeForIndex, stringTokenToInt
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InstanceExplorer

public InstanceExplorer(LangsProvider lp,
                        HasBoySupport hb,
                        NegatedSupport ns,
                        DefaultUnitProviderInterface defaultUnitProvider)
Method Detail

getMaxGranularityCode

public int getMaxGranularityCode()

setInstance

public void setInstance(XBRLInstance instance)

getVectorForKey

public java.util.Vector<XBRLContext> getVectorForKey(CompanyKey ck,
                                                     java.lang.String keyContexts,
                                                     int dateStep)
Access to a Vector of XBRLContexts

Parameters:
ck -
keyContexts -
dateStep -
Returns:
Vector<XBRLContext>

getFactsColumn

public FactsColumn getFactsColumn(CompanyKey ck,
                                  ColumnPeriod period,
                                  int dateStep)
This is never null. A new Facts Column is created if none is found

Parameters:
ck -
period -
dateStep -
Returns:
FactsColumn

getDateStepIterator

public java.util.Iterator<java.lang.String> getDateStepIterator(CompanyKey ck,
                                                                int dateStep)
Parameters:
dateStep -
Returns:
Iterator<String>
Throws:
javax.xml.transform.TransformerException
InstanceExplorerRuntimeException

getColumnKeysIterator

public java.util.Iterator<ColumnPeriod> getColumnKeysIterator(CompanyKey ck,
                                                              int dateStep)

getDateStepNumKeys

public int getDateStepNumKeys(CompanyKey ck,
                              int dateStep)

getColumnsCount

public int[] getColumnsCount(CompanyKey ck,
                             int dateStep,
                             java.util.Collection<XMLElementDefinition> concepts,
                             boolean bSkipEmptyColumns)
Returns an array of indexes of columns with data for the list of concepts in the concepts parameter.

If the concepts parameter is null, the returned array contains all columns, one index per column

The number of elements in the array is the number of columns

If there is no data for the company the function returns an empty array

Parameters:
ck - company key
dateStep - dateStep to consider
concepts - is a Collection of concepts to filter. if null all concepts are selected.
Returns:
array of integers

getColumn

public ColumnPeriod getColumn(CompanyKey ck,
                              int index,
                              int dateStep)

gcCloneAndAdd

public static java.util.GregorianCalendar gcCloneAndAdd(java.util.GregorianCalendar initial,
                                                        int dateStep,
                                                        boolean bSignIsPlus)
Helper method to calculate the date end as a copy of the initial date and an amount of time since then

Parameters:
initial - GregorianCalendar
dateStep - constant indicating the period duration. This constant corresponds with GregorianCalendar defined fields extended by constants defined in InstanceExplorerAbstract class
bSignIsPlus - boolean true means positive period false means negative period
Returns:
GregorianCalendar

getStringOfDateStep

public static java.lang.String getStringOfDateStep(XBRLPeriod period,
                                                   int dateStep,
                                                   HasBoySupport hb)
Parameters:
period - XBRLPeriod
dateStep -
Returns:
String

instanceModeToString

public static java.lang.String instanceModeToString(HandleDateStep.InstantMode instantMode)
Parameters:
instantMode -
Returns:

processContexts

public void processContexts(java.util.Iterator<XBRLContext> contexts)

getAllContexts

public java.util.Collection<XBRLContext> getAllContexts(CompanyKey ck,
                                                        XBRLItem.PeriodType periodType)

Access to a collection of all contexts that are associated with factColumns in this InstanceExplorer. And are of the specified context type.

The returned collection is ordered from the lowest date to the highest date.

If periodType is XBRLItem.UNDEFINED_PERIOD_TYPE then all context are included

Parameters:
ck -
periodType -
Returns:
Collection<XBRLContext>

getCompatibleContexts

public java.util.Iterator<XBRLContext> getCompatibleContexts(XBRLFactItem fact,
                                                             int dateStep)
Description copied from interface: ContextProvider
Returns an iterator over compatible contexts for this fact. the first element in the iterator is the context currently associated to the fact.

Returns:
Iterator<XBRLContext>

addContext

public void addContext(XBRLContext newContext,
                       int dateStep)
Description copied from interface: ContextProvider
Adds a new context to this context provider. This happens when the user creates a new context

Parameters:
newContext - XBRLContext to add
dateStep - the value of the dateStep container for the new context

delContext

public void delContext(XBRLContext ctx)
Removing a context requires removing all facts using the context.

This process is independent from removing the context from the instance document

Parameters:
ctx -

addFact

public void addFact(XBRLFact fact)
Receives notification a fact has been added to the instance being explored

Parameters:
fact -

delFact

public void delFact(XBRLFact fact,
                    XBRLFactsList parent)
Announces a fact has been removed from the instance being explored.

Note: after removing a fact from its container the fact parent is set to null.

The fact has to be removed from the parent container prior to call this method and this is the reason this method has a second parameter that indicated what the parent container was.

Parameters:
fact -
parent -

delColumn

public void delColumn(CompanyKey ck,
                      ColumnPeriod col)
Parameters:
ck -
col -

addColumn

public void addColumn(CompanyKey ck,
                      ColumnPeriod col)
Parameters:
ck -
col -

getAllUnits

public java.util.Collection<XBRLUnit> getAllUnits(CompanyKey ck,
                                                  XBRLItem item)
Returns all the units in the instance document that are used by the company indicated by the CompanyKey parameter. The first element in the collection will be the "preferred" unit for the item indicated in the item parameter. If item is null then the order will be random.

Parameters:
ck -
Returns:
Collection<XBRLUnit>

makePeriod

public static XBRLPeriod makePeriod(XBRLItem.PeriodType periodType,
                                    int dateStep,
                                    DTSContainer dts)

Creates a period of a specified period type (Instant or Duration) and sets the values according to the dateStep value.

For instant periods bigger than days the instant time is set to 24 hours before of the lowest time where today's date is in the dateStep period

For instant periods lower than days the instant time is set to the time of the lowest time where today's date is in the dateStep period. Minutes, seconds are set to 0 to indicate the non required precision.

For periods, the start date and end date is indicating the beginning and ending period time under the range specified by dateStep

Parameters:
periodType -
dateStep -
dts - DTSContainer
Returns:
XBRLPeriod

factChangedContext

public void factChangedContext(XBRLFactItem fact,
                               XBRLContext oldContext,
                               XBRLContext newContext)
Description copied from interface: ContextProvider
Informs the Context provider that the fact has changed its context information.


factChangedUnit

public void factChangedUnit(XBRLFactNumeric fact,
                            XBRLUnit oldUnit,
                            XBRLUnit newUnit)

getDateStepForFact

public int getDateStepForFact(XBRLFactItem item,
                              int dateStep)
Prepares a dateStep depending on the contextual information of the fact. If the fact is instant, the date step received in the dateStep parameter is returned

Parameters:
item - the XBRLFactItem
dateStep - suggested value for date step
Returns:
int representing the dateStep

clear

public void clear()
Specified by:
clear in interface InstanceExplorerInterface
Overrides:
clear in class InstanceExplorerAbstract

findFact

public XBRLFactItem findFact(java.util.ArrayList<Member<?>> allMembers)
Description copied from interface: InstanceExplorerInterface
if the allMembers contains LineTitleMember elements, we need to resolve the hierarchy resolution before calling this method. In other words, this method no longer supports LineTitleMember as members of the ArrayList

Returns:

instanceEvent

public void instanceEvent(InstanceExplorerEvent e)
Specified by:
instanceEvent in interface InstanceExplorerListener
Overrides:
instanceEvent in class InstanceExplorerAbstract


Copyright 2006-2009 Reporting Standard S.L., C/ Torrecilla del Puerto 1, 28043, Madrid, Espaņa