View Javadoc
1   package org.apache.maven.index.packer;
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  import java.util.Arrays;
24  import java.util.Collection;
25  
26  import org.apache.lucene.index.IndexReader;
27  import org.apache.maven.index.context.IndexingContext;
28  
29  import static com.google.common.base.Preconditions.checkNotNull;
30  
31  /**
32   * An index packing request.
33   */
34  public class IndexPackingRequest
35  {
36      public static final int MAX_CHUNKS = 30;
37  
38      private final IndexingContext context;
39  
40      private final IndexReader indexReader;
41  
42      private final File targetDir;
43  
44      private boolean createIncrementalChunks;
45  
46      private boolean createChecksumFiles;
47  
48      private int maxIndexChunks;
49  
50      private boolean useTargetProperties;
51  
52      private Collection<IndexFormat> formats;
53  
54      public IndexPackingRequest( final IndexingContext context, final IndexReader indexReader, final File targetDir )
55      {
56          this.context = checkNotNull( context );
57  
58          this.indexReader = checkNotNull( indexReader );
59  
60          this.targetDir = checkNotNull( targetDir );
61  
62          this.createIncrementalChunks = true;
63  
64          this.createChecksumFiles = false;
65  
66          this.maxIndexChunks = MAX_CHUNKS;
67  
68          this.useTargetProperties = false;
69  
70          this.formats = Arrays.asList( IndexFormat.FORMAT_V1 );
71      }
72  
73      public IndexingContext getContext()
74      {
75          return context;
76      }
77  
78      public IndexReader getIndexReader()
79      {
80          return indexReader;
81      }
82  
83      /**
84       * Sets index formats to be created
85       */
86      public void setFormats( Collection<IndexFormat> formats )
87      {
88          this.formats = formats;
89      }
90  
91      /**
92       * Returns index formats to be created.
93       */
94      public Collection<IndexFormat> getFormats()
95      {
96          return formats;
97      }
98  
99      public File getTargetDir()
100     {
101         return targetDir;
102     }
103 
104     public boolean isCreateIncrementalChunks()
105     {
106         return createIncrementalChunks;
107     }
108 
109     public void setCreateIncrementalChunks( boolean createIncrementalChunks )
110     {
111         this.createIncrementalChunks = createIncrementalChunks;
112     }
113 
114     public boolean isCreateChecksumFiles()
115     {
116         return createChecksumFiles;
117     }
118 
119     public void setCreateChecksumFiles( boolean createChecksumFiles )
120     {
121         this.createChecksumFiles = createChecksumFiles;
122     }
123 
124     public int getMaxIndexChunks()
125     {
126         return maxIndexChunks;
127     }
128 
129     public void setMaxIndexChunks( int maxIndexChunks )
130     {
131         this.maxIndexChunks = maxIndexChunks;
132     }
133 
134     public boolean isUseTargetProperties()
135     {
136         return useTargetProperties;
137     }
138 
139     public void setUseTargetProperties( boolean useTargetProperties )
140     {
141         this.useTargetProperties = useTargetProperties;
142     }
143 
144     /**
145      * Index format enumeration.
146      */
147     public enum IndexFormat
148     {
149         FORMAT_V1;
150     }
151 }