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   =================== DO NOT EDIT THIS FILE ====================
19   Generated by Modello 2.4.0,
20   any modifications will be overwritten.
21   ==============================================================
22   */
23  
24  package org.apache.maven.model;
25  
26  /**
27   * Definition of include or exclude patterns.
28   * 
29   * @version $Revision$ $Date$
30   */
31  @SuppressWarnings( "all" )
32  public class PatternSet
33      implements java.io.Serializable, java.lang.Cloneable, org.apache.maven.model.InputLocationTracker
34  {
35  
36        //--------------------------/
37       //- Class/Member Variables -/
38      //--------------------------/
39  
40      /**
41       * Field includes.
42       */
43      private java.util.List<String> includes;
44  
45      /**
46       * Field excludes.
47       */
48      private java.util.List<String> excludes;
49  
50      /**
51       * Field locations.
52       */
53      private java.util.Map<Object, InputLocation> locations;
54  
55      /**
56       * Field location.
57       */
58      private InputLocation location;
59  
60      /**
61       * Field includesLocation.
62       */
63      private InputLocation includesLocation;
64  
65      /**
66       * Field excludesLocation.
67       */
68      private InputLocation excludesLocation;
69  
70  
71        //-----------/
72       //- Methods -/
73      //-----------/
74  
75      /**
76       * Method addExclude.
77       * 
78       * @param string a string object.
79       */
80      public void addExclude( String string )
81      {
82          getExcludes().add( string );
83      } //-- void addExclude( String )
84  
85      /**
86       * Method addInclude.
87       * 
88       * @param string a string object.
89       */
90      public void addInclude( String string )
91      {
92          getIncludes().add( string );
93      } //-- void addInclude( String )
94  
95      /**
96       * Method clone.
97       * 
98       * @return PatternSet
99       */
100     public PatternSet clone()
101     {
102         try
103         {
104             PatternSet copy = (PatternSet) super.clone();
105 
106             if ( this.includes != null )
107             {
108                 copy.includes = new java.util.ArrayList<String>();
109                 copy.includes.addAll( this.includes );
110             }
111 
112             if ( this.excludes != null )
113             {
114                 copy.excludes = new java.util.ArrayList<String>();
115                 copy.excludes.addAll( this.excludes );
116             }
117 
118             if ( copy.locations != null )
119             {
120                 copy.locations = new java.util.LinkedHashMap( copy.locations );
121             }
122 
123             return copy;
124         }
125         catch ( java.lang.Exception ex )
126         {
127             throw (java.lang.RuntimeException) new java.lang.UnsupportedOperationException( getClass().getName()
128                 + " does not support clone()" ).initCause( ex );
129         }
130     } //-- PatternSet clone()
131 
132     /**
133      * Method getExcludes.
134      * 
135      * @return List
136      */
137     public java.util.List<String> getExcludes()
138     {
139         if ( this.excludes == null )
140         {
141             this.excludes = new java.util.ArrayList<String>();
142         }
143 
144         return this.excludes;
145     } //-- java.util.List<String> getExcludes()
146 
147     /**
148      * Method getIncludes.
149      * 
150      * @return List
151      */
152     public java.util.List<String> getIncludes()
153     {
154         if ( this.includes == null )
155         {
156             this.includes = new java.util.ArrayList<String>();
157         }
158 
159         return this.includes;
160     } //-- java.util.List<String> getIncludes()
161 
162     /**
163      * 
164      * 
165      * @param key a key object.
166      * @return InputLocation
167      */
168     public InputLocation getLocation( Object key )
169     {
170         if ( key instanceof String )
171         {
172             switch ( ( String ) key )
173             {
174                 case "" :
175                 {
176                     return this.location;
177                 }
178                 case "includes" :
179                 {
180                     return includesLocation;
181                 }
182                 case "excludes" :
183                 {
184                     return excludesLocation;
185                 }
186                 default :
187                 {
188                     return getOtherLocation( key );
189                 }
190                 }
191             }
192             else
193             {
194                 return getOtherLocation( key );
195             }
196     } //-- InputLocation getLocation( Object )
197 
198     /**
199      * 
200      * 
201      * @param key a key object.
202      * @param location a location object.
203      */
204     public void setLocation( Object key, InputLocation location )
205     {
206         if ( key instanceof String )
207         {
208             switch ( ( String ) key )
209             {
210                 case "" :
211                 {
212                     this.location = location;
213                     return;
214                 }
215                 case "includes" :
216                 {
217                     includesLocation = location;
218                     return;
219                 }
220                 case "excludes" :
221                 {
222                     excludesLocation = location;
223                     return;
224                 }
225                 default :
226                 {
227                     setOtherLocation( key, location );
228                     return;
229                 }
230             }
231         }
232         else
233         {
234             setOtherLocation( key, location );
235         }
236     } //-- void setLocation( Object, InputLocation )
237 
238     /**
239      * 
240      * 
241      * @param key a key object.
242      * @param location a location object.
243      */
244     public void setOtherLocation( Object key, InputLocation location )
245     {
246         if ( location != null )
247         {
248             if ( this.locations == null )
249             {
250                 this.locations = new java.util.LinkedHashMap<Object, InputLocation>();
251             }
252             this.locations.put( key, location );
253         }
254     } //-- void setOtherLocation( Object, InputLocation )
255 
256     /**
257      * 
258      * 
259      * @param key a key object.
260      * @return InputLocation
261      */
262     private InputLocation getOtherLocation( Object key )
263     {
264         return ( locations != null ) ? locations.get( key ) : null;
265     } //-- InputLocation getOtherLocation( Object )
266 
267     /**
268      * Method removeExclude.
269      * 
270      * @param string a string object.
271      */
272     public void removeExclude( String string )
273     {
274         getExcludes().remove( string );
275     } //-- void removeExclude( String )
276 
277     /**
278      * Method removeInclude.
279      * 
280      * @param string a string object.
281      */
282     public void removeInclude( String string )
283     {
284         getIncludes().remove( string );
285     } //-- void removeInclude( String )
286 
287     /**
288      * Set a list of patterns to exclude, e.g.
289      * <code>**&#47;*.xml</code>
290      * 
291      * @param excludes a excludes object.
292      */
293     public void setExcludes( java.util.List<String> excludes )
294     {
295         this.excludes = excludes;
296     } //-- void setExcludes( java.util.List )
297 
298     /**
299      * Set a list of patterns to include, e.g.
300      * <code>**&#47;*.xml</code>.
301      * 
302      * @param includes a includes object.
303      */
304     public void setIncludes( java.util.List<String> includes )
305     {
306         this.includes = includes;
307     } //-- void setIncludes( java.util.List )
308 
309     
310             
311     /**
312      * @see java.lang.Object#toString()
313      */
314     public String toString()
315     {
316         StringBuilder sb = new StringBuilder( 128 );
317 
318         sb.append("PatternSet [includes: {");
319         for (java.util.Iterator i = getIncludes().iterator(); i.hasNext(); )
320         {
321             String str = (String) i.next();
322             sb.append(str).append(", ");
323         }
324         if (sb.substring(sb.length() - 2).equals(", ")) sb.delete(sb.length() - 2, sb.length());
325 
326         sb.append("}, excludes: {");
327         for (java.util.Iterator i = getExcludes().iterator(); i.hasNext(); )
328         {
329             String str = (String) i.next();
330             sb.append(str).append(", ");
331         }
332         if (sb.substring(sb.length() - 2).equals(", ")) sb.delete(sb.length() - 2, sb.length());
333 
334         sb.append("}]");
335         return sb.toString();
336     }
337             
338           
339 }