View Javadoc
1   // =================== DO NOT EDIT THIS FILE ====================
2   // Generated by Modello 1.9.1,
3   // any modifications will be overwritten.
4   // ==============================================================
5   
6   package org.apache.maven.model;
7   
8   /**
9    * Class InputLocation.
10   * 
11   * @version $Revision: 1008624 $ $Date: 2017-03-19 14:17:57 +0000 (Sun, 19 Mar 2017) $
12   */
13  @SuppressWarnings( "all" )
14  public final class InputLocation
15      implements java.io.Serializable, java.lang.Cloneable, org.apache.maven.model.InputLocationTracker
16  {
17  
18        //--------------------------/
19       //- Class/Member Variables -/
20      //--------------------------/
21  
22      /**
23       * The one-based line number. The value will be non-positive if
24       * unknown.
25       */
26      private int lineNumber = -1;
27  
28      /**
29       * The one-based column number. The value will be non-positive
30       * if unknown.
31       */
32      private int columnNumber = -1;
33  
34      /**
35       * Field source.
36       */
37      private InputSource source;
38  
39      /**
40       * Field locations.
41       */
42      private java.util.Map<Object, InputLocation> locations;
43  
44  
45        //----------------/
46       //- Constructors -/
47      //----------------/
48  
49      public InputLocation(int lineNumber, int columnNumber)
50      {
51          this.lineNumber = lineNumber;
52          this.columnNumber = columnNumber;
53      } //-- org.apache.maven.model.InputLocation(int, int)
54  
55      public InputLocation(int lineNumber, int columnNumber, InputSource source)
56      {
57          this.lineNumber = lineNumber;
58          this.columnNumber = columnNumber;
59          this.source = source;
60      } //-- org.apache.maven.model.InputLocation(int, int, InputSource)
61  
62  
63        //-----------/
64       //- Methods -/
65      //-----------/
66  
67      /**
68       * Method clone.
69       * 
70       * @return InputLocation
71       */
72      public InputLocation clone()
73      {
74          try
75          {
76              InputLocation copy = (InputLocation) super.clone();
77  
78              if ( copy.locations != null )
79              {
80                  copy.locations = new java.util.LinkedHashMap( copy.locations );
81              }
82  
83              return copy;
84          }
85          catch ( java.lang.Exception ex )
86          {
87              throw (java.lang.RuntimeException) new java.lang.UnsupportedOperationException( getClass().getName()
88                  + " does not support clone()" ).initCause( ex );
89          }
90      } //-- InputLocation clone()
91  
92      /**
93       * Get the one-based column number. The value will be
94       * non-positive if unknown.
95       * 
96       * @return int
97       */
98      public int getColumnNumber()
99      {
100         return this.columnNumber;
101     } //-- int getColumnNumber()
102 
103     /**
104      * Get the one-based line number. The value will be
105      * non-positive if unknown.
106      * 
107      * @return int
108      */
109     public int getLineNumber()
110     {
111         return this.lineNumber;
112     } //-- int getLineNumber()
113 
114     /**
115      * 
116      * 
117      * @param key
118      * @return InputLocation
119      */
120     public InputLocation getLocation( Object key )
121     {
122         return ( locations != null ) ? locations.get( key ) : null;
123     } //-- InputLocation getLocation( Object )
124 
125     /**
126      * 
127      * 
128      * @return Map
129      */
130     public java.util.Map<Object, InputLocation> getLocations()
131     {
132         return locations;
133     } //-- java.util.Map<Object, InputLocation> getLocations()
134 
135     /**
136      * Get the source field.
137      * 
138      * @return InputSource
139      */
140     public InputSource getSource()
141     {
142         return this.source;
143     } //-- InputSource getSource()
144 
145     /**
146      * Method merge.
147      * 
148      * @param target
149      * @param sourceDominant
150      * @param source
151      * @return InputLocation
152      */
153     public static InputLocation merge( InputLocation target, InputLocation source, boolean sourceDominant )
154     {
155         if ( source == null )
156         {
157             return target;
158         }
159         else if ( target == null )
160         {
161             return source;
162         }
163 
164         InputLocation result =
165             new InputLocation( target.getLineNumber(), target.getColumnNumber(), target.getSource() );
166 
167         java.util.Map<Object, InputLocation> locations;
168         java.util.Map<Object, InputLocation> sourceLocations = source.getLocations();
169         java.util.Map<Object, InputLocation> targetLocations = target.getLocations();
170         if ( sourceLocations == null )
171         {
172             locations = targetLocations;
173         }
174         else if ( targetLocations == null )
175         {
176             locations = sourceLocations;
177         }
178         else
179         {
180             locations = new java.util.LinkedHashMap();
181             locations.putAll( sourceDominant ? targetLocations : sourceLocations );
182             locations.putAll( sourceDominant ? sourceLocations : targetLocations );
183         }
184         result.setLocations( locations );
185 
186         return result;
187     } //-- InputLocation merge( InputLocation, InputLocation, boolean )
188 
189     /**
190      * Method merge.
191      * 
192      * @param target
193      * @param indices
194      * @param source
195      * @return InputLocation
196      */
197     public static InputLocation merge( InputLocation target, InputLocation source, java.util.Collection<Integer> indices )
198     {
199         if ( source == null )
200         {
201             return target;
202         }
203         else if ( target == null )
204         {
205             return source;
206         }
207 
208         InputLocation result =
209             new InputLocation( target.getLineNumber(), target.getColumnNumber(), target.getSource() );
210 
211         java.util.Map<Object, InputLocation> locations;
212         java.util.Map<Object, InputLocation> sourceLocations = source.getLocations();
213         java.util.Map<Object, InputLocation> targetLocations = target.getLocations();
214         if ( sourceLocations == null )
215         {
216             locations = targetLocations;
217         }
218         else if ( targetLocations == null )
219         {
220             locations = sourceLocations;
221         }
222         else
223         {
224             locations = new java.util.LinkedHashMap<Object, InputLocation>();
225             for ( java.util.Iterator<Integer> it = indices.iterator(); it.hasNext(); )
226             {
227                 InputLocation location;
228                 Integer index = it.next();
229                 if ( index.intValue() < 0 )
230                 {
231                     location = sourceLocations.get( Integer.valueOf( ~index.intValue() ) );
232                 }
233                 else
234                 {
235                     location = targetLocations.get( index );
236                 }
237                 locations.put( Integer.valueOf( locations.size() ), location );
238             }
239         }
240         result.setLocations( locations );
241 
242         return result;
243     } //-- InputLocation merge( InputLocation, InputLocation, java.util.Collection )
244 
245     /**
246      * 
247      * 
248      * @param key
249      * @param location
250      */
251     public void setLocation( Object key, InputLocation location )
252     {
253         if ( location != null )
254         {
255             if ( this.locations == null )
256             {
257                 this.locations = new java.util.LinkedHashMap<Object, InputLocation>();
258             }
259             this.locations.put( key, location );
260         }
261     } //-- void setLocation( Object, InputLocation )
262 
263     /**
264      * 
265      * 
266      * @param locations
267      */
268     public void setLocations( java.util.Map<Object, InputLocation> locations )
269     {
270         this.locations = locations;
271     } //-- void setLocations( java.util.Map )
272 
273     
274             
275 
276     @Override
277     public String toString()
278     {
279         return getLineNumber() + " : " + getColumnNumber() + ", " + getSource();
280     }
281             
282           
283 }