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.model;
20  
21  /**
22   * Class InputSource.
23   *
24   * @version $Revision$ $Date$
25   */
26  @SuppressWarnings("all")
27  public class InputSource implements java.io.Serializable, Cloneable {
28  
29      // --------------------------/
30      // - Class/Member Variables -/
31      // --------------------------/
32  
33      /**
34       *
35       *
36       *             The identifier of the POM in the format {@code
37       * <groupId>:<artifactId>:<version>}.
38       *
39       *
40       */
41      private String modelId;
42  
43      /**
44       *
45       *
46       *             The path/URL of the POM or {@code null} if
47       * unknown.
48       *
49       *
50       */
51      private String location;
52  
53      // ----------------/
54      // - Constructors -/
55      // ----------------/
56  
57      public InputSource() {}
58  
59      public InputSource(org.apache.maven.api.model.InputSource source) {
60          this.modelId = source.getModelId();
61          this.location = source.getLocation();
62      }
63  
64      // -----------/
65      // - Methods -/
66      // -----------/
67  
68      /**
69       * Method clone.
70       *
71       * @return InputSource
72       */
73      public InputSource clone() {
74          try {
75              InputSource copy = (InputSource) super.clone();
76  
77              return copy;
78          } catch (Exception ex) {
79              throw (RuntimeException)
80                      new UnsupportedOperationException(getClass().getName() + " does not support clone()").initCause(ex);
81          }
82      } // -- InputSource clone()
83  
84      /**
85       * Get the path/URL of the POM or {@code null} if unknown.
86       *
87       * @return String
88       */
89      public String getLocation() {
90          return this.location;
91      } // -- String getLocation()
92  
93      /**
94       * Get the identifier of the POM in the format {@code
95       * <groupId>:<artifactId>:<version>}.
96       *
97       * @return String
98       */
99      public String getModelId() {
100         return this.modelId;
101     } // -- String getModelId()
102 
103     /**
104      * Set the path/URL of the POM or {@code null} if unknown.
105      *
106      * @param location
107      */
108     public void setLocation(String location) {
109         this.location = location;
110     } // -- void setLocation( String )
111 
112     /**
113      * Set the identifier of the POM in the format {@code
114      * <groupId>:<artifactId>:<version>}.
115      *
116      * @param modelId
117      */
118     public void setModelId(String modelId) {
119         this.modelId = modelId;
120     } // -- void setModelId( String )
121 
122     @Override
123     public String toString() {
124         return getModelId() + " " + getLocation();
125     }
126 
127     public org.apache.maven.api.model.InputSource toApiSource() {
128         return new org.apache.maven.api.model.InputSource(modelId, location);
129     }
130 }