public class PomEdits extends Object
Modifier and Type | Class and Description |
---|---|
static class |
PomEdits.CompoundOperation
an Operation instance that aggregates multiple operations and performs then in given order.
|
static interface |
PomEdits.Matcher
an interface for identifying child elements that fulfill conditions expressed by the matcher.
|
static interface |
PomEdits.Operation
operation to perform on top of the DOM document.
|
static class |
PomEdits.OperationTuple |
Constructor and Description |
---|
PomEdits() |
Modifier and Type | Method and Description |
---|---|
static PomEdits.Matcher |
childAt(int index)
keeps internal state, needs to be recreated for each query, when used in conjunction with out matchers shall
probably be placed last.
|
static PomEdits.Matcher |
childEquals(String elementName,
String matchingValue) |
static PomEdits.Matcher |
childMissingOrEqual(String elementName,
String matchingValue) |
static Element |
createElement(Element parent,
String name)
helper method, creates a subelement, does not format result.
|
static Element |
createElementWithText(Element parent,
String name,
String value)
helper method, creates a subelement with text embedded.
|
static Element |
elementAtOffset(Document doc,
int offset)
finds the element at offset, if other type of node at offset, will return it's parent element (if any)
|
static Element |
findChild(Element parent,
String name) |
static Element |
findChild(Element parent,
String name,
PomEdits.Matcher... matchers)
finds exactly one (first) occurence of child element with the given name (eg.
|
static List<Element> |
findChilds(Element parent,
String name) |
static void |
format(Node newNode)
formats the node (and content).
|
static Element |
getChild(Element parent,
String... names)
unlike the findChild() equivalent, this one creates the element if not present and returns it.
|
static String |
getTextValue(Node element) |
static Element |
insertAt(Element newElement,
int offset) |
static void |
performOnDOMDocument(PomEdits.OperationTuple... fileOperations)
performs an modifying operation on top the
|
static void |
removeChild(Element parent,
Element child)
proper remove of a child element
|
static void |
removeIfNoChildElement(Element el)
remove the current element if it doesn't contain any sublements, useful for lists etc, works recursively removing
all parents up that don't have any children elements.
|
static void |
setText(Element element,
String value)
sets text value to the given element.
|
static PomEdits.Matcher |
textEquals(String matchingValue) |
public static final String DEPENDENCIES
public static final String GROUP_ID
public static final String ARTIFACT_ID
public static final String DEPENDENCY
public static final String DEPENDENCY_MANAGEMENT
public static final String EXCLUSIONS
public static final String EXCLUSION
public static final String VERSION
public static final String PLUGIN
public static final String CONFIGURATION
public static final String PLUGINS
public static final String PLUGIN_MANAGEMENT
public static final String BUILD
public static final String PARENT
public static final String RELATIVE_PATH
public static final String TYPE
public static final String CLASSIFIER
public static final String OPTIONAL
public static final String SCOPE
public static final String MODULES
public static final String MODULE
public static final String PROFILE
public static final String ID
public static final String NAME
public static final String URL
public static final String DESCRIPTION
public static final String INCEPTION_YEAR
public static final String ORGANIZATION
public static final String SCM
public static final String CONNECTION
public static final String DEV_CONNECTION
public static final String TAG
public static final String ISSUE_MANAGEMENT
public static final String SYSTEM
public static final String SYSTEM_PATH
public static final String CI_MANAGEMENT
public static final String PACKAGING
public static final String PROPERTIES
public static final String EXTENSION
public static final String EXTENSIONS
public static final String PROFILES
public static final String EXECUTIONS
public static final String EXECUTION
public static final String GOAL
public static final String GOALS
public static Element findChild(Element parent, String name, PomEdits.Matcher... matchers)
parent
- name
- matchers
- public static Element createElementWithText(Element parent, String name, String value)
<goals><goal>xxx</goal></goals>
parent
- name
- value
- public static Element createElement(Element parent, String name)
parent
- the parent elementname
- the name of the new elementpublic static void setText(Element element, String value)
element
- value
- public static Element getChild(Element parent, String... names)
parent
- names
- chain of element names to find/createpublic static void removeChild(Element parent, Element child)
public static void removeIfNoChildElement(Element el)
el
- public static Element elementAtOffset(Document doc, int offset)
doc
- offset
- public static void format(Node newNode)
newNode
- public static void performOnDOMDocument(PomEdits.OperationTuple... fileOperations) throws IOException, org.eclipse.core.runtime.CoreException
file
- operation
- IOException
org.eclipse.core.runtime.CoreException
public static PomEdits.Matcher childEquals(String elementName, String matchingValue)
public static PomEdits.Matcher textEquals(String matchingValue)
public static PomEdits.Matcher childMissingOrEqual(String elementName, String matchingValue)
public static PomEdits.Matcher childAt(int index)
elementName
- index
- Copyright © 2005–2015 Sonatype, Inc.. All rights reserved.