com.ihr.xbrl.mapper

## Class MapperBase

- java.lang.Object
- - com.ihr.xbrl.mapper.MapperBase

- All Implemented Interfaces:
    HasFacts
  Direct Known Subclasses:
    Mapper

      public abstract class MapperBase
      extends java.lang.Object
      implements HasFacts

  A Mapper Base is a base class for implementing a Mapper to convert values from any source to XBRL. This class allows for the basic functionality about adding facts, contexts, sections and data sources
  Author:
    Ignacio

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `MapperBase()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.String` | `addContext(MapperContext newContext)` Adds the context.
    `void` | `addFact(Fact newFact)` Adds a new Fact to the end of the Facts container.
    `void` | `addFactAt(Fact newFact, int pos)` Adds a new Fact at the position indicated by pos.
    `void` | `addSection(Section section)` This is called internally when a new Fact is added and the fact contains a section that is not on this file.
    `java.lang.String` | `addSource(XBRLDataSource ds)` Adds the source.
    `java.lang.String` | `addUnit(XBRLUnit newUnit)` Adds the unit.
    `java.util.Vector<java.util.Vector<java.lang.String>>` | `checkDuplicates()` Verifies the content of the mapper file and explore possible duplicate mappings (same concept for the same context and unit mapped more than once) If this happens the mapper has to make an election during the instance document generation time.
    `void` | `delFact(Fact fact)` Removes a fact from the container.
    `void` | `delSection(Section section)` Del section.
    `java.util.Vector<Fact>` | `getAllFactsForElement(XMLElementDefinition definition)` Return all facts associated with this element definition.
    `java.util.Vector<java.lang.String>` | `getAllMapIdentifiersForElement(XMLElementDefinition definition)` Return all map identifiers associated with this element definition.
    `java.util.Iterator<Fact>` | `getChildrenFacts()` Access to an iterator over the children facts of this object.
    `abstract java.lang.String` | `getCompany()` Gets the company.
    `MapperContext` | `getContextById(java.lang.String key)` Gets the context by id.
    `java.util.Collection<MapperContext>` | `getContexts()` Gets the contexts.
    `java.util.Iterator<java.lang.String>` | `getContextsKeys()` Gets the contexts keys.
    `Fact` | `getFactFromMapIdentifier(java.lang.String mapIdentifier)` Returns the Fact associated with the mapIdentifier or null if the mapIdentifier is not associated with any Fact.
    `java.lang.String` | `getKeyForSource(XBRLDataSource source)` Returns the key used for this XBRLDataSource.
    `java.lang.String` | `getMapIdentifierForElement(XMLElementDefinition definition)` Return the first map identifier associated to this element definition.
    `java.lang.String` | `getNewMapIdentifier(XMLElementDefinition element)` Generates a new identifier for the element used as a parameter.
    `HasFacts` | `getParent()` Access to the parent element of a Fact.
    `abstract java.lang.String` | `getScheme()` Gets the scheme.
    `Section` | `getSectionForKey(java.lang.String key)` Gets the section for key.
    `java.util.Set<java.lang.String>` | `getSectionKeys()` Gets the section keys.
    `java.util.Collection<Section>` | `getSections()` Gets the sections.
    `XBRLDataSource` | `getSourceForKey(java.lang.String key)` Returns the XBRLDataSource object associated with the specified key.
    `java.util.Set<java.lang.String>` | `getSourceKeys()` Returns the set of keys for data sources for this mapper.
    `XBRLUnit` | `getUnitForKey(java.lang.String key)` Returns the XBRLUnit object associated with the specified key.
    `java.util.Set<java.lang.String>` | `getUnitKeys()` Returns the set of keys for units for this mapper.
    `abstract MapVersion` | `getVersion()` Gets the version.
    `void` | `registerFact(Fact fact)` Registers a new fact has been added to the container.
    `void` | `unregisterFact(Fact fact)` Same as `HasFacts.registerFact(Fact)` but in this case for removing the information stored.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface com.ihr.xbrl.mapper.HasFacts

      `equals, hashCode`

