Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

o Added svn:eol-style=native

  • Loading branch information...
commit 8225985121ab46c5a2cc09e80375cd93098346b9 1 parent 308acdc
bentmann authored
Showing with 1,926 additions and 1,926 deletions.
  1. +2 −2 NOTICE.txt
  2. +67 −67 src/main/java/org/codehaus/plexus/components/io/filemappers/FileExtensionMapper.java
  3. +28 −28 src/main/java/org/codehaus/plexus/components/io/filemappers/FileMapper.java
  4. +28 −28 src/main/java/org/codehaus/plexus/components/io/filemappers/FlattenFileMapper.java
  5. +21 −21 src/main/java/org/codehaus/plexus/components/io/filemappers/IdentityMapper.java
  6. +55 −55 src/main/java/org/codehaus/plexus/components/io/filemappers/MergeFileMapper.java
  7. +20 −20 src/main/java/org/codehaus/plexus/components/io/fileselectors/AllFilesFileSelector.java
  8. +39 −39 src/main/java/org/codehaus/plexus/components/io/fileselectors/FileInfo.java
  9. +28 −28 src/main/java/org/codehaus/plexus/components/io/fileselectors/FileSelector.java
  10. +63 −63 src/main/java/org/codehaus/plexus/components/io/resources/AbstractPlexusIoArchiveResourceCollection.java
  11. +122 −122 src/main/java/org/codehaus/plexus/components/io/resources/AbstractPlexusIoResource.java
  12. +228 −228 src/main/java/org/codehaus/plexus/components/io/resources/AbstractPlexusIoResourceCollection.java
  13. +112 −112 src/main/java/org/codehaus/plexus/components/io/resources/PlexusIoFileResource.java
  14. +120 −120 src/main/java/org/codehaus/plexus/components/io/resources/PlexusIoFileResourceCollection.java
  15. +120 −120 src/main/java/org/codehaus/plexus/components/io/resources/PlexusIoProxyResourceCollection.java
  16. +51 −51 src/main/java/org/codehaus/plexus/components/io/resources/PlexusIoResource.java
  17. +47 −47 src/main/java/org/codehaus/plexus/components/io/resources/PlexusIoResourceCollection.java
  18. +27 −27 src/main/java/org/codehaus/plexus/components/io/resources/PlexusIoURLResource.java
  19. +64 −64 src/main/java/org/codehaus/plexus/components/io/resources/PlexusIoZipFileResourceCollection.java
  20. +84 −84 src/main/resources/META-INF/plexus/components.xml
  21. +96 −96 src/site/apt/filemappers.apt
  22. +63 −63 src/site/apt/fileselectors.apt
  23. +26 −26 src/site/apt/index.apt
  24. +35 −35 src/site/site.xml
  25. +154 −154 src/test/java/org/codehaus/plexus/components/io/filemappers/FileMapperTest.java
  26. +226 −226 src/test/java/org/codehaus/plexus/components/io/filemappers/ResourcesTest.java
