Package org.jboss.shrinkwrap.impl.base
Class ArchiveBase<T extends Archive<T>>
java.lang.Object
org.jboss.shrinkwrap.impl.base.ArchiveBase<T>
- All Implemented Interfaces:
Archive<T>,Assignable,ArchiveFormatAssociable,Configurable,Identifiable
- Direct Known Subclasses:
MemoryMapArchiveBase
public abstract class ArchiveBase<T extends Archive<T>>
extends Object
implements Archive<T>, Configurable, ArchiveFormatAssociable, Identifiable
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: $
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ConfigurationConfiguration for this archiveprivate StringGlobally-unique ID for this archiveprivate static final LoggerLoggerprivate final StringName of the archive -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedArchiveBase(String name, Configuration configuration) Constructor Creates a new Archive with the specified name -
Method Summary
Modifier and TypeMethodDescriptionadd(Archive<?> archive, ArchivePath path, Class<? extends StreamExporter> exporter) Add an archive under a specific context and maintain the archive name as context path.Adds the specified resource under the context denoted by the specified targetAdds the specified asset under the specified target (directory) using the specified name.add(Asset asset, ArchivePath path, String name) Adds the specified asset under the specified target (directory) using the specified name.add(NamedAsset namedAsset) Adds the asset encapsulated within the specifiedNamedAssetunder the encapsulated name and target (directory)addAsDirectories(String... paths) Adds the specified directories.addAsDirectories(ArchivePath... paths) Adds the specified directories.addAsDirectory(String path) Adds the specified directory.<TYPE extends Assignable>
TYPEWraps an Archive in a different 'view'.protected final TProvides typesafe covariant return of this instancebooleanfilter(Filter<ArchivePath> filter) Obtains all assets matching given filter in this archive as a new Archive.
This is an alias for shallowCopy(Filter).Obtains theNodelocated at the specified pathExposes the actual class used in casting<X extends Archive<X>>
XGet a nestedArchiveas a specific type.
The found Archives must have been added as a Archive, no import is performed.<X extends Archive<X>>
XgetAsType(Class<X> type, String path, ArchiveFormat archiveFormat) Get a nestedArchiveas a specific type using the specifyArchiveFormat<X extends Archive<X>>
XgetAsType(Class<X> type, ArchivePath path) Get a nestedArchiveas a specific type.
The found Archives must have been added as a Archive, no import is performed.<X extends Archive<X>>
XgetAsType(Class<X> type, ArchivePath path, ArchiveFormat archiveFormat) <X extends Archive<X>>
Collection<X> getAsType(Class<X> type, Filter<ArchivePath> filter) Get all nestedArchivematching 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 nestedArchivematching the filter as a specific type using the specifyArchiveFormat.Obtains theConfigurationassociated with thisArchivegetId()Obtains a globally-unique identifier for thisArchivefinal StringgetName()Obtains the name of this archive (ie.inthashCode()Merge the contents from an existing archive without maintaining the archive name in the context path.Merge the contents from an existing archive in a specific path without maintaining the archive name in the context path.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.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.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.merge(Archive<?> source, Filter<ArchivePath> filter) Merge the contents from an existing archive without maintaining the archive name in the context path.Moves the asset under the source path to the target path.move(ArchivePath source, ArchivePath target) Moves the asset under the source path to the target path.voidSets the globally-unique identifierCreates a shallow copy of thisArchive.shallowCopy(Filter<ArchivePath> filter) Creates a shallow copy of thisArchivebased on given filter.Assets from this archive are made available under the same paths.toString()Acts as a shorthand forArchive.toString(Formatter)where theFormatters.SIMPLEis leveraged.toString(boolean verbose) If "true" is specified, acts as a shorthand forArchive.toString(Formatter)where theFormatters.VERBOSEis leveraged.voidwriteTo(OutputStream outputStream, Formatter formatter) Prints the content of thisArchiveto the specifiedOutputStreamon the format defined by the specifiedFormatter.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.jboss.shrinkwrap.api.Archive
add, add, addAsDirectory, addHandlers, contains, contains, delete, delete, get, getContent, getContent
-
Field Details
-
log
Logger -
name
Name of the archive -
configuration
Configuration for this archive -
id
Globally-unique ID for this archive
-
-
Constructor Details
-
ArchiveBase
Constructor Creates a new Archive with the specified name- Parameters:
name- Name of the archiveconfiguration- The configuration for this archive- Throws:
IllegalArgumentException- If the name was not specified
-
-
Method Details
-
getArchiveFormat
- Specified by:
getArchiveFormatin interfaceArchiveFormatAssociable- See Also:
-
add
Adds the specified resource under the context denoted by the specified target -
add
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:
addin interfaceArchive<T extends Archive<T>>- Parameters:
asset-target- The context directory under which to add the assetname- The name to assign the assent under the target namespace- Returns:
- Throws:
IllegalArgumentException- If the target, name, or asset was not specified- See Also:
-
add
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. -
get
Obtains theNodelocated at the specified path -
getAsType
Get a nestedArchiveas a specific type.
The found Archives must have been added as a Archive, no import is performed. -
getAsType
Get all nestedArchivematching the filter as a specific type.
The found Archives must have been added as a Archive, no import is performed.- Specified by:
getAsTypein interfaceArchive<T extends Archive<T>>- Type Parameters:
X-- Parameters:
type- The Type to return the Archive asfilter- Filter to match result- Returns:
- A
Collectionof found Archives matching given filter or emptyCollectionif non found. - See Also:
-
getAsType
Get a nestedArchiveas a specific type.
The found Archives must have been added as a Archive, no import is performed. -
getAsType
Get a nestedArchiveas a specific type using the specifyArchiveFormat -
getAsType
public <X extends Archive<X>> X getAsType(Class<X> type, ArchivePath path, ArchiveFormat archiveFormat) -
getAsType
public <X extends Archive<X>> Collection<X> getAsType(Class<X> type, Filter<ArchivePath> filter, ArchiveFormat archiveFormat) Get all nestedArchivematching the filter as a specific type using the specifyArchiveFormat.- Specified by:
getAsTypein interfaceArchive<T extends Archive<T>>- Type Parameters:
X-- Parameters:
type- The Type to return the Archive asfilter- Filter to match resultarchiveFormat- The archive format- Returns:
- A
Collectionof found Archives matching given filter or emptyCollectionif non found. - See Also:
-
filter
Obtains all assets matching given filter in this archive as a new Archive.
This is an alias for shallowCopy(Filter). -
add
Add an archive under a specific context and maintain the archive name as context path. -
add
Adds the asset encapsulated within the specifiedNamedAssetunder the encapsulated name and target (directory) -
addAsDirectory
Adds the specified directory.- Specified by:
addAsDirectoryin interfaceArchive<T extends Archive<T>>- Parameters:
path- The path to add- Returns:
- This archive
- Throws:
IllegalArgumentException- If no path was specified- See Also:
-
addAsDirectories
Adds the specified directories.- Specified by:
addAsDirectoriesin interfaceArchive<T extends Archive<T>>- Parameters:
paths- The paths to add- Returns:
- This archive
- Throws:
IllegalArgumentException- If no paths were specified- See Also:
-
addAsDirectories
Adds the specified directories.- Specified by:
addAsDirectoriesin interfaceArchive<T extends Archive<T>>- Parameters:
paths- The paths to add- Returns:
- This archive
- Throws:
IllegalArgumentException- If no paths were specified- See Also:
-
getName
Obtains the name of this archive (ie. myLibrary.jar) -
getId
Obtains a globally-unique identifier for thisArchive -
setId
Description copied from interface:IdentifiableSets the globally-unique identifier- Specified by:
setIdin interfaceIdentifiable- Parameters:
id-- Throws:
IllegalArgumentException- If the ID is not specified
-
merge
Merge the contents from an existing archive without maintaining the archive name in the context path. -
merge
Merge the contents from an existing archive without maintaining the archive name in the context path. The filter control whichArchivePaths to include form the sourceArchive. -
merge
Merge the contents from an existing archive in a specific path without maintaining the archive name in the context path. -
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 whichArchivePaths to include form the sourceArchive.- Specified by:
mergein interfaceArchive<T extends Archive<T>>- Parameters:
source- Archive to add contents frompath- Path to add contents tofilter- Filter to use for includingAssets in the merge.- Returns:
- Throws:
IllegalArgumentException- If the path or existing archive is not specified- See Also:
-
merge
Merge the contents from an existing archive in a specific path without maintaining the archive name in the context path. -
shallowCopy
Creates a shallow copy of thisArchive. Assets from this archive are made available under the same paths. However, removing old assets or adding new assets on this archive affects does not affect the new archive.- Specified by:
shallowCopyin interfaceArchive<T extends Archive<T>>- Returns:
- a new archive with a copy of the pointers to the assets
- See Also:
-
shallowCopy
Creates a shallow copy of thisArchivebased on given filter.Assets from this archive are made available under the same paths. However, removing old assets or adding new assets on this archive affects does not affect the new archive.- Specified by:
shallowCopyin interfaceArchive<T extends Archive<T>>- Returns:
- a new archive with a copy of the pointers to the assets
- See Also:
-
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 whichArchivePaths to include form the sourceArchive.- Specified by:
mergein interfaceArchive<T extends Archive<T>>- Parameters:
source- Archive to add contents frompath- Path to add contents tofilter- Filter to use for includingAssets in the merge.- Returns:
- Throws:
IllegalArgumentException- If the path or existing archive is not specified- See Also:
-
move
public T move(ArchivePath source, ArchivePath target) throws IllegalArgumentException, IllegalArchivePathException Moves the asset under the source path to the target path.- Specified by:
movein interfaceArchive<T extends Archive<T>>- Parameters:
source- The context under which to remove the assetstarget- The context under which to add the moved assets- Returns:
- the resulting archive with the moved assets
- Throws:
IllegalArgumentException- If any of the paths is not specifiedIllegalArchivePathException- If the source path is invalid.- See Also:
-
move
public T move(String source, String target) throws IllegalArgumentException, IllegalArchivePathException Moves the asset under the source path to the target path.- Specified by:
movein interfaceArchive<T extends Archive<T>>- Parameters:
source- The context under which to remove the assetstarget- The context under which to add the moved assets- Returns:
- the resulting archive with the moved assets
- Throws:
IllegalArgumentException- If any of the paths is not specifiedIllegalArchivePathException- If the source path is invalid.- See Also:
-
as
Wraps an Archive in a different 'view'.- Specified by:
asin interfaceAssignable- Type Parameters:
TYPE-- Parameters:
clazz- Extension interface to load- Returns:
- The Archive wrapped as TYPE
- See Also:
-
toString
Acts as a shorthand forArchive.toString(Formatter)where theFormatters.SIMPLEis leveraged. -
toString
If "true" is specified, acts as a shorthand forArchive.toString(Formatter)where theFormatters.VERBOSEis leveraged. Otherwise theFormatters.SIMPLEwill be used (equivalent toArchive.toString()). -
toString
Returns a view of thisArchiveas returned from the specifiedFormatter. Common options may be to use the predefined formatters located inFormatters -
writeTo
Prints the content of thisArchiveto the specifiedOutputStreamon the format defined by the specifiedFormatter. The caller is responsible for opening, flushing and eventually closing the stream. -
hashCode
public int hashCode() -
equals
-
getConfiguration
Obtains theConfigurationassociated with thisArchive- Specified by:
getConfigurationin interfaceConfigurable- See Also:
-
getActualClass
Exposes the actual class used in casting- Returns:
-
covariantReturn
Provides typesafe covariant return of this instance
-