View Javadoc

1   package org.apache.maven.index;
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 java.io.File;
23  
24  import org.apache.maven.index.context.IndexingContext;
25  import org.codehaus.plexus.util.StringUtils;
26  
27  /**
28   * A scanning request provides various input parameters for repository scan
29   * 
30   * @author Jason van Zyl
31   */
32  public class ScanningRequest
33  {
34      private final IndexingContext context;
35  
36      private final ArtifactScanningListener artifactScanningListener;
37  
38      private final String startingPath;
39  
40      public ScanningRequest( final IndexingContext context, final ArtifactScanningListener artifactScanningListener )
41      {
42          this( context, artifactScanningListener, null );
43      }
44  
45      public ScanningRequest( final IndexingContext context, final ArtifactScanningListener artifactScanningListener,
46                              final String startingPath )
47      {
48          this.context = context;
49          this.artifactScanningListener = artifactScanningListener;
50          this.startingPath = startingPath;
51      }
52  
53      public IndexingContext getIndexingContext()
54      {
55          return context;
56      }
57  
58      public ArtifactScanningListener getArtifactScanningListener()
59      {
60          return artifactScanningListener;
61      }
62  
63      public String getStartingPath()
64      {
65          return startingPath;
66      }
67  
68      public File getStartingDirectory()
69      {
70          if ( StringUtils.isBlank( startingPath ) )
71          {
72              return getIndexingContext().getRepository();
73          }
74          else
75          {
76              return new File( getIndexingContext().getRepository(), startingPath );
77          }
78      }
79  }