Class XmlModuleDescriptorUpdater.UpdaterHandler
java.lang.Object
org.xml.sax.helpers.DefaultHandler
org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorUpdater.UpdaterHandler
- All Implemented Interfaces:
ContentHandler
,DTDHandler
,EntityResolver
,ErrorHandler
,LexicalHandler
- Enclosing class:
- XmlModuleDescriptorUpdater
private static class XmlModuleDescriptorUpdater.UpdaterHandler
extends DefaultHandler
implements LexicalHandler
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
element position of "configurations" inside "ivy-module"private Boolean
private StringBuilder
private String
private String
private static final int
element position of "dependencies" inside "ivy-module"private final boolean
private boolean
private boolean
private static final Collection<String>
elements that may appear inside of ivy-module/infoprivate boolean
private String
private boolean
private boolean
elements that may appear inside ivy-module, in expected orderprivate String
private final Namespace
private final UpdateOptions
private String
private final PrintWriter
private final Date
private final URL
private final boolean
private final Map<ModuleRevisionId,
String> private final Map<ModuleRevisionId,
String> private final String
private final ParserSettings
private final String
private static final Collection<String>
standard attributes of ivy-module/info -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
characters
(char[] ch, int start, int length) private Map<ModuleRevisionId,
List<InheritableItem>> collateInheritedItems
(ModuleDescriptor merged, InheritableItem[] items) Collect the given list of inherited descriptor items into lists keyed by parent Id.void
comment
(char[] ch, int start, int length) void
endCDATA()
void
void
endDTD()
void
endElement
(String uri, String localName, String qName) void
private void
record the current indent level for future elements that appear at the same depthvoid
void
private void
fillIndents
(int level) Guarantee that indent levels have been calculated up to and including the given depth (starting at 0).private void
private void
flushMergedElementsBefore
(String moduleElement) If publishing in merge mode, guarantee that any merged elements appearing beforemoduleElement
have been written.private String
private String
get the whitespace that should precede new elements at the current depth in the documentprivate PrintWriter
void
ignorableWhitespace
(char[] ch, int start, int length) private void
includeStarted
(Attributes attributes) private void
infoStarted
(Attributes attributes) void
processingInstruction
(String target, String data) private String
private String
removeConfigurationsFromMapping
(String mapping) private void
Set the indent for the given depth.void
void
void
startElement
(String uri, String localName, String qName, Attributes attributes) private void
startElementInConfigurationsConf
(String qName, Attributes attributes) private void
startElementInDependency
(Attributes attributes) private void
startElementWithConfAttributes
(String qName, Attributes attributes) void
startEntity
(String name) private void
startExtends
(Attributes attributes) private void
startPublications
(Attributes attributes) private String
substitute
(ParserSettings ivy, String value) void
private void
private void
writeInheritanceComment
(String itemDescription, Object parentInfo) private void
private void
private void
If no info/description element has yet been written, write the description inherited from the parent descriptor, if any.private void
writeInheritedItems
(ModuleDescriptor merged, InheritableItem[] items, XmlModuleDescriptorUpdater.ItemPrinter printer, 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.Methods inherited from class org.xml.sax.helpers.DefaultHandler
endPrefixMapping, notationDecl, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl
-
Field Details
-
STD_ATTS
standard attributes of ivy-module/info -
MODULE_ELEMENTS
elements that may appear inside ivy-module, in expected order -
CONFIGURATIONS_POSITION
private static final int CONFIGURATIONS_POSITIONelement position of "configurations" inside "ivy-module" -
DEPENDENCIES_POSITION
private static final int DEPENDENCIES_POSITIONelement position of "dependencies" inside "ivy-module" -
INFO_ELEMENTS
elements that may appear inside of ivy-module/info -
settings
-
out
-
resolvedRevisions
-
resolvedBranches
-
status
-
revision
-
pubdate
-
ns
-
replaceInclude
private final boolean replaceInclude -
generateRevConstraint
private final boolean generateRevConstraint -
inHeader
private boolean inHeader -
confs
-
relativePathCtx
-
options
-
organisation
-
defaultConf
-
defaultConfMapping
-
confMappingOverride
-
justOpen
-
indenting
private boolean indenting -
currentIndent
-
indentLevels
-
hasDescription
private boolean hasDescription -
mergedConfigurations
private boolean mergedConfigurations -
mergedDependencies
private boolean mergedDependencies -
newDefaultConf
-
context
-
buffers
-
confAttributeBuffers
-
-
Constructor Details
-
UpdaterHandler
-
-
Method Details
-
startElement
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException - Specified by:
startElement
in interfaceContentHandler
- Overrides:
startElement
in classDefaultHandler
- Throws:
SAXException
-
startExtends
-
startElementInConfigurationsConf
-
startElementWithConfAttributes
-
startPublications
-
startElementInDependency
-
includeStarted
- Throws:
SAXException
-
infoStarted
-
write
-
getWriter
-
getContext
-
substitute
-
removeConfigurationsFromMapping
-
removeConfigurationsFromList
-
ignorableWhitespace
- Specified by:
ignorableWhitespace
in interfaceContentHandler
- Overrides:
ignorableWhitespace
in classDefaultHandler
- Throws:
SAXException
-
characters
- Specified by:
characters
in interfaceContentHandler
- Overrides:
characters
in classDefaultHandler
- Throws:
SAXException
-
endIndent
private void endIndent()record the current indent level for future elements that appear at the same depth -
setIndent
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
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, 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 dataitems
- the list of inherited items to printprinter
- a printer that knows how to write the given type of itemitemName
- the name of the container element, e.g. "configurations"includeContainer
- if true, include an enclosing element nameditemName
. Otherwise just write the inherited items inline, with a comment indicating where they came from.
-
writeInheritanceComment
-
collateInheritedItems
private Map<ModuleRevisionId,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 descriptoritems
- the inherited items to collate- Returns:
- maps parent ModuleRevisionId to a List of InheritedItems imported from that parent
-
writeInheritedDescription
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
-
writeInheritedDependencies
-
flushMergedElementsBefore
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 ofmoduleElement
. 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
isnull
, then all missing merged elements will be flushed.- Parameters:
moduleElement
- a descriptor element name, for example "configurations" or "info"
-
flushAllMergedElements
private void flushAllMergedElements() -
endElement
- Specified by:
endElement
in interfaceContentHandler
- Overrides:
endElement
in classDefaultHandler
- Throws:
SAXException
-
endDocument
- Specified by:
endDocument
in interfaceContentHandler
- Overrides:
endDocument
in classDefaultHandler
- Throws:
SAXException
-
processingInstruction
- Specified by:
processingInstruction
in interfaceContentHandler
- Overrides:
processingInstruction
in classDefaultHandler
- Throws:
SAXException
-
warning
- Specified by:
warning
in interfaceErrorHandler
- Overrides:
warning
in classDefaultHandler
- Throws:
SAXException
-
error
- Specified by:
error
in interfaceErrorHandler
- Overrides:
error
in classDefaultHandler
- Throws:
SAXException
-
fatalError
- Specified by:
fatalError
in interfaceErrorHandler
- Overrides:
fatalError
in classDefaultHandler
- Throws:
SAXException
-
endCDATA
- Specified by:
endCDATA
in interfaceLexicalHandler
- Throws:
SAXException
-
endDTD
- Specified by:
endDTD
in interfaceLexicalHandler
- Throws:
SAXException
-
startCDATA
- Specified by:
startCDATA
in interfaceLexicalHandler
- Throws:
SAXException
-
comment
- Specified by:
comment
in interfaceLexicalHandler
- Throws:
SAXException
-
endEntity
- Specified by:
endEntity
in interfaceLexicalHandler
- Throws:
SAXException
-
startEntity
- Specified by:
startEntity
in interfaceLexicalHandler
- Throws:
SAXException
-
startDTD
- Specified by:
startDTD
in interfaceLexicalHandler
- Throws:
SAXException
-