Class ArtifactSetImpl
- java.lang.Object
-
- org.apache.jackrabbit.vault.fs.impl.ArtifactSetImpl
-
- All Implemented Interfaces:
ArtifactSet
,Dumpable
public class ArtifactSetImpl extends Object implements Dumpable, ArtifactSet
Implements a set of artifacts. The artifacts can be retrieved via anArtifactIterator
. Special artifacts likeArtifactType.PRIMARY
andArtifactType.DIRECTORY
can be retrieved individually. This set only allows one of those artifacts per type. All modifications to this set have no influence on the persisted data.
-
-
Constructor Summary
Constructors Constructor Description ArtifactSetImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(Artifact artifact)
Adds an artifactsCollection<PropertyValueArtifact>
add(Artifact parent, String relPath, String ext, ArtifactType type, Property prop, long lastModified)
Adds anPropertyValueArtifact
with the given name, type and serializerSerializerArtifact
add(Artifact parent, String name, String ext, ArtifactType type, Serializer ser, long lastModified)
Adds anSerializerArtifact
with the given name, type and serializer.void
addAll(Collection<? extends Artifact> artifacts)
Adds a collection of artifactsvoid
addAll(ArtifactSet artifacts)
Adds a set of artifactsvoid
dump(DumpContext ctx, boolean isLast)
Dumps some human readable information using the given context.Artifact
getArtifact(String path)
Returns the artifact with the given path ornull
if it does not exist.ItemFilterSet
getCoverage()
Returns the item filter set that defines the coverage of the items in this artifact set.Artifact
getDirectory()
Returns the directory artifact ornull
.Artifact
getPrimaryData()
Returns the primary data artifact ornull
.boolean
isEmpty()
Checks if this set is empty.Artifact
put(Artifact a)
Puts the given artifact to this set.boolean
remove(Artifact a)
Removes the artifact from this set.Collection<Artifact>
removed()
Returns the collection of removed artifactsvoid
setCoverage(ItemFilterSet filter)
Sets the item filter set that defines the coverage of the items in this artifact set.int
size()
Returns the number of artifacts in this set.int
size(ArtifactType type)
Returns the number of artifacts in this set that have the given type.String
toString()
Collection<Artifact>
values()
Returns a collection of all artifactsCollection<Artifact>
values(ArtifactType type)
Returns a collection of all artifacts that have the given type.
-
-
-
Method Detail
-
getCoverage
public ItemFilterSet getCoverage()
Description copied from interface:ArtifactSet
Returns the item filter set that defines the coverage of the items in this artifact set.- Specified by:
getCoverage
in interfaceArtifactSet
- Returns:
- the item filter set.
-
setCoverage
public void setCoverage(ItemFilterSet filter)
Sets the item filter set that defines the coverage of the items in this artifact set.- Parameters:
filter
- the item filter set.
-
addAll
public void addAll(Collection<? extends Artifact> artifacts)
Description copied from interface:ArtifactSet
Adds a collection of artifacts- Specified by:
addAll
in interfaceArtifactSet
- Parameters:
artifacts
- the artifacts collection
-
addAll
public void addAll(ArtifactSet artifacts)
Description copied from interface:ArtifactSet
Adds a set of artifacts- Specified by:
addAll
in interfaceArtifactSet
- Parameters:
artifacts
- the artifacts set
-
add
public void add(Artifact artifact)
Description copied from interface:ArtifactSet
Adds an artifacts- Specified by:
add
in interfaceArtifactSet
- Parameters:
artifact
- the artifact to add
-
add
public SerializerArtifact add(Artifact parent, String name, String ext, ArtifactType type, Serializer ser, long lastModified)
Adds anSerializerArtifact
with the given name, type and serializer.- Parameters:
parent
- the parent artifactname
- the name of the artifactext
- the extension of the artifacttype
- the type of the artifactser
- the serializer of the artifactlastModified
- the last modified date- Returns:
- the added artifact
-
add
public Collection<PropertyValueArtifact> add(Artifact parent, String relPath, String ext, ArtifactType type, Property prop, long lastModified) throws RepositoryException
Adds anPropertyValueArtifact
with the given name, type and serializer- Parameters:
parent
- parent artifactrelPath
- the name of the artifactext
- the extensiontype
- the type of the artifactprop
- the property of the artifactlastModified
- the last modified date. can be 0.- Returns:
- a collection of artifacts
- Throws:
RepositoryException
- if an error occurs.
-
getPrimaryData
public Artifact getPrimaryData()
Description copied from interface:ArtifactSet
Returns the primary data artifact ornull
.- Specified by:
getPrimaryData
in interfaceArtifactSet
- Returns:
- the primary data artifact or
null
.
-
getDirectory
public Artifact getDirectory()
Description copied from interface:ArtifactSet
Returns the directory artifact ornull
.- Specified by:
getDirectory
in interfaceArtifactSet
- Returns:
- the directory artifact or
null
.
-
isEmpty
public boolean isEmpty()
Description copied from interface:ArtifactSet
Checks if this set is empty.- Specified by:
isEmpty
in interfaceArtifactSet
- Returns:
true
if this set is empty.
-
size
public int size()
Description copied from interface:ArtifactSet
Returns the number of artifacts in this set.- Specified by:
size
in interfaceArtifactSet
- Returns:
- the number of artifacts in this set.
-
remove
public boolean remove(Artifact a)
Removes the artifact from this set.- Parameters:
a
- the artifact to remove- Returns:
true
if the artifact was removed.
-
put
public Artifact put(Artifact a)
Puts the given artifact to this set. In comparison to the add operations, an already existing artifact is replaced. If the type of the newly artifact isArtifactType.BINARY
it equivalent with the same name is replaced.- Parameters:
a
- the artifact to put- Returns:
- the previous artifact or
null
-
size
public int size(ArtifactType type)
Returns the number of artifacts in this set that have the given type.- Parameters:
type
- the artifact type- Returns:
- the number of artifacts in this set that have the given type.
-
values
public Collection<Artifact> values(ArtifactType type)
Returns a collection of all artifacts that have the given type.- Specified by:
values
in interfaceArtifactSet
- Parameters:
type
- the type of the artifacts to return- Returns:
- the artifacts
-
values
public Collection<Artifact> values()
Returns a collection of all artifacts- Specified by:
values
in interfaceArtifactSet
- Returns:
- the artifacts
-
removed
public Collection<Artifact> removed()
Returns the collection of removed artifacts- Specified by:
removed
in interfaceArtifactSet
- Returns:
- the removed artifacts
-
getArtifact
public Artifact getArtifact(String path)
Returns the artifact with the given path ornull
if it does not exist.- Parameters:
path
- the name of the artifact.- Returns:
- the desired artifact or
null
-
dump
public void dump(DumpContext ctx, boolean isLast)
Dumps some human readable information using the given context.
-
-