Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package org.apache.maven.model.jdom;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.maven.model.Build;
import org.apache.maven.model.BuildBase;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.DependencyManagement;
import org.apache.maven.model.DistributionManagement;
import org.apache.maven.model.ModelBase;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.PluginManagement;
import org.apache.maven.model.Reporting;
import org.apache.maven.model.Repository;
import org.jdom2.Element;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import static java.util.Collections.emptyList;
import static org.apache.maven.model.jdom.util.JDomCfg.POM_ELEMENT_ARTIFACT_ID;
import static org.apache.maven.model.jdom.util.JDomCfg.POM_ELEMENT_BUILD;
import static org.apache.maven.model.jdom.util.JDomCfg.POM_ELEMENT_DEPENDENCIES;
import static org.apache.maven.model.jdom.util.JDomCfg.POM_ELEMENT_DEPENDENCY_MANAGEMENT;
import static org.apache.maven.model.jdom.util.JDomCfg.POM_ELEMENT_GROUP_ID;
import static org.apache.maven.model.jdom.util.JDomCfg.POM_ELEMENT_MODULES;
import static org.apache.maven.model.jdom.util.JDomCfg.POM_ELEMENT_PLUGIN;
import static org.apache.maven.model.jdom.util.JDomCfg.POM_ELEMENT_PLUGINS;
import static org.apache.maven.model.jdom.util.JDomCfg.POM_ELEMENT_PLUGIN_MANAGEMENT;
import static org.apache.maven.model.jdom.util.JDomCfg.POM_ELEMENT_PROPERTIES;
import static org.apache.maven.model.jdom.util.JDomCfg.POM_ELEMENT_REPORTING;
import static org.apache.maven.model.jdom.util.JDomCfg.POM_ELEMENT_VERSION;
import static org.apache.maven.model.jdom.util.JDomUtils.getChildElement;
import static org.apache.maven.model.jdom.util.JDomUtils.insertContentElement;
import static org.apache.maven.model.jdom.util.JDomUtils.insertNewElement;
import static org.apache.maven.model.jdom.util.JDomUtils.insertNewNestedElements;
import static org.apache.maven.model.jdom.util.JDomUtils.newDetachedElement;
import static org.apache.maven.model.jdom.util.JDomUtils.rewriteElement;
/**
* @author Robert Scholte (for Maven Release projct, version 3.0)
*/
public class JDomModelBase extends ModelBase implements JDomBacked {
private final Element jdomElement;
public JDomModelBase(Element jdomElement) {
this.jdomElement = jdomElement;
Element dependenciesElement = getChildElement(POM_ELEMENT_DEPENDENCIES, jdomElement);
if (dependenciesElement == null) {
dependenciesElement = newDetachedElement(POM_ELEMENT_DEPENDENCIES, jdomElement);
}
super.setDependencies(new JDomDependencies(dependenciesElement, this));
Element dependencyManagementElement = getChildElement(POM_ELEMENT_DEPENDENCY_MANAGEMENT, jdomElement);
if (dependencyManagementElement == null) {
dependencyManagementElement = newDetachedElement(POM_ELEMENT_DEPENDENCY_MANAGEMENT, jdomElement);
insertNewElement(POM_ELEMENT_DEPENDENCIES, dependencyManagementElement);
}
super.setDependencyManagement(new JDomDependencyManagement(dependencyManagementElement, this));
}
public Build getBuild() {
Element elm = jdomElement.getChild(POM_ELEMENT_BUILD, jdomElement.getNamespace());
if (elm == null) {
return null;
} else {
// this way build setters change DOM tree immediately
return new JDomBuild(elm);
}
}
public void setBuild(BuildBase build) {
if (build == null) {
rewriteElement(POM_ELEMENT_BUILD, null, jdomElement);
} else {
Element jdomBuild = insertNewElement(POM_ELEMENT_BUILD, this.jdomElement);
insertPluginManagement(jdomBuild, build.getPluginManagement());
}
}
public DistributionManagement getDistributionManagement() {
throw new UnsupportedOperationException();
}
public void setDistributionManagement(DistributionManagement distributionManagement) {
throw new UnsupportedOperationException();
}
public void setDependencies(List dependencies) {
if (dependencies == null) {
rewriteElement(POM_ELEMENT_DEPENDENCIES, null, jdomElement);
} else {
new JDomDependencies(insertNewElement(POM_ELEMENT_DEPENDENCIES, jdomElement), this).addAll(dependencies);
}
}
public void setDependencyManagement(DependencyManagement dependencyManagement) {
if (dependencyManagement == null) {
rewriteElement(POM_ELEMENT_DEPENDENCY_MANAGEMENT, null, jdomElement);
} else {
DependencyManagement jdomDependencyManagement = getDependencyManagement();
if (jdomDependencyManagement == null) {
Element dependencyManagementRoot = insertNewElement(POM_ELEMENT_DEPENDENCY_MANAGEMENT, jdomElement);
jdomDependencyManagement = new JDomDependencyManagement(dependencyManagementRoot, this);
}
jdomDependencyManagement.setDependencies(dependencyManagement.getDependencies());
}
}
public List getModules() {
Element modulesElement = getChildElement(POM_ELEMENT_MODULES, jdomElement);
if (modulesElement == null) {
return emptyList();
} else {
return new JDomModules(modulesElement);
}
}
public void setModules(List modules) {
if (modules == null) {
rewriteElement(POM_ELEMENT_MODULES, null, jdomElement);
} else {
List jDomModules = getModules();
if (jDomModules instanceof JDomModules) {
jDomModules.clear();
} else {
jDomModules = new JDomModules(insertNewElement(POM_ELEMENT_MODULES, jdomElement));
}
jDomModules.addAll(modules);
}
}
public List getPluginRepositories() {
throw new UnsupportedOperationException();
}
public void setPluginRepositories(List pluginRepositories) {
throw new UnsupportedOperationException();
}
public Properties getProperties() {
Element properties = jdomElement.getChild(POM_ELEMENT_PROPERTIES, jdomElement.getNamespace());
if (properties == null) {
return null;
} else {
return new JDomProperties(properties);
}
}
public void setProperties(Properties properties) {
if (properties == null) {
rewriteElement(POM_ELEMENT_PROPERTIES, null, jdomElement);
} else {
Properties jDomProperties = getProperties();
if (jDomProperties != null) {
jDomProperties.clear();
} else {
jDomProperties = new JDomProperties(insertNewElement(POM_ELEMENT_PROPERTIES, jdomElement));
}
for (Map.Entry