Coverage Report - com.buckosoft.PicMan.domain.Filter
 
Classes in this File Line Coverage Branch Coverage Complexity
Filter
0%
0/29
0%
0/2
1.154
 
 1  
 /******************************************************************************
 2  
  * Filter.java - Define the filters for one pic.
 3  
  * 
 4  
  * PicMan - The BuckoSoft Picture Manager in Java
 5  
  * Copyright(c) 2005 - Dick Balaska
 6  
  * 
 7  
  */
 8  
 package com.buckosoft.PicMan.domain;
 9  
 
 10  
 import java.io.Serializable;
 11  
 import java.util.Date;
 12  
 import java.util.LinkedHashMap;
 13  
 
 14  
 /** Describe the contents of one Pic. <br>
 15  
  * The Binding is accomplished with Pic Names and not pids so that Filters can be applicable on different machines.
 16  
  * Depending on which machine imported the Pic and when they were synchronized, the pids might not line up
 17  
  * whereas Pic Name is unique. <br>
 18  
  * The filters are stored in a HashMap.  Typically the set/size is indexed by setName_size. i.e. "CarlB_75" which
 19  
  * specifies the CarlB set for size 75.
 20  
  * @author Dick Balaska
 21  
  * @since 2005/07/30
 22  
  */
 23  
 public class Filter implements Serializable {
 24  
 
 25  
         private static final long serialVersionUID = 1L;
 26  
 
 27  
         private        String                        picName;
 28  0
         private        Date                date = new Date();
 29  0
         private        LinkedHashMap<String, Integer>        filters = new LinkedHashMap<String, Integer>();
 30  
   
 31  
         /** Construct an empty Filter
 32  
          */
 33  0
         public Filter() {
 34  0
         }
 35  
 
 36  
         /** Construct a Filter setting the name of the {@link com.buckosoft.PicMan.domain.Pic} that this Filter belongs to
 37  
          * @param name the Pic Name
 38  
          */
 39  0
         public Filter(String name) {
 40  0
                 picName = name;
 41  0
         }
 42  
         
 43  
         /** Set the name of the {@link com.buckosoft.PicMan.domain.Pic} that this Filter belongs to
 44  
          * @param picName the Pic Name
 45  
          */
 46  
         public void setPicName(String picName) {
 47  0
                 this.picName = picName;
 48  0
         }
 49  
         /** Return the name of the Pic.  This is the key that matches a Pic with a Filter.
 50  
          * @return The PicName of this Filter.
 51  
          */
 52  
         public String getPicName() {
 53  0
                 return picName;
 54  
         }
 55  
         
 56  
 //        public void setFilters(LinkedHashMap<String, Integer> filters) {
 57  
 //                this.filters = filters;
 58  
 //        }
 59  
 
 60  
         /** Get a reference to the filter hashmap
 61  
          * @return the filters
 62  
          */
 63  
         public LinkedHashMap<String, Integer> getFilters() {
 64  0
                 return filters;
 65  
         }
 66  
 
 67  
         /** Get the filter value for this string value.
 68  
          * Typically this is a constructed set_size name.
 69  
          * @param f The name of the {@link com.buckosoft.PicMan.domain.Set} to query
 70  
          * @return The value 0-9 for the filter of this set
 71  
          */ 
 72  
         public int        getFilter(String f) {
 73  0
                 Integer i = (Integer)filters.get(f);
 74  0
                 if (i == null)
 75  0
                         return(0);
 76  0
                 return(i.intValue());
 77  
         }
 78  
 
 79  
         /** Get the filter value for this set/size.
 80  
          * @param setName The name of the Set to query
 81  
          * @param size The size to query
 82  
          * @return The value 0-9 for the filter of this set/size.
 83  
          */
 84  
         public        int                getFilter(String setName, int size) {
 85  0
                 String        s = setName + "_" + size;
 86  0
                 return(getFilter(s));
 87  
         }
 88  
         
 89  
         /** Add this value to the Filter for this set
 90  
          * @param setName The name of the Set
 91  
          * @param v 0-9 rate this pic for the specified Set
 92  
          */
 93  
         public        void        addFilter(String setName, int v) {
 94  0
                 filters.put(setName, new Integer(v));
 95  0
         }
 96  
         
 97  
         /** Add this value to the Filter for this set/size.
 98  
          * @param set The set to add.
 99  
          * @param size The size to add.
 100  
          * @param v 0-9 rate this pic for the specified Set/size.
 101  
          */
 102  
         public        void        addFilter(String set, int size, int v) {
 103  0
                 String        s = set + "_" + size;
 104  0
                 addFilter(s, v);
 105  0
         }
 106  
 
 107  
         /** Fetch the time that this filter was last edited.
 108  
          * @return The Date of the last edit.
 109  
          */
 110  0
         public        Date        getDate() { return(date); }
 111  
 
 112  
         /** Set the timestamp for this filter.
 113  
          * @param time The date in milliseconds.
 114  
          */
 115  
         public void setTime(long time) {
 116  0
                 this.date.setTime(time);
 117  0
         }
 118  
         
 119  
         /** Set the timestamp for this filter.
 120  
          * @param date to set this filter to.
 121  
          */
 122  
         public void setTime(Date date) {
 123  0
                 this.date.setTime(date.getTime());
 124  0
         }
 125  
         
 126  
         public void setTimeNow() {
 127  0
                 this.date = new Date();
 128  0
         }
 129  
 }