- - ### Constructor Detail

    - #### MapperBase

          public MapperBase()

  - ### Method Detail

    - #### getChildrenFacts

          public java.util.Iterator<Fact> getChildrenFacts()

      Description copied from interface: `HasFacts`
      Access to an iterator over the children facts of this object.
      Specified by:
        `getChildrenFacts` in interface `HasFacts`
      Returns:
        Iterator over children facts

    - #### getParent

          public HasFacts getParent()

      Description copied from interface: `HasFacts`
      Access to the parent element of a Fact. This is null only when the current HasFacts is a template document
      Specified by:
        `getParent` in interface `HasFacts`
      Returns:
        Fact that represents a tupleFact or templateDocument. Null when current HasFacts object is the template.

    - #### addFact

          public void addFact(Fact newFact)

      Description copied from interface: `HasFacts`
      Adds a new Fact to the end of the Facts container.

      This method does not updates the taxonomy URLs.

      Specified by:
        `addFact` in interface `HasFacts`
      Parameters:
        `newFact` - the new fact to be added

    - #### addFactAt

          public void addFactAt(Fact newFact,
                       int pos)

      Description copied from interface: `HasFacts`
      Adds a new Fact at the position indicated by pos.
      Specified by:
        `addFactAt` in interface `HasFacts`
      Parameters:
        `newFact` - Fact to be added
        `pos` - integer. Zero based

    - #### delFact

          public void delFact(Fact fact)

      Description copied from interface: `HasFacts`
      Removes a fact from the container.
      Specified by:
        `delFact` in interface `HasFacts`
      Parameters:
        `fact` - Fact to remove

    - #### getVersion

          public abstract MapVersion getVersion()

      Gets the version.
      Returns:
        the version

    - #### getScheme

          public abstract java.lang.String getScheme()

      Gets the scheme.
      Returns:
        the scheme

    - #### getCompany

          public abstract java.lang.String getCompany()

      Gets the company.
      Returns:
        the company

    - #### getKeyForSource

          public java.lang.String getKeyForSource(XBRLDataSource source)

      Returns the key used for this XBRLDataSource. This is not efficient because sources are indexed by ID but this is not a problem because only GUIs are interested on this function and there will presumably be quite a small number of sources.

      This method returns null if the source is not found.

      Parameters:
        `source` - XBRLDataSource
      Returns:
        String

    - #### registerFact

          public void registerFact(Fact fact)

      Description copied from interface: `HasFacts`
      Registers a new fact has been added to the container. This method updates the Hashtables in the instance template and passes UP to its parent the registration of facts for tuples. This method is called internally by the API and should not be called manually
      Specified by:
        `registerFact` in interface `HasFacts`
      Parameters:
        `fact` - the fact

    - #### addSource

          public java.lang.String addSource(XBRLDataSource ds)

      Adds the source.
      Parameters:
        `ds` - the ds
      Returns:
        the new source key

    - #### addSection

          public void addSection(Section section)

      This is called internally when a new Fact is added and the fact contains a section that is not on this file.

      It is also possible calling this method for adding sections in advance

      Note: if the section already exists, the old section is replaced by the new section

      Parameters:
        `section` - Section to be added

    - #### delSection

          public void delSection(Section section)

      Del section.
      Parameters:
        `section` - the section

    - #### getContexts

          public java.util.Collection<MapperContext> getContexts()

      Gets the contexts.
      Returns:
        the contexts

    - #### getContextsKeys

          public java.util.Iterator<java.lang.String> getContextsKeys()

      Gets the contexts keys.
      Returns:
        the contexts keys

    - #### getContextById

          public MapperContext getContextById(java.lang.String key)

      Gets the context by id.
      Parameters:
        `key` - the key
      Returns:
        the context by id

    - #### getSections

          public java.util.Collection<Section> getSections()

      Gets the sections.
      Returns:
        the sections

    - #### getSectionKeys

          public java.util.Set<java.lang.String> getSectionKeys()

      Gets the section keys.
      Returns:
        the section keys

    - #### getSectionForKey

          public Section getSectionForKey(java.lang.String key)

      Gets the section for key.
      Parameters:
        `key` - the key
      Returns:
        the section for key

    - #### unregisterFact

          public void unregisterFact(Fact fact)

      Description copied from interface: `HasFacts`
      Same as `HasFacts.registerFact(Fact)` but in this case for removing the information stored.
      Specified by:
        `unregisterFact` in interface `HasFacts`
      Parameters:
        `fact` - the fact

    - #### addUnit

          public java.lang.String addUnit(XBRLUnit newUnit)

      Adds the unit.
      Parameters:
        `newUnit` - the new unit
      Returns:
        the string

    - #### addContext

          public java.lang.String addContext(MapperContext newContext)

      Adds the context.
      Parameters:
        `newContext` - the new context
      Returns:
        the string

    - #### getNewMapIdentifier

          public java.lang.String getNewMapIdentifier(XMLElementDefinition element)

      Generates a new identifier for the element used as a parameter. This operation is not thread safe. The returned value may be duplicate if multiple calls to this method are made without a method to add the new generated Fact
      Parameters:
        `element` - the element
      Returns:
        the new map identifier

    - #### getSourceKeys

          public java.util.Set<java.lang.String> getSourceKeys()

      Returns the set of keys for data sources for this mapper.
      Returns:
        Set<String> with all data source keys

    - #### getSourceForKey

          public XBRLDataSource getSourceForKey(java.lang.String key)

      Returns the XBRLDataSource object associated with the specified key.
      Parameters:
        `key` - string
      Returns:
        XBRLDataSource

    - #### getUnitKeys

          public java.util.Set<java.lang.String> getUnitKeys()

      Returns the set of keys for units for this mapper.
      Returns:
        Set<String> with all unit keys
      Since:
        2.6.11

    - #### getUnitForKey

          public XBRLUnit getUnitForKey(java.lang.String key)

      Returns the XBRLUnit object associated with the specified key.
      Parameters:
        `key` - string
      Returns:
        XBRLUnit
      Since:
        2.6.11

    - #### getMapIdentifierForElement

          public java.lang.String getMapIdentifierForElement(XMLElementDefinition definition)

      Return the first map identifier associated to this element definition.
      Parameters:
        `definition` - XMLElementDefinition
      Returns:
        String or null if not found

    - #### getAllMapIdentifiersForElement

          public java.util.Vector<java.lang.String> getAllMapIdentifiersForElement(XMLElementDefinition definition)

      Return all map identifiers associated with this element definition.
      Parameters:
        `definition` - XMLElementDefinition
      Returns:
        Vector<String>

    - #### getAllFactsForElement

          public java.util.Vector<Fact> getAllFactsForElement(XMLElementDefinition definition)

      Return all facts associated with this element definition.
      Parameters:
        `definition` - XMLElementDefinition
      Returns:
        Vector<Fact>

    - #### getFactFromMapIdentifier

          public Fact getFactFromMapIdentifier(java.lang.String mapIdentifier)

      Returns the Fact associated with the mapIdentifier or null if the mapIdentifier is not associated with any Fact.
      Parameters:
        `mapIdentifier` - string, key unique for each mapIdentifier
      Returns:
        the Fact object associated with this key

    - #### checkDuplicates

          public java.util.Vector<java.util.Vector<java.lang.String>> checkDuplicates()

      Verifies the content of the mapper file and explore possible duplicate mappings (same concept for the same context and unit mapped more than once) If this happens the mapper has to make an election during the instance document generation time.

      If two (or more) facts are mapped to income data one of the following may occurs:

      - The user may want to force duplicates to be processed independently, possibly generating duplicate facts in the output instance
      - The user may be interested in grouping the duplicates in a "sequence reduction" processing unit. In this case, the output of a "sequence reduction processing unit" will always be the minimum number of non duplicate facts.
      Returns:
        a Vector of Vector of Strings. The string matches a fact identifier. The most internal nested Vector contains the all fact identifiers that belongs to a duplicate group. The most external Vector is a Vector of the groups of identifiers.