Class ModifiedPomXMLEventReader
java.lang.Object
org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader
- All Implemented Interfaces:
Iterator,XMLEventReader
Represents the modified pom file. Note: implementations of the StAX API (JSR-173) are not good round-trip rewriting
while keeping all unchanged bytes in the file as is. For example, the StAX API specifies that
CR
characters will be stripped. Current implementations do not keep " and ' characters consistent.- Author:
- Stephen Connolly
-
Constructor Summary
ConstructorsConstructorDescriptionModifiedPomXMLEventReader(StringBuilder pom, XMLInputFactory factory, String path) Constructor ModifiedPomXMLEventReader creates a new ModifiedPomXMLEventReader instance. -
Method Summary
Modifier and TypeMethodDescriptionReturns a copy of the backing string buffer.voidclearMark(int index) Clears the mark.voidclose()getBetween(int index1, int index2) getMarkVerbatim(int index) the verbatim text of the current element whenmark(int)was called.getPath()Returns the verbatim text of the element returned bypeek().getProperty(String name) Getter for property 'verbatim'.booleanhasMark(int index) Returnstrueif the specified mark is defined.booleanhasNext()booleanGetter for property 'modified'.voidmark(int index) Sets a mark to the current event.next()nextTag()org.apache.maven.model.Modelparse()peek()voidremove()voidReplaces the current element with the replacement text.voidreplaceBetween(int index1, int index2, String replacement) Replaces all content between marks index1 and index2 with the replacement text.voidreplaceMark(int index, String replacement) Replaces the specified marked element with the replacement text.voidrewind()Rewind to the start so we can run through again.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Iterator
forEachRemaining
-
Constructor Details
-
ModifiedPomXMLEventReader
public ModifiedPomXMLEventReader(StringBuilder pom, XMLInputFactory factory, String path) throws XMLStreamException Constructor ModifiedPomXMLEventReader creates a new ModifiedPomXMLEventReader instance.- Parameters:
pom- of type StringBuilderfactory- of type XMLInputFactorypath- Path pointing to source of XML- Throws:
XMLStreamException- when
-
-
Method Details
-
rewind
Rewind to the start so we can run through again.- Throws:
XMLStreamException- when things go wrong.
-
isModified
public boolean isModified()Getter for property 'modified'.- Returns:
- Value for property 'modified'.
-
next
-
remove
public void remove() -
nextEvent
- Specified by:
nextEventin interfaceXMLEventReader- Throws:
XMLStreamException
-
peek
- Specified by:
peekin interfaceXMLEventReader- Throws:
XMLStreamException
-
getElementText
- Specified by:
getElementTextin interfaceXMLEventReader- Throws:
XMLStreamException
-
nextTag
- Specified by:
nextTagin interfaceXMLEventReader- Throws:
XMLStreamException
-
getProperty
- Specified by:
getPropertyin interfaceXMLEventReader
-
close
- Specified by:
closein interfaceXMLEventReader- Throws:
XMLStreamException
-
asStringBuilder
Returns a copy of the backing string buffer.- Returns:
- a copy of the backing string buffer.
-
clearMark
public void clearMark(int index) Clears the mark.- Parameters:
index- the mark to clear.
-
getMarkVerbatim
the verbatim text of the current element whenmark(int)was called.- Parameters:
index- The mark index.- Returns:
- the current element when
mark(int)was called.
-
getPeekVerbatim
Returns the verbatim text of the element returned bypeek().- Returns:
- the verbatim text of the element returned by
peek().
-
hasNext
public boolean hasNext()- Specified by:
hasNextin interfaceIterator- Specified by:
hasNextin interfaceXMLEventReader
-
getVerbatim
Getter for property 'verbatim'.- Returns:
- Value for property 'verbatim'.
-
mark
public void mark(int index) Sets a mark to the current event.- Parameters:
index- the mark to set.
-
replace
Replaces the current element with the replacement text.- Parameters:
replacement- The replacement.
-
hasMark
public boolean hasMark(int index) Returnstrueif the specified mark is defined.- Parameters:
index- The mark.- Returns:
trueif the specified mark is defined.
-
getBetween
-
replaceBetween
Replaces all content between marks index1 and index2 with the replacement text.- Parameters:
index1- The event mark to replace after.index2- The event mark to replace before.replacement- The replacement.
-
replaceMark
Replaces the specified marked element with the replacement text.- Parameters:
index- The mark.replacement- The replacement.
-
parse
public org.apache.maven.model.Model parse() throws IOException, org.codehaus.plexus.util.xml.pull.XmlPullParserException- Throws:
IOExceptionorg.codehaus.plexus.util.xml.pull.XmlPullParserException
-
getPath
-