gov.loc.repository.bagit
Interface Bag


public interface Bag

This is the core interface of the BagIt Library, representing a bag from the BagIt spec. Methods are available for creating, manipulating, writing, validating, and verifying bags.

You should not create a Bag instance directly. Instead, use an appropriate method on the BagFactory class.

See Also:
BagFactory

Nested Class Summary
static interface Bag.BagConstants
          Contains names for constants associated with a bag.
static interface Bag.BagPartFactory
          Creates various parts of a bag, as appropriate for the version and underlying implementation of the Bag interface.
static class Bag.Format
          The format of a bag.
 
Method Summary
 void accept(BagVisitor visitor)
          Invokes a BagVisitor.
 void addFileAsTag(java.io.File file)
           
 void addFilesToPayload(java.util.List<java.io.File> files)
           
 void addFileToPayload(java.io.File file)
           
 Bag.BagConstants getBagConstants()
           
 BagFile getBagFile(java.lang.String filepath)
           
 BagInfoTxt getBagInfoTxt()
           
 BagItTxt getBagItTxt()
           
 Bag.BagPartFactory getBagPartFactory()
           
 java.util.Map<Manifest.Algorithm,java.lang.String> getChecksums(java.lang.String filepath)
          Finds checksums in all manifests for a file.
 FetchTxt getFetchTxt()
           
 java.io.File getFile()
           
 Bag.Format getFormat()
           
 java.util.Collection<BagFile> getPayload()
           
 Manifest getPayloadManifest(Manifest.Algorithm algorithm)
           
 java.util.List<Manifest> getPayloadManifests()
           
 Manifest getTagManifest(Manifest.Algorithm algorithm)
           
 java.util.List<Manifest> getTagManifests()
           
 java.util.Collection<BagFile> getTags()
           
 BagFactory.Version getVersion()
          Gets the version of the BagIt spec to which the bag conforms.
 void loadFromPayloadFiles()
          Loads a bag based on the tag files and payload files found on disk.
 void loadFromPayloadManifests()
          Loads a bag based on the tag files found on disk and the payload files listed in the payload manifests.
 Bag makeComplete()
          Makes a bag complete by filling in any pieces necessary to satisfy the BagIt Specification.
 Bag makeComplete(gov.loc.repository.bagit.transformer.Completer completer)
          Invokes a Completer to make a bag complete;
 Bag makeHoley(gov.loc.repository.bagit.transformer.HolePuncher holePuncher, java.lang.String baseUrl, boolean includePayloadDirectoryInUrl, boolean includeTags)
          Invokes a HolePuncher to make a bag holey.
 Bag makeHoley(java.lang.String baseUrl, boolean includePayloadDirectoryInUrl, boolean includeTags)
          Makes a bag holey by creating a fetch.txt and removing payload files.
 void putBagFile(BagFile bagFile)
           
 void putBagFiles(java.util.Collection<BagFile> bagFiles)
           
 void removeBagFile(java.lang.String filepath)
           
 void removePayloadDirectory(java.lang.String filepath)
           
 void setFile(java.io.File file)
           
 gov.loc.repository.bagit.utilities.SimpleResult verify(gov.loc.repository.bagit.verify.Verifier verifier)
          Invokes a Verifier to verify a bag.
 gov.loc.repository.bagit.utilities.SimpleResult verifyComplete()
          Determines whether the bag is complete according to the BagIt Specification.
 gov.loc.repository.bagit.utilities.SimpleResult verifyPayloadManifests()
          Verify that each checksum in every payload manifest can be verified against the appropriate contents.
 gov.loc.repository.bagit.utilities.SimpleResult verifyTagManifests()
          Verify that each checksum in every tag manifest can be verified against the appropriate contents.
 gov.loc.repository.bagit.utilities.SimpleResult verifyValid()
          Determines whether the bag is valid according to the BagIt Specification.
 Bag write(gov.loc.repository.bagit.writer.Writer writer, java.io.File file)
           
 

