View Javadoc

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