View
4 NOTICE.txt
@@ -1,2 +1,2 @@
-This product includes software developed by
-The Apache Software Foundation (http://www.apache.org/).
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
View
134 src/main/java/org/codehaus/plexus/components/io/filemappers/FileExtensionMapper.java
@@ -1,67 +1,67 @@
-package org.codehaus.plexus.components.io.filemappers;
-
-/**
- * An implementation of {@link FileMapper}, which changes the files extension.
- */
-public class FileExtensionMapper extends IdentityMapper
-{
- /**
- * The file extension mappers role-hint: "fileExtension".
- */
- public static final String ROLE_HINT = "fileExtension";
-
- private String targetExtension;
-
- /**
- * Sets the target files extension.
- *
- * @throws IllegalArgumentException
- * The target extension is null or empty.
- */
- public void setTargetExtension( String pTargetExtension )
- {
- if ( pTargetExtension == null )
- {
- throw new IllegalArgumentException( "The target extension is null." );
- }
- if ( pTargetExtension.length() == 0 )
- {
- throw new IllegalArgumentException( "The target extension is empty." );
- }
- if ( pTargetExtension.charAt( 0 ) == '.' )
- {
- targetExtension = pTargetExtension;
- }
- else
- {
- targetExtension = '.' + pTargetExtension;
- }
- }
-
- /**
- * Returns the target files extension.
- */
- public String getTargetExtension()
- {
- return targetExtension;
- }
-
- public String getMappedFileName( String pName )
- {
- final String ext = getTargetExtension();
- if ( ext == null )
- {
- throw new IllegalStateException( "The target extension has not been set." );
- }
- final String name = super.getMappedFileName( pName ); // Check arguments
- final int offset = pName.indexOf( '.' );
- if ( offset == -1 )
- {
- return name + ext;
- }
- else
- {
- return name.substring( 0, offset ) + ext;
- }
- }
-}
+package org.codehaus.plexus.components.io.filemappers;
+
+/**
+ * An implementation of {@link FileMapper}, which changes the files extension.
+ */
+public class FileExtensionMapper extends IdentityMapper
+{
+ /**
+ * The file extension mappers role-hint: "fileExtension".
+ */
+ public static final String ROLE_HINT = "fileExtension";
+
+ private String targetExtension;
+
+ /**
+ * Sets the target files extension.
+ *
+ * @throws IllegalArgumentException
+ * The target extension is null or empty.
+ */
+ public void setTargetExtension( String pTargetExtension )
+ {
+ if ( pTargetExtension == null )
+ {
+ throw new IllegalArgumentException( "The target extension is null." );
+ }
+ if ( pTargetExtension.length() == 0 )
+ {
+ throw new IllegalArgumentException( "The target extension is empty." );
+ }
+ if ( pTargetExtension.charAt( 0 ) == '.' )
+ {
+ targetExtension = pTargetExtension;
+ }
+ else
+ {
+ targetExtension = '.' + pTargetExtension;
+ }
+ }
+
+ /**
+ * Returns the target files extension.
+ */
+ public String getTargetExtension()
+ {
+ return targetExtension;
+ }
+
+ public String getMappedFileName( String pName )
+ {
+ final String ext = getTargetExtension();
+ if ( ext == null )
+ {
+ throw new IllegalStateException( "The target extension has not been set." );
+ }
+ final String name = super.getMappedFileName( pName ); // Check arguments
+ final int offset = pName.indexOf( '.' );
+ if ( offset == -1 )
+ {
+ return name + ext;
+ }
+ else
+ {
+ return name.substring( 0, offset ) + ext;
+ }
+ }
+}
View
56 src/main/java/org/codehaus/plexus/components/io/filemappers/FileMapper.java
@@ -1,28 +1,28 @@
-package org.codehaus.plexus.components.io.filemappers;
-
-/**
- * Interface of a component, which may be used to map file names.
- */
-public interface FileMapper
-{
- /**
- * Role used to register component implementations with the container.
- */
- public static final String ROLE = FileMapper.class.getName();
-
- /**
- * The default role-hint: "default".
- */
- public static final String DEFAULT_ROLE_HINT = "default";
-
- /**
- * Maps the given source name to a target name.
- *
- * @param pName
- * The source name.
- * @return The target name.
- * @throws IllegalArgumentException
- * The source name is null or empty.
- */
- public String getMappedFileName( String pName );
-}
+package org.codehaus.plexus.components.io.filemappers;
+
+/**
+ * Interface of a component, which may be used to map file names.
+ */
+public interface FileMapper
+{
+ /**
+ * Role used to register component implementations with the container.
+ */
+ public static final String ROLE = FileMapper.class.getName();
+
+ /**
+ * The default role-hint: "default".
+ */
+ public static final String DEFAULT_ROLE_HINT = "default";
+
+ /**
+ * Maps the given source name to a target name.
+ *
+ * @param pName
+ * The source name.
+ * @return The target name.
+ * @throws IllegalArgumentException
+ * The source name is null or empty.
+ */
+ public String getMappedFileName( String pName );
+}
View
56 src/main/java/org/codehaus/plexus/components/io/filemappers/FlattenFileMapper.java
@@ -1,28 +1,28 @@
-package org.codehaus.plexus.components.io.filemappers;
-
-/**
- * Implementation of a flattening file mapper: Removes all directory parts.
- */
-public class FlattenFileMapper extends IdentityMapper
-{
- /**
- * The flatten file mappers role-hint: "flatten".
- */
- public static final String ROLE_HINT = "flatten";
-
- public String getMappedFileName( String pName )
- {
- String name = super.getMappedFileName( pName ); // Check for null, etc.
- int offset = pName.lastIndexOf( '/' );
- if ( offset >= 0 )
- {
- name = name.substring( offset + 1 );
- }
- offset = pName.lastIndexOf( '\\' );
- if ( offset >= 0 )
- {
- name = name.substring( offset + 1 );
- }
- return name;
- }
-}
+package org.codehaus.plexus.components.io.filemappers;
+
+/**
+ * Implementation of a flattening file mapper: Removes all directory parts.
+ */
+public class FlattenFileMapper extends IdentityMapper
+{
+ /**
+ * The flatten file mappers role-hint: "flatten".
+ */
+ public static final String ROLE_HINT = "flatten";
+
+ public String getMappedFileName( String pName )
+ {
+ String name = super.getMappedFileName( pName ); // Check for null, etc.
+ int offset = pName.lastIndexOf( '/' );
+ if ( offset >= 0 )
+ {
+ name = name.substring( offset + 1 );
+ }
+ offset = pName.lastIndexOf( '\\' );
+ if ( offset >= 0 )
+ {
+ name = name.substring( offset + 1 );
+ }
+ return name;
+ }
+}
View
42 src/main/java/org/codehaus/plexus/components/io/filemappers/IdentityMapper.java
@@ -1,21 +1,21 @@
-package org.codehaus.plexus.components.io.filemappers;
-
-/**
- * Default implementation of {@link FileMapper}, which performs the identity mapping: All names are left unchanged.
- */
-public class IdentityMapper implements FileMapper
-{
- /**
- * The identity mappers role-hint: "identity".
- */
- public static final String ROLE_HINT = "identity";
-
- public String getMappedFileName( String pName )
- {
- if ( pName == null || pName.length() == 0 )
- {
- throw new IllegalArgumentException( "The source name must not be null." );
- }
- return pName;
- }
-}
+package org.codehaus.plexus.components.io.filemappers;
+
+/**
+ * Default implementation of {@link FileMapper}, which performs the identity mapping: All names are left unchanged.
+ */
+public class IdentityMapper implements FileMapper
+{
+ /**
+ * The identity mappers role-hint: "identity".
+ */
+ public static final String ROLE_HINT = "identity";
+
+ public String getMappedFileName( String pName )
+ {
+ if ( pName == null || pName.length() == 0 )
+ {
+ throw new IllegalArgumentException( "The source name must not be null." );
+ }
+ return pName;
+ }
+}
View
110 src/main/java/org/codehaus/plexus/components/io/filemappers/MergeFileMapper.java
@@ -1,55 +1,55 @@
-package org.codehaus.plexus.components.io.filemappers;
-
-/**
- * A file mapper, which maps to a constant target name.
- */
-public class MergeFileMapper extends IdentityMapper
-{
- /**
- * The merge mappers role-hint: "merge".
- */
- public static final String ROLE_HINT = "merge";
-
- private String targetName;
-
- /**
- * Sets the merge mappers target name.
- *
- * @throws IllegalArgumentException
- * The target name is null or empty.
- */
- public void setTargetName( String pName )
- {
- if ( pName == null )
- {
- throw new IllegalArgumentException( "The target name is null." );
- }
- if ( pName.length() == 0 )
- {
- throw new IllegalArgumentException( "The target name is empty." );
- }
- targetName = pName;
- }
-
- /**
- * Returns the merge mappers target name.
- *
- * @throws IllegalArgumentException
- * The target name is null or empty.
- */
- public String getTargetName()
- {
- return targetName;
- }
-
- public String getMappedFileName( String pName )
- {
- final String name = getTargetName();
- if ( name == null )
- {
- throw new IllegalStateException( "The target file name has not been set." );
- }
- super.getMappedFileName( pName ); // Check for null, etc.
- return name;
- }
-}
+package org.codehaus.plexus.components.io.filemappers;
+
+/**
+ * A file mapper, which maps to a constant target name.
+ */
+public class MergeFileMapper extends IdentityMapper
+{
+ /**
+ * The merge mappers role-hint: "merge".
+ */
+ public static final String ROLE_HINT = "merge";
+
+ private String targetName;
+
+ /**
+ * Sets the merge mappers target name.
+ *
+ * @throws IllegalArgumentException
+ * The target name is null or empty.
+ */
+ public void setTargetName( String pName )
+ {
+ if ( pName == null )
+ {
+ throw new IllegalArgumentException( "The target name is null." );
+ }
+ if ( pName.length() == 0 )
+ {
+ throw new IllegalArgumentException( "The target name is empty." );
+ }
+ targetName = pName;
+ }
+
+ /**
+ * Returns the merge mappers target name.
+ *
+ * @throws IllegalArgumentException
+ * The target name is null or empty.
+ */
+ public String getTargetName()
+ {
+ return targetName;
+ }
+
+ public String getMappedFileName( String pName )
+ {
+ final String name = getTargetName();
+ if ( name == null )
+ {
+ throw new IllegalStateException( "The target file name has not been set." );
+ }
+ super.getMappedFileName( pName ); // Check for null, etc.
+ return name;
+ }
+}
View
40 src/main/java/org/codehaus/plexus/components/io/fileselectors/AllFilesFileSelector.java
@@ -1,20 +1,20 @@
-package org.codehaus.plexus.components.io.fileselectors;
-
-import java.io.IOException;
-
-
-/**
- * The default file selector: Selects all files.
- */
-public class AllFilesFileSelector implements FileSelector
-{
- /**
- * The all files selectors role-hint: "all".
- */
- public static final String ROLE_HINT = "all";
-
- public boolean isSelected( FileInfo fileInfo ) throws IOException
- {
- return true;
- }
-}
+package org.codehaus.plexus.components.io.fileselectors;
+
+import java.io.IOException;
+
+
+/**
+ * The default file selector: Selects all files.
+ */
+public class AllFilesFileSelector implements FileSelector
+{
+ /**
+ * The all files selectors role-hint: "all".
+ */
+ public static final String ROLE_HINT = "all";
+
+ public boolean isSelected( FileInfo fileInfo ) throws IOException
+ {
+ return true;
+ }
+}
View
78 src/main/java/org/codehaus/plexus/components/io/fileselectors/FileInfo.java
@@ -1,39 +1,39 @@
-package org.codehaus.plexus.components.io.fileselectors;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * An object implementing this interface is passed to the
- * file selector when the method
- * {@link FileSelector#isSelected(FileInfo)}
- * is invoked. This object provides information about
- * the file to select or deselect.
- */
-public interface FileInfo
-{
- /**
- * Returns the resources name, which may include path components,
- * like directory names, or something like that. The resources name
- * is expected to be a relative name and the path components must
- * be separated by {@link java.io.File#pathSeparator}
- */
- String getName();
-
- /**
- * Creates an {@link InputStream}, which may be used to read
- * the files contents. This is useful, if the file selector
- * comes to a decision based on the files contents.
- */
- InputStream getContents() throws IOException;
-
- /**
- * Returns, whether the {@link FileInfo} refers to a file.
- */
- boolean isFile();
-
- /**
- * Returns, whether the {@link FileInfo} refers to a directory.
- */
- boolean isDirectory();
-}
+package org.codehaus.plexus.components.io.fileselectors;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * An object implementing this interface is passed to the
+ * file selector when the method
+ * {@link FileSelector#isSelected(FileInfo)}
+ * is invoked. This object provides information about
+ * the file to select or deselect.
+ */
+public interface FileInfo
+{
+ /**
+ * Returns the resources name, which may include path components,
+ * like directory names, or something like that. The resources name
+ * is expected to be a relative name and the path components must
+ * be separated by {@link java.io.File#pathSeparator}
+ */
+ String getName();
+
+ /**
+ * Creates an {@link InputStream}, which may be used to read
+ * the files contents. This is useful, if the file selector
+ * comes to a decision based on the files contents.
+ */
+ InputStream getContents() throws IOException;
+
+ /**
+ * Returns, whether the {@link FileInfo} refers to a file.
+ */
+ boolean isFile();
+
+ /**
+ * Returns, whether the {@link FileInfo} refers to a directory.
+ */
+ boolean isDirectory();
+}
View
56 src/main/java/org/codehaus/plexus/components/io/fileselectors/FileSelector.java
@@ -1,28 +1,28 @@
-package org.codehaus.plexus.components.io.fileselectors;
-
-import java.io.IOException;
-
-
-/**
- * Interface of a component, which selects/deselects files.
- */
-public interface FileSelector
-{
- /**
- * Role used to register component implementations with the container.
- */
- public static final String ROLE = FileSelector.class.getName();
-
- /**
- * The default role-hint: "default".
- */
- public static final String DEFAULT_ROLE_HINT = "default";
-
- /**
- * Returns, whether the given file is selected.
- * @param An instance of FileInfo with the files meta data.
- * It is recommended, that the caller creates an instance
- * of {@link PlexusIoResource}.
- */
- boolean isSelected(FileInfo fileInfo) throws IOException;
-}
+package org.codehaus.plexus.components.io.fileselectors;
+
+import java.io.IOException;
+
+
+/**
+ * Interface of a component, which selects/deselects files.
+ */
+public interface FileSelector
+{
+ /**
+ * Role used to register component implementations with the container.
+ */
+ public static final String ROLE = FileSelector.class.getName();
+
+ /**
+ * The default role-hint: "default".
+ */
+ public static final String DEFAULT_ROLE_HINT = "default";
+
+ /**
+ * Returns, whether the given file is selected.
+ * @param An instance of FileInfo with the files meta data.
+ * It is recommended, that the caller creates an instance
+ * of {@link PlexusIoResource}.
+ */
+ boolean isSelected(FileInfo fileInfo) throws IOException;
+}
View
126 ...rg/codehaus/plexus/components/io/resources/AbstractPlexusIoArchiveResourceCollection.java
@@ -1,63 +1,63 @@
-package org.codehaus.plexus.components.io.resources;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-
-
-/**
- * Default implementation of {@link PlexusIoFileResourceCollection} for
- * zip files, tar files, etc.
- * @author jwi
- *
- */
-public abstract class AbstractPlexusIoArchiveResourceCollection extends AbstractPlexusIoResourceCollection
- implements PlexusIoArchivedResourceCollection
-{
-
- private File file;
-
- /**
- * Sets the zip file
- */
- public void setFile( File file )
- {
- this.file = file;
- }
-
- /**
- * Returns the zip file
- */
- public File getFile()
- {
- return file;
- }
-
- /**
- * Returns an iterator over the archives entries.
- */
- protected abstract Iterator getEntries() throws IOException;
-
- public Iterator getResources() throws IOException
- {
- final List result = new ArrayList();
- for (Iterator it = getEntries(); it.hasNext(); )
- {
- final PlexusIoResource res = (PlexusIoResource) it.next();
- if ( isSelected( res ) )
- {
- result.add( res );
- }
- }
- return result.iterator();
- }
-
- public long getLastModified() throws IOException
- {
- File f = getFile();
- return f == null ? PlexusIoResource.UNKNOWN_MODIFICATION_DATE : f.lastModified();
- }
-}
+package org.codehaus.plexus.components.io.resources;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+
+
+/**
+ * Default implementation of {@link PlexusIoFileResourceCollection} for
+ * zip files, tar files, etc.
+ * @author jwi
+ *
+ */
+public abstract class AbstractPlexusIoArchiveResourceCollection extends AbstractPlexusIoResourceCollection
+ implements PlexusIoArchivedResourceCollection
+{
+
+ private File file;
+
+ /**
+ * Sets the zip file
+ */
+ public void setFile( File file )
+ {
+ this.file = file;
+ }
+
+ /**
+ * Returns the zip file
+ */
+ public File getFile()
+ {
+ return file;
+ }
+
+ /**
+ * Returns an iterator over the archives entries.
+ */
+ protected abstract Iterator getEntries() throws IOException;
+
+ public Iterator getResources() throws IOException
+ {
+ final List result = new ArrayList();
+ for (Iterator it = getEntries(); it.hasNext(); )
+ {
+ final PlexusIoResource res = (PlexusIoResource) it.next();
+ if ( isSelected( res ) )
+ {
+ result.add( res );
+ }
+ }
+ return result.iterator();
+ }
+
+ public long getLastModified() throws IOException
+ {
+ File f = getFile();
+ return f == null ? PlexusIoResource.UNKNOWN_MODIFICATION_DATE : f.lastModified();
+ }
+}
View
244 src/main/java/org/codehaus/plexus/components/io/resources/AbstractPlexusIoResource.java
@@ -1,122 +1,122 @@
-package org.codehaus.plexus.components.io.resources;
-
-
-/**
- * Default implementation of {@link PlexusIoResource}.
- */
-public abstract class AbstractPlexusIoResource implements PlexusIoResource
-{
- private String name;
-
- private long lastModified, size;
-
- private boolean isFile, isDirectory, isExisting;
-
- /**
- * Creates a new instance with default settings.
- */
- public AbstractPlexusIoResource()
- {
- }
-
- /**
- * Creates a new instance. The settings are copied
- * from the given resource.
- */
- public AbstractPlexusIoResource( PlexusIoResource plexusIoResource )
- {
- setName( plexusIoResource.getName() );
- setLastModified( plexusIoResource.getLastModified() );
- setSize( plexusIoResource.getSize() );
- setFile( plexusIoResource.isFile() );
- setDirectory( plexusIoResource.isDirectory() );
- setExisting( plexusIoResource.isExisting() );
- }
-
- /**
- * Sets the date, when the resource was last modified.
- * @param Date of last modification, if known.
- * Otherwise, {@link #UNKNOWN_MODIFICATION_DATE}.
- * @see java.io.File#lastModified()
- */
- public void setLastModified( long lastModified )
- {
- this.lastModified = lastModified;
- }
-
- public long getLastModified()
- {
- return lastModified;
- }
-
- /**
- * Sets the resources name, which may include path components,
- * like directory names, or something like that. The resources name
- * is expected to be a relative name and the path components must
- * be separated by {@link java.io.File#pathSeparator}
- */
- public void setName( String name )
- {
- this.name = name;
- }
-
- public String getName()
- {
- return name;
- }
-
- /**
- * Sets the resources size.
- * @param size The resources size, if known. Otherwise returns
- * {@link #UNKNOWN_RESOURCE_SIZE}.
- * @see java.io.File#length()
- */
- public void setSize( long size )
- {
- this.size = size;
- }
-
- public long getSize()
- {
- return size;
- }
-
- /**
- * Sets, whether the resource is a directory.
- */
- public void setDirectory( boolean isDirectory )
- {
- this.isDirectory = isDirectory;
- }
-
- public boolean isDirectory()
- {
- return isDirectory;
- }
-
- /**
- * Sets, whether the resource exists.
- */
- public void setExisting( boolean isExisting )
- {
- this.isExisting = isExisting;
- }
-
- public boolean isExisting()
- {
- return isExisting;
- }
-
- /**
- * Sets, whether the resource is a file.
- */
- public void setFile( boolean isFile )
- {
- this.isFile = isFile;
- }
-
- public boolean isFile()
- {
- return isFile;
- }
-}
+package org.codehaus.plexus.components.io.resources;
+
+
+/**
+ * Default implementation of {@link PlexusIoResource}.
+ */
+public abstract class AbstractPlexusIoResource implements PlexusIoResource
+{
+ private String name;
+
+ private long lastModified, size;
+
+ private boolean isFile, isDirectory, isExisting;
+
+ /**
+ * Creates a new instance with default settings.
+ */
+ public AbstractPlexusIoResource()
+ {
+ }
+
+ /**
+ * Creates a new instance. The settings are copied
+ * from the given resource.
+ */
+ public AbstractPlexusIoResource( PlexusIoResource plexusIoResource )
+ {
+ setName( plexusIoResource.getName() );
+ setLastModified( plexusIoResource.getLastModified() );
+ setSize( plexusIoResource.getSize() );
+ setFile( plexusIoResource.isFile() );
+ setDirectory( plexusIoResource.isDirectory() );
+ setExisting( plexusIoResource.isExisting() );
+ }
+
+ /**
+ * Sets the date, when the resource was last modified.
+ * @param Date of last modification, if known.
+ * Otherwise, {@link #UNKNOWN_MODIFICATION_DATE}.
+ * @see java.io.File#lastModified()
+ */
+ public void setLastModified( long lastModified )
+ {
+ this.lastModified = lastModified;
+ }
+
+ public long getLastModified()
+ {
+ return lastModified;
+ }
+
+ /**
+ * Sets the resources name, which may include path components,
+ * like directory names, or something like that. The resources name
+ * is expected to be a relative name and the path components must
+ * be separated by {@link java.io.File#pathSeparator}
+ */
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * Sets the resources size.
+ * @param size The resources size, if known. Otherwise returns
+ * {@link #UNKNOWN_RESOURCE_SIZE}.
+ * @see java.io.File#length()
+ */
+ public void setSize( long size )
+ {
+ this.size = size;
+ }
+
+ public long getSize()
+ {
+ return size;
+ }
+
+ /**
+ * Sets, whether the resource is a directory.
+ */
+ public void setDirectory( boolean isDirectory )
+ {
+ this.isDirectory = isDirectory;
+ }
+
+ public boolean isDirectory()
+ {
+ return isDirectory;
+ }
+
+ /**
+ * Sets, whether the resource exists.
+ */
+ public void setExisting( boolean isExisting )
+ {
+ this.isExisting = isExisting;
+ }
+
+ public boolean isExisting()
+ {
+ return isExisting;
+ }
+
+ /**
+ * Sets, whether the resource is a file.
+ */
+ public void setFile( boolean isFile )
+ {
+ this.isFile = isFile;
+ }
+
+ public boolean isFile()
+ {
+ return isFile;
+ }
+}
View
456 .../java/org/codehaus/plexus/components/io/resources/AbstractPlexusIoResourceCollection.java
@@ -1,228 +1,228 @@
-package org.codehaus.plexus.components.io.resources;
-
-import java.io.IOException;
-import java.util.Iterator;
-
-import org.codehaus.plexus.components.io.filemappers.FileMapper;
-import org.codehaus.plexus.components.io.filemappers.PrefixFileMapper;
-import org.codehaus.plexus.components.io.fileselectors.FileSelector;
-
-
-
-/**
- * Default implementation of a resource collection.
- */
-public abstract class AbstractPlexusIoResourceCollection implements PlexusIoResourceCollection
-{
- 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 FileMapper[] fileMappers;
-
- /**
- * Sets a string of patterns, which excluded files
- * should match.
- */
- public void setExcludes( String[] excludes )
- {
- this.excludes = excludes;
- }
-
- /**
- * Returns a string of patterns, which excluded files
- * should match.
- */
- 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;
- }
-
- /**
- * Returns a set of file selectors, which should be used
- * to select the included files.
- */
- public FileSelector[] getFileSelectors()
- {
- return fileSelectors;
- }
-
- /**
- * Sets a string of patterns, which included files
- * should match.
- */
- public void setIncludes( String[] includes )
- {
- this.includes = includes;
- }
-
- /**
- * Returns a string of patterns, which included files
- * should match.
- */
- public String[] getIncludes()
- {
- return includes;
- }
-
- /**
- * Sets the prefix, which the file sets contents shall
- * have.
- */
- public void setPrefix( String prefix )
- {
- this.prefix = prefix;
- }
-
- /**
- * Returns the prefix, which the file sets contents shall
- * have.
- */
- 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;
- }
-
- /**
- * Returns, whether the include/exclude patterns are
- * case sensitive. Defaults to true.
- */
- public boolean isCaseSensitive()
- {
- return caseSensitive;
- }
-
- /**
- * Sets, whether the default excludes are being
- * applied. Defaults to true.
- */
- public void setUsingDefaultExcludes( boolean usingDefaultExcludes )
- {
- this.usingDefaultExcludes = usingDefaultExcludes;
- }
-
- /**
- * Returns, whether the default excludes are being
- * applied. Defaults to true.
- */
- public boolean isUsingDefaultExcludes()
- {
- return usingDefaultExcludes;
- }
-
- /**
- * Sets, whether empty directories are being included. Defaults
- * to true.
- */
- public void setIncludingEmptyDirectories( boolean includingEmptyDirectories )
- {
- this.includingEmptyDirectories = includingEmptyDirectories;
- }
-
- /**
- * Returns, whether empty directories are being included. Defaults
- * to true.
- */
- public boolean isIncludingEmptyDirectories()
- {
- return includingEmptyDirectories;
- }
-
- protected boolean isSelected( PlexusIoResource plexusIoResource ) throws IOException
- {
- FileSelector[] fileSelectors = getFileSelectors();
- if ( fileSelectors != null )
- {
- for ( int i = 0; i < fileSelectors.length; i++ )
- {
- if ( !fileSelectors[i].isSelected( plexusIoResource ) )
- {
- return false;
- }
- }
- }
- return true;
- }
-
- /**
- * Returns the file name mappers, which are used to transform
- * the resource names.
- */
- public FileMapper[] getFileMappers()
- {
- return fileMappers;
- }
-
- /**
- * Sets the file name mappers, which are used to transform
- * the resource names.
- */
- public void setFileMappers( FileMapper[] fileMappers )
- {
- this.fileMappers = fileMappers;
- }
-
- public String getName( PlexusIoResource resource )
- throws IOException
- {
- String name = resource.getName();
- final FileMapper[] mappers = getFileMappers();
- if ( mappers != null )
- {
- for ( int i = 0; i < mappers.length; i++ )
- {
- name = mappers[i].getMappedFileName( name );
- }
- }
- return PrefixFileMapper.getMappedFileName( getPrefix(), name );
- }
-
- public long getLastModified()
- throws IOException
- {
- long lastModified = PlexusIoResource.UNKNOWN_MODIFICATION_DATE;
- for ( final Iterator iter = getResources(); iter.hasNext(); )
- {
- final PlexusIoResource res = (PlexusIoResource) iter.next();
- long l = res.getLastModified();
- if ( l == PlexusIoResource.UNKNOWN_MODIFICATION_DATE )
- {
- return PlexusIoResource.UNKNOWN_MODIFICATION_DATE;
- }
- if ( lastModified == PlexusIoResource.UNKNOWN_MODIFICATION_DATE
- || l > lastModified )
- {
- lastModified = l;
- }
- }
- return lastModified;
- }
-}
+package org.codehaus.plexus.components.io.resources;
+
+import java.io.IOException;
+import java.util.Iterator;
+
+import org.codehaus.plexus.components.io.filemappers.FileMapper;
+import org.codehaus.plexus.components.io.filemappers.PrefixFileMapper;
+import org.codehaus.plexus.components.io.fileselectors.FileSelector;
+
+
+
+/**
+ * Default implementation of a resource collection.
+ */
+public abstract class AbstractPlexusIoResourceCollection implements PlexusIoResourceCollection
+{
+ 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 FileMapper[] fileMappers;
+
+ /**
+ * Sets a string of patterns, which excluded files
+ * should match.
+ */
+ public void setExcludes( String[] excludes )
+ {
+ this.excludes = excludes;
+ }
+
+ /**
+ * Returns a string of patterns, which excluded files
+ * should match.
+ */
+ 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;
+ }
+
+ /**
+ * Returns a set of file selectors, which should be used
+ * to select the included files.
+ */
+ public FileSelector[] getFileSelectors()
+ {
+ return fileSelectors;
+ }
+
+ /**
+ * Sets a string of patterns, which included files
+ * should match.
+ */
+ public void setIncludes( String[] includes )
+ {
+ this.includes = includes;
+ }
+
+ /**
+ * Returns a string of patterns, which included files
+ * should match.
+ */
+ public String[] getIncludes()
+ {
+ return includes;
+ }
+
+ /**
+ * Sets the prefix, which the file sets contents shall
+ * have.
+ */
+ public void setPrefix( String prefix )
+ {
+ this.prefix = prefix;
+ }
+
+ /**
+ * Returns the prefix, which the file sets contents shall
+ * have.
+ */
+ 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;
+ }
+
+ /**
+ * Returns, whether the include/exclude patterns are
+ * case sensitive. Defaults to true.
+ */
+ public boolean isCaseSensitive()
+ {
+ return caseSensitive;
+ }
+
+ /**
+ * Sets, whether the default excludes are being
+ * applied. Defaults to true.
+ */
+ public void setUsingDefaultExcludes( boolean usingDefaultExcludes )
+ {
+ this.usingDefaultExcludes = usingDefaultExcludes;
+ }
+
+ /**
+ * Returns, whether the default excludes are being
+ * applied. Defaults to true.
+ */
+ public boolean isUsingDefaultExcludes()
+ {
+ return usingDefaultExcludes;
+ }
+
+ /**
+ * Sets, whether empty directories are being included. Defaults
+ * to true.
+ */
+ public void setIncludingEmptyDirectories( boolean includingEmptyDirectories )
+ {
+ this.includingEmptyDirectories = includingEmptyDirectories;
+ }
+
+ /**
+ * Returns, whether empty directories are being included. Defaults
+ * to true.
+ */
+ public boolean isIncludingEmptyDirectories()
+ {
+ return includingEmptyDirectories;
+ }
+
+ protected boolean isSelected( PlexusIoResource plexusIoResource ) throws IOException
+ {
+ FileSelector[] fileSelectors = getFileSelectors();
+ if ( fileSelectors != null )
+ {
+ for ( int i = 0; i < fileSelectors.length; i++ )
+ {
+ if ( !fileSelectors[i].isSelected( plexusIoResource ) )
+ {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Returns the file name mappers, which are used to transform
+ * the resource names.
+ */
+ public FileMapper[] getFileMappers()
+ {
+ return fileMappers;
+ }
+
+ /**
+ * Sets the file name mappers, which are used to transform
+ * the resource names.
+ */
+ public void setFileMappers( FileMapper[] fileMappers )
+ {
+ this.fileMappers = fileMappers;
+ }
+
+ public String getName( PlexusIoResource resource )
+ throws IOException
+ {
+ String name = resource.getName();
+ final FileMapper[] mappers = getFileMappers();
+ if ( mappers != null )
+ {
+ for ( int i = 0; i < mappers.length; i++ )
+ {
+ name = mappers[i].getMappedFileName( name );
+ }
+ }
+ return PrefixFileMapper.getMappedFileName( getPrefix(), name );
+ }
+
+ public long getLastModified()
+ throws IOException
+ {
+ long lastModified = PlexusIoResource.UNKNOWN_MODIFICATION_DATE;
+ for ( final Iterator iter = getResources(); iter.hasNext(); )
+ {
+ final PlexusIoResource res = (PlexusIoResource) iter.next();
+ long l = res.getLastModified();
+ if ( l == PlexusIoResource.UNKNOWN_MODIFICATION_DATE )
+ {
+ return PlexusIoResource.UNKNOWN_MODIFICATION_DATE;
+ }
+ if ( lastModified == PlexusIoResource.UNKNOWN_MODIFICATION_DATE
+ || l > lastModified )
+ {
+ lastModified = l;
+ }
+ }
+ return lastModified;
+ }
+}
View
224 src/main/java/org/codehaus/plexus/components/io/resources/PlexusIoFileResource.java
@@ -1,112 +1,112 @@
-package org.codehaus.plexus.components.io.resources;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-
-
-/**
- * Implementation of {@link PlexusIoResource} for files.
- */
-public class PlexusIoFileResource implements PlexusIoResource
-{
- private File file;
-
- private String name;
-
- /**
- * Creates a new instance.
- */
- public PlexusIoFileResource()
- {
- // Does nothing
- }
-
- /**
- * Creates a new instance.
- */
- public PlexusIoFileResource( File file )
- {
- this( file, file.getPath().replace( '\\', '/' ) );
- }
-
- /**
- * Creates a new instance.
- */
- public PlexusIoFileResource( File file, String name )
- {
- this.file = file;
- this.name = name;
- }
-
- /**
- * Sets the resources file.
- */
- public void setFile( File file )
- {
- this.file = file;
- }
-
- /**
- * Returns the resources file.
- */
- public File getFile()
- {
- return file;
- }
-
- /**
- * Sets the resources name.
- */
- public void setName( String name )
- {
- this.name = name;
- }
-
- public String getName()
- {
- return name;
- }
-
- public long getLastModified()
- {
- return file.lastModified();
- }
-
- public boolean isFile()
- {
- return file.isFile();
- }
-
- public boolean isDirectory()
- {
- return file.isDirectory();
- }
-
- public boolean isExisting()
- {
- return file.exists();
- }
-
- public long getSize()
- {
- if ( !isExisting() )
- {
- return PlexusIoResource.UNKNOWN_RESOURCE_SIZE;
- }
- long result = file.length();
- return result == 0 ? PlexusIoResource.UNKNOWN_RESOURCE_SIZE : result;
- }
-
- public InputStream getContents() throws IOException
- {
- return new FileInputStream( getFile() );
- }
-
- public URL getURL() throws IOException
- {
- return getFile().toURI().toURL();
- }
-}
+package org.codehaus.plexus.components.io.resources;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+
+/**
+ * Implementation of {@link PlexusIoResource} for files.
+ */
+public class PlexusIoFileResource implements PlexusIoResource
+{
+ private File file;
+
+ private String name;
+
+ /**
+ * Creates a new instance.
+ */
+ public PlexusIoFileResource()
+ {
+ // Does nothing
+ }
+
+ /**
+ * Creates a new instance.
+ */
+ public PlexusIoFileResource( File file )
+ {
+ this( file, file.getPath().replace( '\\', '/' ) );
+ }
+
+ /**
+ * Creates a new instance.
+ */
+ public PlexusIoFileResource( File file, String name )
+ {
+ this.file = file;
+ this.name = name;
+ }
+
+ /**
+ * Sets the resources file.
+ */
+ public void setFile( File file )
+ {
+ this.file = file;
+ }
+
+ /**
+ * Returns the resources file.
+ */
+ public File getFile()
+ {
+ return file;
+ }
+
+ /**
+ * Sets the resources name.
+ */
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public long getLastModified()
+ {
+ return file.lastModified();
+ }
+
+ public boolean isFile()
+ {
+ return file.isFile();
+ }
+
+ public boolean isDirectory()
+ {
+ return file.isDirectory();
+ }
+
+ public boolean isExisting()
+ {
+ return file.exists();
+ }
+
+ public long getSize()
+ {
+ if ( !isExisting() )
+ {
+ return PlexusIoResource.UNKNOWN_RESOURCE_SIZE;
+ }
+ long result = file.length();
+ return result == 0 ? PlexusIoResource.UNKNOWN_RESOURCE_SIZE : result;
+ }
+
+ public InputStream getContents() throws IOException
+ {
+ return new FileInputStream( getFile() );
+ }
+
+ public URL getURL() throws IOException
+ {
+ return getFile().toURI().toURL();
+ }
+}
View
240 ...main/java/org/codehaus/plexus/components/io/resources/PlexusIoFileResourceCollection.java
@@ -1,120 +1,120 @@
-package org.codehaus.plexus.components.io.resources;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.codehaus.plexus.util.DirectoryScanner;
-
-
-/**
- * Implementation of {@link PlexusIoResourceCollection} for the set
- * of files in a common directory.
- */
-public class PlexusIoFileResourceCollection extends AbstractPlexusIoResourceCollection
-{
- /**
- * Role hint of this component
- */
- public static final String ROLE_HINT = "files";
-
- private File baseDir;
-
- private boolean isFollowingSymLinks = true;
-
- /**
- * Sets the file collections base directory.
- */
- public void setBaseDir( File baseDir )
- {
- this.baseDir = baseDir;
- }
-
- /**
- * Returns the file collections base directory.
- */
- public File getBaseDir()
- {
- return baseDir;
- }
-
- /**
- * Returns, whether symbolic links should be followed.
- * Defaults to true.
- */
- public boolean isFollowingSymLinks()
- {
- return isFollowingSymLinks;
- }
-
- /**
- * Returns, whether symbolic links should be followed.
- * Defaults to true.
- */
- public void setFollowingSymLinks( boolean pIsFollowingSymLinks )
- {
- isFollowingSymLinks = pIsFollowingSymLinks;
- }
-
- private void addResources( List list, String[] resources ) throws IOException
- {
- String prefix = getPrefix();
- if ( prefix != null && prefix.length() == 0 )
- {
- prefix = null;
- }
-
- final File dir = getBaseDir();
- for ( int i = 0; i < resources.length; i++ )
- {
- String name = resources[i];
- String sourceDir = name.replace( '\\', '/' );
- PlexusIoFileResource resource = new PlexusIoFileResource( new File( dir, sourceDir ), name );
- if ( isSelected( resource ) )
- {
- if ( prefix != null )
- {
- resource.setName( prefix + name );
- }
- list.add( resource );
- }
- }
- }
-
- public Iterator getResources() throws IOException
- {
- final DirectoryScanner ds = new DirectoryScanner();
- final File dir = getBaseDir();
- ds.setBasedir( dir );
- final String[] inc = getIncludes();
- if ( inc != null && inc.length > 0 )
- {
- ds.setIncludes( inc );
- }
- final String[] exc = getExcludes();
- if ( exc != null && exc.length > 0 )
- {
- ds.setExcludes( exc );
- }
- if ( isUsingDefaultExcludes() )
- {
- ds.addDefaultExcludes();
- }
- ds.setCaseSensitive( isCaseSensitive() );
- ds.setFollowSymlinks( isFollowingSymLinks() );
- ds.scan();
-
- final List result = new ArrayList();
- if ( isIncludingEmptyDirectories() )
- {
- String[] dirs = ds.getIncludedDirectories();
- addResources( result, dirs );
- }
-
- String[] files = ds.getIncludedFiles();
- addResources( result, files );
- return result.iterator();
- }
-}
+package org.codehaus.plexus.components.io.resources;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.codehaus.plexus.util.DirectoryScanner;
+
+
+/**
+ * Implementation of {@link PlexusIoResourceCollection} for the set
+ * of files in a common directory.
+ */
+public class PlexusIoFileResourceCollection extends AbstractPlexusIoResourceCollection
+{
+ /**
+ * Role hint of this component
+ */
+ public static final String ROLE_HINT = "files";
+
+ private File baseDir;
+
+ private boolean isFollowingSymLinks = true;
+
+ /**
+ * Sets the file collections base directory.
+ */
+ public void setBaseDir( File baseDir )
+ {
+ this.baseDir = baseDir;
+ }
+
+ /**
+ * Returns the file collections base directory.
+ */
+ public File getBaseDir()
+ {
+ return baseDir;
+ }
+
+ /**
+ * Returns, whether symbolic links should be followed.
+ * Defaults to true.
+ */
+ public boolean isFollowingSymLinks()
+ {
+ return isFollowingSymLinks;
+ }
+
+ /**
+ * Returns, whether symbolic links should be followed.
+ * Defaults to true.
+ */
+ public void setFollowingSymLinks( boolean pIsFollowingSymLinks )
+ {
+ isFollowingSymLinks = pIsFollowingSymLinks;
+ }
+
+ private void addResources( List list, String[] resources ) throws IOException
+ {
+ String prefix = getPrefix();
+ if ( prefix != null && prefix.length() == 0 )
+ {
+ prefix = null;
+ }
+
+ final File dir = getBaseDir();
+ for ( int i = 0; i < resources.length; i++ )
+ {
+ String name = resources[i];
+ String sourceDir = name.replace( '\\', '/' );
+ PlexusIoFileResource resource = new PlexusIoFileResource( new File( dir, sourceDir ), name );
+ if ( isSelected( resource ) )
+ {
+ if ( prefix != null )
+ {
+ resource.setName( prefix + name );
+ }
+ list.add( resource );
+ }
+ }
+ }
+
+ public Iterator getResources() throws IOException
+ {
+ final DirectoryScanner ds = new DirectoryScanner();
+ final File dir = getBaseDir();
+ ds.setBasedir( dir );
+ final String[] inc = getIncludes();
+ if ( inc != null && inc.length > 0 )
+ {
+ ds.setIncludes( inc );
+ }
+ final String[] exc = getExcludes();
+ if ( exc != null && exc.length > 0 )
+ {
+ ds.setExcludes( exc );
+ }
+ if ( isUsingDefaultExcludes() )
+ {
+ ds.addDefaultExcludes();
+ }
+ ds.setCaseSensitive( isCaseSensitive() );
+ ds.setFollowSymlinks( isFollowingSymLinks() );
+ ds.scan();
+
+ final List result = new ArrayList();
+ if ( isIncludingEmptyDirectories() )
+ {
+ String[] dirs = ds.getIncludedDirectories();
+ addResources( result, dirs );
+ }
+
+ String[] files = ds.getIncludedFiles();
+ addResources( result, files );
+ return result.iterator();
+ }
+}
View
240 ...ain/java/org/codehaus/plexus/components/io/resources/PlexusIoProxyResourceCollection.java
@@ -1,120 +1,120 @@
-package org.codehaus.plexus.components.io.resources;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.codehaus.plexus.components.io.filemappers.FileMapper;
-import org.codehaus.plexus.components.io.fileselectors.FileSelector;
-import org.codehaus.plexus.components.io.fileselectors.IncludeExcludeFileSelector;
-
-
-/**
- * Implementation of {@link PlexusIoResourceCollection} for an archives
- * contents.
- */
-public class PlexusIoProxyResourceCollection extends AbstractPlexusIoResourceCollection
-{
- private PlexusIoResourceCollection src;
-
- /**
- * Sets the archive to read.
- */
- public void setSrc( PlexusIoResourceCollection src )
- {
- this.src = src;
- }
-
- /**
- * Returns the archive to read.
- */
- public PlexusIoResourceCollection getSrc()
- {
- return src;
- }
-
- protected FileSelector getDefaultFileSelector()
- {
- IncludeExcludeFileSelector fileSelector = new IncludeExcludeFileSelector();
- fileSelector.setIncludes( getIncludes() );
- fileSelector.setExcludes( getExcludes() );
- fileSelector.setCaseSensitive( isCaseSensitive() );
- fileSelector.setUseDefaultExcludes( isUsingDefaultExcludes() );
- return fileSelector;
- }
-
- public Iterator getResources() throws IOException
- {
- final List result = new ArrayList();
- final FileSelector fileSelector = getDefaultFileSelector();
- String prefix = getPrefix();
- if ( prefix != null && prefix.length() == 0 )
- {
- prefix = null;
- }
- for ( Iterator iter = getSrc().getResources(); iter.hasNext(); )
- {
- PlexusIoResource plexusIoResource = (PlexusIoResource) iter.next();
- if ( !fileSelector.isSelected( plexusIoResource ) )
- {
- continue;
- }
- if ( !isSelected( plexusIoResource ) )
- {
- continue;
- }
- if ( plexusIoResource.isDirectory() && !isIncludingEmptyDirectories() )
- {
- continue;
- }
- if ( prefix != null )
- {
- final PlexusIoResource r = plexusIoResource;
- AbstractPlexusIoResource resourceImpl = new AbstractPlexusIoResource( plexusIoResource )
- {
- public InputStream getContents() throws IOException
- {
- return r.getContents();
- }
-
- public URL getURL() throws IOException
- {
- return r.getURL();
- }
- };
- resourceImpl.setName( prefix + plexusIoResource.getName() );
- plexusIoResource = resourceImpl;
- }
- result.add( plexusIoResource );
- }
- return result.iterator();
- }
-
- public String getName( PlexusIoResource resource )
- throws IOException
- {
- String name = resource.getName();
- final FileMapper[] mappers = getFileMappers();
- if ( mappers != null )
- {
- for ( int i = 0; i < mappers.length; i++ )
- {
- name = mappers[i].getMappedFileName( name );
- }
- }
- /*
- * The prefix is applied when creating the resource.
- * return PrefixFileMapper.getMappedFileName( getPrefix(), name );
- */
- return name;
- }
-
- public long getLastModified()
- throws IOException
- {
- return src.getLastModified();
- }
-}
+package org.codehaus.plexus.components.io.resources;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.codehaus.plexus.components.io.filemappers.FileMapper;
+import org.codehaus.plexus.components.io.fileselectors.FileSelector;
+import org.codehaus.plexus.components.io.fileselectors.IncludeExcludeFileSelector;
+
+
+/**
+ * Implementation of {@link PlexusIoResourceCollection} for an archives
+ * contents.
+ */
+public class PlexusIoProxyResourceCollection extends AbstractPlexusIoResourceCollection
+{
+ private PlexusIoResourceCollection src;
+
+ /**
+ * Sets the archive to read.
+ */
+ public void setSrc( PlexusIoResourceCollection src )
+ {
+ this.src = src;
+ }
+
+ /**
+ * Returns the archive to read.
+ */
+ public PlexusIoResourceCollection getSrc()
+ {
+ return src;
+ }
+
+ protected FileSelector getDefaultFileSelector()
+ {
+ IncludeExcludeFileSelector fileSelector = new IncludeExcludeFileSelector();
+ fileSelector.setIncludes( getIncludes() );
+ fileSelector.setExcludes( getExcludes() );
+ fileSelector.setCaseSensitive( isCaseSensitive() );
+ fileSelector.setUseDefaultExcludes( isUsingDefaultExcludes() );
+ return fileSelector;
+ }
+
+ public Iterator getResources() throws IOException
+ {
+ final List result = new ArrayList();
+ final FileSelector fileSelector = getDefaultFileSelector();
+ String prefix = getPrefix();
+ if ( prefix != null && prefix.length() == 0 )
+ {
+ prefix = null;
+ }
+ for ( Iterator iter = getSrc().getResources(); iter.hasNext(); )
+ {
+ PlexusIoResource plexusIoResource = (PlexusIoResource) iter.next();
+ if ( !fileSelector.isSelected( plexusIoResource ) )
+ {
+ continue;
+ }
+ if ( !isSelected( plexusIoResource ) )
+ {
+ continue;
+ }
+ if ( plexusIoResource.isDirectory() && !isIncludingEmptyDirectories() )
+ {
+ continue;
+ }
+ if ( prefix != null )
+ {
+ final PlexusIoResource r = plexusIoResource;
+ AbstractPlexusIoResource resourceImpl = new AbstractPlexusIoResource( plexusIoResource )
+ {
+ public InputStream getContents() throws IOException
+ {
+ return r.getContents();
+ }
+
+ public URL getURL() throws IOException
+ {
+ return r.getURL();
+ }
+ };
+ resourceImpl.setName( prefix + plexusIoResource.getName() );
+ plexusIoResource = resourceImpl;
+ }
+ result.add( plexusIoResource );
+ }
+ return result.iterator();
+ }
+
+ public String getName( PlexusIoResource resource )
+ throws IOException
+ {
+ String name = resource.getName();
+ final FileMapper[] mappers = getFileMappers();
+ if ( mappers != null )
+ {
+ for ( int i = 0; i < mappers.length; i++ )
+ {
+ name = mappers[i].getMappedFileName( name );
+ }
+ }
+ /*
+ * The prefix is applied when creating the resource.
+ * return PrefixFileMapper.getMappedFileName( getPrefix(), name );
+ */
+ return name;
+ }
+
+ public long getLastModified()
+ throws IOException
+ {
+ return src.getLastModified();
+ }
+}
View
102 src/main/java/org/codehaus/plexus/components/io/resources/PlexusIoResource.java
@@ -1,51 +1,51 @@
-package org.codehaus.plexus.components.io.resources;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-
-import org.codehaus.plexus.components.io.fileselectors.FileInfo;
-
-
-/**
- * A resource is a file-like entity. It may be an actual file,
- * an URL, a zip entry, or something like that.
- */
-public interface PlexusIoResource extends FileInfo
-{
- /**
- * Unknown resource size.
- */
- public static final long UNKNOWN_RESOURCE_SIZE = -1;
-
- /**
- * Unknown modification date
- */
- public static final long UNKNOWN_MODIFICATION_DATE = 0;
-
- /**
- * Returns the date, when the resource was last modified, if known.
- * Otherwise, returns {@link #UNKNOWN_MODIFICATION_DATE}.
- * @see java.io.File#lastModified()
- */
- long getLastModified();
-
- /**
- * Returns, whether the resource exists.
- */
- boolean isExisting();
-
- /**
- * Returns the resources size, if known. Otherwise returns
- * {@link #UNKNOWN_RESOURCE_SIZE}.
- */
- long getSize();
-
- /**
- * Returns an {@link URL}, which may be used to reference the
- * resource, if possible.
- * @return An URL referencing the resource, if possible, or null.
- * In the latter case, you are forced to use {@link #getInputStream()}.
- */
- URL getURL() throws IOException;
-}
+package org.codehaus.plexus.components.io.resources;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import org.codehaus.plexus.components.io.fileselectors.FileInfo;
+
+
+/**
+ * A resource is a file-like entity. It may be an actual file,
+ * an URL, a zip entry, or something like that.
+ */
+public interface PlexusIoResource extends FileInfo
+{
+ /**
+ * Unknown resource size.
+ */
+ public static final long UNKNOWN_RESOURCE_SIZE = -1;
+
+ /**
+ * Unknown modification date
+ */
+ public static final long UNKNOWN_MODIFICATION_DATE = 0;
+
+ /**
+ * Returns the date, when the resource was last modified, if known.
+ * Otherwise, returns {@link #UNKNOWN_MODIFICATION_DATE}.
+ * @see java.io.File#lastModified()
+ */
+ long getLastModified();
+
+ /**
+ * Returns, whether the resource exists.
+ */
+ boolean isExisting();
+
+ /**
+ * Returns the resources size, if known. Otherwise returns
+ * {@link #UNKNOWN_RESOURCE_SIZE}.
+ */
+ long getSize();
+
+ /**
+ * Returns an {@link URL}, which may be used to reference the
+ * resource, if possible.
+ * @return An URL referencing the resource, if possible, or null.
+ * In the latter case, you are forced to use {@link #getInputStream()}.
+ */
+ URL getURL() throws IOException;
+}
View
94 src/main/java/org/codehaus/plexus/components/io/resources/PlexusIoResourceCollection.java
@@ -1,47 +1,47 @@
-package org.codehaus.plexus.components.io.resources;
-
-import java.io.IOException;
-import java.util.Iterator;
-
-
-/**
- * A resource collection is a set of {@link PlexusIoResource} instances.
- */
-public interface PlexusIoResourceCollection
-{
- /**
- * Role of the ResourceCollection component.
- */
- public static final String ROLE = PlexusIoResourceCollection.class.getName();
-
- /**
- * Role hint of the default resource collection, which is a set
- * of files in a base directory.
- */
- public static final String DEFAULT_ROLE_HINT = "default";
-
- /**
- * Returns an iterator over the resources in the collection.
- */
- Iterator getResources() throws IOException;
-
- /**
- * Returns the resources suggested name. This is used for
- * integrating file mappers.
- * @param resource A resource, which has been obtained by
- * calling {@link #getResources()}.
- */
- String getName( PlexusIoResource resource ) throws IOException;
-
- /**
- * Returns the collections last modification time. For a
- * collection of files, this might be the last modification
- * time of the file, which has been modified at last. For an
- * archive file, this might be the modification time of the
- * archive file.
- * @return {@link PlexusIoResource#UNKNOWN_MODIFICATION_DATE},
- * if the collections last modification time is unknown,
- * otherwise the last modification time in milliseconds.
- */
- long getLastModified() throws IOException;
-}
+package org.codehaus.plexus.components.io.resources;
+
+import java.io.IOException;
+import java.util.Iterator;
+
+
+/**
+ * A resource collection is a set of {@link PlexusIoResource} instances.
+ */
+public interface PlexusIoResourceCollection
+{
+ /**
+ * Role of the ResourceCollection component.
+ */
+ public static final String ROLE = PlexusIoResourceCollection.class.getName();
+
+ /**
+ * Role hint of the default resource collection, which is a set
+ * of files in a base directory.
+ */
+ public static final String DEFAULT_ROLE_HINT = "default";
+
+ /**
+ * Returns an iterator over the resources in the collection.
+ */
+ Iterator getResources() throws IOException;
+
+ /**
+ * Returns the resources suggested name. This is used for
+ * integrating file mappers.
+ * @param resource A resource, which has been obtained by
+ * calling {@link #getResources()}.
+ */
+ String getName( PlexusIoResource resource ) throws IOException;
+
+ /**
+ * Returns the collections last modification time. For a
+ * collection of files, this might be the last modification
+ * time of the file, which has been modified at last. For an
+ * archive file, this might be the modification time of the
+ * archive file.
+ * @return {@link PlexusIoResource#UNKNOWN_MODIFICATION_DATE},
+ * if the collections last modification time is unknown,
+ * otherwise the last modification time in milliseconds.
+ */
+ long getLastModified() throws IOException;
+}
View
54 src/main/java/org/codehaus/plexus/components/io/resources/PlexusIoURLResource.java
@@ -1,27 +1,27 @@
-package org.codehaus.plexus.components.io.resources;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-
-public class PlexusIoURLResource extends AbstractPlexusIoResource
-{
- private URL url;
-
-
- public InputStream getContents() throws IOException
- {
- return getURL().openStream();
- }
-
- public URL getURL() throws IOException
- {
- return url;
- }
-
- public void setURL( URL pUrl )
- {
- url = pUrl;
- }
-
-}
+package org.codehaus.plexus.components.io.resources;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+public class PlexusIoURLResource extends AbstractPlexusIoResource
+{
+ private URL url;
+
+
+ public InputStream getContents() throws IOException
+ {
+ return getURL().openStream();
+ }
+
+ public URL getURL() throws IOException
+ {
+ return url;
+ }
+
+ public void setURL( URL pUrl )
+ {
+ url = pUrl;
+ }
+
+}
View
128 ...n/java/org/codehaus/plexus/components/io/resources/PlexusIoZipFileResourceCollection.java
@@ -1,64 +1,64 @@
-package org.codehaus.plexus.components.io.resources;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-
-
-public class PlexusIoZipFileResourceCollection extends AbstractPlexusIoArchiveResourceCollection
-{
- /**
- * The zip file resource collections role hint.
- */
- public static final String ROLE_HINT = "zipFile";
-
- /**
- * The zip file resource collections role hint for jar files.
- */
- public static final String JAR_ROLE_HINT = "jarFile";
-
- protected Iterator getEntries() throws IOException
- {
- final File f = getFile();
- if ( f == null )
- {
- throw new IOException( "The zip file has not been set." );
- }
- final URL url = new URL( "jar:" + f.toURI().toURL() + "!/");
- final ZipFile zipFile = new ZipFile( f );
- final Enumeration en = zipFile.entries();
- return new Iterator(){
- public boolean hasNext()
- {
- return en.hasMoreElements();
- }
- public Object next()
- {
- final ZipEntry entry = (ZipEntry) en.nextElement();
- final PlexusIoURLResource res = new PlexusIoURLResource(){
- public URL getURL() throws IOException
- {
- return new URL( url, entry.getName() );
- }
- };
- final boolean dir = entry.isDirectory();
- res.setName( entry.getName() );
- res.setDirectory( dir );
- res.setExisting( true );
- res.setFile( !dir );
- long l = entry.getTime();
- res.setLastModified( l == -1 ? PlexusIoResource.UNKNOWN_MODIFICATION_DATE : l );
- res.setSize( dir ? PlexusIoResource.UNKNOWN_RESOURCE_SIZE : entry.getSize() );
- return res;
- }
- public void remove()
- {
- throw new UnsupportedOperationException( "Removing isn't implemented." );
- }
- };
- }
-}
+package org.codehaus.plexus.components.io.resources;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+
+public class PlexusIoZipFileResourceCollection extends AbstractPlexusIoArchiveResourceCollection
+{
+ /**
+ * The zip file resource collections role hint.
+ */
+ public static final String ROLE_HINT = "zipFile";
+
+ /**
+ * The zip file resource collections role hint for jar files.
+ */
+ public static final String JAR_ROLE_HINT = "jarFile";
+
+ protected Iterator getEntries() throws IOException
+ {
+ final File f = getFile();
+ if ( f == null )
+ {
+ throw new IOException( "The zip file has not been set." );
+ }
+ final URL url = new URL( "jar:" + f.toURI().toURL() + "!/");
+ final ZipFile zipFile = new ZipFile( f );
+ final Enumeration en = zipFile.entries();
+ return new Iterator(){
+ public boolean hasNext()
+ {
+ return en.hasMoreElements();
+ }
+ public Object next()
+ {
+ final ZipEntry entry = (ZipEntry) en.nextElement();
+ final PlexusIoURLResource res = new PlexusIoURLResource(){
+ public URL getURL() throws IOException
+ {
+ return new URL( url, entry.getName() );
+ }
+ };