com.ihr.xbrl.pojo

## Class XBRLPojoGenerator

- java.lang.Object
- - com.ihr.xbrl.pojo.XBRLPojoGenerator

-     public class XBRLPojoGenerator
      extends java.lang.Object

  Generates a POJO version of any other RS object version and recursively do the same for all required objects. For example, the generation of a com.ihr.xbrl.om.instance.XBRLInstance object will also convert the DTS objects, including the taxonomy, namespaces, linkbases, contexts etc etc.

  If the conversion is launched for the storage of the object in a permanent repository then it is required to set up this generator with a session object that will be used for storing the data in the database.
  if the session is not set then the conversion cannot be stored in a database but can be used for any other purposes.

  Author:
    Ignacio

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `EXTERNAL_FILES_DOCUMENT_CONTENT_METHOD` The EXTERNAL_FILES_DOCUMENT_CONTENT_METHOD property indicates how the content "nodes" of an XBRL Document already loaded from an external web site is going to be transformed into a sequence of bytes for storage into the content of the DOCUMENTS table.
    `static java.lang.String` | `READSOURCE` This is another possible value for the EXTERNAL_FILES_DOCUMENT_CONTENT_METHOD property.
    `static java.lang.String` | `SERIALIZE` This is the default value for the EXTERNAL_FILES_DOCUMENT_CONTENT_METHOD property.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `XBRLPojoGenerator()` Instantiates a new XBRL pojo generator.
    `XBRLPojoGenerator(java.util.Properties props)` Instantiates a new XBRL pojo generator.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `addClassExtension(PojoExtension<?,?> extension)` Register a new PojoExtension class to capture events during the generation of the POJO object model.
    `void` | `clear()` Liberates all resources cached during the pojo model generation
    `DTSContainer` | `generate(DTSContainer dts)` Generates a POJO version of the non POJO DTSContainer.
    `Namespace` | `generate(org.jdom.Namespace ns)` Generate.
    `QName` | `generate(javax.xml.namespace.QName q)` Generate.
    `XBRLHasDocumentation` | `generate(XBRLAllowsDocumentation parent)` Generate.
    `XBRLArcroleType` | `generate(XBRLArcroleType dtsArcroleType)` Generate.
    `XMLAttribute` | `generate(XBRLAttribute dtsAtt)` Generate.
    `XBRLContext` | `generate(XBRLContext context)` Generate.
    `XBRLDocument` | `generate(XBRLDocument dtsDoc)` Generate.
    `XBRLDocumentation` | `generate(XBRLDocumentation dtsDoc)` Generate.
    `XBRLEntity` | `generate(XBRLEntity entity)` Generate.
    `XBRLExtendedLink` | `generate(XBRLExtendedLink dtsExtLink)` Generate.
    `XBRLFact` | `generate(XBRLFact fact)` Generate.
    `XBRLFactItem` | `generate(XBRLFactItem fact)` Generate.
    `XBRLFactString` | `generate(XBRLFactNonNumeric fact)` Generate.
    `XBRLFactNumeric` | `generate(XBRLFactNumeric fact)` Generate.
    `XBRLFactList` | `generate(XBRLFactsList list)` FactList is an interface so generate the appropriate class.
    `XBRLFactTuple` | `generate(XBRLFactTuple fact)` Generate.
    `XBRLImport` | `generate(XBRLImport dtsImport)` Generate.
    `XBRLInstance` | `generate(XBRLInstance instance)` Generate.
    `XBRLInstance` | `generate(XBRLInstance instance, boolean bForUpdate)` Generates a new pojo instance document based on the content of the instance document submitted as a parameter.
    `XBRLInstance` | `generate(XBRLInstance instance, boolean bForUpdate, java.lang.String pathConversionRule)` Generates a new pojo instance document based on the content of the instance document submitted as a parameter.
    `XBRLItem` | `generate(XBRLItem dtsItem)` Generate.
    `XBRLLinkbase` | `generate(XBRLLinkbase dtsLinkbase)` Generate.
    `XBRLPeriod` | `generate(XBRLPeriod period)` Generate.
    `XBRLRelationship` | `generate(XBRLRelationship dtsRel)` Generate.
    `XBRLResource` | `generate(XBRLResource dtsRes)` Generate.
    `XBRLRoleArcroleType` | `generate(XBRLRoleAndArcroleTypes parent)` Generate.
    `XBRLRoleType` | `generate(XBRLRoleType dtsRoleType)` Generate.
    `XBRLScenario` | `generate(XBRLScenario scenario)` Generate.
    `XBRLSegment` | `generate(XBRLSegment segment)` Generate.
    `XBRLTaxonomy` | `generate(XBRLTaxonomy dtsTaxonomy)` Generate.
    `XBRLTuple` | `generate(XBRLTuple dtsTuple)` Generate.
    `XBRLUnit` | `generate(XBRLUnit unit)` Generate.
    `XBRLUsedOn` | `generate(XBRLUsedOn dtsOn)` Generate.
    `XMLFragment` | `generate(XMLFragment node)` Generate.
    `int` | `getObjectsCount()` Gets the objects count.
    `java.lang.String` | `getStatistics()` Gets the statistics.
    `void` | `registerBar(DTSLoadingBarInterface bar)` Register bar.
    `void` | `setSession(org.hibernate.Session session, DbUtil.Database databaseType)` Sets the session with the database.

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

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

