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       *
55       *
56       *             The location of the POM from which this POM was
57       * imported from or {@code null} if unknown.
58       */
59      private InputLocation importedFrom;
60  
61      // ----------------/
62      // - Constructors -/
63      // ----------------/
64  
65      public InputSource() {}
66  
67      public InputSource(org.apache.maven.api.model.InputSource source) {
68          this.modelId = source.getModelId();
69          this.location = source.getLocation();
70          this.importedFrom = source.getImportedFrom() != null ? new InputLocation(source.getImportedFrom()) : null;
71      }
72  
73      // -----------/
74      // - Methods -/
75      // -----------/
76  
77      /**
78       * Method clone.
79       *
80       * @return InputSource
81       */
82      public InputSource clone() {
83          try {
84              InputSource copy = (InputSource) super.clone();
85  
86              return copy;
87          } catch (Exception ex) {
88              throw (RuntimeException)
89                      new UnsupportedOperationException(getClass().getName() + " does not support clone()").initCause(ex);
90          }
91      } // -- InputSource clone()
92  
93      /**
94       * Get the path/URL of the POM or {@code null} if unknown.
95       *
96       * @return String
97       */
98      public String getLocation() {
99          return this.location;
100     } // -- String getLocation()
101 
102     /**
103      * Get the identifier of the POM in the format {@code
104      * <groupId>:<artifactId>:<version>}.
105      *
106      * @return String
107      */
108     public String getModelId() {
109         return this.modelId;
110     } // -- String getModelId()
111 
112     /**
113      * Set the path/URL of the POM or {@code null} if unknown.
114      *
115      * @param location
116      */
117     public void setLocation(String location) {
118         this.location = location;
119     } // -- void setLocation( String )
120 
121     /**
122      * Set the identifier of the POM in the format {@code
123      * <groupId>:<artifactId>:<version>}.
124      *
125      * @param modelId
126      */
127     public void setModelId(String modelId) {
128         this.modelId = modelId;
129     } // -- void setModelId( String )
130 
131     /**
132      * Get the location of the POM from which this POM was
133      *
134      * @return
135      */
136     public InputLocation getImportedFrom() {
137         return importedFrom;
138     }
139 
140     /**
141      * Set the location of the POM from which this POM was imported from.
142      *
143      * @param importedFrom
144      */
145     public void setImportedFrom(InputLocation importedFrom) {
146         this.importedFrom = importedFrom;
147     }
148 
149     @Override
150     public String toString() {
151         return getModelId() + " " + getLocation();
152     }
153 
154     public org.apache.maven.api.model.InputSource toApiSource() {
155         return new org.apache.maven.api.model.InputSource(modelId, location);
156     }
157 }