public abstract class ArchiveBase<T extends Archive<T>> extends Object implements Archive<T>, Configurable, ArchiveFormatAssociable, Identifiable
Archive
. Contains support for operations (typically overloaded) that are not specific
to any particular storage implementation, and may be delegated to other forms.Modifier | Constructor and Description |
---|---|
protected |
ArchiveBase(String name,
Configuration configuration)
Constructor
Creates a new Archive with the specified name
|
Modifier and Type | Method and Description |
---|---|
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> |
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) |
T |
filter(Filter<ArchivePath> filter)
Obtains all assets matching given filter in this archive as a new Archive.
This is an alias for shallowCopy(Filter). |
Node |
get(String path)
Obtains the
Node located at the specified path |
protected abstract Class<T> |
getActualClass()
Exposes the actual class used in casting
|
ArchiveFormat |
getArchiveFormat() |
<X extends Archive<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>> |
getAsType(Class<X> type,
ArchivePath path,
ArchiveFormat archiveFormat)
|
<X extends Archive<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>> |
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>> |
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>> |
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 |
getId()
Obtains a globally-unique identifier for 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.
|
T |
move(ArchivePath source,
ArchivePath target)
Moves the asset under the source path to the target path.
|
T |
move(String source,
String target)
Moves the asset under the source path to the target path.
|
void |
setId(String id)
Sets the globally-unique identifier
|
Archive<T> |
shallowCopy()
Creates a shallow copy of this
Archive . |
Archive<T> |
shallowCopy(Filter<ArchivePath> filter)
Creates a shallow copy of this
Archive based on given filter.Assets from this archive are made available
under the same paths. |
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)
|
void |
writeTo(OutputStream outputStream,
Formatter formatter)
Prints the content of this
Archive to the specified OutputStream on the format defined by the
specified Formatter . |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
add, add, addAsDirectory, addHandlers, contains, contains, delete, delete, get, getContent, getContent
protected ArchiveBase(String name, Configuration configuration) throws IllegalArgumentException
name
- Name of the archiveconfiguration
- The configuration for this archiveIllegalArgumentException
- If the name was not specifiedpublic ArchiveFormat getArchiveFormat()
getArchiveFormat
in interface ArchiveFormatAssociable
ArchiveFormatAssociable.getArchiveFormat()
public T add(Asset asset, String target) throws IllegalArgumentException
public T add(Asset asset, String target, String name) throws IllegalArgumentException
add
in interface Archive<T extends Archive<T>>
target
- The context directory under which to add the assetname
- The name to assign the assent under the target namespaceIllegalArgumentException
- If the target, name, or asset was not specifiedArchive.add(org.jboss.shrinkwrap.api.asset.Asset, java.lang.String,
java.lang.String)
public T add(Asset asset, ArchivePath path, String name)
add
in interface Archive<T extends Archive<T>>
path
- The context directory under which to add the assetname
- The name to assign the assent under the target namespaceorg.jboss.shrinkwrap.api.Archive#add(org.jboss.shrinkwrap.api.ArchivePath, java.lang.String,
org.jboss.shrinkwrap.api.asset.Asset)
public Node get(String path) throws IllegalArgumentException
Node
located at the specified pathget
in interface Archive<T extends Archive<T>>
Node
, or null if nothing is found at the PathIllegalArgumentException
- If the path is not specifiedArchive.get(java.lang.String)
public <X extends Archive<X>> X getAsType(Class<X> type, String path)
Archive
as a specific type.public <X extends Archive<X>> Collection<X> getAsType(Class<X> type, Filter<ArchivePath> filter)
Archive
matching the filter as a specific type.getAsType
in interface Archive<T extends Archive<T>>
type
- The Type to return the Archive asfilter
- Filter to match resultCollection
of found Archives matching given filter or empty Collection
if non found.Archive.getAsType(java.lang.Class, org.jboss.shrinkwrap.api.Filter)
public <X extends Archive<X>> X getAsType(Class<X> type, ArchivePath path)
Archive
as a specific type.getAsType
in interface Archive<T extends Archive<T>>
type
- The Type to return the Archive aspath
- The location of the ArchiveArchivePath
Archive.getAsType(java.lang.Class, org.jboss.shrinkwrap.api.ArchivePath)
public <X extends Archive<X>> X getAsType(Class<X> type, String path, ArchiveFormat archiveFormat)
Archive
as a specific type using the specify ArchiveFormat
getAsType
in interface Archive<T extends Archive<T>>
type
- The Type to return the Archive aspath
- The location of the ArchivearchiveFormat
- The archive formatArchive.getAsType(java.lang.Class, java.lang.String,
org.jboss.shrinkwrap.api.ArchiveFormat)
public <X extends Archive<X>> X getAsType(Class<X> type, ArchivePath path, ArchiveFormat archiveFormat)
getAsType
in interface Archive<T extends Archive<T>>
type
- The Type to return the Archive aspath
- The location of the ArchivearchiveFormat
- The archive formatArchivePath
Archive.getAsType(java.lang.Class, org.jboss.shrinkwrap.api.ArchivePath,
org.jboss.shrinkwrap.api.ArchiveFormat)
public <X extends Archive<X>> Collection<X> getAsType(Class<X> type, Filter<ArchivePath> filter, ArchiveFormat archiveFormat)
Archive
matching the filter as a specific type using the specify ArchiveFormat
.getAsType
in interface Archive<T extends Archive<T>>
type
- The Type to return the Archive asfilter
- Filter to match resultarchiveFormat
- The archive formatCollection
of found Archives matching given filter or empty Collection
if non found.Archive.getAsType(java.lang.Class, org.jboss.shrinkwrap.api.Filter,
org.jboss.shrinkwrap.api.ArchiveFormat)
public T filter(Filter<ArchivePath> filter)
public T add(Archive<?> archive, ArchivePath path, Class<? extends StreamExporter> exporter)
add
in interface Archive<T extends Archive<T>>
archive
- to addpath
- to useexporter
- Exporter type to use in fulfilling the Asset.openStream()
contract for the added (nested)
archive.Archive.add(org.jboss.shrinkwrap.api.Archive, org.jboss.shrinkwrap.api.ArchivePath,
java.lang.Class)
public T add(NamedAsset namedAsset)
NamedAsset
under the encapsulated name and target
(directory)public T addAsDirectory(String path) throws IllegalArgumentException
addAsDirectory
in interface Archive<T extends Archive<T>>
path
- The path to addIllegalArgumentException
- If no path was specifiedArchive.addAsDirectory(java.lang.String)
public T addAsDirectories(ArchivePath... paths) throws IllegalArgumentException
addAsDirectories
in interface Archive<T extends Archive<T>>
paths
- The paths to addIllegalArgumentException
- If no paths were specifiedArchive.addAsDirectories(org.jboss.shrinkwrap.api.ArchivePath[])
public T addAsDirectories(String... paths) throws IllegalArgumentException
addAsDirectories
in interface Archive<T extends Archive<T>>
paths
- The paths to addIllegalArgumentException
- If no paths were specifiedArchive.addAsDirectories(java.lang.String[])
public final String getName()
public String getId()
Archive
getId
in interface Archive<T extends Archive<T>>
getId
in interface Identifiable
Archive.getId()
public void setId(String id) throws IllegalArgumentException
Identifiable
setId
in interface Identifiable
IllegalArgumentException
- If the ID is not specifiedpublic T merge(Archive<?> source) throws IllegalArgumentException
merge
in interface Archive<T extends Archive<T>>
source
- Archive to add contents fromIllegalArgumentException
- If the existing archive is not specifiedArchive.merge(org.jboss.shrinkwrap.api.Archive)
public T merge(Archive<?> source, Filter<ArchivePath> filter) throws IllegalArgumentException
ArchivePath
s to include form the source Archive
.merge
in interface Archive<T extends Archive<T>>
source
- Archive to add contents fromIllegalArgumentException
- If the existing archive is not specifiedArchive.merge(org.jboss.shrinkwrap.api.Archive, org.jboss.shrinkwrap.api.Filter)
public T merge(Archive<?> source, ArchivePath path) throws IllegalArgumentException
merge
in interface Archive<T extends Archive<T>>
source
- Archive to add contents frompath
- Path to add contents toIllegalArgumentException
- If the path or existing archive is not specifiedorg.jboss.shrinkwrap.api.Archive#merge(org.jboss.shrinkwrap.api.ArchivePath,
org.jboss.shrinkwrap.api.Archive)
public T merge(Archive<?> source, String path, Filter<ArchivePath> filter) throws IllegalArgumentException
ArchivePath
s to include form the source Archive
.merge
in interface Archive<T extends Archive<T>>
source
- Archive to add contents frompath
- Path to add contents tofilter
- Filter to use for including Asset
s in the merge.IllegalArgumentException
- If the path or existing archive is not specifiedArchive.merge(org.jboss.shrinkwrap.api.Archive, java.lang.String,
org.jboss.shrinkwrap.api.Filter)
public T merge(Archive<?> source, String path) throws IllegalArgumentException
merge
in interface Archive<T extends Archive<T>>
source
- Archive to add contents frompath
- Path to add contents toIllegalArgumentException
- If the path or existing archive is not specifiedArchive.merge(org.jboss.shrinkwrap.api.Archive, java.lang.String)
public final Archive<T> shallowCopy()
Archive
. 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.shallowCopy
in interface Archive<T extends Archive<T>>
Archive.shallowCopy()
public final Archive<T> shallowCopy(Filter<ArchivePath> filter)
Archive
based 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.shallowCopy
in interface Archive<T extends Archive<T>>
Archive.shallowCopy(Filter)
public T merge(Archive<?> source, ArchivePath path, Filter<ArchivePath> filter) throws IllegalArgumentException
ArchivePath
s to include form the source Archive
.merge
in interface Archive<T extends Archive<T>>
source
- Archive to add contents frompath
- Path to add contents tofilter
- Filter to use for including Asset
s in the merge.IllegalArgumentException
- If the path or existing archive is not specifiedorg.jboss.shrinkwrap.api.Archive#merge(org.jboss.shrinkwrap.api.Archive, org.jboss.shrinkwrap.api.Path,
org.jboss.shrinkwrap.api.Filter)
public T move(ArchivePath source, ArchivePath target) throws IllegalArgumentException, IllegalArchivePathException
move
in interface Archive<T extends Archive<T>>
source
- The context under which to remove the assetstarget
- The context under which to add the moved assetsIllegalArgumentException
- If any of the paths is not specifiedIllegalArchivePathException
- If the source path is invalid.Archive.move(org.jboss.shrinkwrap.api.ArchivePath, org.jboss.shrinkwrap.api.ArchivePath)
public T move(String source, String target) throws IllegalArgumentException, IllegalArchivePathException
move
in interface Archive<T extends Archive<T>>
source
- The context under which to remove the assetstarget
- The context under which to add the moved assetsIllegalArgumentException
- If any of the paths is not specifiedIllegalArchivePathException
- If the source path is invalid.Archive.move(java.lang.String, java.lang.String)
public <TYPE extends Assignable> TYPE as(Class<TYPE> clazz)
as
in interface Assignable
clazz
- Extension interface to loadAssignable.as(java.lang.Class)
public String toString()
Archive.toString(Formatter)
where the Formatters.SIMPLE
is leveraged.public String toString(boolean verbose)
Archive.toString(Formatter)
where the
Formatters.VERBOSE
is leveraged. Otherwise the Formatters.SIMPLE
will be used (equivalent to
Archive.toString()
).public String toString(Formatter formatter) throws IllegalArgumentException
Archive
as returned from the specified Formatter
. Common options may be to
use the predefined formatters located in Formatters
toString
in interface Archive<T extends Archive<T>>
IllegalArgumentException
- If the formatter is not specifiedArchive.toString(org.jboss.shrinkwrap.api.formatter.Formatter)
public void writeTo(OutputStream outputStream, Formatter formatter) throws IllegalArgumentException
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.public int hashCode()
public boolean equals(Object obj)
public Configuration getConfiguration()
Configuration
associated with this Archive
getConfiguration
in interface Configurable
Configurable.getConfiguration()
protected abstract Class<T> getActualClass()
protected final T covariantReturn()
Copyright © 2016 JBoss by Red Hat. All rights reserved.