Skip to content

Commit 512f188

Browse files
committed
Reformat code
1 parent 441117b commit 512f188

22 files changed

+442
-679
lines changed

pom.xml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
<scm>
1818
<connection>scm:git:git@github.com:codehaus-plexus/plexus-resources.git</connection>
1919
<developerConnection>scm:git:git@github.com:codehaus-plexus/plexus-resources.git</developerConnection>
20-
<url>http://github.com/codehaus-plexus/plexus-resources</url>
2120
<tag>plexus-resources-1.2.0</tag>
21+
<url>http://github.com/codehaus-plexus/plexus-resources</url>
2222
</scm>
2323
<issueManagement>
2424
<system>jira</system>
@@ -98,15 +98,17 @@
9898
<groupId>org.apache.maven.plugins</groupId>
9999
<artifactId>maven-scm-publish-plugin</artifactId>
100100
<configuration>
101-
<content>${project.reporting.outputDirectory}</content><!-- mono-module doesn't require site:stage -->
101+
<content>${project.reporting.outputDirectory}</content>
102+
<!-- mono-module doesn't require site:stage -->
102103
</configuration>
103104
<executions>
104105
<execution>
105106
<id>scm-publish</id>
106-
<phase>site-deploy</phase><!-- deploy site with maven-scm-publish-plugin -->
107+
<!-- deploy site with maven-scm-publish-plugin -->
107108
<goals>
108109
<goal>publish-scm</goal>
109110
</goals>
111+
<phase>site-deploy</phase>
110112
</execution>
111113
</executions>
112114
</plugin>

src/main/java/org/codehaus/plexus/resource/DefaultResourceManager.java

Lines changed: 71 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@
2424
* SOFTWARE.
2525
*/
2626

27+
import javax.inject.Inject;
28+
import javax.inject.Named;
29+
30+
import java.io.File;
31+
import java.io.FileOutputStream;
32+
import java.io.IOException;
33+
import java.io.InputStream;
34+
import java.io.OutputStream;
35+
import java.util.Map;
2736

2837
import org.codehaus.plexus.resource.loader.FileResourceCreationException;
2938
import org.codehaus.plexus.resource.loader.ResourceIOException;
@@ -34,32 +43,21 @@
3443
import org.slf4j.Logger;
3544
import org.slf4j.LoggerFactory;
3645

