001    /*
002     =================== DO NOT EDIT THIS FILE ====================
003     Generated by Modello 1.4.1 on 2013-02-24 03:32:14,
004     any modifications will be overwritten.
005     ==============================================================
006     */
007    
008    package org.apache.maven.model;
009    
010    /**
011     * Class InputLocation.
012     * 
013     * @version $Revision$ $Date$
014     */
015    @SuppressWarnings( "all" )
016    public final class InputLocation
017        implements java.io.Serializable, java.lang.Cloneable, org.apache.maven.model.InputLocationTracker
018    {
019    
020          //--------------------------/
021         //- Class/Member Variables -/
022        //--------------------------/
023    
024        /**
025         * The one-based line number. The value will be non-positive if
026         * unknown.
027         */
028        private int lineNumber = -1;
029    
030        /**
031         * The one-based column number. The value will be non-positive
032         * if unknown.
033         */
034        private int columnNumber = -1;
035    
036        /**
037         * Field source.
038         */
039        private InputSource source;
040    
041        /**
042         * Field locations.
043         */
044        private java.util.Map<Object, InputLocation> locations;
045    
046    
047          //----------------/
048         //- Constructors -/
049        //----------------/
050    
051        public InputLocation(int lineNumber, int columnNumber)
052        {
053            this.lineNumber = lineNumber;
054            this.columnNumber = columnNumber;
055        } //-- org.apache.maven.model.InputLocation(int, int)
056    
057        public InputLocation(int lineNumber, int columnNumber, InputSource source)
058        {
059            this.lineNumber = lineNumber;
060            this.columnNumber = columnNumber;
061            this.source = source;
062        } //-- org.apache.maven.model.InputLocation(int, int, InputSource)
063    
064    
065          //-----------/
066         //- Methods -/
067        //-----------/
068    
069        /**
070         * Method clone.
071         * 
072         * @return InputLocation
073         */
074        public InputLocation clone()
075        {
076            try
077            {
078                InputLocation copy = (InputLocation) super.clone();
079    
080                if ( copy.locations != null )
081                {
082                    copy.locations = new java.util.LinkedHashMap( copy.locations );
083                }
084    
085                return copy;
086            }
087            catch ( java.lang.Exception ex )
088            {
089                throw (java.lang.RuntimeException) new java.lang.UnsupportedOperationException( getClass().getName()
090                    + " does not support clone()" ).initCause( ex );
091            }
092        } //-- InputLocation clone()
093    
094        /**
095         * Get the one-based column number. The value will be
096         * non-positive if unknown.
097         * 
098         * @return int
099         */
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    }