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 intelement position of "configurations" inside "ivy-module"private Booleanprivate StringBuilderprivate Stringprivate Stringprivate static final intelement position of "dependencies" inside "ivy-module"private final booleanprivate booleanprivate booleanprivate static final Collection<String>elements that may appear inside of ivy-module/infoprivate booleanprivate Stringprivate booleanprivate booleanelements that may appear inside ivy-module, in expected orderprivate Stringprivate final Namespaceprivate final UpdateOptionsprivate Stringprivate final PrintWriterprivate final Dateprivate final URLprivate final booleanprivate final Map<ModuleRevisionId,String> private final Map<ModuleRevisionId,String> private final Stringprivate final ParserSettingsprivate final Stringprivate static final Collection<String>standard attributes of ivy-module/info -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcharacters(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.voidcomment(char[] ch, int start, int length) voidendCDATA()voidvoidendDTD()voidendElement(String uri, String localName, String qName) voidprivate voidrecord the current indent level for future elements that appear at the same depthvoidvoidprivate voidfillIndents(int level) Guarantee that indent levels have been calculated up to and including the given depth (starting at 0).private voidprivate voidflushMergedElementsBefore(String moduleElement) If publishing in merge mode, guarantee that any merged elements appearing beforemoduleElementhave been written.private Stringprivate Stringget the whitespace that should precede new elements at the current depth in the documentprivate PrintWritervoidignorableWhitespace(char[] ch, int start, int length) private voidincludeStarted(Attributes attributes) private voidinfoStarted(Attributes attributes) voidprocessingInstruction(String target, String data) private Stringprivate StringremoveConfigurationsFromMapping(String mapping) private voidSet the indent for the given depth.voidvoidvoidstartElement(String uri, String localName, String qName, Attributes attributes) private voidstartElementInConfigurationsConf(String qName, Attributes attributes) private voidstartElementInDependency(Attributes attributes) private voidstartElementWithConfAttributes(String qName, Attributes attributes) voidstartEntity(String name) private voidstartExtends(Attributes attributes) private voidstartPublications(Attributes attributes) private Stringsubstitute(ParserSettings ivy, String value) voidprivate voidprivate voidwriteInheritanceComment(String itemDescription, Object parentInfo) private voidprivate voidprivate voidIf no info/description element has yet been written, write the description inherited from the parent descriptor, if any.private voidwriteInheritedItems(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:
startElementin interfaceContentHandler- Overrides:
startElementin classDefaultHandler- Throws:
SAXException
-
startExtends
-
startElementInConfigurationsConf
-
startElementWithConfAttributes
-
startPublications
-
startElementInDependency
-
includeStarted
- Throws:
SAXException
-
infoStarted
-
write
-
getWriter
-
getContext
-
substitute
-
removeConfigurationsFromMapping
-
removeConfigurationsFromList
-
ignorableWhitespace
- Specified by:
ignorableWhitespacein interfaceContentHandler- Overrides:
ignorableWhitespacein classDefaultHandler- Throws:
SAXException
-
characters
- Specified by:
charactersin interfaceContentHandler- Overrides:
charactersin 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
moduleElementhave 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
moduleElementisnull, 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:
endElementin interfaceContentHandler- Overrides:
endElementin classDefaultHandler- Throws:
SAXException
-
endDocument
- Specified by:
endDocumentin interfaceContentHandler- Overrides:
endDocumentin classDefaultHandler- Throws:
SAXException
-
processingInstruction
- Specified by:
processingInstructionin interfaceContentHandler- Overrides:
processingInstructionin classDefaultHandler- Throws:
SAXException
-
warning
- Specified by:
warningin interfaceErrorHandler- Overrides:
warningin classDefaultHandler- Throws:
SAXException
-
error
- Specified by:
errorin interfaceErrorHandler- Overrides:
errorin classDefaultHandler- Throws:
SAXException
-
fatalError
- Specified by:
fatalErrorin interfaceErrorHandler- Overrides:
fatalErrorin classDefaultHandler- Throws:
SAXException
-
endCDATA
- Specified by:
endCDATAin interfaceLexicalHandler- Throws:
SAXException
-
endDTD
- Specified by:
endDTDin interfaceLexicalHandler- Throws:
SAXException
-
startCDATA
- Specified by:
startCDATAin interfaceLexicalHandler- Throws:
SAXException
-
comment
- Specified by:
commentin interfaceLexicalHandler- Throws:
SAXException
-
endEntity
- Specified by:
endEntityin interfaceLexicalHandler- Throws:
SAXException
-
startEntity
- Specified by:
startEntityin interfaceLexicalHandler- Throws:
SAXException
-
startDTD
- Specified by:
startDTDin interfaceLexicalHandler- Throws:
SAXException
-