forked from codehaus-plexus/plexus-archiver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAbstractFileSet.java
211 lines (176 loc) · 4.84 KB
/
AbstractFileSet.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
/*
* Copyright 2014 The Codehaus Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.codehaus.plexus.archiver.util;
import javax.annotation.Nonnull;
import org.codehaus.plexus.archiver.BaseFileSet;
import org.codehaus.plexus.components.io.filemappers.FileMapper;
import org.codehaus.plexus.components.io.fileselectors.FileSelector;
import org.codehaus.plexus.components.io.functions.InputStreamTransformer;
/**
* Default implementation of {@link BaseFileSet}.
*
* @since 1.0-alpha-9
*/
public abstract class AbstractFileSet<T extends AbstractFileSet>
implements BaseFileSet
{
private String prefix;
private String[] includes;
private String[] excludes;
private FileSelector[] fileSelectors;
private boolean caseSensitive = true;
private boolean usingDefaultExcludes = true;
private boolean includingEmptyDirectories = true;
private InputStreamTransformer streamTransformer = null;
private FileMapper[] fileMappers;
/**
* Sets a string of patterns, which excluded files
* should match.
*/
public void setExcludes( String[] excludes )
{
this.excludes = excludes;
}
@Override
public String[] getExcludes()
{
return excludes;
}
/**
* Sets a set of file selectors, which should be used
* to select the included files.
*/
public void setFileSelectors( FileSelector[] fileSelectors )
{
this.fileSelectors = fileSelectors;
}
@Override
public FileSelector[] getFileSelectors()
{
return fileSelectors;
}
/**
* Sets a string of patterns, which included files
* should match.
*/
public void setIncludes( String[] includes )
{
this.includes = includes;
}
@Override
public String[] getIncludes()
{
return includes;
}
/**
* Sets the prefix, which the file sets contents shall
* have.
*/
public void setPrefix( String prefix )
{
this.prefix = prefix;
}
@Override
public String getPrefix()
{
return prefix;
}
/**
* Sets, whether the include/exclude patterns are
* case sensitive. Defaults to true.
*/
public void setCaseSensitive( boolean caseSensitive )
{
this.caseSensitive = caseSensitive;
}
@Override
public boolean isCaseSensitive()
{
return caseSensitive;
}
/**
* Sets, whether the default excludes are being
* applied. Defaults to true.
*/
public void setUsingDefaultExcludes( boolean usingDefaultExcludes )
{
this.usingDefaultExcludes = usingDefaultExcludes;
}
@Override
public boolean isUsingDefaultExcludes()
{
return usingDefaultExcludes;
}
/**
* Sets, whether empty directories are being included. Defaults
* to true.
*/
public void setIncludingEmptyDirectories( boolean includingEmptyDirectories )
{
this.includingEmptyDirectories = includingEmptyDirectories;
}
@Override
public boolean isIncludingEmptyDirectories()
{
return includingEmptyDirectories;
}
public T prefixed( String prefix )
{
setPrefix( prefix );
return (T) this;
}
public T include( String[] includes )
{
setIncludes( includes );
return (T) this;
}
public T exclude( String[] excludes )
{
setExcludes( excludes );
return (T) this;
}
public T includeExclude( String[] includes, String[] excludes )
{
return (T) include( includes ).exclude( excludes );
}
public T includeEmptyDirs( boolean includeEmptyDirectories )
{
setIncludingEmptyDirectories( includeEmptyDirectories );
return (T) this;
}
public void setStreamTransformer( @Nonnull InputStreamTransformer streamTransformer )
{
this.streamTransformer = streamTransformer;
}
@Override
public InputStreamTransformer getStreamTransformer()
{
return streamTransformer;
}
/**
* Sets a set of file mappers, which should be used
* to change the filename of the included files.
*/
public void setFileMappers( FileMapper[] fileMappers )
{
this.fileMappers = fileMappers;
}
@Override
public FileMapper[] getFileMappers()
{
return fileMappers;
}
}