View Javadoc
1   package org.codehaus.mojo.axistools.axis;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.maven.artifact.factory.ArtifactFactory;
23  import org.apache.maven.artifact.repository.ArtifactRepository;
24  import org.apache.maven.plugin.logging.Log;
25  import org.apache.maven.project.MavenProject;
26  
27  import java.io.File;
28  import java.util.Iterator;
29  import java.util.List;
30  
31  /**
32   * Convience baseclass for shared parameters, getters and setters, and methods
33   * for the Axis Plugins
34   *
35   * @author: jesse
36   * @version: $Id$
37   */
38  public abstract class AbstractAxisPlugin
39  {
40      protected File sourceDirectory;
41  
42      protected File outputDirectory;
43  
44      protected File timestampDirectory;
45  
46      protected int staleMillis;
47  
48      protected MavenProject project;
49  
50      protected ArtifactRepository localRepository;
51  
52      protected ArtifactFactory artifactFactory;
53  
54      protected List pluginArtifacts;
55  
56      protected Log log;
57  
58      /**
59       * Replaces all characters in the given name except for the '.'. and
60       * alphanumeric characters to make it a safe valid file name.
61       * <p/>
62       * <p/>
63       * Possible drawback: This uses JDK 1.4 regular expressions and will not
64       * compile with older J2SE versions.
65       *
66       * @param aName name to make safe
67       * @return the safe file name
68       */
69      protected String createSafeFileName( String aName )
70      {
71          String fileName = aName.replaceAll( "[^\\p{Alnum}\\.]", "-" );
72  
73          if ( !fileName.endsWith( ".wsdl" ) )
74          {
75              fileName += ".wsdl";
76          }
77          return fileName;
78      }
79  
80      /**
81       * Converts a list to a comma delimited string.
82       */
83      protected String listToCommaDelimitedString( List list )
84      {
85          StringBuffer strbuf = new StringBuffer();
86  
87          if ( list != null )
88          {
89              for ( Iterator i = list.iterator(); i.hasNext(); )
90              {
91                  strbuf.append( (String) i.next() );
92                  if ( i.hasNext() )
93                  {
94                      strbuf.append( "," );
95                  }
96              }
97          }
98          return strbuf.toString();
99      }
100 
101     protected Log getLog()
102     {
103         return log;
104     }
105 
106     public void setLog( Log log )
107     {
108         this.log = log;
109     }
110 
111     public void setSourceDirectory( File sourceDirectory )
112     {
113         this.sourceDirectory = sourceDirectory;
114     }
115 
116     public void setOutputDirectory( File outputDirectory )
117     {
118         this.outputDirectory = outputDirectory;
119     }
120 
121     public void setTimestampDirectory( File timestampDirectory )
122     {
123         this.timestampDirectory = timestampDirectory;
124     }
125 
126     public void setStaleMillis( int staleMillis )
127     {
128         this.staleMillis = staleMillis;
129     }
130 
131     public void setProject( MavenProject project )
132     {
133         this.project = project;
134     }
135 
136     public void setLocalRepository( ArtifactRepository localRepository )
137     {
138         this.localRepository = localRepository;
139     }
140 
141     public void setArtifactFactory( ArtifactFactory artifactFactory )
142     {
143         this.artifactFactory = artifactFactory;
144     }
145 
146     public void setPluginArtifacts( List pluginArtifacts )
147     {
148         this.pluginArtifacts = pluginArtifacts;
149     }
150 
151 }