public void removeChild( int i ) { Xpp3Dom child = getChild( i ); childMap.values().remove( child ); childList.remove( i ); // In case of any dangling references child.setParent( null ); }
/** * Copy constructor with alternative name. */ public Xpp3Dom( Xpp3Dom src, String name ) { this.name = name; int childCount = src.getChildCount(); childList = new ArrayList<Xpp3Dom>( childCount ); childMap = new HashMap<String, Xpp3Dom>( childCount << 1 ); setValue( src.getValue() ); String[] attributeNames = src.getAttributeNames(); for ( String attributeName : attributeNames ) { setAttribute( attributeName, src.getAttribute( attributeName ) ); } for ( int i = 0; i < childCount; i++ ) { addChild( new Xpp3Dom( src.getChild( i ) ) ); } }
childDom = dominant.getChild( recessiveChild.getName() );
private String extractFromServerConfiguration(Object configuration, String prop) { if (configuration != null) { Xpp3Dom dom = (Xpp3Dom) configuration; Xpp3Dom element = dom.getChild(prop); if (element != null) { return element.getValue(); } } return null; }
private List<Object> toList(Xpp3Dom node, String childName) { List<Object> list = new ArrayList<>(); int n = node.getChildCount(); for (int i = 0; i < n; i++) { Xpp3Dom child = node.getChild(i); if (!childName.equals(child.getName())) { throw new YAMLException(format("child name: '%s' does not match expected name: '%s' at node %s", child.getName(), childName, node)); } Object childValue = child.getValue(); if (childValue == null) { childValue = toMap(child); } list.add(childValue); } return list; } }
private List<String> extract(String childname, Xpp3Dom config) { final Xpp3Dom subelement = config.getChild(childname); if (subelement != null) { List<String> result = new LinkedList<>(); final Xpp3Dom[] children = subelement.getChildren(); for (Xpp3Dom child : children) { result.add(child.getValue()); } return result; } return Collections.emptyList(); }
public static String getPluginConfigParameter ( MavenProject project, String parameter, String defaultValue ) { String value = null; for ( Plugin plugin : project.getBuild().getPlugins() ) { if ( plugin.getArtifactId().equals( PluginInfo.getArtifactId() ) ) { Xpp3Dom configuration = getMojoConfiguration( plugin ); if ( configuration != null && configuration.getChild( parameter ) != null ) { value = configuration.getChild( parameter ).getValue() ; } } } // if we got nothing, fall back to the default value return ( StringUtils.isEmpty( value ) ) ? defaultValue : value; }
for ( int i = dom.getChildCount() - 1; i >= 0; i-- ) Xpp3Dom child = dom.getChild( i ); if ( "wagonProvider".equals( child.getName() ) )
/** * @since 3.3.0 */ public ExtensionDescriptor build( InputStream is ) throws IOException { ExtensionDescriptor extensionDescriptor = new ExtensionDescriptor(); Xpp3Dom dom; try { dom = Xpp3DomBuilder.build( ReaderFactory.newXmlReader( is ) ); } catch ( XmlPullParserException e ) { throw (IOException) new IOException( e.getMessage() ).initCause( e ); } if ( !"extension".equals( dom.getName() ) ) { throw new IOException( "Unexpected root element \"" + dom.getName() + "\", expected \"extension\"" ); } extensionDescriptor.setExportedPackages( parseStrings( dom.getChild( "exportedPackages" ) ) ); extensionDescriptor.setExportedArtifacts( parseStrings( dom.getChild( "exportedArtifacts" ) ) ); return extensionDescriptor; }
public XmlPlexusConfiguration( Xpp3Dom dom ) { super( dom.getName(), dom.getValue() ); // attrs String[] attributes = dom.getAttributeNames(); for (String attribute : attributes) { setAttribute(attribute, dom.getAttribute(attribute)); } // children int childCount = dom.getChildCount(); for ( int i = 0; i < childCount; i++ ) { addChild( new XmlPlexusConfiguration( dom.getChild( i ) ) ); } }
Xpp3Dom javahome = dom.getChild( JavaToolchainImpl.KEY_JAVAHOME ); if ( javahome == null )
private List<String> extractStrings(String element, Xpp3Dom configuration) { Xpp3Dom groups = configuration.getChild(element); if (groups != null) { String[] parts = groups.getValue().split(" "); return Arrays.asList(parts); } else { return Collections.emptyList(); } }
private void convertTestFailureIgnore(ReportOptions option, Xpp3Dom configuration) { Xpp3Dom testFailureIgnore = configuration.getChild("testFailureIgnore"); if (testFailureIgnore != null) { option.setSkipFailingTests(Boolean.parseBoolean(testFailureIgnore.getValue())); } } }
protected String getAttribute(Xpp3Dom tag, String attributeName) { Xpp3Dom attributeDom = tag.getChild(attributeName); checkState(attributeDom != null, format("'%s' element not declared at '%s' in the pom file of the artifact '%s'", attributeName, tag.toString(), artifactFolder.getName())); String attributeValue = attributeDom.getValue().trim(); checkState(!isEmpty(attributeValue), format("'%s' was defined but has an empty value at '%s' declared in the pom file of the artifact %s", attributeName, tag.toString(), artifactFolder.getName())); return attributeValue; }
private String getSourceVersion(BuildBase build) { for (Plugin plugin : build.getPlugins()) { if (!"maven-compiler-plugin".equals(plugin.getArtifactId())) { continue; } Xpp3Dom configuration = (Xpp3Dom) plugin.getConfiguration(); if (configuration != null) { Xpp3Dom source = configuration.getChild("source"); if (source != null) { return source.getValue(); } } break; } return null; }
/** * Lookup the mojo leveraging the actual subprojects pom * * @param goal * @param pom * @return a Mojo instance * @throws Exception */ protected Mojo lookupEmptyMojo( String goal, File pom ) throws Exception { File pluginPom = new File( getBasedir(), "pom.xml" ); Xpp3Dom pluginPomDom = Xpp3DomBuilder.build( ReaderFactory.newXmlReader( pluginPom ) ); String artifactId = pluginPomDom.getChild( "artifactId" ).getValue(); String groupId = resolveFromRootThenParent( pluginPomDom, "groupId" ); String version = resolveFromRootThenParent( pluginPomDom, "version" ); return lookupMojo( groupId, artifactId, version, goal, null ); }
/** * Lookup the mojo leveraging the actual subprojects pom * * @param goal * @param pom * @return a Mojo instance * @throws Exception */ protected Mojo lookupMojo( String goal, File pom ) throws Exception { File pluginPom = new File( getBasedir(), "pom.xml" ); Xpp3Dom pluginPomDom = Xpp3DomBuilder.build( ReaderFactory.newXmlReader( pluginPom ) ); String artifactId = pluginPomDom.getChild( "artifactId" ).getValue(); String groupId = resolveFromRootThenParent( pluginPomDom, "groupId" ); String version = resolveFromRootThenParent( pluginPomDom, "version" ); PlexusConfiguration pluginConfiguration = extractPluginConfiguration( artifactId, pom ); return lookupMojo( groupId, artifactId, version, goal, pluginConfiguration ); }