Class XmlModuleDescriptorUpdater.UpdaterHandler

  • All Implemented Interfaces:
    org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler, org.xml.sax.ext.LexicalHandler
    Enclosing class:
    XmlModuleDescriptorUpdater

    private static class XmlModuleDescriptorUpdater.UpdaterHandler
    extends org.xml.sax.helpers.DefaultHandler
    implements org.xml.sax.ext.LexicalHandler
    • Field Detail

      • STD_ATTS

        private static final java.util.Collection<java.lang.String> STD_ATTS
        standard attributes of ivy-module/info
      • MODULE_ELEMENTS

        private static final java.util.List<java.lang.String> MODULE_ELEMENTS
        elements that may appear inside ivy-module, in expected order
      • CONFIGURATIONS_POSITION

        private static final int CONFIGURATIONS_POSITION
        element position of "configurations" inside "ivy-module"
      • DEPENDENCIES_POSITION

        private static final int DEPENDENCIES_POSITION
        element position of "dependencies" inside "ivy-module"
      • INFO_ELEMENTS

        private static final java.util.Collection<java.lang.String> INFO_ELEMENTS
        elements that may appear inside of ivy-module/info
      • out

        private final java.io.PrintWriter out
      • resolvedRevisions

        private final java.util.Map<ModuleRevisionId,​java.lang.String> resolvedRevisions
      • resolvedBranches

        private final java.util.Map<ModuleRevisionId,​java.lang.String> resolvedBranches
      • status

        private final java.lang.String status
      • revision

        private final java.lang.String revision
      • pubdate

        private final java.util.Date pubdate
      • replaceInclude

        private final boolean replaceInclude
      • generateRevConstraint

        private final boolean generateRevConstraint
      • inHeader

        private boolean inHeader
      • confs

        private final java.util.List<java.lang.String> confs
      • relativePathCtx

        private final java.net.URL relativePathCtx
      • organisation

        private java.lang.String organisation
      • defaultConf

        private java.lang.String defaultConf
      • defaultConfMapping

        private java.lang.String defaultConfMapping
      • confMappingOverride

        private java.lang.Boolean confMappingOverride
      • justOpen

        private java.lang.String justOpen
      • indenting

        private boolean indenting
      • currentIndent

        private java.lang.StringBuilder currentIndent
      • indentLevels

        private java.util.List<java.lang.String> indentLevels
      • hasDescription

        private boolean hasDescription
      • mergedConfigurations

        private boolean mergedConfigurations
      • mergedDependencies

        private boolean mergedDependencies
      • newDefaultConf

        private java.lang.String newDefaultConf
      • context

        private java.util.Stack<java.lang.String> context
    • Constructor Detail

      • UpdaterHandler

        public UpdaterHandler​(java.net.URL relativePathCtx,
                              java.io.PrintWriter out,
                              UpdateOptions options)
    • Method Detail

      • startElement

        public void startElement​(java.lang.String uri,
                                 java.lang.String localName,
                                 java.lang.String qName,
                                 org.xml.sax.Attributes attributes)
                          throws org.xml.sax.SAXException
        Specified by:
        startElement in interface org.xml.sax.ContentHandler
        Overrides:
        startElement in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXException
      • startExtends

        private void startExtends​(org.xml.sax.Attributes attributes)
      • startElementInConfigurationsConf

        private void startElementInConfigurationsConf​(java.lang.String qName,
                                                      org.xml.sax.Attributes attributes)
      • startElementWithConfAttributes

        private void startElementWithConfAttributes​(java.lang.String qName,
                                                    org.xml.sax.Attributes attributes)
      • startPublications

        private void startPublications​(org.xml.sax.Attributes attributes)
      • startElementInDependency

        private void startElementInDependency​(org.xml.sax.Attributes attributes)
      • includeStarted

        private void includeStarted​(org.xml.sax.Attributes attributes)
                             throws org.xml.sax.SAXException
        Throws:
        org.xml.sax.SAXException
      • infoStarted

        private void infoStarted​(org.xml.sax.Attributes attributes)
      • write

        private void write​(java.lang.String content)
      • getWriter

        private java.io.PrintWriter getWriter()
      • getContext

        private java.lang.String getContext()
      • substitute

        private java.lang.String substitute​(ParserSettings ivy,
                                            java.lang.String value)
      • removeConfigurationsFromMapping

        private java.lang.String removeConfigurationsFromMapping​(java.lang.String mapping)
      • removeConfigurationsFromList

        private java.lang.String removeConfigurationsFromList​(java.lang.String list)
      • ignorableWhitespace

        public void ignorableWhitespace​(char[] ch,
                                        int start,
                                        int length)
                                 throws org.xml.sax.SAXException
        Specified by:
        ignorableWhitespace in interface org.xml.sax.ContentHandler
        Overrides:
        ignorableWhitespace in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXException
      • characters

        public void characters​(char[] ch,
                               int start,
                               int length)
                        throws org.xml.sax.SAXException
        Specified by:
        characters in interface org.xml.sax.ContentHandler
        Overrides:
        characters in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXException
      • endIndent

        private void endIndent()
        record the current indent level for future elements that appear at the same depth
      • setIndent

        private void setIndent​(int level,
                               java.lang.String indent)
        Set the indent for the given depth. Indents less than the provided depth will be calculated automatically, if they have not already been defined.
      • fillIndents

        private void fillIndents​(int level)
        Guarantee that indent levels have been calculated up to and including the given depth (starting at 0).
      • getIndent

        private java.lang.String getIndent()
        get the whitespace that should precede new elements at the current depth in the document
      • writeInheritedItems

        private void writeInheritedItems​(ModuleDescriptor merged,
                                         InheritableItem[] items,
                                         XmlModuleDescriptorUpdater.ItemPrinter printer,
                                         java.lang.String itemName,
                                         boolean includeContainer)
        Write XML elements that do not appear in the source descriptor, but have been copied in from a parent module descriptor via <extends> declaration.
        Parameters:
        merged - child descriptor containing the merged data
        items - the list of inherited items to print
        printer - a printer that knows how to write the given type of item
        itemName - the name of the container element, e.g. "configurations"
        includeContainer - if true, include an enclosing element named itemName. Otherwise just write the inherited items inline, with a comment indicating where they came from.
      • writeInheritanceComment

        private void writeInheritanceComment​(java.lang.String itemDescription,
                                             java.lang.Object parentInfo)
      • collateInheritedItems

        private java.util.Map<ModuleRevisionId,​java.util.List<InheritableItem>> collateInheritedItems​(ModuleDescriptor merged,
                                                                                                            InheritableItem[] items)
        Collect the given list of inherited descriptor items into lists keyed by parent Id. Thus all of the items inherited from parent A can be written together, then all of the items from parent B, and so on.
        Parameters:
        merged - the merged child descriptor
        items - the inherited items to collate
        Returns:
        maps parent ModuleRevisionId to a List of InheritedItems imported from that parent
      • writeInheritedDescription

        private void writeInheritedDescription​(ModuleDescriptor merged)
        If no info/description element has yet been written, write the description inherited from the parent descriptor, if any. Calling this method more than once has no affect.
      • writeInheritedConfigurations

        private void writeInheritedConfigurations​(ModuleDescriptor merged)
      • writeInheritedDependencies

        private void writeInheritedDependencies​(ModuleDescriptor merged)
      • flushMergedElementsBefore

        private void flushMergedElementsBefore​(java.lang.String moduleElement)

        If publishing in merge mode, guarantee that any merged elements appearing before moduleElement have been written. This method should be called before we write the start tag of moduleElement. This covers cases where merged elements like "configurations" and "dependencies" appear in the parent descriptor, but are completely missing in the child descriptor.

        For example, if "moduleElement" is "dependencies", guarantees that "configurations" has been written. If moduleElement is null, then all missing merged elements will be flushed.

        Parameters:
        moduleElement - a descriptor element name, for example "configurations" or "info"
      • flushAllMergedElements

        private void flushAllMergedElements()
      • endElement

        public void endElement​(java.lang.String uri,
                               java.lang.String localName,
                               java.lang.String qName)
                        throws org.xml.sax.SAXException
        Specified by:
        endElement in interface org.xml.sax.ContentHandler
        Overrides:
        endElement in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXException
      • endDocument

        public void endDocument()
                         throws org.xml.sax.SAXException
        Specified by:
        endDocument in interface org.xml.sax.ContentHandler
        Overrides:
        endDocument in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXException
      • processingInstruction

        public void processingInstruction​(java.lang.String target,
                                          java.lang.String data)
                                   throws org.xml.sax.SAXException
        Specified by:
        processingInstruction in interface org.xml.sax.ContentHandler
        Overrides:
        processingInstruction in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXException
      • warning

        public void warning​(org.xml.sax.SAXParseException e)
                     throws org.xml.sax.SAXException
        Specified by:
        warning in interface org.xml.sax.ErrorHandler
        Overrides:
        warning in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXException
      • error

        public void error​(org.xml.sax.SAXParseException e)
                   throws org.xml.sax.SAXException
        Specified by:
        error in interface org.xml.sax.ErrorHandler
        Overrides:
        error in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXException
      • fatalError

        public void fatalError​(org.xml.sax.SAXParseException e)
                        throws org.xml.sax.SAXException
        Specified by:
        fatalError in interface org.xml.sax.ErrorHandler
        Overrides:
        fatalError in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXException
      • endCDATA

        public void endCDATA()
                      throws org.xml.sax.SAXException
        Specified by:
        endCDATA in interface org.xml.sax.ext.LexicalHandler
        Throws:
        org.xml.sax.SAXException
      • endDTD

        public void endDTD()
                    throws org.xml.sax.SAXException
        Specified by:
        endDTD in interface org.xml.sax.ext.LexicalHandler
        Throws:
        org.xml.sax.SAXException
      • startCDATA

        public void startCDATA()
                        throws org.xml.sax.SAXException
        Specified by:
        startCDATA in interface org.xml.sax.ext.LexicalHandler
        Throws:
        org.xml.sax.SAXException
      • comment

        public void comment​(char[] ch,
                            int start,
                            int length)
                     throws org.xml.sax.SAXException
        Specified by:
        comment in interface org.xml.sax.ext.LexicalHandler
        Throws:
        org.xml.sax.SAXException
      • endEntity

        public void endEntity​(java.lang.String name)
                       throws org.xml.sax.SAXException
        Specified by:
        endEntity in interface org.xml.sax.ext.LexicalHandler
        Throws:
        org.xml.sax.SAXException
      • startEntity

        public void startEntity​(java.lang.String name)
                         throws org.xml.sax.SAXException
        Specified by:
        startEntity in interface org.xml.sax.ext.LexicalHandler
        Throws:
        org.xml.sax.SAXException
      • startDTD

        public void startDTD​(java.lang.String name,
                             java.lang.String publicId,
                             java.lang.String systemId)
                      throws org.xml.sax.SAXException
        Specified by:
        startDTD in interface org.xml.sax.ext.LexicalHandler
        Throws:
        org.xml.sax.SAXException