View Javadoc

1   /*
2    * $Id$
3    */
4   
5   package org.apache.maven.model;
6   
7     //---------------------------------/
8    //- Imported classes and packages -/
9   //---------------------------------/
10  
11  import java.util.Date;
12  
13  /**
14   * Definition of include or exclude patterns.
15   * 
16   * @version $Revision$ $Date$
17   */
18  public class PatternSet implements java.io.Serializable {
19  
20  
21        //--------------------------/
22       //- Class/Member Variables -/
23      //--------------------------/
24  
25      /**
26       * Field includes.
27       */
28      private java.util.List includes;
29  
30      /**
31       * Field excludes.
32       */
33      private java.util.List excludes;
34  
35  
36        //-----------/
37       //- Methods -/
38      //-----------/
39  
40      /**
41       * Method addExclude.
42       * 
43       * @param string
44       */
45      public void addExclude( String string )
46      {
47          if ( !(string instanceof String) )
48          {
49              throw new ClassCastException( "PatternSet.addExcludes(string) parameter must be instanceof " + String.class.getName() );
50          }
51          getExcludes().add( string );
52      } //-- void addExclude( String ) 
53  
54      /**
55       * Method addInclude.
56       * 
57       * @param string
58       */
59      public void addInclude( String string )
60      {
61          if ( !(string instanceof String) )
62          {
63              throw new ClassCastException( "PatternSet.addIncludes(string) parameter must be instanceof " + String.class.getName() );
64          }
65          getIncludes().add( string );
66      } //-- void addInclude( String ) 
67  
68      /**
69       * Method getExcludes.
70       * 
71       * @return java.util.List
72       */
73      public java.util.List getExcludes()
74      {
75          if ( this.excludes == null )
76          {
77              this.excludes = new java.util.ArrayList();
78          }
79      
80          return this.excludes;
81      } //-- java.util.List getExcludes() 
82  
83      /**
84       * Method getIncludes.
85       * 
86       * @return java.util.List
87       */
88      public java.util.List getIncludes()
89      {
90          if ( this.includes == null )
91          {
92              this.includes = new java.util.ArrayList();
93          }
94      
95          return this.includes;
96      } //-- java.util.List getIncludes() 
97  
98      /**
99       * Method removeExclude.
100      * 
101      * @param string
102      */
103     public void removeExclude( String string )
104     {
105         if ( !(string instanceof String) )
106         {
107             throw new ClassCastException( "PatternSet.removeExcludes(string) parameter must be instanceof " + String.class.getName() );
108         }
109         getExcludes().remove( string );
110     } //-- void removeExclude( String ) 
111 
112     /**
113      * Method removeInclude.
114      * 
115      * @param string
116      */
117     public void removeInclude( String string )
118     {
119         if ( !(string instanceof String) )
120         {
121             throw new ClassCastException( "PatternSet.removeIncludes(string) parameter must be instanceof " + String.class.getName() );
122         }
123         getIncludes().remove( string );
124     } //-- void removeInclude( String ) 
125 
126     /**
127      * Set 
128      *             
129      *             A list of patterns to exclude, e.g.
130      * <code>**&#47;*.xml</code>
131      *             
132      *           
133      * 
134      * @param excludes
135      */
136     public void setExcludes( java.util.List excludes )
137     {
138         this.excludes = excludes;
139     } //-- void setExcludes( java.util.List ) 
140 
141     /**
142      * Set 
143      *             
144      *             A list of patterns to include, e.g.
145      * <code>**&#47;*.xml</code>.
146      *             
147      *           
148      * 
149      * @param includes
150      */
151     public void setIncludes( java.util.List includes )
152     {
153         this.includes = includes;
154     } //-- void setIncludes( java.util.List ) 
155 
156 
157             
158     /**
159      * @see java.lang.Object#toString()
160      */
161     public String toString()
162     {
163         StringBuffer sb = new StringBuffer();
164 
165         sb.append("PatternSet [includes: {");
166         for (java.util.Iterator i = getIncludes().iterator(); i.hasNext(); )
167         {
168             String str = (String) i.next();
169             sb.append(str).append(", ");
170         }
171         if (sb.substring(sb.length() - 2).equals(", ")) sb.delete(sb.length() - 2, sb.length());
172 
173         sb.append("}, excludes: {");
174         for (java.util.Iterator i = getExcludes().iterator(); i.hasNext(); )
175         {
176             String str = (String) i.next();
177             sb.append(str).append(", ");
178         }
179         if (sb.substring(sb.length() - 2).equals(", ")) sb.delete(sb.length() - 2, sb.length());
180 
181         sb.append("}]");
182         return sb.toString();
183     }
184             
185           
186     private String modelEncoding = "UTF-8";
187 
188     /**
189      * Set an encoding used for reading/writing the model.
190      *
191      * @param modelEncoding the encoding used when reading/writing the model.
192      */
193     public void setModelEncoding( String modelEncoding )
194     {
195         this.modelEncoding = modelEncoding;
196     }
197 
198     /**
199      * @return the current encoding used when reading/writing this model.
200      */
201     public String getModelEncoding()
202     {
203         return modelEncoding;
204     }
205 }