Coverage report

  %line %branch
mnemosyne.archiver.SnapshotDirectory
100% 
100% 

 1  
 /*
 2  
  * Copyright 2004 Charles Blaxland
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *     http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package mnemosyne.archiver;
 17  
 
 18  
 import mnemosyne.core.PersistentRoot;
 19  
 import org.apache.commons.logging.Log;
 20  
 import org.apache.commons.logging.LogFactory;
 21  
 
 22  
 import java.io.*;
 23  
 
 24  
 /**
 25  
  * @version $Id: SnapshotDirectory.java,v 1.1.1.1 2004/08/07 06:40:54 charlesblaxland Exp $
 26  
  */
 27  
 public class SnapshotDirectory extends ArchiveDirectory
 28  
 {
 29  4
     private static final Log log = LogFactory.getLog(SnapshotDirectory.class);
 30  
 
 31  
     private static final String SNAPSHOT_FILE_PREFIX    = "";
 32  
     private static final String SNAPSHOT_FILE_POSTFIX   = "_snapshot";
 33  
     private static final String SNAPSHOT_FILE_EXTENSION = "snp";
 34  
 
 35  
     public SnapshotDirectory(String directoryName, ArchiveSequence sequence)
 36  
     {
 37  7
         super(directoryName, sequence);
 38  7
     }
 39  
 
 40  
     protected String prefix()
 41  
     {
 42  22
         return SNAPSHOT_FILE_PREFIX;
 43  
     }
 44  
 
 45  
     protected String postfix()
 46  
     {
 47  22
         return SNAPSHOT_FILE_POSTFIX;
 48  
     }
 49  
 
 50  
     protected String extension()
 51  
     {
 52  15
         return SNAPSHOT_FILE_EXTENSION;
 53  
     }
 54  
 
 55  
     public long getLatestSnapshotSequenceNumber()
 56  
     {
 57  5
         if (archiveFiles.isEmpty())
 58  
         {
 59  1
             return -1;
 60  
         }
 61  
         else
 62  
         {
 63  4
             return extractFileSequenceNumber((String)archiveFiles.last());
 64  
         }
 65  
     }
 66  
 
 67  
     public PersistentRoot readLatestSnapshot() throws ArchiverException
 68  
     {
 69  3
         if (archiveFiles.isEmpty())
 70  
         {
 71  1
             log.info("No snapshots found");
 72  1
             return null;
 73  
         }
 74  
 
 75  2
         String latestSnapshotName = (String)archiveFiles.last();
 76  2
         File latestSnapshot = constructArchiveFile(latestSnapshotName);
 77  2
         return (PersistentRoot) readArchiveFile(latestSnapshot);
 78  
     }
 79  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.