Clover coverage report -
Coverage timestamp: Fri Nov 19 2004 13:41:51 PST
file stats: LOC: 110   Methods: 17
NCLOC: 88   Classes: 2
 
 Source file Conditionals Statements Methods TOTAL
CollectionMeta.java 83.3% 92% 94.1% 91.7%
coverage coverage
 1    package photospace.meta;
 2   
 3    import java.util.*;
 4    import org.apache.commons.collections.*;
 5   
 6    public abstract class CollectionMeta extends Meta
 7    {
 8    private List files = new ArrayList();
 9    protected int total;
 10    private int start;
 11    private int end;
 12   
 13  13 public FolderMeta[] getFolders()
 14    {
 15  13 List folders = new ArrayList(CollectionUtils.select(files, new TypePredicate(FolderMeta.class)));
 16  13 return (FolderMeta[]) folders.toArray(new FolderMeta[] {});
 17    }
 18   
 19  17 public PhotoMeta[] getPhotos()
 20    {
 21  17 List photos = new ArrayList(CollectionUtils.select(files, new TypePredicate(PhotoMeta.class)));
 22  17 return (PhotoMeta[]) photos.toArray(new PhotoMeta[] {});
 23    }
 24   
 25  37 public Meta[] getFiles()
 26    {
 27  37 return (Meta[]) files.toArray(new Meta[] {});
 28    }
 29   
 30  50 public void addFile(Meta meta)
 31    {
 32  50 files.add(meta);
 33    }
 34   
 35  11 public void addFiles(Meta[] metas)
 36    {
 37  11 files.addAll(Arrays.asList(metas));
 38    }
 39   
 40  0 public void clearFiles()
 41    {
 42  0 files.clear();
 43    }
 44   
 45  7 public boolean containsFile(Meta meta)
 46    {
 47  7 return files.contains(meta);
 48    }
 49   
 50  3 public void sortFiles(Comparator comparator)
 51    {
 52  3 Collections.sort(files, comparator);
 53    }
 54   
 55  35 public Date getCreated()
 56    {
 57  21 if (super.getCreated() != null) return super.getCreated();
 58  2 if (getPhotos().length != 0) return getPhotos()[0].getCreated();
 59  0 if (getFolders().length != 0) return getFolders()[0].getCreated();
 60   
 61  12 return null;
 62    }
 63   
 64  40 public int getTotal()
 65    {
 66  40 return total;
 67    }
 68   
 69  47 public void setTotal(int total)
 70    {
 71  47 this.total = total;
 72    }
 73   
 74  72 public int getStart()
 75    {
 76  72 return start;
 77    }
 78   
 79  47 public void setStart(int start)
 80    {
 81  47 this.start = start;
 82    }
 83   
 84  97 public int getEnd()
 85    {
 86  97 return end;
 87    }
 88   
 89  47 public void setEnd(int end)
 90    {
 91  47 this.end = end;
 92    }
 93   
 94    private static class TypePredicate
 95    implements Predicate
 96    {
 97    Class type;
 98   
 99  30 public TypePredicate(Class type)
 100    {
 101  30 this.type = type;
 102    }
 103   
 104  8 public boolean evaluate(Object obj)
 105    {
 106  8 return type.isAssignableFrom(obj.getClass());
 107   
 108    }
 109    }
 110    }