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