public abstract class ArchiveBase<T extends Archive<T>> extends java.lang.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 and Type | Field and Description |
---|---|
private Configuration |
configuration
Configuration for this archive
|
private java.lang.String |
id
Globally-unique ID for this archive
|
private static java.util.logging.Logger |
log
Logger
|
private java.lang.String |
name
Name of the archive
|
Modifier | Constructor and Description |
---|---|
protected |
ArchiveBase(java.lang.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,
java.lang.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,
java.lang.String name)
Adds the specified asset under the specified target (directory) using the specified name.
|
T |
add(Asset asset,
java.lang.String target)
Adds the specified resource under the context denoted by the specified target
|
T |
add(Asset asset,
java.lang.String target,
java.lang.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(java.lang.String... paths)
Adds the specified directories.
|
T |
addAsDirectory(java.lang.String path)
Adds the specified directory.
|
<TYPE extends Assignable> |
as(java.lang.Class<TYPE> clazz)
Wraps an Archive in a different 'view'.
|
protected T |
covariantReturn()
Provides typesafe covariant return of this instance
|
boolean |
equals(java.lang.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(java.lang.String path)
Obtains the
Node located at the specified path |
protected abstract java.lang.Class<T> |
getActualClass()
Exposes the actual class used in casting
|
ArchiveFormat |
getArchiveFormat() |
<X extends Archive<X>> |
getAsType(java.lang.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(java.lang.Class<X> type,
ArchivePath path,
ArchiveFormat archiveFormat)
|
<X extends Archive<X>> |
getAsType(java.lang.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(java.lang.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(java.lang.Class<X> type,
java.lang.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(java.lang.Class<X> type,
java.lang.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 |
java.lang.String |
getId()
Obtains a globally-unique identifier for this
Archive |
java.lang.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,
java.lang.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,
java.lang.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(java.lang.String source,
java.lang.String target)
Moves the asset under the source path to the target path.
|
void |
setId(java.lang.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. |
java.lang.String |
toString()
Acts as a shorthand for
Archive.toString(Formatter) where the Formatters.SIMPLE is leveraged. |
java.lang.String |
toString(boolean verbose)
If "true" is specified, acts as a shorthand for
Archive.toString(Formatter) where the
Formatters.VERBOSE is leveraged. |
java.lang.String |
toString(Formatter formatter)
|
void |
writeTo(java.io.OutputStream outputStream,
Formatter formatter)
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
add, add, addAsDirectory, addHandlers, contains, contains, delete, delete, get, getContent, getContent
private static final java.util.logging.Logger log
private final java.lang.String name
private final Configuration configuration
private java.lang.String id
protected ArchiveBase(java.lang.String name, Configuration configuration) throws java.lang.IllegalArgumentException
name
- Name of the archiveconfiguration
- The configuration for this archivejava.lang.IllegalArgumentException
- If the name was not specifiedpublic ArchiveFormat getArchiveFormat()
getArchiveFormat
in interface ArchiveFormatAssociable
ArchiveFormatAssociable.getArchiveFormat()
public T add(Asset asset, java.lang.String target) throws java.lang.IllegalArgumentException
public T add(Asset asset, java.lang.String target, java.lang.String name) throws java.lang.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 namespacejava.lang.IllegalArgumentException
- 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, java.lang.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(java.lang.String path) throws java.lang.IllegalArgumentException
Node
located at the specified pathpublic <X extends Archive<X>> X getAsType(java.lang.Class<X> type, java.lang.String path)
Archive
as a specific type.public <X extends Archive<X>> java.util.Collection<X> getAsType(java.lang.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(java.lang.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(java.lang.Class<X> type, java.lang.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(java.lang.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>> java.util.Collection<X> getAsType(java.lang.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, java.lang.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(java.lang.String path) throws java.lang.IllegalArgumentException
addAsDirectory
in interface Archive<T extends Archive<T>>
path
- The path to addjava.lang.IllegalArgumentException
- If no path was specifiedArchive.addAsDirectory(java.lang.String)
public T addAsDirectories(ArchivePath... paths) throws java.lang.IllegalArgumentException
addAsDirectories
in interface Archive<T extends Archive<T>>
paths
- The paths to addjava.lang.IllegalArgumentException
- If no paths were specifiedArchive.addAsDirectories(org.jboss.shrinkwrap.api.ArchivePath[])
public T addAsDirectories(java.lang.String... paths) throws java.lang.IllegalArgumentException
addAsDirectories
in interface Archive<T extends Archive<T>>
paths
- The paths to addjava.lang.IllegalArgumentException
- If no paths were specifiedArchive.addAsDirectories(java.lang.String[])
public final java.lang.String getName()
public java.lang.String getId()
Archive
getId
in interface Archive<T extends Archive<T>>
getId
in interface Identifiable
Archive.getId()
public void setId(java.lang.String id) throws java.lang.IllegalArgumentException
Identifiable
setId
in interface Identifiable
java.lang.IllegalArgumentException
- If the ID is not specifiedpublic T merge(Archive<?> source) throws java.lang.IllegalArgumentException
public T merge(Archive<?> source, Filter<ArchivePath> filter) throws java.lang.IllegalArgumentException
ArchivePath
s to include form the source Archive
.public T merge(Archive<?> source, ArchivePath path) throws java.lang.IllegalArgumentException
merge
in interface Archive<T extends Archive<T>>
source
- Archive to add contents frompath
- Path to add contents tojava.lang.IllegalArgumentException
- 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, java.lang.String path, Filter<ArchivePath> filter) throws java.lang.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.java.lang.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, java.lang.String path) throws java.lang.IllegalArgumentException
merge
in interface Archive<T extends Archive<T>>
source
- Archive to add contents frompath
- Path to add contents tojava.lang.IllegalArgumentException
- 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 java.lang.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.java.lang.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 java.lang.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 assetsjava.lang.IllegalArgumentException
- 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(java.lang.String source, java.lang.String target) throws java.lang.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 assetsjava.lang.IllegalArgumentException
- 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(java.lang.Class<TYPE> clazz)
as
in interface Assignable
clazz
- Extension interface to loadAssignable.as(java.lang.Class)
public java.lang.String toString()
Archive.toString(Formatter)
where the Formatters.SIMPLE
is leveraged.public java.lang.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 java.lang.String toString(Formatter formatter) throws java.lang.IllegalArgumentException
Archive
as returned from the specified Formatter
. Common options may be to
use the predefined formatters located in Formatters
public void writeTo(java.io.OutputStream outputStream, Formatter formatter) throws java.lang.IllegalArgumentException
public int hashCode()
hashCode
in class java.lang.Object
org.jboss.shrinkwrap.api.Archive#hashCode()
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
org.jboss.shrinkwrap.api.Archive#equals(Object)
public Configuration getConfiguration()
Configuration
associated with this Archive
getConfiguration
in interface Configurable
Configurable.getConfiguration()
protected abstract java.lang.Class<T> getActualClass()
protected final T covariantReturn()