Method Detail

getVersion

BagFactory.Version getVersion()
Gets the version of the BagIt spec to which the bag conforms.

Returns:
The version of the bag. Will never be null.

getFile

java.io.File getFile()

setFile

void setFile(java.io.File file)

getPayloadManifests

java.util.List<Manifest> getPayloadManifests()

getPayloadManifest

Manifest getPayloadManifest(Manifest.Algorithm algorithm)

getTagManifests

java.util.List<Manifest> getTagManifests()

getTagManifest

Manifest getTagManifest(Manifest.Algorithm algorithm)

getTags

java.util.Collection<BagFile> getTags()

getPayload

java.util.Collection<BagFile> getPayload()

removeBagFile

void removeBagFile(java.lang.String filepath)

removePayloadDirectory

void removePayloadDirectory(java.lang.String filepath)

getBagFile

BagFile getBagFile(java.lang.String filepath)

putBagFile

void putBagFile(BagFile bagFile)

putBagFiles

void putBagFiles(java.util.Collection<BagFile> bagFiles)

addFileToPayload

void addFileToPayload(java.io.File file)

addFilesToPayload

void addFilesToPayload(java.util.List<java.io.File> files)

addFileAsTag

void addFileAsTag(java.io.File file)

getChecksums

java.util.Map<Manifest.Algorithm,java.lang.String> getChecksums(java.lang.String filepath)
Finds checksums in all manifests for a file.


getBagItTxt

BagItTxt getBagItTxt()

getBagInfoTxt

BagInfoTxt getBagInfoTxt()

getFetchTxt

FetchTxt getFetchTxt()

getFormat

Bag.Format getFormat()

verifyValid

gov.loc.repository.bagit.utilities.SimpleResult verifyValid()
Determines whether the bag is valid according to the BagIt Specification.


verifyComplete

gov.loc.repository.bagit.utilities.SimpleResult verifyComplete()
Determines whether the bag is complete according to the BagIt Specification.


verify

gov.loc.repository.bagit.utilities.SimpleResult verify(gov.loc.repository.bagit.verify.Verifier verifier)
Invokes a Verifier to verify a bag.


verifyPayloadManifests

gov.loc.repository.bagit.utilities.SimpleResult verifyPayloadManifests()
Verify that each checksum in every payload manifest can be verified against the appropriate contents.


verifyTagManifests

gov.loc.repository.bagit.utilities.SimpleResult verifyTagManifests()
Verify that each checksum in every tag manifest can be verified against the appropriate contents.


loadFromPayloadManifests

void loadFromPayloadManifests()
Loads a bag based on the tag files found on disk and the payload files listed in the payload manifests.


loadFromPayloadFiles

void loadFromPayloadFiles()
Loads a bag based on the tag files and payload files found on disk.


accept

void accept(BagVisitor visitor)
Invokes a BagVisitor.


write

Bag write(gov.loc.repository.bagit.writer.Writer writer,
          java.io.File file)

makeHoley

Bag makeHoley(java.lang.String baseUrl,
              boolean includePayloadDirectoryInUrl,
              boolean includeTags)
Makes a bag holey by creating a fetch.txt and removing payload files.


makeHoley

Bag makeHoley(gov.loc.repository.bagit.transformer.HolePuncher holePuncher,
              java.lang.String baseUrl,
              boolean includePayloadDirectoryInUrl,
              boolean includeTags)
Invokes a HolePuncher to make a bag holey.


makeComplete

Bag makeComplete()
Makes a bag complete by filling in any pieces necessary to satisfy the BagIt Specification.


makeComplete

Bag makeComplete(gov.loc.repository.bagit.transformer.Completer completer)
Invokes a Completer to make a bag complete;


getBagConstants

Bag.BagConstants getBagConstants()

getBagPartFactory

Bag.BagPartFactory getBagPartFactory()