T
- public abstract class MemoryMapArchiveBase<T extends Archive<T>> extends ArchiveBase<T> implements Archive<T>
Modifier and Type | Field and Description |
---|---|
private java.util.Map<ArchivePath,NodeImpl> |
content
Storage for the
Node s. |
private java.util.List<ArchiveEventHandler> |
handlers |
private java.util.Map<ArchivePath,ArchiveAsset> |
nestedArchives
Storage for the
ArchiveAsset s. |
Constructor and Description |
---|
MemoryMapArchiveBase(Configuration configuration)
Constructor
This constructor will generate a unique
Archive.getName() per instance. |
MemoryMapArchiveBase(java.lang.String archiveName,
Configuration configuration)
Constructor
This constructor will generate an
Archive with the provided 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(Archive<?> archive,
java.lang.String 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)
Adds the specified asset under the specified path into the target context
|
T |
addAsDirectory(ArchivePath path)
Adds the specified directory.
|
private T |
addAsset(ArchivePath path,
Asset asset) |
T |
addHandlers(ArchiveEventHandler... handlers)
Add an array of listeners for call back based.
|
private void |
addNewNode(ArchivePath path,
Asset handledAsset) |
boolean |
contains(ArchivePath path)
Denotes whether this archive contains a resource at the specified path
|
boolean |
contains(java.lang.String path)
Denotes whether this archive contains a resource at the specified path
|
Node |
delete(ArchivePath path)
|
Node |
delete(java.lang.String archivePath)
|
Node |
get(ArchivePath path)
Obtains the
Node located at the specified path |
java.util.Map<ArchivePath,Node> |
getContent()
Obtains all assets in this archive, along with their respective paths.
|
java.util.Map<ArchivePath,Node> |
getContent(Filter<ArchivePath> filter)
Obtains all assets matching given filter in this archive, along with its respective Path.
|
private Node |
getNestedNode(ArchivePath path)
Attempt to get the asset from a nested archive.
|
private ArchivePath |
getNestedPath(ArchivePath fullPath,
ArchivePath basePath)
Given a full path and a base path return a new path containing the full path with the base path removed from the
beginning.
|
private Asset |
invokeHandlers(ArchivePath path,
Asset asset) |
private boolean |
nestedContains(ArchivePath path)
Check to see if a path is found in a nested archive
|
private NodeImpl |
obtainParent(ArchivePath path)
|
private Node |
removeNodeRecursively(NodeImpl node,
ArchivePath path)
Removes the specified node and its associated children from the contents
of this archive.
|
private boolean |
startsWith(ArchivePath fullPath,
ArchivePath startingPath)
Check to see if one path starts with another
|
add, add, add, add, addAsDirectories, addAsDirectories, addAsDirectory, as, covariantReturn, equals, filter, get, getActualClass, getArchiveFormat, getAsType, getAsType, getAsType, getAsType, getAsType, getAsType, getConfiguration, getId, getName, hashCode, merge, merge, merge, merge, merge, merge, move, move, setId, shallowCopy, shallowCopy, toString, toString, toString, writeTo
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
add, add, add, add, addAsDirectories, addAsDirectories, addAsDirectory, filter, get, getAsType, getAsType, getAsType, getAsType, getAsType, getAsType, getId, getName, merge, merge, merge, merge, merge, merge, move, move, shallowCopy, shallowCopy, toString, toString, toString, writeTo
as
private final java.util.Map<ArchivePath,NodeImpl> content
Node
s.private final java.util.Map<ArchivePath,ArchiveAsset> nestedArchives
ArchiveAsset
s. Used to help get access to nested archive content.private final java.util.List<ArchiveEventHandler> handlers
public MemoryMapArchiveBase(Configuration configuration) throws java.lang.IllegalArgumentException
Archive.getName()
per instance.configuration
- The configuration for this archivejava.lang.IllegalArgumentException
- If the configuration is not specifiedpublic MemoryMapArchiveBase(java.lang.String archiveName, Configuration configuration) throws java.lang.IllegalArgumentException
Archive
with the provided name.archiveName
- configuration
- The configuration for this archivejava.lang.IllegalArgumentException
- If the name or configuration is not specifiedpublic T add(Asset asset, ArchivePath path)
public T add(Archive<?> archive, java.lang.String 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, java.lang.String, java.lang.Class)
public T add(Archive<?> archive, ArchivePath path, java.lang.Class<? extends StreamExporter> exporter)
add
in interface Archive<T extends Archive<T>>
add
in class ArchiveBase<T extends Archive<T>>
archive
- to addpath
- to useexporter
- Exporter type to use in fulfilling the Asset.openStream()
contract for the added (nested)
archive.ArchiveBase.add(org.jboss.shrinkwrap.api.Archive,
org.jboss.shrinkwrap.api.ArchivePath, java.lang.Class)
public T addAsDirectory(ArchivePath 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(org.jboss.shrinkwrap.api.ArchivePath)
private T addAsset(ArchivePath path, Asset asset)
private void addNewNode(ArchivePath path, Asset handledAsset)
public T addHandlers(ArchiveEventHandler... handlers)
addHandlers
in interface Archive<T extends Archive<T>>
org.jboss.shrinkwrap.api.Archive#addListener(org.jboss.shrinkwrap.api.Filter, org.jboss.shrinkwrap.api.ArchiveEventHandler)
private Asset invokeHandlers(ArchivePath path, Asset asset)
public boolean contains(ArchivePath path)
public boolean contains(java.lang.String path) throws java.lang.IllegalArgumentException
public Node delete(ArchivePath path)
Node
in the Archive
at the specified ArchivePath
. If the path is a directory,
recursively removes all contents. If the path does not exist, return null.private Node removeNodeRecursively(NodeImpl node, ArchivePath path)
node
- the node to remove recursivelypath
- the path denoting the specified nodepublic Node delete(java.lang.String archivePath)
Node
in the Archive
at the ArchivePath
indicated by the specified String
archivePath. If the path is a directory, recursively removes all contents. If the path does not exist, return
null.public Node get(ArchivePath path)
Node
located at the specified pathpublic java.util.Map<ArchivePath,Node> getContent()
getContent
in interface Archive<T extends Archive<T>>
Archive.getContent()
public java.util.Map<ArchivePath,Node> getContent(Filter<ArchivePath> filter)
getContent
in interface Archive<T extends Archive<T>>
Archive.getContent(org.jboss.shrinkwrap.api.Filter)
private boolean nestedContains(ArchivePath path)
private Node getNestedNode(ArchivePath path)
path
- private boolean startsWith(ArchivePath fullPath, ArchivePath startingPath)
fullPath
- startingPath
- private ArchivePath getNestedPath(ArchivePath fullPath, ArchivePath basePath)
fullPath
- basePath
- private NodeImpl obtainParent(ArchivePath path)
Node
from the content of the Archive
. If the Node
doesn�t exists in
the specified location, it is created and added to the Archive
. The same happens to all its non-existing
parents. However, if the Node
is an asset, an IllegalArchivePathException is thrown.path
- The ArchivePath
from which we are obtaining the Node
Node
in the specified pathIllegalArchivePathException
- if the node is an Asset