com.ihr.xbrl.om.instance

## Class XBRLPeriod

- java.lang.Object
- - com.ihr.xbrl.om.XMLFragment
  - - com.ihr.xbrl.om.instance.XBRLPeriod

- All Implemented Interfaces:
    HasAdditionalEqualityForReassignation, XBRLRelationshipPoint, Thinable, XMLHasParent, java.lang.Cloneable, javax.xml.namespace.NamespaceContext

      public class XBRLPeriod
      extends XMLFragment
      implements java.lang.Cloneable, HasAdditionalEqualityForReassignation

  A period information according to the content of the context container in the XBRL 2.1 specification.
  Author:
    Ignacio

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `DATE_END` Constant to refer to the END date or datetime of this period.
    `static int` | `DATE_INSTANT` Constant to refer to the INSTANT date or datetime of this period.
    `static int` | `DATE_START` Constant to refer to the START date or datetime of this period.
    `static javax.xml.namespace.QName` | `periodNode` Constant xbrli:period used during serialization of periods.
    `static com.ihr.xbrl.om.instance.XBRLPeriod.TimeSorter` | `TimeSorterInstance` Sorts Periods so they are ordered according to the following criteria: (a) duration periods are ordered according to the date in the middle of the period.

    - ### Fields inherited from class com.ihr.xbrl.om.XMLFragment

      `CONCEPT_LABEL, CONCEPT_QNAME, EASY_TO_READ, ELEMENT_LABEL, EMPTYRELATIONSHIPSITERATORINSTANCE, EMPTYXMLFRAGMENTITERATORINSTANCE, FACT_CONCEPT_DATATYPE, FACT_CONCEPT_LABEL, FACT_QNAME, HIDE_COMMON_ACCURACY, idQName, NO_POSITION, OrderComparator, OrderComparator2, PERIOD_TYPE, PERIOD_VALUE, SHORT_TEXT, SOURCE_DOCUMENT, XPATH, XPOINTER`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `XBRLPeriod(DTSContainer dts)` Creates a FOREVER period.
    `XBRLPeriod(DTSContainer dts, java.util.GregorianCalendar instant, boolean bHasTimeZone, boolean bHasTime)` Creates a INSTANT period with the instant date The date value will be set to the Gregorian Calender used in the parameter.
    `XBRLPeriod(DTSContainer dts, java.util.GregorianCalendar start, java.util.GregorianCalendar end, boolean bHasTimeZone, boolean bHasTime)` Instantiates a new XBRL period.
    `XBRLPeriod(DTSContainer dts, java.lang.String instantDate)` Creates a INSTANT period with the instantDate Note: As dates are in ISO 8601 format, the date representation "2007-08-31" is assumed to be in the NO_TIMEZONE time zone.
    `XBRLPeriod(DTSContainer dts, java.lang.String startDate, java.lang.String endDate)` Creates a DURATION period with the startDate and endDate Note: As dates are in ISO 8601 format, the date representation "2007-08-31" is assumed to be in the NO_TIMEZONE time zone.
    `XBRLPeriod(DTSContainer dts, net.sf.saxon.s9api.XdmNode node)` Creates a XBRLPeriod reading the content of the XdmNode node supplied as a parameter.
    `XBRLPeriod(XBRLPeriod other)` Creates an new period as a copy of the current period.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static java.util.GregorianCalendar` | `adjust24h(java.util.GregorianCalendar calendar, boolean sign)` Adjust24h.
    `void` | `clear()` Frees-up used memory This method should not be invoqued on live objects in the DTS.
    `XBRLPeriod` | `clone()`
    `XBRLPeriod` | `clone(DTSContainer newDTS)` Clone.
    `boolean` | `equals(java.lang.Object other)` Sets a new XPathFunctionResolver for this object.
    `org.jdom.Element` | `generateNode(boolean relativize, java.net.URI base)` Serializes to a jdom Element the representation of the properties of this Information Item This method should be called from classes derived from this class
    `java.util.GregorianCalendar` | `getComparableDate()` Gets the comparable date.
    `java.lang.String` | `getDate(int type)` String representation of the date in the period. adjusted according to XBRL specification rules.
    `java.util.Iterator<XMLFragment>` | `getElements()` For complex type resources this returns an iterator with all children XML fragments This method may be overwriten by other classes in the hierarchy.
    `java.lang.String` | `getFriendlyName()` Returns a string description that represents the element content in a form that users can understand.
    `java.lang.String` | `getFriendlyName(int modifiers, LabelsProvider lp)` Returns a string description that represents the element content in a form that users can understand.
    `java.util.GregorianCalendar` | `getGregorianCalendarDate(int type)` Returns the value of the date for the type requested.
    `java.lang.String` | `getLocalizedPeriodType()` Returns a localized string representing the period type. this is, in English "instant" or "duration".
    `static java.lang.String` | `getLocalizedPeriodType(XBRLItem.PeriodType periodType)` Returns a localized string representing the period type. this is, in English "instant" or "duration".
    `XBRLItem.PeriodType` | `getPeriodType()` Returns XBRLItem.DURATION or XBRLItem.INSTANT depending on the context period information.
    `java.lang.String` | `getRawDate(int type)` String representation of the date in the period.
    `java.util.Date` | `getRawDateUtil(int code)` Returns the raw date (the one specified by syntax) in the context.
    `java.util.GregorianCalendar` | `getRawGregorianCalendarDate(int type)` Returns the value of the date for the type requested.
    `int` | `hashCode()`
    `boolean` | `isDuration()` Checks if is duration.
    `boolean` | `isForever()` Checks if is forever.
    `boolean` | `isInstant()` Checks if is instant.
    `static java.lang.String` | `iso8601(java.util.GregorianCalendar c, boolean hasTimezone, boolean hasTime)` Returns a string representation in iso8601 standard with the value of variable c yyyy-MM-dd'T'HH:mm:ss.SSSZ is the complete patters that can be used some parts of this pattern can be omited according to the values of hasTimezone and hasTime below.
    `static java.util.GregorianCalendar` | `iso8601(java.lang.String value, boolean bAdd24h)` Converts a string of the format yyyy-MM-dd to the apropriate GregorianCalendar object.
    `boolean` | `resolve_equal2(net.sf.saxon.s9api.XdmNode otherXdmNode)` resolves content that is added by this XMLFragment during XMLNode serialization and may not be available to the lower levels in the hierarchy.
    `boolean` | `s_equal2(java.lang.Object other)` Resolves s_equal2 comparison of this node against the other node.
    `void` | `setDate(int type, java.lang.String strDate)` Sets the value of the specified field.
    `java.lang.String` | `toString()` Returns the XML representation of this object as an String.
    `XBRLValidationReport` | `validate()` Produces a XBRLValidationReport object for this period object.

    - ### Methods inherited from class com.ihr.xbrl.om.XMLFragment

      `addAttribute, addChild, addFromRelationship, addNamespace, addNamespace, addToRelationship, addXMLChild, changeBase, checkBase, delAttribute, delAttribute, equalXdmValues, evaluateBoolean, evaluateList, evaluateNode, evaluateNumber, evaluateString, generateId, generateNodeNamespacesAndAttributes, generateNodeValue, generatePrefix, getAllAttributes, getAttribute, getAttributeBooleanValue, getAttributeQNameValue, getAttributes, getAttributes, getAttributeStringValue, getAttributeValue, getBase, getBase, getBaseURI, getBooleanValue, getChild, getContainer, getContainerDocumentURI, getDeclaredNamespaces, getDocument, getElementsHashCode, getFragment, getFromRelationships, getFromRelationships, getFromRelationships, getFromRelationships, getFromRelationships, getGenericLabelText, getId, getLang, getNamespaceURI, getNodeName, getNumberOfAttributes, getNumberOfElements, getNumberOfFromRelationships, getNumberOfToRelationships, getOrGenerateId, getParent, getPrefix, getPrefixes, getQNameValue, getRelationshipsBases, getRelationshipsChain, getRelationshipTypes, getStaticContext, getStaticNamespace, getStringValue, getToolTipText, getToRelationships, getToRelationships, getToRelationships, getToRelationships, getToRelationships, getValue, getXPathExecutable, getXPathNamespaceContext, getXPathToNode, getXPathToRoot, getXPointerElementScheme, getXPointerElementScheme, getXPointerShorthandScheme, getXPointerToNode, isDead, isNamespaceDefined, isXdmDocumentAttached, objEquals, objHashCode, qNameToString, removeAttribute, removeChild, removeChild, removeFromRelationship, removeToRelationship, removeXMLChild, resetElements, resetHash, resolveHRef, resolveHRef, s_equal2, s_equal2, setAttributes, setBase, setDocument, setDocumentAndReload, setElements, setId, setLang, setNamespaceContext, setNamespaces, setNode, setNodeName, setParent, setRegenerateNodeIfnotFound, setValue, setValue, setVariablesDefined, size, thin, valueEquals, xEqual`

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

      `getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### TimeSorterInstance

          public static com.ihr.xbrl.om.instance.XBRLPeriod.TimeSorter TimeSorterInstance

      Sorts Periods so they are ordered according to the following criteria:

      (a) duration periods are ordered according to the date in the middle of the period.

      (b) instant periods are ordered according to the date represented.

      (c) Forever periods are duration periods. they are equal to forever periods or always start earlier that any other duration period. Forever period and instant period comparison result in -1.

      (d) Instant and Duration periods are ordered according to a date that is in the middle of the period

    - #### periodNode

          public static final javax.xml.namespace.QName periodNode

      Constant xbrli:period used during serialization of periods.

    - #### DATE_INSTANT

          public static final int DATE_INSTANT

      Constant to refer to the INSTANT date or datetime of this period.
      See Also:
        Constant Field Values

    - #### DATE_START

          public static final int DATE_START

      Constant to refer to the START date or datetime of this period.
      See Also:
        Constant Field Values

    - #### DATE_END

          public static final int DATE_END

      Constant to refer to the END date or datetime of this period.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### XBRLPeriod

          public XBRLPeriod(DTSContainer dts,
                    net.sf.saxon.s9api.XdmNode node)

      Creates a XBRLPeriod reading the content of the XdmNode node supplied as a parameter.
      Parameters:
        `dts` - DTSContainer for this new period
        `node` - XdmNode XML node s9api where data will be read from

    - #### XBRLPeriod

          public XBRLPeriod(DTSContainer dts)

      Creates a FOREVER period.
      Parameters:
        `dts` - DTSContainer

    - #### XBRLPeriod

          public XBRLPeriod(DTSContainer dts,
                    java.lang.String startDate,
                    java.lang.String endDate)

      Creates a DURATION period with the startDate and endDate Note: As dates are in ISO 8601 format, the date representation "2007-08-31" is assumed to be in the NO_TIMEZONE time zone. If you don't want this, you may specify a date in the format 2007-08-31+0100 or 2007-08-31T01:00:00.000+0000
      Parameters:
        `dts` - - DTSContainer
        `startDate` - - Date string in ISO 8601 format
        `endDate` - - Date string in ISO 8601 format

    - #### XBRLPeriod

          public XBRLPeriod(DTSContainer dts,
                    java.lang.String instantDate)

      Creates a INSTANT period with the instantDate Note: As dates are in ISO 8601 format, the date representation "2007-08-31" is assumed to be in the NO_TIMEZONE time zone. If you don't want this, you may specify a date in the format 2007-08-31+01:00 or 2007-08-31T01:00:00.000+00:00
      Parameters:
        `dts` - - DTSContainer
        `instantDate` - - Date string in ISO 8601 format

    - #### XBRLPeriod

          public XBRLPeriod(DTSContainer dts,
                    java.util.GregorianCalendar instant,
                    boolean bHasTimeZone,
                    boolean bHasTime)

      Creates a INSTANT period with the instant date The date value will be set to the Gregorian Calender used in the parameter.
      Parameters:
        `dts` - - DTSContainer
        `instant` - - Gregorian Calendar
        `bHasTimeZone` - the b has time zone
        `bHasTime` - the b has time

    - #### XBRLPeriod

          public XBRLPeriod(DTSContainer dts,
                    java.util.GregorianCalendar start,
                    java.util.GregorianCalendar end,
                    boolean bHasTimeZone,
                    boolean bHasTime)

      Instantiates a new XBRL period.
      Parameters:
        `dts` - the dts
        `start` - the start
        `end` - the end
        `bHasTimeZone` - the b has time zone
        `bHasTime` - the b has time

    - #### XBRLPeriod

          public XBRLPeriod(XBRLPeriod other)

      Creates an new period as a copy of the current period. This is the constructor used by clone() method but make public for convenience
      Parameters:
        `other` - XBRLPeriod

  - ### Method Detail

    - #### getComparableDate

          public java.util.GregorianCalendar getComparableDate()

      Gets the comparable date.
      Returns:
        the comparable date

    - #### clear

          public void clear()
                     throws java.lang.Throwable

      Description copied from class: `XMLFragment`
      Frees-up used memory

      This method should not be invoqued on live objects in the DTS. It is automatically invoqued by the API when an object is no longer used and referenced by other objects. It is save not to call it directly.

      Overrides:
        `clear` in class `XMLFragment`
      Throws:
        `java.lang.Throwable` - the throwable

    - #### clone

          public XBRLPeriod clone()

      Overrides:
        `clone` in class `XMLFragment`

    - #### clone

          public XBRLPeriod clone(DTSContainer newDTS)

      Description copied from class: `XMLFragment`
      Clone.
      Overrides:
        `clone` in class `XMLFragment`
      Parameters:
        `newDTS` - the new dts
      Returns:
        the XML fragment

    - #### getPeriodType

          public XBRLItem.PeriodType getPeriodType()

      Returns XBRLItem.DURATION or XBRLItem.INSTANT depending on the context period information. Forever periods are considered DURATION.
      Returns:
        XBRLItem.PeriodType

    - #### getFriendlyName

          public java.lang.String getFriendlyName()

      Description copied from class: `XMLFragment`
      Returns a string description that represents the element content in a form that users can understand. This method may be overridden by parent classes.

      Remarks, this method may return very long names not suitable for user interface

      Overrides:
        `getFriendlyName` in class `XMLFragment`
      Returns:
        Non empty String. Internationalization is enabled

    - #### getFriendlyName

          public java.lang.String getFriendlyName(int modifiers,
                                         LabelsProvider lp)

      Description copied from class: `XMLFragment`
      Returns a string description that represents the element content in a form that users can understand. This method may be override by parent classes.

      This function accepts flags that are defined as constants in XMLFragment in order to modify the output.

      - `XMLFragment.XPOINTER` includes the element position in the source file using the XPointer specification. Note, if the document is created from objects the value may not be available
      - `XMLFragment.XPATH` includes the element position in the source file using XPATH. Note, if the document is created from objects the value may not be available
      - `XMLFragment.NO_POSITION` does not include the element position in the source file.
      - `XMLFragment.CONCEPT_QNAME` for XBRLItem, XBRLTuple and XMLElementDefinition.
      - `XMLFragment.CONCEPT_LABEL` for XBRLItem and XBRLTuple.
      - `XMLFragment.FACT_QNAME` for facts.
      - `XMLFragment.FACT_CONCEPT_LABEL` for facts.
      - `XMLFragment.SHORT_TEXT` for resources, returns the resource text, id or xlink:label
      - `XMLFragment.EASY_TO_READ` for contexts, returns the context date and dimensions in a user friendly text representation
      Overrides:
        `getFriendlyName` in class `XMLFragment`
      Parameters:
        `modifiers` - integer
        `lp` - the lp
      Returns:
        Non empty String. Internationalization is enabled

    - #### isInstant

          public boolean isInstant()

      Checks if is instant.
      Returns:
        true if this period is of the XBRL instant type

    - #### isDuration

          public boolean isDuration()

      Checks if is duration.
      Returns:
        true if this period is of the XBRL duration type. Forever periods are duration

    - #### isForever

          public boolean isForever()

      Checks if is forever.
      Returns:
        true if this period is forever

    - #### getDate

          public java.lang.String getDate(int type)

      String representation of the date in the period. adjusted according to XBRL specification rules. That is, adding 24 hours to period end and instant dates and keeping the date on period start dates.
      Parameters:
        `type` - code indicating what to obtain. DATE_INSTANT, DATE_START or DATE_END
      Returns:
        String

    - #### getRawDate

          public java.lang.String getRawDate(int type)

      String representation of the date in the period. NOT adjusted according to XBRL specification rules. That is, not adding 24 hours to any date
      Parameters:
        `type` - code indicating what to obtain. DATE_INSTANT, DATE_START or DATE_END
      Returns:
        String

    - #### getGregorianCalendarDate

          public java.util.GregorianCalendar getGregorianCalendarDate(int type)

      Returns the value of the date for the type requested. returned values are adjusted according to XBRL specification rules Valid types are: XBRLPeriod.DATE_END XBRLPeriod.DATE_START XBRLPeriod.DATE_INSTANT
      Parameters:
        `type` - one of the constants below
      Returns:
        a GregorianCalendar

    - #### getRawGregorianCalendarDate

          public java.util.GregorianCalendar getRawGregorianCalendarDate(int type)

      Returns the value of the date for the type requested. NOT adjusted to XBRL interpretation. returned values are NOT adjusted according to XBRL specification rules Valid types are: XBRLPeriod.DATE_END XBRLPeriod.DATE_START XBRLPeriod.DATE_INSTANT
      Parameters:
        `type` - one of the constants below
      Returns:
        a GregorianCalendar

    - #### adjust24h

          public static java.util.GregorianCalendar adjust24h(java.util.GregorianCalendar calendar,
                                              boolean sign)

      Adjust24h.
      Parameters:
        `calendar` - the calendar
        `sign` - boolean (true) to add 24 hours (false) to substract 24 hours
      Returns:
        a new GregorianCalendar object. The original object is not modified

    - #### validate

          public XBRLValidationReport validate()

      Produces a XBRLValidationReport object for this period object.
      Returns:
        XBRLValidationReport

    - #### equals

          public boolean equals(java.lang.Object other)

      Description copied from class: `XMLFragment`
      Sets a new XPathFunctionResolver for this object.
      Overrides:
        `equals` in class `XMLFragment`
      Parameters:
        `other` - the other
      Returns:
        true, if successful

    - #### s_equal2

          public boolean s_equal2(java.lang.Object other)

      Description copied from class: `XMLFragment`
      Resolves s_equal2 comparison of this node against the other node.
      Overrides:
        `s_equal2` in class `XMLFragment`
      Parameters:
        `other` - The other node (preferably an XMLFragment) that contains a non null NodeInfo document.
      Returns:
        boolean

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `XMLFragment`

    - #### generateNode

          public org.jdom.Element generateNode(boolean relativize,
                                      java.net.URI base)
                                        throws XBRLSerializationException

      Description copied from class: `XMLFragment`
      Serializes to a jdom Element the representation of the properties of this Information Item This method should be called from classes derived from this class
      Overrides:
        `generateNode` in class `XMLFragment`
      Parameters:
        `relativize` - boolean indicating if URIs should be relativized to the base URI (see next argument)
        `base` - the URI to which some attributes of this object should be relativided
      Returns:
        a clone of the surrounding jdom Element so it can be incorporated into multiple trees
      Throws:
        `XBRLSerializationException` - the XBRL serialization exception

    - #### iso8601

          public static java.lang.String iso8601(java.util.GregorianCalendar c,
                                 boolean hasTimezone,
                                 boolean hasTime)

      Returns a string representation in iso8601 standard with the value of variable c yyyy-MM-dd'T'HH:mm:ss.SSSZ is the complete patters that can be used some parts of this pattern can be omited according to the values of hasTimezone and hasTime below. By default only yyy-MM-dd is used. if hasTime is true, then 'T'HH:mm:ss.SSS" is added if hasTimezone is true, then Z is added
      Parameters:
        `c` - GregorianCalendar
        `hasTimezone` - boolean value, true means c has time zone information
        `hasTime` - boolean value, true means c has time information
      Returns:
        String

    - #### iso8601

          public static java.util.GregorianCalendar iso8601(java.lang.String value,
                                            boolean bAdd24h)

      Converts a string of the format yyyy-MM-dd to the apropriate GregorianCalendar object. Returns null if there are errors in the string
      Parameters:
        `value` - string in the format yyyy-MM-dd
        `bAdd24h` - for period end dates this must be set to true
      Returns:
        GregorianCalendar

    - #### setDate

          public void setDate(int type,
                     java.lang.String strDate)
                       throws XBRLValidationException

      Sets the value of the specified field.
      Parameters:
        `type` - this is the field, DATE_END, DATE_INSTANT, DATE_START
        `strDate` - iso8601 date string
      Throws:
        `XBRLValidationException` - the XBRL validation exception

    - #### getRawDateUtil

          public java.util.Date getRawDateUtil(int code)

      Returns the raw date (the one specified by syntax) in the context. "raw" means no +1PD will be assumed for instance dates or endDate dates The return value is a Date in this case.
      Parameters:
        `code` - this is the field, DATE_END, DATE_INSTANT, DATE_START
      Returns:
        a java.util.Date

    - #### toString

          public java.lang.String toString()

      Description copied from class: `XMLFragment`
      Returns the XML representation of this object as an String.
      Overrides:
        `toString` in class `XMLFragment`
      Returns:
        the string

    - #### getElements

          public java.util.Iterator<XMLFragment> getElements()

      Description copied from class: `XMLFragment`
      For complex type resources this returns an iterator with all children XML fragments This method may be overwriten by other classes in the hierarchy.
      Overrides:
        `getElements` in class `XMLFragment`
      Returns:
        Iterator

    - #### getLocalizedPeriodType

          public java.lang.String getLocalizedPeriodType()

      Returns a localized string representing the period type. this is, in English "instant" or "duration". Forever contexts are returned as duration.
      Returns:
        localized string

    - #### getLocalizedPeriodType

          public static java.lang.String getLocalizedPeriodType(XBRLItem.PeriodType periodType)

      Returns a localized string representing the period type. this is, in English "instant" or "duration". Forever contexts are returned as duration.
      Parameters:
        `periodType` - constant indicating XBRLItem.INSTANT or XBRLItem.DURATION
      Returns:
        localized string

    - #### resolve_equal2

          public boolean resolve_equal2(net.sf.saxon.s9api.XdmNode otherXdmNode)

      Description copied from interface: `HasAdditionalEqualityForReassignation`
      resolves content that is added by this XMLFragment during XMLNode serialization and may not be available to the lower levels in the hierarchy.
      Specified by:
        `resolve_equal2` in interface `HasAdditionalEqualityForReassignation`
      Overrides:
        `resolve_equal2` in class `XMLFragment`
      Parameters:
        `otherXdmNode` - the other xdm node
      Returns:
        true, if successful