ShrinkWrap Aggregator and Build Parent 1.0.0-cr-1

org.jboss.shrinkwrap.impl.base
Class ArchiveBase<T extends Archive<T>>

java.lang.Object
  extended by org.jboss.shrinkwrap.impl.base.ArchiveBase<T>
All Implemented Interfaces:
Archive<T>, Assignable, ArchiveFormatAssociable, Configurable
Direct Known Subclasses:
MemoryMapArchiveBase

public abstract class ArchiveBase<T extends Archive<T>>
extends Object
implements Archive<T>, Configurable, ArchiveFormatAssociable

ArchiveBase Base implementation of Archive. Contains support for operations (typically overloaded) that are not specific to any particular storage implementation, and may be delegated to other forms.

Version:
$Revision: $
Author:
ALR, John Bailey

Constructor Summary
protected ArchiveBase(String name, Configuration configuration)
          Constructor Creates a new Archive with the specified name
 
Method Summary
 T add(Archive<?> archive, ArchivePath path, Class<? extends StreamExporter> exporter)
          Add an archive under a specific context and maintain the archive name as context path.
 T add(Asset asset, ArchivePath path, String name)
          Adds the specified asset under the specified target (directory) using the specified name.
 T add(Asset asset, String target)
          Adds the specified resource under the context denoted by the specified target
 T add(Asset asset, String target, String name)
          Adds the specified asset under the specified target (directory) using the specified name.
 T add(NamedAsset namedAsset)
          Adds the asset encapsulated within the specified NamedAsset under the encapsulated name and target (directory)
 T addAsDirectories(ArchivePath... paths)
          Adds the specified directories.
 T addAsDirectories(String... paths)
          Adds the specified directories.
 T addAsDirectory(String path)
          Adds the specified directory.
<TYPE extends Assignable>
TYPE
as(Class<TYPE> clazz)
          Wraps an Archive in a different 'view'.
protected  T covariantReturn()
          Provides typesafe covariant return of this instance
 boolean equals(Object obj)
          
 Node get(String path)
          Obtains the Node located at the specified path
protected abstract  Class<T> getActualClass()
          Returns the actual typed class for this instance, used in safe casting for covariant return types
 ArchiveFormat getArchiveFormat()
          
<X extends Archive<X>>
X
getAsType(Class<X> type, ArchivePath path)
          Get a nested Archive as a specific type.

The found Archives must have been added as a Archive, no import is performed.
<X extends Archive<X>>
X
getAsType(Class<X> type, ArchivePath path, ArchiveFormat archiveFormat)
          Get a nested Archive located in a ArchivePath as a specific type using the specify ArchiveFormat
<X extends Archive<X>>
Collection<X>
getAsType(Class<X> type, Filter<ArchivePath> filter)
          Get all nested Archive matching the filter as a specific type.

The found Archives must have been added as a Archive, no import is performed.
<X extends Archive<X>>
Collection<X>
getAsType(Class<X> type, Filter<ArchivePath> filter, ArchiveFormat archiveFormat)
          Get all nested Archive matching the filter as a specific type using the specify ArchiveFormat.
<X extends Archive<X>>
X
getAsType(Class<X> type, String path)
          Get a nested Archive as a specific type.

