View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.shared.release.transform.jdom2;
20  
21  import java.util.ArrayList;
22  import java.util.Collections;
23  import java.util.List;
24  import java.util.Map;
25  
26  import org.apache.maven.model.ReportPlugin;
27  import org.apache.maven.model.Reporting;
28  import org.jdom2.Element;
29  
30  /**
31   * JDOM2 implementation of poms REPORTING element
32   *
33   * @author Robert Scholte
34   * @since 3.0
35   */
36  public class JDomReporting extends Reporting {
37  
38      private final Element reporting;
39  
40      /**
41       * <p>Constructor for JDomReporting.</p>
42       *
43       * @param reporting a {@link org.jdom2.Element} object
44       */
45      public JDomReporting(Element reporting) {
46          this.reporting = reporting;
47      }
48  
49      @Override
50      public void addPlugin(ReportPlugin reportPlugin) {
51          throw new UnsupportedOperationException();
52      }
53  
54      @Override
55      public String getOutputDirectory() {
56          throw new UnsupportedOperationException();
57      }
58  
59      @Override
60      public List<ReportPlugin> getPlugins() {
61          Element pluginsElm = reporting.getChild("plugins", reporting.getNamespace());
62          if (pluginsElm == null) {
63              return Collections.emptyList();
64          } else {
65              List<Element> pluginElms = pluginsElm.getChildren("plugin", reporting.getNamespace());
66  
67              List<ReportPlugin> plugins = new ArrayList<>(pluginElms.size());
68  
69              for (Element pluginElm : pluginElms) {
70                  plugins.add(new JDomReportPlugin(pluginElm));
71              }
72  
73              return plugins;
74          }
75      }
76  
77      @Override
78      public void removePlugin(ReportPlugin reportPlugin) {
79          throw new UnsupportedOperationException();
80      }
81  
82      @Override
83      public void setOutputDirectory(String outputDirectory) {
84          throw new UnsupportedOperationException();
85      }
86  
87      @Override
88      public void setPlugins(List<ReportPlugin> plugins) {
89          throw new UnsupportedOperationException();
90      }
91  
92      @Override
93      public void flushReportPluginMap() {
94          throw new UnsupportedOperationException();
95      }
96  
97      @Override
98      public Map<String, ReportPlugin> getReportPluginsAsMap() {
99          throw new UnsupportedOperationException();
100     }
101 
102     @Override
103     public boolean isExcludeDefaults() {
104         throw new UnsupportedOperationException();
105     }
106 
107     @Override
108     public void setExcludeDefaults(boolean excludeDefaults) {
109         throw new UnsupportedOperationException();
110     }
111 }