37-
import java.io.File;
38-
import java.io.FileOutputStream;
39-
import java.io.IOException;
40-
import java.io.InputStream;
41-
import java.io.OutputStream;
42-
import java.util.Map;
43-
import javax.inject.Inject;
44-
import javax.inject.Named;
45-
4646
/**
4747
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
4848
* @author Jason van Zyl
4949
* @version $Id$
5050
*/
5151
@Named
52-
public class DefaultResourceManager implements ResourceManager
53-
{
54-
private static final Logger LOGGER = LoggerFactory.getLogger( DefaultResourceManager.class );
52+
public class DefaultResourceManager implements ResourceManager {
53+
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultResourceManager.class);
5554

5655
private final Map<String, ResourceLoader> resourceLoaders;
5756

5857
private File outputDirectory;
5958

6059
@Inject
61-
public DefaultResourceManager( Map<String, ResourceLoader> resourceLoaders )
62-
{
60+
public DefaultResourceManager(Map<String, ResourceLoader> resourceLoaders) {
6361
this.resourceLoaders = resourceLoaders;
6462
}
6563

@@ -68,173 +66,131 @@ public DefaultResourceManager( Map<String, ResourceLoader> resourceLoaders )
6866
// ----------------------------------------------------------------------
6967

7068
@Override
71-
public InputStream getResourceAsInputStream( String name )
72-
throws ResourceNotFoundException
73-
{
74-
PlexusResource resource = getResource( name );
75-
try
76-
{
69+
public InputStream getResourceAsInputStream(String name) throws ResourceNotFoundException {
70+
PlexusResource resource = getResource(name);
71+
try {
7772
return resource.getInputStream();
78-
}
79-
catch ( IOException e )
80-
{
81-
throw new ResourceIOException( "Failed to open resource " + resource.getName() + ": " + e.getMessage(), e );
73+
} catch (IOException e) {
74+
throw new ResourceIOException("Failed to open resource " + resource.getName() + ": " + e.getMessage(), e);
8275
}
8376
}
8477

8578
@Override
86-
public File getResourceAsFile( String name )
87-
throws ResourceNotFoundException, FileResourceCreationException
88-
{
89-
return getResourceAsFile( getResource( name ) );
79+
public File getResourceAsFile(String name) throws ResourceNotFoundException, FileResourceCreationException {
80+
return getResourceAsFile(getResource(name));
9081
}
9182

9283
@Override
93-
public File getResourceAsFile( String name, String outputPath )
94-
throws ResourceNotFoundException, FileResourceCreationException
95-
{
96-
if ( outputPath == null )
97-
{
98-
return getResourceAsFile( name );
84+
public File getResourceAsFile(String name, String outputPath)
85+
throws ResourceNotFoundException, FileResourceCreationException {
86+
if (outputPath == null) {
87+
return getResourceAsFile(name);
9988
}
100-
PlexusResource resource = getResource( name );
89+
PlexusResource resource = getResource(name);
10190
File outputFile;
102-
if ( outputDirectory != null )
103-
{
104-
outputFile = new File( outputDirectory, outputPath );
105-
}
106-
else
107-
{
108-
outputFile = new File( outputPath );
91+
if (outputDirectory != null) {
92+
outputFile = new File(outputDirectory, outputPath);
93+
} else {
94+
outputFile = new File(outputPath);
10995
}
110-
createResourceAsFile( resource, outputFile );
96+
createResourceAsFile(resource, outputFile);
11197
return outputFile;
11298
}
11399

114100
@Override
115-
public File resolveLocation( String name, String outputPath )
116-
{
101+
public File resolveLocation(String name, String outputPath) {
117102
// Honour what the original locator does and return null ...
118-
try
119-
{
120-
return getResourceAsFile( name, outputPath );
121-
}
122-
catch ( Exception e )
123-
{
103+
try {
104+
return getResourceAsFile(name, outputPath);
105+
} catch (Exception e) {
124106
return null;
125107
}
126108
}
127109

128110
@Override
129-
public File resolveLocation( String name )
130-
{
111+
public File resolveLocation(String name) {
131112
// Honour what the original locator does and return null ...
132-
try
133-
{
134-
return getResourceAsFile( name );
135-
}
136-
catch ( Exception e )
137-
{
113+
try {
114+
return getResourceAsFile(name);
115+
} catch (Exception e) {
138116
return null;
139117
}
140118
}
141119

142120
@Override
143-
public void setOutputDirectory( File outputDirectory )
144-
{
121+
public void setOutputDirectory(File outputDirectory) {
145122
this.outputDirectory = outputDirectory;
146123
}
147124

148125
@Override
149-
public void addSearchPath( String id, String path )
150-
{
151-
ResourceLoader loader = resourceLoaders.get( id );
126+
public void addSearchPath(String id, String path) {
127+
ResourceLoader loader = resourceLoaders.get(id);
152128

153-
if ( loader == null )
154-
{
155-
throw new IllegalArgumentException( "unknown resource loader: " + id );
129+
if (loader == null) {
130+
throw new IllegalArgumentException("unknown resource loader: " + id);
156131
}
157132

158-
loader.addSearchPath( path );
133+
loader.addSearchPath(path);
159134
}
160135

161136
@Override
162-
public PlexusResource getResource( String name )
163-
throws ResourceNotFoundException
164-
{
165-
for ( ResourceLoader resourceLoader : resourceLoaders.values() )
166-
{
167-
try
168-
{
169-
PlexusResource resource = resourceLoader.getResource( name );
137+
public PlexusResource getResource(String name) throws ResourceNotFoundException {
138+
for (ResourceLoader resourceLoader : resourceLoaders.values()) {
139+
try {
140+
PlexusResource resource = resourceLoader.getResource(name);
170141

171-
LOGGER.debug( "The resource '{}' was found as '{}'", name, resource.getName() );
142+
LOGGER.debug("The resource '{}' was found as '{}'", name, resource.getName());
172143

173144
return resource;
174-
}
175-
catch ( ResourceNotFoundException e )
176-
{
177-
LOGGER.debug( "The resource '{}' was not found with resourceLoader '{}'",
178-
name, resourceLoader.getClass().getName() );
145+
} catch (ResourceNotFoundException e) {
146+
LOGGER.debug(
147+
"The resource '{}' was not found with resourceLoader '{}'",
148+
name,
149+
resourceLoader.getClass().getName());
179150
}
180151
}
181152

182-
throw new ResourceNotFoundException( name );
153+
throw new ResourceNotFoundException(name);
183154
}
184155

185156
@Override
186-
public File getResourceAsFile( PlexusResource resource )
187-
throws FileResourceCreationException
188-
{
189-
try
190-
{
157+
public File getResourceAsFile(PlexusResource resource) throws FileResourceCreationException {
158+
try {
191159
File f = resource.getFile();
192-
if ( f != null )
193-
{
160+
if (f != null) {
194161
return f;
195162
}
196-
}
197-
catch ( IOException e )
198-
{
163+
} catch (IOException e) {
199164
// Ignore this, try to make use of resource.getInputStream().
200165
}
201166

202-
final File outputFile = FileUtils.createTempFile( "plexus-resources", "tmp", outputDirectory );
167+
final File outputFile = FileUtils.createTempFile("plexus-resources", "tmp", outputDirectory);
203168
outputFile.deleteOnExit();
204-
createResourceAsFile( resource, outputFile );
169+
createResourceAsFile(resource, outputFile);
205170
return outputFile;
206171
}
207172

208173
@Override
209-
public void createResourceAsFile( PlexusResource resource, File outputFile )
210-
throws FileResourceCreationException
211-
{
174+
public void createResourceAsFile(PlexusResource resource, File outputFile) throws FileResourceCreationException {
212175
InputStream is = null;
213176
OutputStream os = null;
214-
try
215-
{
177+
try {
216178
is = resource.getInputStream();
217179
File dir = outputFile.getParentFile();
218-
if ( !dir.isDirectory() && !dir.mkdirs() )
219-
{
220-
throw new FileResourceCreationException( "Failed to create directory " + dir.getPath() );
180+
if (!dir.isDirectory() && !dir.mkdirs()) {
181+
throw new FileResourceCreationException("Failed to create directory " + dir.getPath());
221182
}
222-
os = new FileOutputStream( outputFile );
223-
IOUtil.copy( is, os );
183+
os = new FileOutputStream(outputFile);
184+
IOUtil.copy(is, os);
224185
is.close();
225186
is = null;
226187
os.close();
227188
os = null;
228-
}
229-
catch ( IOException e )
230-
{
231-
throw new FileResourceCreationException( "Cannot create file-based resource:" + e.getMessage(), e );
232-
}
233-
finally
234-
{
235-
IOUtil.close( is );
236-
IOUtil.close( os );
189+
} catch (IOException e) {
190+
throw new FileResourceCreationException("Cannot create file-based resource:" + e.getMessage(), e);
191+
} finally {
192+
IOUtil.close(is);
193+
IOUtil.close(os);
237194
}
238195
}
239-
240196
}

src/main/java/org/codehaus/plexus/resource/PlexusResource.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,10 @@
3333
/**
3434
* A resource is a byte stream, possibly (but not necessarily) with additional attributes like {@link File}, {@link URL}
3535
* , or {@link URI}.
36-
*
36+
*
3737
* @since 1.0-alpha-5
3838
*/
39-
public interface PlexusResource
40-
{
39+
public interface PlexusResource {
4140
/**
4241
* <p>
4342
* Returns the resource as an {@link InputStream}. In general, you should not assume, that this method may me called
@@ -49,7 +48,7 @@ public interface PlexusResource
4948
* If you need a reliable way of reloading the resource more than once, then you should use
5049
* {@link ResourceManager#getResourceAsFile(PlexusResource)}.
5150
* </p>
52-
*
51+
*
5352
* @return An {@link InputStream} with the resources contents, never null.
5453
*/
5554
InputStream getInputStream() throws IOException;
@@ -59,7 +58,7 @@ public interface PlexusResource
5958
* Returns the resource as a file, if possible. A resource doesn't need to be available as a file: If you require a
6059
* file, use {@link ResourceManager#getResourceAsFile(PlexusResource)}.
6160
* </p>
62-
*
61+
*
6362
* @return A {@link File} containing the resources contents, if available, or null.
6463
*/
6564
File getFile() throws IOException;
@@ -68,7 +67,7 @@ public interface PlexusResource
6867
* <p>
6968
* Returns the resources URL, if possible. A resource doesn't need to have an URL.
7069
* </p>
71-
*
70+
*
7271
* @return The resources URL, if available, or null.
7372
*/
7473
URL getURL() throws IOException;
@@ -77,7 +76,7 @@ public interface PlexusResource
7776
* <p>
7877
* Returns the resources URI, if possible. A resource doesn't need to have an URI.
7978
* </p>
80-
*
79+
*
8180
* @return The resources URI, if available, or null.
8281
*/
8382
URI getURI() throws IOException;

0 commit comments

Comments
 (0)