Skip to content

Commit 8348e0b

Browse files
author
trygvis
committed
o Cleaning up the code:
- Applying our code style. - Fixed tons of IDEA inspector issues.
1 parent b51af09 commit 8348e0b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+5378
-3799
lines changed

src/main/java/org/codehaus/plexus/archiver/AbstractArchiver.java

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -27,38 +27,36 @@
2727
import java.util.Map;
2828

2929
/**
30-
* @version $Revision$ $Date$
30+
* @version $Id$
3131
*/
32-
public abstract class AbstractArchiver extends AbstractLogEnabled
32+
public abstract class AbstractArchiver
33+
extends AbstractLogEnabled
3334
implements Archiver
3435
{
3536
/**
3637
* Default value for the dirmode attribute.
3738
*/
38-
public static final int DEFAULT_DIR_MODE =
39-
UnixStat.DIR_FLAG | UnixStat.DEFAULT_DIR_PERM;
39+
public static final int DEFAULT_DIR_MODE = UnixStat.DIR_FLAG | UnixStat.DEFAULT_DIR_PERM;
4040

4141
/**
4242
* Default value for the filemode attribute.
4343
*/
44-
public static final int DEFAULT_FILE_MODE =
45-
UnixStat.FILE_FLAG | UnixStat.DEFAULT_FILE_PERM;
44+
public static final int DEFAULT_FILE_MODE = UnixStat.FILE_FLAG | UnixStat.DEFAULT_FILE_PERM;
4645

4746
private Logger logger;
4847

4948
private File destFile;
5049

5150
private Map filesMap = new LinkedHashMap();
52-
51+
5352
private Map dirsMap = new LinkedHashMap();
5453

5554
private int defaultFileMode = DEFAULT_FILE_MODE;
56-
55+
5756
private boolean includeEmptyDirs = true;
5857

5958
private int defaultDirectoryMode = DEFAULT_DIR_MODE;
60-
61-
59+
6260
public void setDefaultFileMode( int mode )
6361
{
6462
defaultFileMode = ( mode & UnixStat.PERM_MASK ) | UnixStat.FILE_FLAG;
@@ -68,7 +66,7 @@ public int getDefaultFileMode()
6866
{
6967
return defaultFileMode;
7068
}
71-
69+
7270
public void setDefaultDirectoryMode( int mode )
7371
{
7472
defaultDirectoryMode = ( mode & UnixStat.PERM_MASK ) | UnixStat.DIR_FLAG;
@@ -78,7 +76,7 @@ public int getDefaultDirectoryMode()
7876
{
7977
return defaultDirectoryMode;
8078
}
81-
79+
8280
public void addDirectory( File directory )
8381
throws ArchiverException
8482
{
@@ -96,7 +94,7 @@ public void addDirectory( File directory, String[] includes, String[] excludes )
9694
{
9795
addDirectory( directory, "", includes, excludes );
9896
}
99-
97+
10098
public void addDirectory( File directory, String prefix, String[] includes, String[] excludes )
10199
throws ArchiverException
102100
{
@@ -109,13 +107,13 @@ public void addDirectory( File directory, String prefix, String[] includes, Stri
109107
for ( int i = 0; i < includes.length; i++ )
110108
{
111109
String pattern;
112-
pattern = includes[i].replace( '/', File.separatorChar ).replace(
110+
pattern = includes[ i ].replace( '/', File.separatorChar ).replace(
113111
'\\', File.separatorChar );
114112
if ( pattern.endsWith( File.separator ) )
115113
{
116114
pattern += "**";
117115
}
118-
includesPattern[i] = pattern;
116+
includesPattern[ i ] = pattern;
119117
}
120118
}
121119

@@ -125,16 +123,16 @@ public void addDirectory( File directory, String prefix, String[] includes, Stri
125123
for ( int i = 0; i < excludes.length; i++ )
126124
{
127125
String pattern;
128-
pattern = excludes[i].replace( '/', File.separatorChar ).replace(
126+
pattern = excludes[ i ].replace( '/', File.separatorChar ).replace(
129127
'\\', File.separatorChar );
130128
if ( pattern.endsWith( File.separator ) )
131129
{
132130
pattern += "**";
133131
}
134-
excludesPattern[i] = pattern;
132+
excludesPattern[ i ] = pattern;
135133
}
136134
}
137-
135+
138136
DirectoryScanner scanner = new DirectoryScanner();
139137

140138
if ( includes != null )
@@ -146,7 +144,7 @@ public void addDirectory( File directory, String prefix, String[] includes, Stri
146144
{
147145
scanner.setExcludes( excludesPattern );
148146
}
149-
147+
150148
if ( !directory.isDirectory() )
151149
{
152150
throw new ArchiverException( directory.getAbsolutePath() + " isn't a directory." );
@@ -162,27 +160,29 @@ public void addDirectory( File directory, String prefix, String[] includes, Stri
162160

163161
for ( int i = 0; i < dirs.length; i++ )
164162
{
165-
String sourceDir = dirs[i].replace( '\\', '/' );
166-
163+
String sourceDir = dirs[ i ].replace( '\\', '/' );
164+
167165
String targetDir = ( prefix == null ? "" : prefix ) + sourceDir;
168166

169167
getDirs().put( targetDir, ArchiveEntry.createEntry( targetDir,
170-
new File( basedir, sourceDir ), getDefaultFileMode(), getDefaultDirectoryMode() ) );
168+
new File( basedir, sourceDir ),
169+
getDefaultFileMode(), getDefaultDirectoryMode() ) );
171170
}
172171
}
173172

174173
String[] files = scanner.getIncludedFiles();
175-
174+
176175
for ( int i = 0; i < files.length; i++ )
177176
{
178-
String sourceFile = files[i].replace( '\\', '/' );
179-
177+
String sourceFile = files[ i ].replace( '\\', '/' );
178+
180179
String targetFile = ( prefix == null ? "" : prefix ) + sourceFile;
181180

182181
filesMap.put( targetFile, ArchiveEntry.createEntry( targetFile,
183-
new File( basedir, sourceFile ), getDefaultFileMode(), getDefaultDirectoryMode() ) );
182+
new File( basedir, sourceFile ), getDefaultFileMode(),
183+
getDefaultDirectoryMode() ) );
184184
}
185-
185+
186186
}
187187

188188
public void addFile( File inputFile, String destFileName )
@@ -212,15 +212,15 @@ protected Map getFiles()
212212
{
213213
if ( !includeEmptyDirs )
214214
{
215-
return filesMap;
215+
return filesMap;
216216
}
217-
217+
218218
Map resources = new LinkedHashMap();
219219

220220
resources.putAll( getDirs() );
221-
221+
222222
resources.putAll( filesMap );
223-
223+
224224
return resources;
225225
}
226226

@@ -257,7 +257,7 @@ public boolean getIncludeEmptyDirs()
257257
return includeEmptyDirs;
258258
}
259259

260-
public void setIncludeEmptyDirs(boolean includeEmptyDirs)
260+
public void setIncludeEmptyDirs( boolean includeEmptyDirs )
261261
{
262262
this.includeEmptyDirs = includeEmptyDirs;
263263
}

src/main/java/org/codehaus/plexus/archiver/AbstractUnArchiver.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,17 @@
1717
* limitations under the License.
1818
*/
1919

20-
import java.io.IOException;
21-
import java.io.File;
22-
2320
import org.codehaus.plexus.logging.AbstractLogEnabled;
2421

22+
import java.io.File;
23+
import java.io.IOException;
24+
2525
/**
2626
* @author <a href="mailto:[email protected]">Emmanuel Venisse</a>
2727
* @version $Revision$ $Date$
2828
*/
29-
public abstract class AbstractUnArchiver extends AbstractLogEnabled
29+
public abstract class AbstractUnArchiver
30+
extends AbstractLogEnabled
3031
implements UnArchiver
3132
{
3233
private File destDirectory;
@@ -77,13 +78,15 @@ public void setOverwrite( boolean b )
7778
overwrite = b;
7879
}
7980

80-
public void extract() throws ArchiverException, IOException
81+
public void extract()
82+
throws ArchiverException, IOException
8183
{
8284
validate();
8385
execute();
8486
}
85-
86-
protected void validate() throws ArchiverException
87+
88+
protected void validate()
89+
throws ArchiverException
8790
{
8891
if ( sourceFile == null )
8992
{
@@ -122,6 +125,7 @@ protected void validate() throws ArchiverException
122125
destFile = null;
123126
}
124127
}
125-
126-
protected abstract void execute() throws ArchiverException, IOException;
128+
129+
protected abstract void execute()
130+
throws ArchiverException, IOException;
127131
}

src/main/java/org/codehaus/plexus/archiver/ArchiveEntry.java

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -31,39 +31,37 @@ public class ArchiveEntry
3131
public static final int DIRECTORY = 2;
3232

3333
private String name;
34-
34+
3535
private File file;
3636

3737
private int type;
3838

3939
private int mode;
4040

4141
/**
42-
* @param name the filename as it will appear in the archive
42+
* @param name the filename as it will appear in the archive
4343
* @param original original filename
44-
* @param type FILE or DIRECTORY
45-
* @param mode octal unix style permissions
44+
* @param type FILE or DIRECTORY
45+
* @param mode octal unix style permissions
4646
*/
4747
private ArchiveEntry( String name, File original, int type, int mode )
4848
{
4949
this.name = name;
5050
this.file = original;
5151
this.type = type;
52-
this.mode = ( mode & UnixStat.PERM_MASK ) |
53-
( type == FILE ? UnixStat.FILE_FLAG : UnixStat.DIR_FLAG );
52+
this.mode = ( mode & UnixStat.PERM_MASK ) |
53+
( type == FILE ? UnixStat.FILE_FLAG : UnixStat.DIR_FLAG );
5454
}
5555

5656
/**
57-
*
5857
* @return the filename of this entry in the archive.
5958
*/
6059
public String getName()
6160
{
62-
return name;
61+
return name;
6362
}
64-
63+
6564
/**
66-
*
6765
* @return The original file that will be stored in the archive.
6866
*/
6967
public File getFile()
@@ -73,6 +71,7 @@ public File getFile()
7371

7472
/**
7573
* TODO: support for SYMLINK?
74+
*
7675
* @return FILE or DIRECTORY
7776
*/
7877
public int getType()
@@ -89,35 +88,35 @@ public int getMode()
8988
}
9089

9190
public static ArchiveEntry createFileEntry( String target, File file, int permissions )
92-
throws ArchiverException
91+
throws ArchiverException
9392
{
94-
if ( ! file.isFile() )
95-
{
96-
throw new ArchiverException( "Not a file: " + file );
97-
}
98-
else
99-
{
100-
return new ArchiveEntry( target, file, FILE, permissions );
101-
}
93+
if ( ! file.isFile() )
94+
{
95+
throw new ArchiverException( "Not a file: " + file );
96+
}
97+
else
98+
{
99+
return new ArchiveEntry( target, file, FILE, permissions );
100+
}
102101
}
103102

104103
public static ArchiveEntry createDirectoryEntry( String target, File file, int permissions )
105-
throws ArchiverException
104+
throws ArchiverException
106105
{
107-
if ( ! file.isDirectory() )
108-
{
109-
throw new ArchiverException( "Not a directory: " + file );
110-
}
111-
else
112-
{
113-
return new ArchiveEntry( target, file, DIRECTORY, permissions );
114-
}
106+
if ( ! file.isDirectory() )
107+
{
108+
throw new ArchiverException( "Not a directory: " + file );
109+
}
110+
else
111+
{
112+
return new ArchiveEntry( target, file, DIRECTORY, permissions );
113+
}
115114
}
116115

117116
/**
118117
* Creates the correct ArchiveEntry instance for either a FILE or a
119118
* DIRECTORY.
120-
*
119+
*
121120
* @param target
122121
* @param file
123122
* @param filePerm
@@ -126,19 +125,19 @@ public static ArchiveEntry createDirectoryEntry( String target, File file, int p
126125
* @throws ArchiverException when file is neither a directory nor a file.
127126
*/
128127
public static ArchiveEntry createEntry( String target, File file, int filePerm, int dirPerm )
129-
throws ArchiverException
128+
throws ArchiverException
130129
{
131130
if ( file.isDirectory() )
132131
{
133-
return createDirectoryEntry( target, file, dirPerm );
132+
return createDirectoryEntry( target, file, dirPerm );
134133
}
135134
else if ( file.isFile() )
136135
{
137-
return createFileEntry( target, file, filePerm );
136+
return createFileEntry( target, file, filePerm );
138137
}
139138
else // FIXME: handle symlinks?
140139
{
141-
throw new ArchiverException( "Neither a file nor a directory: " + file );
140+
throw new ArchiverException( "Neither a file nor a directory: " + file );
142141
}
143142
}
144143
}

0 commit comments

Comments
 (0)