The found Archives must have been added as a Archive, no import is performed.
<X extends Archive<X>>
X
getAsType(Class<X> type, String path, ArchiveFormat archiveFormat)
          Get a nested Archive as a specific type using the specify ArchiveFormat
 Configuration getConfiguration()
          Obtains the Configuration associated with this Archive
 String getName()
          Obtains the name of this archive (ie.
 int hashCode()
          
 T merge(Archive<?> source)
          Merge the contents from an existing archive without maintaining the archive name in the context path.
 T merge(Archive<?> source, ArchivePath path)
          Merge the contents from an existing archive in a specific path without maintaining the archive name in the context path.
 T merge(Archive<?> source, ArchivePath path, Filter<ArchivePath> filter)
          Merge the contents from an existing archive in a specific path without maintaining the archive name in the context path.
 T merge(Archive<?> source, Filter<ArchivePath> filter)
          Merge the contents from an existing archive without maintaining the archive name in the context path.
 T merge(Archive<?> source, String path)
          Merge the contents from an existing archive in a specific path without maintaining the archive name in the context path.
 T merge(Archive<?> source, String path, Filter<ArchivePath> filter)
          Merge the contents from an existing archive in a specific path without maintaining the archive name in the context path.
 String toString()
          Acts as a shorthand for Archive.toString(Formatter) where the Formatters.SIMPLE is leveraged.
 String toString(boolean verbose)
          If "true" is specified, acts as a shorthand for Archive.toString(Formatter) where the Formatters.VERBOSE is leveraged.
 String toString(Formatter formatter)
          Returns a view of this Archive as returned from the specified Formatter.
 void writeTo(OutputStream outputStream, Formatter formatter)
          Prints the content of this Archive to the specified OutputStream on the format defined by the specified Formatter.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jboss.shrinkwrap.api.Archive
add, add, addAsDirectory, contains, contains, delete, delete, get, getContent, getContent
 

Constructor Detail

ArchiveBase

protected ArchiveBase(String name,
                      Configuration configuration)
               throws IllegalArgumentException
Constructor Creates a new Archive with the specified name

Parameters:
name - Name of the archive
configuration - The configuration for this archive
Throws:
IllegalArgumentException - If the name was not specified
Method Detail

getArchiveFormat

public ArchiveFormat getArchiveFormat()

Specified by:
getArchiveFormat in interface ArchiveFormatAssociable
See Also:
ArchiveFormatAssociable.getArchiveFormat()

add

public T add(Asset asset,
             String target)
                         throws IllegalArgumentException
Adds the specified resource under the context denoted by the specified target

Specified by:
add in interface Archive<T extends Archive<T>>
Returns:
Throws:
IllegalArgumentException - If either the target or asset is not specified
See Also:
org.jboss.shrinkwrap.api.Archive#add(java.lang.String, org.jboss.shrinkwrap.api.asset.Asset)

add

public T add(Asset asset,
             String target,
             String name)
                         throws IllegalArgumentException
Adds the specified asset under the specified target (directory) using the specified name. The resultant path will be treating the specified path as a prefix namespace, then appending the name.

Specified by:
add in interface Archive<T extends Archive<T>>
target - The context directory under which to add the asset
name - The name to assign the assent under the target namespace
Returns:
Throws:
IllegalArgumentException - If the target, name, or asset was not specified
See Also:
Archive.add(org.jboss.shrinkwrap.api.asset.Asset, java.lang.String, java.lang.String)

add

public T add(Asset asset,
             ArchivePath path,
             String name)
Adds the specified asset under the specified target (directory) using the specified name. The resultant path will be treating the specified path as a prefix namespace, then appending the name.

Specified by:
add in interface Archive<T extends Archive<T>>
path - The context directory under which to add the asset
name - The name to assign the assent under the target namespace
Returns:
See Also:
org.jboss.shrinkwrap.api.Archive#add(org.jboss.shrinkwrap.api.ArchivePath, java.lang.String, org.jboss.shrinkwrap.api.asset.Asset)

get

public Node get(String path)
         throws IllegalArgumentException
Obtains the Node located at the specified path

Specified by:
get in interface Archive<T extends Archive<T>>
Returns:
The Node, or null if nothing is found at the Path
Throws:
IllegalArgumentException - If the path is not specified
See Also:
Archive.get(java.lang.String)

getAsType

public <X extends Archive<X>> X getAsType(Class<X> type,
                                          String path)
Get a nested Archive as a specific type.

The found Archives must have been added as a Archive, no import is performed.

Specified by:
getAsType in interface Archive<T extends Archive<T>>
Parameters:
type - The Type to return the Archive as
path - The location of the Archive
Returns:
The found Archive as given type or null if none found at given path
See Also:
Archive.getAsType(java.lang.Class, java.lang.String)

getAsType

public <X extends Archive<X>> Collection<X> getAsType(Class<X> type,
                                                      Filter<ArchivePath> filter)
Get all nested Archive matching the filter as a specific type.

The found Archives must have been added as a Archive, no import is performed.

Specified by:
getAsType in interface Archive<T extends Archive<T>>
Parameters:
type - The Type to return the Archive as
filter - Filter to match result
Returns:
A Collection of found Archives matching given filter or empty Collection if non found.
See Also:
Archive.getAsType(java.lang.Class, org.jboss.shrinkwrap.api.Filter)

getAsType

public <X extends Archive<X>> X getAsType(Class<X> type,
                                          ArchivePath path)
Get a nested Archive as a specific type.

The found Archives must have been added as a Archive, no import is performed.

Specified by:
getAsType in interface Archive<T extends Archive<T>>
Parameters:
type - The Type to return the Archive as
path - The location of the Archive
Returns:
The found Archive as given type or null if none found at given ArchivePath
See Also:
Archive.getAsType(java.lang.Class, org.jboss.shrinkwrap.api.ArchivePath)

getAsType

public <X extends Archive<X>> X getAsType(Class<X> type,
                                          String path,
                                          ArchiveFormat archiveFormat)
Get a nested Archive as a specific type using the specify ArchiveFormat

Specified by:
getAsType in interface Archive<T extends Archive<T>>
Parameters:
type - The Type to return the Archive as
path - The location of the Archive
Returns:
The found Archive as given type or null if none found at the given path
See Also:
Archive.getAsType(java.lang.Class, java.lang.String, org.jboss.shrinkwrap.api.ArchiveFormat)

getAsType

public <X extends Archive<X>> X getAsType(Class<X> type,
                                          ArchivePath path,
                                          ArchiveFormat archiveFormat)
Get a nested Archive located in a ArchivePath as a specific type using the specify ArchiveFormat

Specified by:
getAsType in interface Archive<T extends Archive<T>>
Parameters:
type - The Type to return the Archive as
path - The location of the Archive
Returns:
The found Archive as given type or null if none found at given ArchivePath
See Also:
Archive.getAsType(java.lang.Class, org.jboss.shrinkwrap.api.ArchivePath, org.jboss.shrinkwrap.api.ArchiveFormat)

getAsType

public <X extends Archive<X>> Collection<X> getAsType(Class<X> type,
                                                      Filter<ArchivePath> filter,
                                                      ArchiveFormat archiveFormat)
Get all nested Archive matching the filter as a specific type using the specify ArchiveFormat.

Specified by:
getAsType in interface Archive<T extends Archive<T>>
Parameters:
type - The Type to return the Archive as
filter - Filter to match result
Returns:
A Collection of found Archives matching given filter or empty Collection if non found.
See Also:
Archive.getAsType(java.lang.Class, org.jboss.shrinkwrap.api.Filter, org.jboss.shrinkwrap.api.ArchiveFormat)

add

public T add(Archive<?> archive,
             ArchivePath path,
             Class<? extends StreamExporter> exporter)
Add an archive under a specific context and maintain the archive name as context path.

Specified by:
add in interface Archive<T extends Archive<T>>
Parameters:
archive - to add
path - to use
exporter - Exporter type to use in fulfilling the Asset.openStream() contract for the added (nested) archive.
Returns:
See Also:
Archive.add(org.jboss.shrinkwrap.api.Archive, org.jboss.shrinkwrap.api.ArchivePath, java.lang.Class)

add

public T add(NamedAsset namedAsset)
Adds the asset encapsulated within the specified NamedAsset under the encapsulated name and target (directory)

Specified by:
add in interface Archive<T extends Archive<T>>
Returns:
See Also:
org.jboss.shrinkwrap.api.Archive#add(NamedAsset))

addAsDirectory

public T addAsDirectory(String path)
                                    throws IllegalArgumentException
Adds the specified directory.

Specified by:
addAsDirectory in interface Archive<T extends Archive<T>>
Parameters:
path - The path to add
Returns:
This archive
Throws:
IllegalArgumentException - If no path was specified
See Also:
Archive.addAsDirectory(java.lang.String)

addAsDirectories

public T addAsDirectories(ArchivePath... paths)
                                      throws IllegalArgumentException
Adds the specified directories.

Specified by:
addAsDirectories in interface Archive<T extends Archive<T>>
Parameters:
paths - The paths to add
Returns:
This archive
Throws:
IllegalArgumentException - If no paths were specified
See Also:
Archive.addAsDirectories(org.jboss.shrinkwrap.api.ArchivePath[])

addAsDirectories

public T addAsDirectories(String... paths)
                                      throws IllegalArgumentException
Adds the specified directories.

Specified by:
addAsDirectories in interface Archive<T extends Archive<T>>
Parameters:
paths - The paths to add
Returns:
This archive
Throws:
IllegalArgumentException - If no paths were specified
See Also:
Archive.addAsDirectories(java.lang.String[])

getName

public final String getName()
Obtains the name of this archive (ie. myLibrary.jar)

Specified by:
getName in interface Archive<T extends Archive<T>>
See Also:
Archive.getName()

merge

public T merge(Archive<?> source)
                           throws IllegalArgumentException
Merge the contents from an existing archive without maintaining the archive name in the context path.

Specified by:
merge in interface Archive<T extends Archive<T>>
Parameters:
source - Archive to add contents from
Returns:
Throws:
IllegalArgumentException - If the existing archive is not specified
See Also:
Archive.merge(org.jboss.shrinkwrap.api.Archive)

merge

public T merge(Archive<?> source,
               Filter<ArchivePath> filter)
                           throws IllegalArgumentException
Merge the contents from an existing archive without maintaining the archive name in the context path. The filter control which ArchivePaths to include form the source Archive.

Specified by:
merge in interface Archive<T extends Archive<T>>
Parameters:
source - Archive to add contents from
Returns:
Throws:
IllegalArgumentException - If the existing archive is not specified
See Also:
Archive.merge(org.jboss.shrinkwrap.api.Archive, org.jboss.shrinkwrap.api.Filter)

merge

public T merge(Archive<?> source,
               ArchivePath path)
                           throws IllegalArgumentException
Merge the contents from an existing archive in a specific path without maintaining the archive name in the context path.

Specified by:
merge in interface Archive<T extends Archive<T>>
Parameters:
source - Archive to add contents from
path - Path to add contents to
Returns:
Throws:
IllegalArgumentException - If the path or existing archive is not specified
See Also:
org.jboss.shrinkwrap.api.Archive#merge(org.jboss.shrinkwrap.api.ArchivePath, org.jboss.shrinkwrap.api.Archive)

merge

public T merge(Archive<?> source,
               String path,
               Filter<ArchivePath> filter)
                           throws IllegalArgumentException
Merge the contents from an existing archive in a specific path without maintaining the archive name in the context path. The filter control which ArchivePaths to include form the source Archive.

Specified by:
merge in interface Archive<T extends Archive<T>>
Parameters:
source - Archive to add contents from
path - Path to add contents to
filter - Filter to use for including Assets in the merge.
Returns:
Throws:
IllegalArgumentException - If the path or existing archive is not specified
See Also:
Archive.merge(org.jboss.shrinkwrap.api.Archive, java.lang.String, org.jboss.shrinkwrap.api.Filter)

merge

public T merge(Archive<?> source,
               String path)
                           throws IllegalArgumentException
Merge the contents from an existing archive in a specific path without maintaining the archive name in the context path.

Specified by:
merge in interface Archive<T extends Archive<T>>
Parameters:
source - Archive to add contents from
path - Path to add contents to
Returns:
Throws:
IllegalArgumentException - If the path or existing archive is not specified
See Also:
Archive.merge(org.jboss.shrinkwrap.api.Archive, java.lang.String)

merge

public T merge(Archive<?> source,
               ArchivePath path,
               Filter<ArchivePath> filter)
                           throws IllegalArgumentException
Merge the contents from an existing archive in a specific path without maintaining the archive name in the context path. The filter control which ArchivePaths to include form the source Archive.

Specified by:
merge in interface Archive<T extends Archive<T>>
Parameters:
source - Archive to add contents from
path - Path to add contents to
filter - Filter to use for including Assets in the merge.
Returns:
Throws:
IllegalArgumentException - If the path or existing archive is not specified
See Also:
org.jboss.shrinkwrap.api.Archive#merge(org.jboss.shrinkwrap.api.Archive, org.jboss.shrinkwrap.api.Path, org.jboss.shrinkwrap.api.Filter)

as

public <TYPE extends Assignable> TYPE as(Class<TYPE> clazz)
Wraps an Archive in a different 'view'.

Specified by:
as in interface Assignable
Parameters:
clazz - Extension interface to load
Returns:
The Archive wrapped as TYPE
See Also:
Assignable.as(java.lang.Class)

toString

public String toString()
Acts as a shorthand for Archive.toString(Formatter) where the Formatters.SIMPLE is leveraged.

Specified by:
toString in interface Archive<T extends Archive<T>>
Overrides:
toString in class Object
See Also:
Archive.toString()

toString

public String toString(boolean verbose)
If "true" is specified, acts as a shorthand for Archive.toString(Formatter) where the Formatters.VERBOSE is leveraged. Otherwise the Formatters.SIMPLE will be used (equivalent to Archive.toString()).

Specified by:
toString in interface Archive<T extends Archive<T>>
Returns:
See Also:
Archive.toString(boolean)

toString

public String toString(Formatter formatter)
                throws IllegalArgumentException
Returns a view of this Archive as returned from the specified Formatter. Common options may be to use the predefined formatters located in Formatters

Specified by:
toString in interface Archive<T extends Archive<T>>
Returns:
Throws:
IllegalArgumentException - If the formatter is not specified
See Also:
Archive.toString(org.jboss.shrinkwrap.api.formatter.Formatter)

writeTo

public void writeTo(OutputStream outputStream,
                    Formatter formatter)
             throws IllegalArgumentException
Prints the content of this Archive to the specified OutputStream on the format defined by the specified Formatter. The caller is responsible for opening, flushing and eventually closing the stream.

Specified by:
writeTo in interface Archive<T extends Archive<T>>
Parameters:
outputStream - the stream to print the archive contents to
formatter - the output format
Throws:
IllegalArgumentException - if an exceptions occur when writing the archive contents.

hashCode

public int hashCode()

Overrides:
hashCode in class Object
See Also:
org.jboss.shrinkwrap.api.Archive#hashCode()

equals

public boolean equals(Object obj)

Overrides:
equals in class Object
See Also:
org.jboss.shrinkwrap.api.Archive#equals(Object)

getConfiguration

public Configuration getConfiguration()
Obtains the Configuration associated with this Archive

Specified by:
getConfiguration in interface Configurable
See Also:
Configurable.getConfiguration()

getActualClass

protected abstract Class<T> getActualClass()
Returns the actual typed class for this instance, used in safe casting for covariant return types

Returns:

covariantReturn

protected final T covariantReturn()
Provides typesafe covariant return of this instance


ShrinkWrap Aggregator and Build Parent 1.0.0-cr-1

Copyright © 2011 JBoss, a division of Red Hat, Inc.. All Rights Reserved.