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.PRIMARYandArtifactType.DIRECTORYcan 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 voidadd(Artifact artifact)Adds an artifactsCollection<PropertyValueArtifact>add(Artifact parent, String relPath, String ext, ArtifactType type, Property prop, long lastModified)Adds anPropertyValueArtifactwith the given name, type and serializerSerializerArtifactadd(Artifact parent, String name, String ext, ArtifactType type, Serializer ser, long lastModified)Adds anSerializerArtifactwith the given name, type and serializer.voidaddAll(Collection<? extends Artifact> artifacts)Adds a collection of artifactsvoidaddAll(ArtifactSet artifacts)Adds a set of artifactsvoiddump(DumpContext ctx, boolean isLast)Dumps some human readable information using the given context.ArtifactgetArtifact(String path)Returns the artifact with the given path ornullif it does not exist.ItemFilterSetgetCoverage()Returns the item filter set that defines the coverage of the items in this artifact set.ArtifactgetDirectory()Returns the directory artifact ornull.ArtifactgetPrimaryData()Returns the primary data artifact ornull.booleanisEmpty()Checks if this set is empty.Artifactput(Artifact a)Puts the given artifact to this set.booleanremove(Artifact a)Removes the artifact from this set.Collection<Artifact>removed()Returns the collection of removed artifactsvoidsetCoverage(ItemFilterSet filter)Sets the item filter set that defines the coverage of the items in this artifact set.intsize()Returns the number of artifacts in this set.intsize(ArtifactType type)Returns the number of artifacts in this set that have the given type.StringtoString()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:ArtifactSetReturns the item filter set that defines the coverage of the items in this artifact set.- Specified by:
getCoveragein 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:ArtifactSetAdds a collection of artifacts- Specified by:
addAllin interfaceArtifactSet- Parameters:
artifacts- the artifacts collection
-
addAll
public void addAll(ArtifactSet artifacts)
Description copied from interface:ArtifactSetAdds a set of artifacts- Specified by:
addAllin interfaceArtifactSet- Parameters:
artifacts- the artifacts set
-
add
public void add(Artifact artifact)
Description copied from interface:ArtifactSetAdds an artifacts- Specified by:
addin interfaceArtifactSet- Parameters:
artifact- the artifact to add
-
add
public SerializerArtifact add(Artifact parent, String name, String ext, ArtifactType type, Serializer ser, long lastModified)
Adds anSerializerArtifactwith 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 anPropertyValueArtifactwith 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:ArtifactSetReturns the primary data artifact ornull.- Specified by:
getPrimaryDatain interfaceArtifactSet- Returns:
- the primary data artifact or
null.
-
getDirectory
public Artifact getDirectory()
Description copied from interface:ArtifactSetReturns the directory artifact ornull.- Specified by:
getDirectoryin interfaceArtifactSet- Returns:
- the directory artifact or
null.
-
isEmpty
public boolean isEmpty()
Description copied from interface:ArtifactSetChecks if this set is empty.- Specified by:
isEmptyin interfaceArtifactSet- Returns:
trueif this set is empty.
-
size
public int size()
Description copied from interface:ArtifactSetReturns the number of artifacts in this set.- Specified by:
sizein 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:
trueif 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.BINARYit 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:
valuesin 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:
valuesin interfaceArtifactSet- Returns:
- the artifacts
-
removed
public Collection<Artifact> removed()
Returns the collection of removed artifacts- Specified by:
removedin interfaceArtifactSet- Returns:
- the removed artifacts
-
getArtifact
public Artifact getArtifact(String path)
Returns the artifact with the given path ornullif 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.
-
-