- - ### Field Detail

    - #### EXTERNAL_FILES_DOCUMENT_CONTENT_METHOD

          public static final java.lang.String EXTERNAL_FILES_DOCUMENT_CONTENT_METHOD

      The EXTERNAL_FILES_DOCUMENT_CONTENT_METHOD property indicates how the content "nodes" of an XBRL Document already loaded from an external web site is going to be transformed into a sequence of bytes for storage into the content of the DOCUMENTS table. Possible values are:

      serialize: this is the default value. Means, the API will generate a new XBRLDocument (Taxonomy or Linkbase) from the original content. The new file will be semantically equivalent to the original one (same content) but may not be syntactically equal. The generation will always success because the document has been already loaded and validated. The generation is faster than obtaining it fron an external web site.

      readsource: this will open a new http connection to the external web site and will read the content again from the original location.

      See Also:
        Constant Field Values

    - #### SERIALIZE

          public static final java.lang.String SERIALIZE

      This is the default value for the EXTERNAL_FILES_DOCUMENT_CONTENT_METHOD property.
      See Also:
        `EXTERNAL_FILES_DOCUMENT_CONTENT_METHOD`, Constant Field Values

    - #### READSOURCE

          public static final java.lang.String READSOURCE

      This is another possible value for the EXTERNAL_FILES_DOCUMENT_CONTENT_METHOD property.
      See Also:
        `EXTERNAL_FILES_DOCUMENT_CONTENT_METHOD`, Constant Field Values

  - ### Constructor Detail

    - #### XBRLPojoGenerator

          public XBRLPojoGenerator()

      Instantiates a new XBRL pojo generator.

    - #### XBRLPojoGenerator

          public XBRLPojoGenerator(java.util.Properties props)

      Instantiates a new XBRL pojo generator.
      Parameters:
        `props` - the props

  - ### Method Detail

    - #### generate

          public XBRLInstance generate(XBRLInstance instance)
                                throws XBRLPojoGenerationException

      Generate.
      Parameters:
        `instance` - the instance
      Returns:
        the XBRL instance
      Throws:
        `XBRLPojoGenerationException` - the XBRL pojo generation exception

    - #### generate

          public XBRLInstance generate(XBRLInstance instance,
                              boolean bForUpdate)
                                throws XBRLPojoGenerationException

      Generates a new pojo instance document based on the content of the instance document submitted as a parameter. the variable bForUpdate may have two values: true, means that a new pojo will be created from the content of the instance regardless an instance already exist in the database. If a new instance exist in the database that instance will be updated. If bForUpdate is false then if an existing instance is in the database for the given document URI (key) then the document in the database is returned.
      Parameters:
        `instance` - RS Object model XBRL instance
        `bForUpdate` - boolean
      Returns:
        instance in the POJO object model
      Throws:
        `XBRLPojoGenerationException` - the XBRL pojo generation exception

    - #### generate

          public XBRLInstance generate(XBRLInstance instance,
                              boolean bForUpdate,
                              java.lang.String pathConversionRule)
                                throws XBRLPojoGenerationException

      Generates a new pojo instance document based on the content of the instance document submitted as a parameter. the variable bForUpdate may have two values: true, means that a new pojo will be created from the content of the instance regardless an instance already exist in the database. If a new instance exist in the database that instance will be updated. If bForUpdate is false then if an existing instance is in the database for the given document URI (key) then the document in the database is returned.
      Parameters:
        `instance` - RS Object model XBRL instance
        `bForUpdate` - boolean
        `pathConversionRule` - the path conversion rule
      Returns:
        instance in the POJO object model
      Throws:
        `XBRLPojoGenerationException` - the XBRL pojo generation exception

    - #### generate

          public XBRLFactList generate(XBRLFactsList list)
                                throws XBRLPojoGenerationException

      FactList is an interface so generate the appropriate class.
      Parameters:
        `list` - the list
      Returns:
        XBRLFactList
      Throws:
        `XBRLPojoGenerationException` - the XBRL pojo generation exception

    - #### generate

          public XBRLFact generate(XBRLFact fact)
                            throws XBRLPojoGenerationException

      Generate.
      Parameters:
        `fact` - the fact
      Returns:
        XBRLFact
      Throws:
        `XBRLPojoGenerationException` - the XBRL pojo generation exception

    - #### generate

          public XBRLFactItem generate(XBRLFactItem fact)
                                throws XBRLPojoGenerationException

      Generate.
      Parameters:
        `fact` - the fact
      Returns:
        XBRLFactItem
      Throws:
        `XBRLPojoGenerationException` - the XBRL pojo generation exception

    - #### generate

          public XBRLFactTuple generate(XBRLFactTuple fact)
                                 throws XBRLPojoGenerationException

      Generate.
      Parameters:
        `fact` - the fact
      Returns:
        XBRLFactTuple
      Throws:
        `XBRLPojoGenerationException` - the XBRL pojo generation exception

    - #### generate

          public XBRLFactString generate(XBRLFactNonNumeric fact)
                                  throws XBRLPojoGenerationException

      Generate.
      Parameters:
        `fact` - the fact
      Returns:
        XBRLFactString
      Throws:
        `XBRLPojoGenerationException` - the XBRL pojo generation exception

    - #### generate

          public XBRLFactNumeric generate(XBRLFactNumeric fact)
                                   throws XBRLPojoGenerationException

      Generate.
      Parameters:
        `fact` - the fact
      Returns:
        XBRLFactNumeric
      Throws:
        `XBRLPojoGenerationException` - the XBRL pojo generation exception

    - #### generate

          public XBRLUnit generate(XBRLUnit unit)
                            throws XBRLPojoGenerationException

      Generate.
      Parameters:
        `unit` - the unit
      Returns:
        XBRLUnit pojo
      Throws:
        `XBRLPojoGenerationException`

    - #### generate

          public XBRLContext generate(XBRLContext context)
                               throws XBRLPojoGenerationException

      Generate.
      Parameters:
        `context` - the context
      Returns:
        XBRLContext
      Throws:
        `XBRLPojoGenerationException` - the XBRL pojo generation exception

    - #### generate

          public XBRLScenario generate(XBRLScenario scenario)
                                throws XBRLPojoGenerationException

      Generate.
      Parameters:
        `scenario` - the scenario
      Returns:
        XBRLScenario
      Throws:
        `XBRLPojoGenerationException` - the XBRL pojo generation exception

    - #### generate

          public XBRLPeriod generate(XBRLPeriod period)
                              throws XBRLPojoGenerationException

      Generate.
      Parameters:
        `period` - the period
      Returns:
        XBRLPeriod
      Throws:
        `XBRLPojoGenerationException`

    - #### generate

          public XBRLEntity generate(XBRLEntity entity)
                              throws XBRLPojoGenerationException

      Generate.
      Parameters:
        `entity` - the entity
      Returns:
        XBRLEntity
      Throws:
        `XBRLPojoGenerationException` - the XBRL pojo generation exception

    - #### generate

          public XBRLSegment generate(XBRLSegment segment)
                               throws XBRLPojoGenerationException

      Generate.
      Parameters:
        `segment` - the segment
      Returns:
        XBRLSegment
      Throws:
        `XBRLPojoGenerationException` - the XBRL pojo generation exception

    - #### generate

          public DTSContainer generate(DTSContainer dts)
                                throws XBRLPojoGenerationException

      Generates a POJO version of the non POJO DTSContainer.
      Parameters:
        `dts` - Regular, non POJO, DTS Container
      Returns:
        DTSContainer
      Throws:
        `XBRLPojoGenerationException` - the XBRL pojo generation exception

    - #### clear

          public void clear()

      Liberates all resources cached during the pojo model generation

    - #### generate

          public XBRLItem generate(XBRLItem dtsItem)
                            throws XBRLPojoGenerationException

      Generate.
      Parameters:
        `dtsItem` - the dts item
      Returns:
        the XBRL item
      Throws:
        `XBRLPojoGenerationException` - the XBRL pojo generation exception

    - #### generate

          public QName generate(javax.xml.namespace.QName q)
                         throws XBRLPojoGenerationException

      Generate.
      Parameters:
        `q` - QName
      Returns:
        QName pojo
      Throws:
        `XBRLPojoGenerationException`

    - #### generate

          public Namespace generate(org.jdom.Namespace ns)
                             throws XBRLPojoGenerationException

      Generate.
      Parameters:
        `ns` - the ns
      Returns:
        Namespace pojo
      Throws:
        `XBRLPojoGenerationException`

    - #### generate

          public XMLAttribute generate(XBRLAttribute dtsAtt)
                                throws XBRLPojoGenerationException

      Generate.
      Parameters:
        `dtsAtt` - the dts att
      Returns:
        XMLAttribute
      Throws:
        `XBRLPojoGenerationException` - the XBRL pojo generation exception

    - #### generate

          public XBRLTuple generate(XBRLTuple dtsTuple)
                             throws XBRLPojoGenerationException

      Generate.
      Parameters:
        `dtsTuple` - the dts tuple
      Returns:
        the XBRL tuple
      Throws:
        `XBRLPojoGenerationException` - the XBRL pojo generation exception

    - #### generate

          public XBRLTaxonomy generate(XBRLTaxonomy dtsTaxonomy)
                                throws XBRLPojoGenerationException

      Generate.
      Parameters:
        `dtsTaxonomy` - the dts taxonomy
      Returns:
        the XBRL taxonomy
      Throws:
        `XBRLPojoGenerationException` - the XBRL pojo generation exception

    - #### generate

          public XBRLImport generate(XBRLImport dtsImport)
                              throws XBRLPojoGenerationException

      Generate.
      Parameters:
        `dtsImport` - the dts import
      Returns:
        XBRLImport
      Throws:
        `XBRLPojoGenerationException` - the XBRL pojo generation exception

    - #### generate

          public XBRLResource generate(XBRLResource dtsRes)
                                throws XBRLPojoGenerationException

      Generate.
      Parameters:
        `dtsRes` - the dts res
      Returns:
        the XBRL resource
      Throws:
        `XBRLPojoGenerationException` - the XBRL pojo generation exception

    - #### generate

          public XBRLExtendedLink generate(XBRLExtendedLink dtsExtLink)
                                    throws XBRLPojoGenerationException

      Generate.
      Parameters:
        `dtsExtLink` - the dts ext link
      Returns:
        XBRLExtendedLink
      Throws:
        `XBRLPojoGenerationException` - the XBRL pojo generation exception

    - #### generate

          public XBRLDocument generate(XBRLDocument dtsDoc)
                                throws XBRLPojoGenerationException

      Generate.
      Parameters:
        `dtsDoc` - the dts doc
      Returns:
        XBRLDocument
      Throws:
        `XBRLPojoGenerationException` - the XBRL pojo generation exception

    - #### generate

          public XBRLRelationship generate(XBRLRelationship dtsRel)
                                    throws XBRLPojoGenerationException

      Generate.
      Parameters:
        `dtsRel` - the dts rel
      Returns:
        XBRLRelationship
      Throws:
        `XBRLPojoGenerationException` - the XBRL pojo generation exception

    - #### generate

          public XMLFragment generate(XMLFragment node)
                               throws XBRLPojoGenerationException

      Generate.
      Parameters:
        `node` - the node
      Returns:
        XMLFragment
      Throws:
        `XBRLPojoGenerationException` - the XBRL pojo generation exception

    - #### generate

          public XBRLLinkbase generate(XBRLLinkbase dtsLinkbase)
                                throws XBRLPojoGenerationException

      Generate.
      Parameters:
        `dtsLinkbase` - the dts linkbase
      Returns:
        XBRLLinkbase
      Throws:
        `XBRLPojoGenerationException` - the XBRL pojo generation exception

    - #### generate

          public XBRLArcroleType generate(XBRLArcroleType dtsArcroleType)
                                   throws XBRLPojoGenerationException

      Generate.
      Parameters:
        `dtsArcroleType` - the dts arcrole type
      Returns:
        XBRLArcroleType
      Throws:
        `XBRLPojoGenerationException` - the XBRL pojo generation exception

    - #### generate

          public XBRLRoleType generate(XBRLRoleType dtsRoleType)
                                throws XBRLPojoGenerationException

      Generate.
      Parameters:
        `dtsRoleType` - the dts role type
      Returns:
        XBRLRoleType
      Throws:
        `XBRLPojoGenerationException` - the XBRL pojo generation exception

    - #### generate

          public XBRLDocumentation generate(XBRLDocumentation dtsDoc)
                                     throws XBRLPojoGenerationException

      Generate.
      Parameters:
        `dtsDoc` - the dts doc
      Returns:
        the XBRL documentation
      Throws:
        `XBRLPojoGenerationException` - the XBRL pojo generation exception

    - #### generate

          public XBRLHasDocumentation generate(XBRLAllowsDocumentation parent)
                                        throws XBRLPojoGenerationException

      Generate.
      Parameters:
        `parent` - the parent
      Returns:
        XBRLHasDocumentation
      Throws:
        `XBRLPojoGenerationException` - the XBRL pojo generation exception

    - #### generate

          public XBRLRoleArcroleType generate(XBRLRoleAndArcroleTypes parent)
                                       throws XBRLPojoGenerationException

      Generate.
      Parameters:
        `parent` - the parent
      Returns:
        the XBRL role arcrole type
      Throws:
        `XBRLPojoGenerationException` - the XBRL pojo generation exception

    - #### generate

          public XBRLUsedOn generate(XBRLUsedOn dtsOn)
                              throws XBRLPojoGenerationException

      Generate.
      Parameters:
        `dtsOn` - the dts on
      Returns:
        XBRLUsedOn
      Throws:
        `XBRLPojoGenerationException` - the XBRL pojo generation exception

    - #### registerBar

          public void registerBar(DTSLoadingBarInterface bar)

      Register bar.
      Parameters:
        `bar` - the bar

    - #### getObjectsCount

          public int getObjectsCount()

      Gets the objects count.
      Returns:
        the objects count

    - #### getStatistics

          public java.lang.String getStatistics()

      Gets the statistics.
      Returns:
        the statistics

    - #### setSession

          public void setSession(org.hibernate.Session session,
                        DbUtil.Database databaseType)

      Sets the session with the database. If the session is set objects are created only if they don't exist in the database. If there is no session set new objects are always created
      Parameters:
        `session` - Session object to set
        `databaseType` - the database type

    - #### addClassExtension

          public boolean addClassExtension(PojoExtension<?,?> extension)

      Register a new PojoExtension class to capture events during the generation of the POJO object model. PojoExtension instances can extend the storage model class by class
      Parameters:
        `extension` - the new PojoExtension class. Note there shall be no duplicates this is the reason hashCode and equals shall be implemented on every PojoExtension